/** * Get stored {@link LogRecord log records} if enabled by setting {@link TestProperties#RECORD_LOG_LEVEL} or an empty list. * * @return list of log records or an empty list. */ protected final List<LogRecord> getLoggedRecords() { return getLogHandler().getRecords(); }
/** * Build a new application deployment context configured by the current state of this * application deployment context builder. * * @return this application deployment context builder. */ public DeploymentContext build() { final DeploymentContext lld = new DeploymentContext(this); reset(); return lld; }
/** * Build a new servlet deployment context configured by the current state of this * servlet deployment context builder. * * @return this servlet deployment context builder. */ @Override public ServletDeploymentContext build() { ServletDeploymentContext wd = new ServletDeploymentContext(this); reset(); return wd; }
@Override protected DeploymentContext configureDeployment() { return ServletDeploymentContext.builder(new DropwizardTestResourceConfig(configuration)) .initParam(ServletProperties.JAXRS_APPLICATION_CLASS, DropwizardTestResourceConfig.class.getName()) .initParam(DropwizardTestResourceConfig.CONFIGURATION_ID, configuration.getId()) .build(); }
/** * Creates a web target to be sent to the resource under testing. * * @param path relative path (from tested application base URI) this web target should point to. * @return the created JAX-RS web target. */ public WebTarget target(String path) { return getJerseyTest().target(path); }
/** * Create a builder with one initialization parameter. * * @param name the parameter name. * @param value the parameter value. */ public Builder(String name, String value) { initParam(name, value); }
/** * Create a new deployment context for a JAX-RS / Jersey application instance. * <p> * The created deployment context will be configured to use default values. * </p> * * @param applicationClass a JAX-RS / Jersey application to be tested. * @return new deployment context instance associated with the JAX-RS / Jersey application to be tested. * * @throws java.lang.NullPointerException in case the {@code applicationClass} is {@code null}. */ public static DeploymentContext newInstance(final Class<? extends Application> applicationClass) { return new Builder(applicationClass).build(); }
@Override public Builder contextPath(String contextPath) { super.contextPath(contextPath); return this; }
/** * Create new servlet deployment context builder initialized from the supplied initialization parameters. * * @param initParams a map of initialization parameters. The parameters will be copied. * @return new servlet deployment context builder instance initialized from the supplied initialization parameters. * * @throws java.lang.NullPointerException is the specified map is {@code null}. */ public static Builder builder(final Map<String, String> initParams) { return new Builder().initParams(initParams); }
/** * Returns the pre-configured {@link Client} for this test. For sending * requests prefer {@link #target(String)} * * @return the {@link JerseyTest} configured {@link Client} */ public Client client() { return getJerseyTest().client(); }
/** * Create a new deployment context builder for a JAX-RS / Jersey application instance. * * @param application a JAX-RS / Jersey application to be tested. * @return new deployment context builder instance associated with the JAX-RS / Jersey application to be tested. * * @throws java.lang.NullPointerException in case the {@code application} is {@code null}. */ public static Builder builder(final Application application) { return new Builder(application); }
/** * Create a new servlet deployment context builder for a JAX-RS / Jersey application instance. * * @param applicationClass a JAX-RS / Jersey application to be tested. * @return new servlet deployment context builder instance associated with the JAX-RS / Jersey application to be tested. * * @throws java.lang.NullPointerException in case the {@code applicationClass} is {@code null}. */ public static Builder builder(final Class<? extends Application> applicationClass) { return new Builder(applicationClass); }
@Override protected TestNgStrategy configureStrategy() { return new ContainerPerMethodTestNgStrategy(); } }
/** * Get the JAX-RS test client that is {@link #configureClient(org.glassfish.jersey.client.ClientConfig) pre-configured} * for this test. * * @return the configured test client. */ public final Client client() { return getClient(); }
/** * Retrieves {@link Handler log handler} capable of storing {@link LogRecord logged records}. * * @return log handler. */ private JerseyTestLogHandler getLogHandler() { if (logHandler == null) { logHandler = new JerseyTestLogHandler(); } return logHandler; }
@Override protected TestNgStrategy configureStrategy() { return new ContainerPerClassTestNgStrategy(); } }
@Override protected void reset() { super.reset(); this.initParams = null; this.contextParams = null; this.servletInstance = null; this.servletClass = ServletContainer.class; this.filters = null; this.listeners = null; this.servletPath = ""; } }
/** * Return {@code true} if log recoding is enabled. * * @return {@code true} if log recoding is enabled, {@code false} otherwise. */ private boolean isLogRecordingEnabled() { return getProperty(TestProperties.RECORD_LOG_LEVEL) != null; }
/** * Create a new deployment context builder for a JAX-RS / Jersey application instance. * * @param applicationClass a JAX-RS / Jersey application to be tested. * @return new deployment context builder instance associated with the JAX-RS / Jersey application to be tested. * * @throws java.lang.NullPointerException in case the {@code applicationClass} is {@code null}. */ public static Builder builder(final Class<? extends Application> applicationClass) { return new Builder(applicationClass); }
/** * Create a new servlet deployment context builder for a JAX-RS / Jersey application instance. * * @param application a JAX-RS / Jersey application to be tested. * @return new servlet deployment context builder instance associated with the JAX-RS / Jersey application to be tested. * * @throws java.lang.NullPointerException in case the {@code application} is {@code null}. */ public static Builder builder(final Application application) { return new Builder(application); }