本文整理汇总了Java中org.glassfish.jersey.test.spi.TestContainer类的典型用法代码示例。如果您正苦于以下问题:Java TestContainer类的具体用法?Java TestContainer怎么用?Java TestContainer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TestContainer类属于org.glassfish.jersey.test.spi包,在下文中一共展示了TestContainer类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: start
import org.glassfish.jersey.test.spi.TestContainer; //导入依赖的package包/类
public TestServiceRunner start() {
ServiceConfig serviceConfigwithProps = serviceConfig.addPropertiesAndApplyToBindings(propertyMap);
ServiceConfig serviceConfigWithContext = ServiceConfigInitializer.finalize(serviceConfigwithProps);
JerseyConfig jerseyConfig = new JerseyConfig(serviceConfigWithContext.serviceDefinition)
.addRegistrators(serviceConfigWithContext.registrators)
.addBinders(serviceConfigWithContext.binders);
serviceConfigWithContext.addons.forEach(it -> it.addToJerseyConfig(jerseyConfig));
DeploymentContext context = DeploymentContext.builder(jerseyConfig.getResourceConfig()).build();
URI uri = UriBuilder.fromUri("http://localhost/").port(0).build();
TestContainer testContainer = new InMemoryTestContainerFactory().create(uri, context);
testContainer.start();
ClientConfig clientConfig = testContainer.getClientConfig();
ClientGenerator clientGenerator = clientConfigurator.apply(
ClientGenerator.defaults(serviceConfigWithContext.serviceDefinition)
.clientConfigBase(clientConfig)
);
Client client = clientGenerator.generate();
Runtime runtime = new Runtime(serviceConfigWithContext, jerseyConfig, testContainer, clientConfig, uri, client, stubConfigurator, targetConfigurator);
return withServiceConfig(serviceConfigWithContext).withRuntime(runtime);
}
开发者ID:code-obos,项目名称:servicebuilder,代码行数:24,代码来源:TestServiceRunner.java
示例2: getTestContainerFactory
import org.glassfish.jersey.test.spi.TestContainer; //导入依赖的package包/类
@Override
protected TestContainerFactory getTestContainerFactory() {
final URI baseURI = getBaseURI();
return (uri, deploymentContext) -> new TestContainer() {
@Override
public ClientConfig getClientConfig() {
return clientConfig;
}
@Override
public URI getBaseUri() {
return baseURI;
}
@Override
public void start() {
// noop
}
@Override
public void stop() {
// noop
}
};
}
开发者ID:apache,项目名称:usergrid,代码行数:26,代码来源:AbstractRestIT.java
示例3: getClient
import org.glassfish.jersey.test.spi.TestContainer; //导入依赖的package包/类
/**
* 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);
}
开发者ID:amacoder,项目名称:demo-restWS-spring-jersey-tomcat-mybatis,代码行数:30,代码来源:SpringContextJerseyTest.java
示例4: getTestContainerFactory
import org.glassfish.jersey.test.spi.TestContainer; //导入依赖的package包/类
protected TestContainerFactory getTestContainerFactory() throws TestContainerException {
final TestContainerFactory testContainerFactory = super.getTestContainerFactory();
return new TestContainerFactory() {
@Override
public TestContainer create(URI baseUri, DeploymentContext deploymentContext) {
TestContainer container = testContainerFactory.create(baseUri, deploymentContext);
try {
Field field = container.getClass().getDeclaredField("server");
field.setAccessible(true);
Server server = (Server) field.get(container);
Handler handler = server.getHandler();
SecurityHandler securityHandler = identityManager.getSecurityHandler();
if (securityHandler.getHandler() == null) {
securityHandler.setHandler(handler);
}
server.setHandler(securityHandler);
}
catch (Exception e) {
throw new IllegalStateException(e);
}
return container;
}
};
}
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:28,代码来源:SecurityModuleIntTest.java
示例5: run
import org.glassfish.jersey.test.spi.TestContainer; //导入依赖的package包/类
public static <T> T run(Application application, BiFunction<ClientConfig, URI, T> testfun) {
DeploymentContext context = DeploymentContext.builder(application).build();
URI uri = UriBuilder.fromUri("http://localhost/").port(0).build();
final TestContainer testContainer = new InMemoryTestContainerFactory().create(uri, context);
testContainer.start();
ClientConfig clientConfig1 = testContainer.getClientConfig();
try {
return testfun.apply(clientConfig1, uri);
} finally {
testContainer.stop();
}
}
开发者ID:code-obos,项目名称:servicebuilder,代码行数:16,代码来源:EmbeddedJerseyServer.java
示例6: getContainer
import org.glassfish.jersey.test.spi.TestContainer; //导入依赖的package包/类
private TestContainer getContainer(ApplicationHandler application, TestContainerFactory tcf) {
if (application == null) {
throw new IllegalArgumentException("The application cannot be null");
}
return tcf.create(getBaseUri(), application);
}
开发者ID:Ellychou,项目名称:Todo-Jersey-Spring-MyBatis,代码行数:8,代码来源:SpringContextJerseyTest.java
示例7: create
import org.glassfish.jersey.test.spi.TestContainer; //导入依赖的package包/类
@Override
public TestContainer create(URI baseUri, ApplicationHandler application) throws IllegalArgumentException {
URI uri = UriBuilder.fromUri(baseUri).port(baseUri.getPort() + getCount()).build();
System.out.println("Uri: " + uri);
System.out.println("App: " + application.getConfiguration().getApplication().getClass().getName());
return new MyTestContainer(uri, application);
}
开发者ID:williamwebb,项目名称:divide,代码行数:9,代码来源:WebContainerFactory.java
示例8: getTestContainerFactory
import org.glassfish.jersey.test.spi.TestContainer; //导入依赖的package包/类
@Override
protected TestContainerFactory getTestContainerFactory() {
final URI baseURI = getBaseUri();
return new TestContainerFactory() {
@Override
public TestContainer create(URI uri, DeploymentContext deploymentContext) {
return new TestContainer() {
@Override
public ClientConfig getClientConfig() {
return clientConfig;
}
@Override
public URI getBaseUri() {
return baseURI;
}
@Override
public void start() {
// noop
}
@Override
public void stop() {
// noop
}
};
}
};
}
开发者ID:apache,项目名称:usergrid,代码行数:34,代码来源:OrganizationTest.java
示例9: create
import org.glassfish.jersey.test.spi.TestContainer; //导入依赖的package包/类
@Override
public TestContainer create(URI baseUri, DeploymentContext deploymentContext) {
return new GrizzlyTestContainer(baseUri, deploymentContext.getResourceConfig());
}
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:5,代码来源:MCRJerseyTest.java
示例10: getTestContainerFactory
import org.glassfish.jersey.test.spi.TestContainer; //导入依赖的package包/类
@Override
protected TestContainerFactory getTestContainerFactory() throws TestContainerException {
return new TestContainerFactory() {
@Override
public TestContainer create(final URI baseUri, DeploymentContext deploymentContext) {
return new TestContainer() {
private HelixRestServer _helixRestServer;
@Override
public ClientConfig getClientConfig() {
return null;
}
@Override
public URI getBaseUri() {
return baseUri;
}
@Override
public void start() {
// Create namespace manifest map
List<HelixRestNamespace> namespaces = new ArrayList<>();
// Add test namespace
namespaces.add(new HelixRestNamespace(TEST_NAMESPACE, HelixRestNamespace.HelixMetadataStoreType.ZOOKEEPER,
_zkAddrTestNS, false));
// Add default namesapce
namespaces.add(new HelixRestNamespace(ZK_ADDR));
try {
_helixRestServer = new HelixRestServer(namespaces, baseUri.getPort(), baseUri.getPath(),
Arrays.<AuditLogger>asList(_auditLogger));
_helixRestServer.start();
} catch (Exception ex) {
throw new TestContainerException(ex);
}
}
@Override
public void stop() {
_helixRestServer.shutdown();
}
};
}
};
}
开发者ID:apache,项目名称:helix,代码行数:44,代码来源:AbstractTestClass.java
示例11: create
import org.glassfish.jersey.test.spi.TestContainer; //导入依赖的package包/类
/**
* @see org.glassfish.jersey.test.spi.TestContainerFactory#create(java.net.URI,
* org.glassfish.jersey.test.DeploymentContext)
*/
@Override
public TestContainer create(final URI baseUri, final DeploymentContext context) throws IllegalArgumentException {
return new CdiAwareInMemoryTestContainer(baseUri, context);
}
开发者ID:gtcGroup,项目名称:jped-parent-project,代码行数:9,代码来源:CdiAwareInMemoryTestContainerFactory.java
注:本文中的org.glassfish.jersey.test.spi.TestContainer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论