Package org.springframework.test.context.junit4.statements

Examples of org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks


  private static final void runTestClassAndAssertStats(Class<?> testClass, int expectedTestCount) {
    final int expectedTestFailureCount = 0;
    final int expectedTestStartedCount = expectedTestCount;
    final int expectedTestFinishedCount = expectedTestCount;

    TrackingRunListener listener = new TrackingRunListener();
    JUnitCore jUnitCore = new JUnitCore();
    jUnitCore.addListener(listener);
    jUnitCore.run(testClass);

    assertEquals("Verifying number of failures for test class [" + testClass + "].", expectedTestFailureCount,
      listener.getTestFailureCount());
    assertEquals("Verifying number of tests started for test class [" + testClass + "].", expectedTestStartedCount,
      listener.getTestStartedCount());
    assertEquals("Verifying number of tests finished for test class [" + testClass + "].",
      expectedTestFinishedCount, listener.getTestFinishedCount());
  }
View Full Code Here


*/
public class ServletContextAwareBeanWacTests {

  @Test
  public void ensureServletContextAwareBeanIsProcessedProperlyWhenExecutingJUnitManually() {
    TrackingRunListener listener = new TrackingRunListener();
    JUnitCore junit = new JUnitCore();
    junit.addListener(listener);

    junit.run(BasicAnnotationConfigWacTests.class);

    assertEquals(3, listener.getTestStartedCount());
    assertEquals(3, listener.getTestFinishedCount());
    assertEquals(0, listener.getTestFailureCount());
  }
View Full Code Here

  @Test
  public void findSam() {
    Person sam = personService.findByName(SAM);
    assertNotNull("Should be able to find Sam", sam);
    DriversLicense driversLicense = sam.getDriversLicense();
    assertNotNull("Sam's driver's license should not be null", driversLicense);
    assertEquals("Verifying Sam's driver's license number", new Long(1234), driversLicense.getNumber());
  }
View Full Code Here

    assertEquals("Verifying Sam's driver's license number", new Long(1234), driversLicense.getNumber());
  }

  @Test
  public void saveJuergenWithDriversLicense() {
    DriversLicense driversLicense = new DriversLicense(2L, 2222L);
    Person juergen = new Person(JUERGEN, driversLicense);
    int numRows = countRowsInPersonTable();
    personService.save(juergen);
    assertPersonCount(numRows + 1);
    assertNotNull("Should be able to save and retrieve Juergen", personService.findByName(JUERGEN));
View Full Code Here

    assertNotNull("SessionFactory should have been autowired.", sessionFactory);
  }

  @Test
  public void findSam() {
    Person sam = personService.findByName(SAM);
    assertNotNull("Should be able to find Sam", sam);
    DriversLicense driversLicense = sam.getDriversLicense();
    assertNotNull("Sam's driver's license should not be null", driversLicense);
    assertEquals("Verifying Sam's driver's license number", new Long(1234), driversLicense.getNumber());
  }
View Full Code Here

  }

  @Test
  public void saveJuergenWithDriversLicense() {
    DriversLicense driversLicense = new DriversLicense(2L, 2222L);
    Person juergen = new Person(JUERGEN, driversLicense);
    int numRows = countRowsInPersonTable();
    personService.save(juergen);
    assertPersonCount(numRows + 1);
    assertNotNull("Should be able to save and retrieve Juergen", personService.findByName(JUERGEN));
    assertNotNull("Juergen's ID should have been set", juergen.getId());
  }
View Full Code Here

    assertNotNull("Juergen's ID should have been set", juergen.getId());
  }

  @Test(expected = ConstraintViolationException.class)
  public void saveJuergenWithNullDriversLicense() {
    personService.save(new Person(JUERGEN));
  }
View Full Code Here

  public void saveJuergenWithNullDriversLicense() {
    personService.save(new Person(JUERGEN));
  }

  private void updateSamWithNullDriversLicense() {
    Person sam = personService.findByName(SAM);
    assertNotNull("Should be able to find Sam", sam);
    sam.setDriversLicense(null);
    personService.save(sam);
  }
View Full Code Here

   * @see RunAfterTestClassCallbacks
   */
  @Override
  protected Statement withAfterClasses(Statement statement) {
    Statement junitAfterClasses = super.withAfterClasses(statement);
    return new RunAfterTestClassCallbacks(junitAfterClasses, getTestContextManager());
  }
View Full Code Here

   * @see RunAfterTestClassCallbacks
   */
  @Override
  protected Statement withAfterClasses(Statement statement) {
    Statement junitAfterClasses = super.withAfterClasses(statement);
    return new RunAfterTestClassCallbacks(junitAfterClasses, getTestContextManager());
  }
View Full Code Here

TOP

Related Classes of org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks

Copyright © 2018 www.massapicom. 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.