/** * Create an instance of test {@link Client} using the client configuration provided by the * configured {@link org.glassfish.jersey.test.spi.TestContainer}. * * <p>If the {@code TestContainer} does not provide any client configuration (passed {@code * clientConfig} is {@code null}), the default implementation of this method first creates an * empty new {@link org.glassfish.jersey.client.ClientConfig} instance. The client configuration * (provided by test container or created) is then passed to {@link * #configureClient(org.glassfish.jersey.client.ClientConfig)} which can be overridden in the * {@code JerseyTest} subclass to provide custom client configuration. At last, new JAX-RS {@link * Client} instance is created based on the resulting client configuration. * * @param clientConfig test client default configuration. May be {@code null}. * @return A Client instance. */ private Client getClient(ClientConfig clientConfig) { if (clientConfig == null) { clientConfig = new ClientConfig(); } // check if logging is required if (isEnabled(TestProperties.LOG_TRAFFIC)) { clientConfig.register(new LoggingFilter(LOGGER, isEnabled(TestProperties.DUMP_ENTITY))); } configureClient(clientConfig); return ClientBuilder.newClient(clientConfig); }
/** * Creates an instance of {@link Client}. * * <p>Checks whether TestContainer provides ClientConfig instance and if not, empty new {@link * org.glassfish.jersey.client.ClientConfig} instance will be used to create new client instance. * * <p>This method is called exactly once when JerseyTest is created. * * @param tc instance of {@link TestContainer} * @param applicationHandler instance of {@link ApplicationHandler} * @return A Client instance. */ protected Client getClient(TestContainer tc, ApplicationHandler applicationHandler) { ClientConfig cc = tc.getClientConfig(); if (cc == null) { cc = new ClientConfig(); } // check if logging is required if (isEnabled(TestProperties.LOG_TRAFFIC)) { cc.register(new LoggingFilter(LOGGER, isEnabled(TestProperties.DUMP_ENTITY))); } configureClient(cc); return ClientBuilder.newClient(cc); }