当前位置: 首页>>代码示例>>Java>>正文


Java JerseyClientBuilder类代码示例

本文整理汇总了Java中org.glassfish.jersey.client.JerseyClientBuilder的典型用法代码示例。如果您正苦于以下问题:Java JerseyClientBuilder类的具体用法?Java JerseyClientBuilder怎么用?Java JerseyClientBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JerseyClientBuilder类属于org.glassfish.jersey.client包,在下文中一共展示了JerseyClientBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testSwaggerJson

import org.glassfish.jersey.client.JerseyClientBuilder; //导入依赖的package包/类
@Test
public void testSwaggerJson() {
	Client client = JerseyClientBuilder.createClient();

	WebTarget target = client.target("http://localhost:" + port + "/v1/docs");
	Response response = target.request().get();
	Assert.assertEquals(200, response.getStatus());
	Assert.assertNotNull(response.getEntity());
	Assert.assertEquals("application/json", response.getMediaType().toString());

	target = client.target("http://localhost:" + port + "/v2/docs");
	response = target.request().get();
	Assert.assertEquals(200, response.getStatus());
	Assert.assertNotNull(response.getEntity());
	Assert.assertEquals("application/json", response.getMediaType().toString());
}
 
开发者ID:holon-platform,项目名称:holon-jaxrs,代码行数:17,代码来源:TestSwaggerJerseyAutoDetectMulti.java

示例2: testSwaggerYaml

import org.glassfish.jersey.client.JerseyClientBuilder; //导入依赖的package包/类
@Test
public void testSwaggerYaml() {
	Client client = JerseyClientBuilder.createClient();

	WebTarget target = client.target("http://localhost:" + port + "/v1/docs").queryParam("type", "yaml");
	Response response = target.request().get();
	Assert.assertEquals(200, response.getStatus());
	Assert.assertNotNull(response.getEntity());
	Assert.assertEquals("application/yaml", response.getMediaType().toString());

	target = client.target("http://localhost:" + port + "/v2/docs").queryParam("type", "yaml");
	response = target.request().get();
	Assert.assertEquals(200, response.getStatus());
	Assert.assertNotNull(response.getEntity());
	Assert.assertEquals("application/yaml", response.getMediaType().toString());
}
 
开发者ID:holon-platform,项目名称:holon-jaxrs,代码行数:17,代码来源:TestSwaggerJerseyAutoDetectMulti.java

示例3: testSwaggerJson

import org.glassfish.jersey.client.JerseyClientBuilder; //导入依赖的package包/类
@Test
public void testSwaggerJson() {
	Client client = JerseyClientBuilder.createClient();
	
	WebTarget target = client.target("http://localhost:" + port + "/docs1");
	Response response = target.request().get();
	Assert.assertEquals(200, response.getStatus());
	Assert.assertNotNull(response.getEntity());
	Assert.assertEquals("application/json", response.getMediaType().toString());
	
	target = client.target("http://localhost:" + port + "/docs2");
	response = target.request().get();
	Assert.assertEquals(200, response.getStatus());
	Assert.assertNotNull(response.getEntity());
	Assert.assertEquals("application/json", response.getMediaType().toString());
}
 
开发者ID:holon-platform,项目名称:holon-jaxrs,代码行数:17,代码来源:TestSwaggerJerseyAutoConfigurationGroups.java

示例4: testSwaggerYaml

import org.glassfish.jersey.client.JerseyClientBuilder; //导入依赖的package包/类
@Test
public void testSwaggerYaml() {
	Client client = JerseyClientBuilder.createClient();
	
	WebTarget target = client.target("http://localhost:" + port + "/docs1").queryParam("type", "yaml");
	Response response = target.request().get();
	Assert.assertEquals(200, response.getStatus());
	Assert.assertNotNull(response.getEntity());
	Assert.assertEquals("application/yaml", response.getMediaType().toString());
	
	target = client.target("http://localhost:" + port + "/docs2").queryParam("type", "yaml");
	response = target.request().get();
	Assert.assertEquals(200, response.getStatus());
	Assert.assertNotNull(response.getEntity());
	Assert.assertEquals("application/yaml", response.getMediaType().toString());
}
 
开发者ID:holon-platform,项目名称:holon-jaxrs,代码行数:17,代码来源:TestSwaggerJerseyAutoConfigurationGroups.java

示例5: testBasic

