Package javax.ws.rs.client

Examples of javax.ws.rs.client.WebTarget.path()


    @Test
    public void testHelloWorld() throws Exception {
        WebTarget t = target();
        t.register(new LoggingFilter());
        Response r = t.path("helloworld").request().get();
        assertEquals(200, r.getStatus());
        assertEquals("Hello World!", r.readEntity(String.class));
    }

    @Test
View Full Code Here


    @Test
    public void testSingletonScopedSpringService() {
        final BigDecimal newBalance = new BigDecimal(Math.random());
        final WebTarget t = target(getResourceFullPath());

        t.path("/singleton/xyz123").request().put(Entity.entity(newBalance.toString(), MediaType.TEXT_PLAIN_TYPE));
        final BigDecimal balance = t.path("/singleton/autowired/xyz123").request().get(BigDecimal.class);
        assertEquals(newBalance, balance);
    }

    @Test
View Full Code Here

    public void testSingletonScopedSpringService() {
        final BigDecimal newBalance = new BigDecimal(Math.random());
        final WebTarget t = target(getResourceFullPath());

        t.path("/singleton/xyz123").request().put(Entity.entity(newBalance.toString(), MediaType.TEXT_PLAIN_TYPE));
        final BigDecimal balance = t.path("/singleton/autowired/xyz123").request().get(BigDecimal.class);
        assertEquals(newBalance, balance);
    }

    @Test
    public void testRequestScopedSpringService() {
View Full Code Here

    @Test
    public void testRequestScopedSpringService() {
        final BigDecimal newBalance = new BigDecimal(Math.random());
        final WebTarget t = target(getResourceFullPath());
        final BigDecimal balance = t.path("request/abc456").request().put(Entity.text(newBalance), BigDecimal.class);
        assertEquals(newBalance, balance);
    }

    @Test
    public void testPrototypeScopedSpringService() {
View Full Code Here

    @Test
    public void testPrototypeScopedSpringService() {
        final BigDecimal newBalance = new BigDecimal(Math.random());
        final WebTarget t = target(getResourceFullPath());
        final BigDecimal balance = t.path("prototype/abc456").request().put(Entity.text(newBalance), BigDecimal.class);
        assertEquals(new BigDecimal("987.65"), balance);
    }
}
View Full Code Here

    @Test
    public void testTimeout() throws Exception {
        final WebTarget resourceTarget = target("timeout");
        resourceTarget.register(new LoggingFilter());
        final Future<Response> responseFuture = resourceTarget.path("suspend").request().async().get();

        // Set timeout.
        assertThat(resourceTarget.path("timeout").request().post(Entity.text("500")).getStatus(), equalTo(204));

        // Wait for it.
View Full Code Here

        final WebTarget resourceTarget = target("timeout");
        resourceTarget.register(new LoggingFilter());
        final Future<Response> responseFuture = resourceTarget.path("suspend").request().async().get();

        // Set timeout.
        assertThat(resourceTarget.path("timeout").request().post(Entity.text("500")).getStatus(), equalTo(204));

        // Wait for it.
        assertThat(responseFuture.get().readEntity(String.class), equalTo("timeout1=true_timeout2=true_handled"));
    }
}
View Full Code Here

    @Test
    public void testResourceScope() {
        final WebTarget t = target(getResourceFullPath());
        final String message = "hello, world";
        final String echo = t.path("message").request().put(Entity.text(message), String.class);
        assertEquals(message, echo);
        final String msg = t.path("message").request().get(String.class);
        assertEquals(message, msg);
    }
View Full Code Here

    public void testResourceScope() {
        final WebTarget t = target(getResourceFullPath());
        final String message = "hello, world";
        final String echo = t.path("message").request().put(Entity.text(message), String.class);
        assertEquals(message, echo);
        final String msg = t.path("message").request().get(String.class);
        assertEquals(message, msg);
    }

}
View Full Code Here

        final EventSource[] sources = new EventSource[MAX_LISTENERS];
        final AtomicInteger sizeEventsCount = new AtomicInteger(0);

        for (int i = 0; i < MAX_LISTENERS; i++) {
            final int id = i;
            final EventSource es = EventSource.target(itemsTarget.path("events"))
                    .named("SOURCE " + id).build();
            sources[id] = es;

            final Queue<Integer> indexes = new ConcurrentLinkedQueue<Integer>();
            indexQueues.add(indexes);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.