use of com.sun.jersey.api.client.Client in project hadoop by apache.
the class TestTimelineReaderWebServices method testGetEntitiesNoMatch.
@Test
public void testGetEntitiesNoMatch() throws Exception {
Client client = createClient();
try {
URI uri = URI.create("http://localhost:" + serverPort + "/ws/v2/" + "timeline/clusters/cluster1/apps/app1/entities/app?" + "metricfilters=metric7%20ge%200&isrelatedto=type1:tid1_1:tid1_2," + "type2:tid2_1%60&relatesto=flow:flow1&eventfilters=event_2,event_4" + "&infofilters=info2%20eq%203.5&createdtimestart=1425016502030&" + "createdtimeend=1425016502060");
ClientResponse resp = getResponse(client, uri);
Set<TimelineEntity> entities = resp.getEntity(new GenericType<Set<TimelineEntity>>() {
});
assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, resp.getType().toString());
assertNotNull(entities);
assertEquals(0, entities.size());
} finally {
client.destroy();
}
}
use of com.sun.jersey.api.client.Client in project hadoop by apache.
the class TestTimelineReaderWebServices method testGetEntitiesBasedOnCreatedTime.
@Test
public void testGetEntitiesBasedOnCreatedTime() throws Exception {
Client client = createClient();
try {
URI uri = URI.create("http://localhost:" + serverPort + "/ws/v2/" + "timeline/clusters/cluster1/apps/app1/entities/app?" + "createdtimestart=1425016502030&createdtimeend=1425016502060");
ClientResponse resp = getResponse(client, uri);
Set<TimelineEntity> entities = resp.getEntity(new GenericType<Set<TimelineEntity>>() {
});
assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, resp.getType().toString());
assertNotNull(entities);
assertEquals(1, entities.size());
assertTrue("Entity with id_4 should have been present in response.", entities.contains(newEntity("app", "id_4")));
uri = URI.create("http://localhost:" + serverPort + "/ws/v2/timeline/" + "clusters/cluster1/apps/app1/entities/app?createdtimeend" + "=1425016502010");
resp = getResponse(client, uri);
entities = resp.getEntity(new GenericType<Set<TimelineEntity>>() {
});
assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, resp.getType().toString());
assertNotNull(entities);
assertEquals(3, entities.size());
assertFalse("Entity with id_4 should not have been present in response.", entities.contains(newEntity("app", "id_4")));
uri = URI.create("http://localhost:" + serverPort + "/ws/v2/timeline/" + "clusters/cluster1/apps/app1/entities/app?createdtimestart=" + "1425016502010");
resp = getResponse(client, uri);
entities = resp.getEntity(new GenericType<Set<TimelineEntity>>() {
});
assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, resp.getType().toString());
assertNotNull(entities);
assertEquals(1, entities.size());
assertTrue("Entity with id_4 should have been present in response.", entities.contains(newEntity("app", "id_4")));
} finally {
client.destroy();
}
}
use of com.sun.jersey.api.client.Client in project commons by twitter.
the class Main method getModules.
@Override
public Iterable<? extends Module> getModules() {
return Arrays.asList(new HttpModule(), new LogModule(), new StatsModule(), new AbstractModule() {
@Override
protected void configure() {
bind(new TypeLiteral<Closure<String>>() {
}).toInstance(new Closure<String>() {
private final Client http = Client.create();
@Override
public void execute(String path) {
http.asyncResource("http://" + PING_TARGET.get() + path).get(String.class);
}
});
install(new JerseyServletModule() {
@Override
protected void configureServlets() {
filter("/ping*").through(GuiceContainer.class, ImmutableMap.<String, String>of());
Registration.registerEndpoint(binder(), "/ping");
bind(PingHandler.class);
}
});
}
});
}
use of com.sun.jersey.api.client.Client in project neo4j by neo4j.
the class EnterpriseServerIT method shouldRequireAuthorizationForHAStatusEndpoints.
@Test
public void shouldRequireAuthorizationForHAStatusEndpoints() throws Exception {
// Given
NeoServer server = EnterpriseServerBuilder.server().withProperty(GraphDatabaseSettings.auth_enabled.name(), "true").usingDataDir(folder.getRoot().getAbsolutePath()).withProperty(mode.name(), "HA").withProperty(server_id.name(), "1").withProperty(initial_hosts.name(), ":5001").persistent().build();
try {
server.start();
server.getDatabase();
assertThat(server.getDatabase().getGraph(), is(instanceOf(HighlyAvailableGraphDatabase.class)));
Client client = Client.create();
ClientResponse r = client.resource("http://localhost:7474/db/manage/server/ha").accept(APPLICATION_JSON).get(ClientResponse.class);
assertEquals(401, r.getStatus());
} finally {
server.stop();
}
}
use of com.sun.jersey.api.client.Client in project neo4j by neo4j.
the class EnterpriseServerIT method shouldAllowDisablingAuthorizationOnHAStatusEndpoints.
@Test
public void shouldAllowDisablingAuthorizationOnHAStatusEndpoints() throws Exception {
// Given
NeoServer server = EnterpriseServerBuilder.server().withProperty(GraphDatabaseSettings.auth_enabled.name(), "true").withProperty(HaSettings.ha_status_auth_enabled.name(), "false").usingDataDir(folder.getRoot().getAbsolutePath()).withProperty(mode.name(), "HA").withProperty(server_id.name(), "1").withProperty(initial_hosts.name(), ":5001").persistent().build();
try {
server.start();
server.getDatabase();
assertThat(server.getDatabase().getGraph(), is(instanceOf(HighlyAvailableGraphDatabase.class)));
Client client = Client.create();
ClientResponse r = client.resource("http://localhost:7474/db/manage/server/ha").accept(APPLICATION_JSON).get(ClientResponse.class);
assertEquals(200, r.getStatus());
assertThat(r.getEntity(String.class), containsString("master"));
} finally {
server.stop();
}
}
Aggregations