import org.glassfish.jersey.client.JerseyClientBuilder; //导入依赖的package包/类
@Test
@Ignore
public void testBasic() {
    String clientName = "community";
    Client client = new JerseyClientBuilder().build();

    Publication p = new Publication();
    p.setPublicationUid(1L);
    p.setTitle("Test title");

    String url = String.format("http://localhost:%d%s/publications", APP.getLocalPort(),
            APP.getEnvironment().getApplicationContext().getContextPath());
    Response response = client.target(url)
            .request()
            .header("X-Client-Id", clientName)
            .post(Entity.entity(p, MediaType.APPLICATION_JSON_TYPE));

    Publication p2 = response.readEntity(Publication.class);
    assertNotEquals(p, p2);

    assertEquals(clientName, p2.getLastModificationClientId());
}
 
开发者ID:researchgate,项目名称:restler,代码行数:23,代码来源:PublicationResourceTest.java

示例6: testExternalDao

import org.glassfish.jersey.client.JerseyClientBuilder; //导入依赖的package包/类
@Test
public void testExternalDao() {
    Client client = new JerseyClientBuilder().build();

    Publication p = new Publication();
    p.setPublicationUid(1L);
    p.setTitle("Test title");

    String url = String.format("http://localhost:%d%s/publications", APP.getLocalPort(),
            APP.getEnvironment().getApplicationContext().getContextPath());
    client.target(url)
            .request()
            .post(Entity.entity(p, MediaType.APPLICATION_JSON_TYPE));

    url = String.format("http://localhost:%d%s/publications/external/1", APP.getLocalPort(),
            APP.getEnvironment().getApplicationContext().getContextPath());

    Publication p2 = client.target(url).request().get(Publication.class);

    assertEquals(p, p2);
}
 
开发者ID:researchgate,项目名称:restler,代码行数:22,代码来源:PublicationResourceTest.java

示例7: testListGroup

import org.glassfish.jersey.client.JerseyClientBuilder; //导入依赖的package包/类
public void testListGroup() {
        String uri = getUrl("listGroup");
        Client client= JerseyClientBuilder.newBuilder().build();
        
        ListGroupRequest req = new ListGroupRequest();
        req.showAll = true;
        
        Response rsp = client.target(uri).request().accept(MediaType.APPLICATION_JSON).headers(fixedHeader).buildPost(Entity.entity(req, MediaType.APPLICATION_JSON)).invoke();
        GenericResponseObj ret = rsp.readEntity(GenericResponseObj.class);
        if (!ret.isSuccess()) {
            System.out.println(ret.getError());
        } else {
//           List<Group> groups = ret.getData(List<Group>.class);
            System.out.println();
        }
    }
 
开发者ID:projectsrepos,项目名称:jim,代码行数:17,代码来源:GroupRestServiceTest.java

示例8: initUsers

import org.glassfish.jersey.client.JerseyClientBuilder; //导入依赖的package包/类
public void initUsers() throws ImException {
    Client client= JerseyClientBuilder.newBuilder().build();
    Map<String ,Object> header = new HashMap<String, Object>();
    header.put("appId", "sfa");
    header.put("tenantId", "hengda");
    header.put("operatorId", "1");

    for (Integer index = 0; index < 1; index++) {
        Map<String, Object> body = new HashMap<String, Object>();
        body.put("gatewayUserId", index);
        Response rsp = client.target("http://172.16.0.22:8090/api/im/groupManager/createUser")
                             .request()
                             .accept(MediaType.APPLICATION_JSON)
                             .headers(new MultivaluedHashMap<String, Object>(header))
                             .buildPost(Entity.entity(body, MediaType.APPLICATION_JSON))
                             .invoke();
        HashMap<String, Object> ret = rsp.readEntity(HashMap.class);
        if("1".equals(ret.get("status").toString())){
            System.out.println("Create user success --> " + index);
        }
    }
}
 
开发者ID:projectsrepos,项目名称:jim,代码行数:23,代码来源:UserServiceTest.java

示例9: tenureTest

import org.glassfish.jersey.client.JerseyClientBuilder; //导入依赖的package包/类
@Test
public void tenureTest() throws Exception {
    JerseyClient jerseyClient = new JerseyClientBuilder().build();
    long start = System.currentTimeMillis();
    long now = start;
    int attempt = 1;
    while (now - start < 60000) {
        String content = jerseyClient.target("http://127.0.0.1:" + appRule.getLocalPort())
                .request()
                .get()
                .readEntity(String.class);
        assertThat(content).contains("\"Host\": \"nghttp2.org:443\"");
        now = System.currentTimeMillis();
        if (attempt++ % 5 == 0) { // 5 attempts reuse the same connection
            Thread.sleep(4000); // Force reopening the connection
            attempt = 1;
        }
    }
    jerseyClient.close();
}
 
开发者ID:arteam,项目名称:dropwizard-http2-client,代码行数:21,代码来源:GoLangProxyIntegrationTest.java

