Examples of TestContext


Examples of org.jboss.arquillian.impl.context.TestContext

   public void before(Object testInstance, Method testMethod) throws Exception
   {
      Validate.notNull(testInstance, "TestInstance must be specified");
      Validate.notNull(testMethod, "TestMethod must be specified");
     
      TestContext testContext = contextLifecycle.createRestoreTestContext(testInstance);
      try
      {
         testContext.fire(new Before(testInstance, testMethod));
      }
      finally
      {
         activeContext.push(testContext);
      }
View Full Code Here

Examples of org.jboss.arquillian.impl.context.TestContext

   public TestResult test(TestMethodExecutor testMethodExecutor) throws Exception
   {
      Validate.notNull(testMethodExecutor, "TestMethodExecutor must be specified");
     
      Test test = new Test(testMethodExecutor);
      TestContext context = contextLifecycle.createRestoreTestContext(testMethodExecutor.getInstance());
      context.fire(test);
      return context.get(TestResult.class);
   }
View Full Code Here

Examples of org.jboss.arquillian.impl.core.spi.context.TestContext

      }
   }

   public void createTestContext(@Observes EventContext<TestEvent> context)
   {
      TestContext testContext = this.testContextInstance.get();
      try
      {
         testContext.activate(context.getEvent().getTestInstance());
         context.proceed();
      }
      finally
      {
         testContext.deactivate();
      }
   }
View Full Code Here

Examples of org.jboss.arquillian.test.spi.context.TestContext

      }
   }

   public void createTestContext(@Observes(precedence=100) EventContext<TestEvent> context)
   {
      TestContext testContext = this.testContextInstance.get();
      try
      {
         testContext.activate(context.getEvent().getTestInstance());
         context.proceed();
      }
      finally
      {
         testContext.deactivate();
      }
   }
View Full Code Here

Examples of org.jboss.arquillian.test.spi.context.TestContext

      }
   }

   public void createTestContext(@Observes(precedence = 100) EventContext<TestEvent> context)
   {
      TestContext testContext = this.testContextInstance.get();
      try
      {
         testContext.activate(context.getEvent().getTestInstance());
         context.proceed();
      }
      finally
      {
         testContext.deactivate();
         if (After.class.isAssignableFrom(context.getEvent().getClass()))
         {
            testContext.destroy(context.getEvent().getTestInstance());
         }
      }
   }
View Full Code Here

Examples of org.sonatype.nexus.integrationtests.TestContext

  @Test
  public void createUser()
      throws Exception
  {
    TestContext testContext = TestContainer.getInstance().getTestContext();
    testContext.useAdminForRequests();

    // create user,
    UserResource resource = new UserResource();
    resource.setUserId(USER_ID);
    resource.setFirstName("Marvin Velo");
    resource.setEmail("velo@earth.com");
    resource.setStatus("active");
    resource.addRole("nx-admin");
    userUtil.createUser(resource);

    // get email
    // two e-mails (first confirming user creating and second with users pw)
    emailServerHelper.waitForMail(2);
    Thread.sleep(1000); //w8 a few more

    MimeMessage[] msgs = emailServerHelper.getReceivedMessages();
    String password = null;
    StringBuilder emailsContent = new StringBuilder();

    /// make sure we have at least 1 message
    Assert.assertTrue("No emails recieved.", msgs.length > 0);

    for (MimeMessage mimeMessage : msgs) {
      emailsContent.append(GreenMailUtil.getHeaders(mimeMessage)).append('\n');

      // Sample body: Your new password is ********
      String body = GreenMailUtil.getBody(mimeMessage);
      emailsContent.append(body).append('\n').append('\n');

      int index = body.indexOf("Your new password is ");
      int passwordStartIndex = index + "Your new password is ".length();
      if (index != -1) {
        password = body.substring(passwordStartIndex, body.indexOf('\n', passwordStartIndex)).trim();
        log.debug("New password:\n" + password);
        break;
      }
    }

    Assert.assertNotNull(password, "Didn't recieve a password.  Got the following messages:\n" + emailsContent);

    // login with generated password
    testContext.setUsername(USER_ID);
    testContext.setPassword(password);
    Status status = UserCreationUtil.login();
    Assert.assertTrue(status.isSuccess());

    // set new password
    String newPassword = "velo123";
    status = ChangePasswordUtils.changePassword(USER_ID, password, newPassword);
    Assert.assertTrue(status.isSuccess());

    // check if the user is 'active'
    testContext.useAdminForRequests();
    UserResource user = userUtil.getUser(USER_ID);
    Assert.assertEquals(user.getStatus(), "active");

    // login with new password
    testContext.setUsername(USER_ID);
    testContext.setPassword(newPassword);
    status = UserCreationUtil.login();
    Assert.assertTrue(status.isSuccess());
  }
View Full Code Here

Examples of org.springframework.test.context.TestContext

*/
public final class SpringTestPlugin extends AbstractTestPlugin {
    public void prepareTestInstance(Context context) {
        try {
            final TestContextManager manager = new TestContextManager(context.getTest().getTargetClass());
            final TestContext ctx = manager.testContext();
            context.setAttribute("org.springframework.test.context.TestContextManager", manager);
            context.setAttribute("org.springframework.test.context.TestContext", ctx);
            setupContextLoader(ctx, new MycilaContextLoader(context));
            manager.prepareTestInstance(context.getTest().getTarget());
            context.setAttribute("org.springframework.context.ApplicationContext", manager.testContext().getApplicationContext());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.