示例#1
0
  /**
   * Tear down the test by invoking {@link TestContainer#stop() } on the test container obtained
   * from the test container factory.
   *
   * @throws Exception if an exception is thrown during tearing down the test environment.
   */
  @After
  public void tearDown() throws Exception {
    if (isLogRecordingEnabled()) {
      loggedRuntimeRecords.clear();
      unregisterLogHandler();
    }

    try {
      tc.stop();
    } finally {
      Client old = client.getAndSet(null);
      close(old);
    }
  }
示例#2
0
  /**
   * Tear down the test by {@link TestContainer#stop() stopping} the test container obtained from
   * the {@link #getTestContainerFactory() test container factory} and by {@link
   * javax.ws.rs.client.Client#close() closing} and discarding the {@link
   * #configureClient(org.glassfish.jersey.client.ClientConfig) pre-configured} test client that was
   * {@link #setUp() set up} for the test.
   *
   * @throws Exception if an exception is thrown during tearing down the test environment.
   */
  @After
  public void tearDown() throws Exception {
    if (isLogRecordingEnabled()) {
      unregisterLogHandler();
    }

    try {
      TestContainer oldContainer = setTestContainer(null);
      if (oldContainer != null) {
        oldContainer.stop();
      }
    } finally {
      closeIfNotNull(setClient(null));
    }
  }
示例#3
0
 /**
  * Construct a new instance with an application descriptor that defines how the test container is
  * configured.
  *
  * @param jaxrsApplication an application describing how to configure the test container.
  * @throws TestContainerException if the default test container factory cannot be obtained, or the
  *     application descriptor is not supported by the test container factory.
  */
 public JerseyTest(Application jaxrsApplication) throws TestContainerException {
   ResourceConfig config = getResourceConfig(jaxrsApplication);
   config.register(
       new ServiceFinderBinder<TestContainerFactory>(
           TestContainerFactory.class, null, RuntimeType.SERVER));
   if (isLogRecordingEnabled()) {
     registerLogHandler();
   }
   this.application = new ApplicationHandler(config);
   this.tc = getContainer(application, getTestContainerFactory());
   if (isLogRecordingEnabled()) {
     loggedStartupRecords.addAll(loggedRuntimeRecords);
     loggedRuntimeRecords.clear();
     unregisterLogHandler();
   }
 }