Esempio n. 1
0
  /**
   * Construct a new instance with a test container factory.
   *
   * <p>An extending class must implement the {@link #configure()} method to provide an application
   * descriptor.
   *
   * @param testContainerFactory the test container factory to use for testing.
   * @throws TestContainerException if the application descriptor is not supported by the test
   *     container factory.
   */
  public JerseyTest(TestContainerFactory testContainerFactory) {
    setTestContainerFactory(testContainerFactory);

    ResourceConfig config = getResourceConfig(configure());
    config.register(
        new ServiceFinderBinder<TestContainerFactory>(
            TestContainerFactory.class, null, RuntimeType.SERVER));
    if (isLogRecordingEnabled()) {
      registerLogHandler();
    }
    this.application = new ApplicationHandler(config);
    this.tc = getContainer(application, testContainerFactory);
    if (isLogRecordingEnabled()) {
      loggedStartupRecords.addAll(loggedRuntimeRecords);
      loggedRuntimeRecords.clear();
      unregisterLogHandler();
    }
  }