示例10: upload

import org.glassfish.jersey.client.JerseyClientBuilder; //导入依赖的package包/类
private void upload(String server, String environment, File file, boolean dryRun) throws Exception {
    JerseyClient client = new JerseyClientBuilder()
    		.register(HttpAuthenticationFeature.basic("user", "pass")) // set.getUser(), set.getPass()
    		.register(MultiPartFeature.class)
    		.build();
    JerseyWebTarget t = client.target(UriBuilder.fromUri(server).build()).path("rest").path("items").path("upload");

    FileDataBodyPart filePart = new FileDataBodyPart("file", file);
    String fn = file.getName();
    fn = fn.substring(0, fn.lastIndexOf("_report") + 7); // die tempnummer am ende des filenamens noch wegoperieren!
	System.out.println(fn);
    filePart.setContentDisposition(FormDataContentDisposition.name("file").fileName(fn).build());

    FormDataMultiPart formDataMultiPart = new FormDataMultiPart();
    MultiPart multipartEntity = formDataMultiPart.field("comment", "Analysis from BfR").bodyPart(filePart);

    if (!dryRun) {
	    Response response = t.queryParam("environment", environment).request().post(Entity.entity(multipartEntity, MediaType.MULTIPART_FORM_DATA));
	    System.out.println(response.getStatus() + " \n" + response.readEntity(String.class));

	    response.close();
    }

    formDataMultiPart.close();
    multipartEntity.close();
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:27,代码来源:TracingXmlOutNodeModel.java

示例11: Pandora

import org.glassfish.jersey.client.JerseyClientBuilder; //导入依赖的package包/类
public Pandora(AnnaConfig config) {
    this.appId = config.getPandora().getAppId();
    this.userKey = config.getPandora().getUserKey();
    this.pandoraBot = config.getPandora().getBot();

    ClientConfig cfg = new ClientConfig(JacksonJsonProvider.class);
    cfg.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);
    client = JerseyClientBuilder.createClient(cfg);
}
 
开发者ID:wireapp,项目名称:anna-bot,代码行数:10,代码来源:Pandora.java

示例12: getClient

import org.glassfish.jersey.client.JerseyClientBuilder; //导入依赖的package包/类
@Override
protected Client getClient() {
	ClientConfig config = new ClientConfig();
	config = config.register(TestContextResolver.class).property(GsonFeature.JAXRS_DISABLE_GSON_CONTEXT_RESOLVER,
			"");
	return JerseyClientBuilder.createClient(config);
}
 
开发者ID:holon-platform,项目名称:holon-json,代码行数:8,代码来源:TestJerseyIntegrationCustomResolver.java

示例13: testEndpoint

import org.glassfish.jersey.client.JerseyClientBuilder; //导入依赖的package包/类
@Test
public void testEndpoint() {
	Client client = JerseyClientBuilder.createClient();
	WebTarget target = client.target("http://localhost:" + port + "/api/test").path("ping");
	String response = target.request().get(String.class);
	Assert.assertEquals("pong", response);
}
 
开发者ID:holon-platform,项目名称:holon-jaxrs,代码行数:8,代码来源:TestSwaggerJerseyAutoConfigurationPath.java

示例14: testSwaggerJson

import org.glassfish.jersey.client.JerseyClientBuilder; //导入依赖的package包/类
@Test
public void testSwaggerJson() {
	Client client = JerseyClientBuilder.createClient();
	WebTarget target = client.target("http://localhost:" + port + "/api/docs");
	Response response = target.request().get();
	Assert.assertEquals(200, response.getStatus());
	Assert.assertNotNull(response.getEntity());
	Assert.assertEquals("application/json", response.getMediaType().toString());
}
 
开发者ID:holon-platform,项目名称:holon-jaxrs,代码行数:10,代码来源:TestSwaggerJerseyAutoConfigurationPath.java

示例15: testSwaggerYaml

import org.glassfish.jersey.client.JerseyClientBuilder; //导入依赖的package包/类
@Test
public void testSwaggerYaml() {
	Client client = JerseyClientBuilder.createClient();
	WebTarget target = client.target("http://localhost:" + port + "/api/docs").queryParam("type", "yaml");
	Response response = target.request().get();
	Assert.assertEquals(200, response.getStatus());
	Assert.assertNotNull(response.getEntity());
	Assert.assertEquals("application/yaml", response.getMediaType().toString());
}
 
开发者ID:holon-platform,项目名称:holon-jaxrs,代码行数:10,代码来源:TestSwaggerJerseyAutoConfigurationPath.java


注:本文中的org.glassfish.jersey.client.JerseyClientBuilder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。