Package javax.ws.rs.client

Examples of javax.ws.rs.client.WebTarget


    if ( !dataStore.exists( EntitiesDesignDocument.DOCUMENT_ID, true ) ) {
      dataStore.saveDocument( new EntitiesDesignDocument() );
    }

    Client client = ClientBuilder.newBuilder().build();
    WebTarget target = client.target( dataStore.getDatabaseIdentifier().getDatabaseUri() );
    ResteasyWebTarget rtarget = (ResteasyWebTarget) target;

    return rtarget.proxy( DatabaseTestClient.class );
  }
View Full Code Here


    return configuration;
  }

  private static void createServerAdminUser() {
    Client client = ClientBuilder.newClient();
    WebTarget target = client.target( serverUri + "/_config/admins/" + serverAdminUser );
    target.request().put( Entity.text( "\"" + serverAdminPassword + "\"" ) ).close();
  }
View Full Code Here

    target.request().put( Entity.text( "\"" + serverAdminPassword + "\"" ) ).close();
  }

  private static void createDatabaseUser() throws Exception {
    // 1.) create user
    WebTarget target = client.target( serverUri + "/_users/org.couchdb.user:" + databaseUser );
    Response response = target.request().put( Entity.text(
        "{ " +
            "\"_id\" : \"org.couchdb.user:" + databaseUser + "\", " +
            "\"type\" : \"user\", " +
            "\"name\" : \"" + databaseUser + "\", " +
            "\"roles\" : [], " +
            "\"password\" : \"" + databaseUserPassword + "\"" +
        " }" )
        );

    String entity = response.readEntity( String.class );
    databaseUserRevision = (String) new ObjectMapper().readValue( entity, Map.class ).get( "rev" );
    response.close();

    // 2.) make the user an admin of the database
    target = client.target( serverUri + "/" + database + "/_security" );
    response = target.request().put( Entity.text(
        "{" +
            "\"admins\": {" +
                "\"names\":[\"" + databaseUser + "\"]," +
                " \"roles\":[]" +
            "}, " +
View Full Code Here

    response.close();
  }

  private static void createTestDatabase() {
    WebTarget target = client.target( serverUri + "/" + database );
    target.request().put( null ).close();
  }
View Full Code Here

    WebTarget target = client.target( serverUri + "/" + database );
    target.request().put( null ).close();
  }

  private static void deleteDatabaseUser() {
    WebTarget target = client.target( serverUri + "/_users/org.couchdb.user:" + databaseUser + "?rev=" + databaseUserRevision );
    target.request().delete().close();
  }
View Full Code Here

    WebTarget target = client.target( serverUri + "/_users/org.couchdb.user:" + databaseUser + "?rev=" + databaseUserRevision );
    target.request().delete().close();
  }

  private static void dropTestDatabase() {
    WebTarget target = client.target( serverUri + "/" + database );
    target.request().delete().close();
  }
View Full Code Here

    WebTarget target = client.target( serverUri + "/" + database );
    target.request().delete().close();
  }

  private static void deleteServerAdminUser() {
    WebTarget target = client.target( serverUri + "/_config/admins/" + serverAdminUser );
    target.request().delete().close();
  }
View Full Code Here

        return new JerseyTestConfig().property("contextConfig", context);
    }

    @Test
    public void testBraveJersey2() {
        WebTarget target = target("/brave-jersey2/test");
        target.register(new BraveClientRequestFilter(clientTracer, Optional.<String>absent()));
        target.register(new BraveClientResponseFilter(clientTracer, Optional.<String>absent()));

        final EndPointSubmitter endPointSubmitter = Brave.getEndPointSubmitter();
        endPointSubmitter.submit("127.0.0.1", 9998, "brave-jersey2");
        final Response response = target.request().get();
        assertEquals(200, response.getStatus());

        final List<Span> collectedSpans = SpanCollectorForTesting.getInstance().getCollectedSpans();
        assertEquals(2, collectedSpans.size());
        final Span clientSpan = collectedSpans.get(0);
View Full Code Here

        this.client = ClientBuilder.newClient();
    }

    public String changeInterval(String location,int newValue){
        JsonObject interval = Json.createObjectBuilder().add("interval", newValue).add("location",location).build();
        WebTarget administrationTarget = getAdministrationTarget();
        final Response response = administrationTarget.request().post(Entity.json(interval));
        return response.readEntity(JsonObject.class).getString("nextTimeout");

    }
View Full Code Here

    }

    public void listenToMethodStatistics(Consumer<MethodsStatistics> consumer, Consumer<Throwable> error, String application, String ejbName) {
        final String uri = getUri();
        System.out.println("Uri: " + uri);
        WebTarget target = this.client.target(uri);

        target.
                resolveTemplate("application", application).
                resolveTemplate("ejb", ejbName).
                request(MediaType.APPLICATION_JSON).async().get(new InvocationCallback<JsonObject>() {
            @Override
            public void completed(JsonObject jsonObject) {
View Full Code Here

TOP

Related Classes of javax.ws.rs.client.WebTarget

Copyright © 2018 www.massapicom. 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.