本文整理汇总了Java中org.glassfish.jersey.test.spi.TestContainerException类的典型用法代码示例。如果您正苦于以下问题:Java TestContainerException类的具体用法?Java TestContainerException怎么用?Java TestContainerException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TestContainerException类属于org.glassfish.jersey.test.spi包,在下文中一共展示了TestContainerException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import org.glassfish.jersey.test.spi.TestContainerException; //导入依赖的package包/类
@Override
public void start() {
System.out.println("Starting GrizzlyTestContainer...");
try {
this.server = GrizzlyHttpServerFactory.createHttpServer(uri, rc);
// Initialize and register Jersey Servlet
WebappContext context = new WebappContext("WebappContext", "");
ServletRegistration registration = context.addServlet("ServletContainer", ServletContainer.class);
registration.setInitParameter("javax.ws.rs.Application", rc.getClass().getName());
// Add an init parameter - this could be loaded from a parameter in the constructor
registration.setInitParameter("myparam", "myvalue");
registration.addMapping("/*");
context.deploy(server);
} catch (ProcessingException e) {
throw new TestContainerException(e);
}
}
示例2: SpringContextJerseyTest
import org.glassfish.jersey.test.spi.TestContainerException; //导入依赖的package包/类
/**
* An extending class must implement the {@link #configure()} method to
* provide an application descriptor.
*
* @throws TestContainerException if the default test container factory
* cannot be obtained, or the application descriptor is not
* supported by the test container factory.
*/
public SpringContextJerseyTest() throws TestContainerException {
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, getTestContainerFactory());
if (isLogRecordingEnabled()) {
loggedStartupRecords.addAll(loggedRuntimeRecords);
loggedRuntimeRecords.clear();
unregisterLogHandler();
}
}
示例3: getTestContainerFactory
import org.glassfish.jersey.test.spi.TestContainerException; //导入依赖的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;
}
};
}
示例4: setup
import org.glassfish.jersey.test.spi.TestContainerException; //导入依赖的package包/类
public void setup() throws Exception {
singletons.add(new InternalExceptionMapper());
test = new JerseyTest() {
@Override
protected TestContainerFactory getTestContainerFactory() throws TestContainerException {
return new InMemoryTestContainerFactory();
}
@Override
protected DeploymentContext configureDeployment() {
final DropwizardResourceConfig resourceConfig = new DropwizardResourceConfig();
for (Object singleton : singletons) {
resourceConfig.register(singleton);
}
ServletDeploymentContext deploymentContext = ServletDeploymentContext.builder(resourceConfig)
.initParam(ServletProperties.JAXRS_APPLICATION_CLASS, DropwizardResourceConfig.class.getName())
.build();
return deploymentContext;
}
@Override
protected void configureClient(ClientConfig config) {
JacksonJsonProvider jsonProvider = new JacksonJsonProvider();
jsonProvider.setMapper(Jackson.newObjectMapper());
config.register(jsonProvider);
}
};
test.setUp();
}
示例5: getTestContainerFactory
import org.glassfish.jersey.test.spi.TestContainerException; //导入依赖的package包/类
@Override
protected TestContainerFactory getTestContainerFactory() throws TestContainerException {
return new InMemoryTestContainerFactory();
}
示例6: getTestContainerFactory
import org.glassfish.jersey.test.spi.TestContainerException; //导入依赖的package包/类
@Override
protected TestContainerFactory getTestContainerFactory() throws TestContainerException {
return new ExtendedGrizzlyTestContainerFactory();
}
示例7: getTestContainerFactory
import org.glassfish.jersey.test.spi.TestContainerException; //导入依赖的package包/类
@Override
protected TestContainerFactory getTestContainerFactory() throws TestContainerException {
return JerseyRule.this.getTestContainerFactory();
}
示例8: getTestContainerFactory
import org.glassfish.jersey.test.spi.TestContainerException; //导入依赖的package包/类
@Override
protected TestContainerFactory getTestContainerFactory() throws TestContainerException {
return new ExtendedGrizzlyTestContainerFactory();
}
示例9: getTestContainerFactory
import org.glassfish.jersey.test.spi.TestContainerException; //导入依赖的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();
}
};
}
};
}
示例10: JerseyTestOnPojo
import org.glassfish.jersey.test.spi.TestContainerException; //导入依赖的package包/类
public JerseyTestOnPojo() throws TestContainerException {
super(new InMemoryTestContainerFactory());
}
示例11: JerseyTestOnDerby
import org.glassfish.jersey.test.spi.TestContainerException; //导入依赖的package包/类
public JerseyTestOnDerby() throws TestContainerException {
super(new InMemoryTestContainerFactory());
}
示例12: RemoteConverterTestDelegate
import org.glassfish.jersey.test.spi.TestContainerException; //导入依赖的package包/类
public RemoteConverterTestDelegate(boolean operational) throws TestContainerException {
this.operational = operational;
this.jerseyTest = new ConfiguredJerseyTest();
}
示例13: getTestContainerFactory
import org.glassfish.jersey.test.spi.TestContainerException; //导入依赖的package包/类
@Override
protected TestContainerFactory getTestContainerFactory() throws TestContainerException {
return new GrizzlyWebTestContainerFactory();
}
示例14: getTestContainerFactory
import org.glassfish.jersey.test.spi.TestContainerException; //导入依赖的package包/类
@Override
protected final TestContainerFactory getTestContainerFactory() throws TestContainerException {
return new GrizzlyWebTestContainerFactory();
}
示例15: getTestContainerFactory
import org.glassfish.jersey.test.spi.TestContainerException; //导入依赖的package包/类
@Override
protected TestContainerFactory getTestContainerFactory() throws TestContainerException {
return new GrizzlyWebTestContainerFactory();
}