本文整理汇总了Java中org.glassfish.jersey.test.JerseyTest类的典型用法代码示例。如果您正苦于以下问题:Java JerseyTest类的具体用法?Java JerseyTest怎么用?Java JerseyTest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JerseyTest类属于org.glassfish.jersey.test包,在下文中一共展示了JerseyTest类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createJerseyTest
import org.glassfish.jersey.test.JerseyTest; //导入依赖的package包/类
private JerseyTest createJerseyTest(Boolean binaryCompressionOnly) {
return new JerseyTest() {
@Override
protected Application configure() {
ResourceConfig config = new ResourceConfig();
config.register(TestResource.class);
config.register(EncodingFilter.class);
config.register(GZipEncoder.class);
config.register(GatewayBinaryResponseFilter.class);
if (binaryCompressionOnly != null) {
config.property(GatewayBinaryResponseFilter.BINARY_COMPRESSION_ONLY_PROPERTY,
binaryCompressionOnly);
}
return config;
}
};
}
示例2: configure
import org.glassfish.jersey.test.JerseyTest; //导入依赖的package包/类
@Override
protected Application configure() {
ResourceConfig resourceConfig = new ResourceConfig()
.register(LocatorFeature.class)
.register(JacksonFeature.class)
.register(RxJerseyClientFeature.class)
.register(ServerResource.class)
.register(new AbstractBinder() {
@Override
protected void configure() {
bind(RxJerseyTest.this).to(JerseyTest.class);
}
});
configure(resourceConfig);
return resourceConfig;
}
示例3: setup
import org.glassfish.jersey.test.JerseyTest; //导入依赖的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();
}
示例4: setApplicationContext
import org.glassfish.jersey.test.JerseyTest; //导入依赖的package包/类
@Autowired
public void setApplicationContext(final ApplicationContext context)
{
_jerseyTest = new JerseyTest()
{
@Override
protected Application configure()
{
// Find first available port.
forceSet(TestProperties.CONTAINER_PORT, "0");
ResourceConfig application = new GraviteeApplication(authenticationProviderManager);
application.property("contextConfig", context);
decorate(application);
return application;
}
@Override
protected void configureClient(ClientConfig config) {
super.configureClient(config);
config.register(ObjectMapperResolver.class);
}
};
}
示例5: signUpUser
import org.glassfish.jersey.test.JerseyTest; //导入依赖的package包/类
public static synchronized Credentials signUpUser(JerseyTest test) throws Exception{
PublicKey publicKey = getPublicKey(test);
Credentials signInUser = TestUtils.getTestUser();
signInUser.encryptPassword(publicKey);
String user = test.target("/auth").request().post(TestUtils.toEntity(signInUser), String.class);
Credentials returnedUser = TestUtils.getGson().fromJson(user,Credentials.class);
assertEquals(signInUser.getUsername(), returnedUser.getUsername());
return returnedUser;
}
示例6: registerToken
import org.glassfish.jersey.test.JerseyTest; //导入依赖的package包/类
private Response registerToken(Credentials user, PublicKey key, JerseyTest test){
EncryptedEntity.Writter entity = new EncryptedEntity.Writter(key);
entity.put("token", "whatwhat");
Response response = target("/push")
.request()
.header(ContainerRequest.AUTHORIZATION, "CUSTOM " + user.getAuthToken())
.buildPost(TestUtils.toEntity(entity)).invoke();
int statusCode = response.getStatus();
assertEquals(200,statusCode);
return response;
}
示例7: getJerseyTest
import org.glassfish.jersey.test.JerseyTest; //导入依赖的package包/类
protected JerseyTest getJerseyTest() {
// This is instantiated on demand since we need subclasses to register the resources they need
// passed along, but JerseyTest calls configure() from its constructor.
if (test == null) {
test = new JettyJerseyTest();
}
return test;
}
示例8: getHarness
import org.glassfish.jersey.test.JerseyTest; //导入依赖的package包/类
public JerseyTest getHarness() {
return harness;
}
示例9: getPublicKey
import org.glassfish.jersey.test.JerseyTest; //导入依赖的package包/类
public static synchronized PublicKey getPublicKey(JerseyTest test) throws Exception{
String publicKeyBytes = test.target("/auth/key").request().get(String.class);
byte[] bytes = TestUtils.getGson().fromJson(publicKeyBytes,byte[].class);
return Crypto.pubKeyFromBytes(bytes);
}
示例10: runJerseyTest
import org.glassfish.jersey.test.JerseyTest; //导入依赖的package包/类
/**
* <ol>
* <li>calls {@link JerseyTest#setUp()}
* <li>passes the initialized JerseyTest to the consumer.
* <li>calls {@link JerseyTest#tearDown()}
* </ol>
*
* @param jerseyTest
* @param test
* @throws Exception
*/
public void runJerseyTest(JerseyTest jerseyTest, ThrowingConsumer<JerseyTest> test) throws Exception {
try {
jerseyTest.setUp();
test.accept(jerseyTest);
} finally {
jerseyTest.tearDown();
}
}