本文整理匯總了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();
}
}