use of javax.ws.rs.client.WebTarget in project jersey by jersey.
the class JerseyWebTargetTest method testResolveTemplatesEmptyMap.
@Test
public void testResolveTemplatesEmptyMap() {
WebTarget wt = target;
wt = wt.resolveTemplates(Collections.<String, Object>emptyMap());
assertEquals(target, wt);
}
use of javax.ws.rs.client.WebTarget in project jersey by jersey.
the class JerseyWebTargetTest method testResolveTemplatesEncodeSlashEmptyMap.
@Test
public void testResolveTemplatesEncodeSlashEmptyMap() {
WebTarget wt = target;
wt = wt.resolveTemplates(Collections.<String, Object>emptyMap(), false);
assertEquals(target, wt);
}
use of javax.ws.rs.client.WebTarget in project jersey by jersey.
the class JerseyWebTargetTest method testResolveTemplateNull1.
@Test(expected = NullPointerException.class)
public void testResolveTemplateNull1() {
WebTarget wt = target;
wt.resolveTemplate(null, "", true);
}
use of javax.ws.rs.client.WebTarget in project jersey by jersey.
the class ShutdownHookLeakTest method testShutdownHookDoesNotLeak.
@SuppressWarnings("unchecked")
@Test
public void testShutdownHookDoesNotLeak() throws Exception {
final Client client = ClientBuilder.newClient();
final WebTarget target = client.target("http://example.com");
final Collection shutdownHooks = getShutdownHooks(client);
for (int i = 0; i < ITERATIONS; i++) {
// Create/Initialize client runtime.
target.property("Washington", "Irving").request().property("how", "now").buildGet().property("Irving", "Washington");
}
System.gc();
int notEnqueued = 0;
int notNull = 0;
for (final Object o : shutdownHooks) {
if (((WeakReference<JerseyClient.ShutdownHook>) o).get() != null) {
notNull++;
}
if (!((WeakReference<JerseyClient.ShutdownHook>) o).isEnqueued()) {
notEnqueued++;
}
}
assertThat("Non-null shutdown hook references count should not copy number of property invocation", // 66 % seems like a reasonable threshold for this test to keep it stable
notNull, is(lessThan(THRESHOLD)));
assertThat("Shutdown hook references count not enqueued in the ReferenceQueue should not copy number of property invocation", // 66 % seems like a reasonable threshold for this test to keep it stable
notEnqueued, is(lessThan(THRESHOLD)));
}
use of javax.ws.rs.client.WebTarget in project jersey by jersey.
the class WebTargetPropertiesTest method testPropagation.
@Test
public void testPropagation() {
Client c = ClientBuilder.newBuilder().newClient();
c.property("a", "val");
WebTarget w1 = c.target("http://a");
w1.property("b", "val");
WebTarget w2 = w1.path("c");
w2.property("c", "val");
assertTrue(c.getConfiguration().getProperties().containsKey("a"));
assertTrue(w1.getConfiguration().getProperties().containsKey("a"));
assertTrue(w2.getConfiguration().getProperties().containsKey("a"));
assertFalse(c.getConfiguration().getProperties().containsKey("b"));
assertTrue(w1.getConfiguration().getProperties().containsKey("b"));
assertTrue(w2.getConfiguration().getProperties().containsKey("b"));
assertFalse(c.getConfiguration().getProperties().containsKey("c"));
assertFalse(w1.getConfiguration().getProperties().containsKey("c"));
assertTrue(w2.getConfiguration().getProperties().containsKey("c"));
w2.property("a", null);
assertTrue(c.getConfiguration().getProperties().containsKey("a"));
assertTrue(w1.getConfiguration().getProperties().containsKey("a"));
assertFalse(w2.getConfiguration().getProperties().containsKey("a"));
}
Aggregations