當前位置: 首頁>>代碼示例>>Java>>正文


Java WebResource.accept方法代碼示例

本文整理匯總了Java中com.sun.jersey.api.client.WebResource.accept方法的典型用法代碼示例。如果您正苦於以下問題:Java WebResource.accept方法的具體用法?Java WebResource.accept怎麽用?Java WebResource.accept使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.sun.jersey.api.client.WebResource的用法示例。


在下文中一共展示了WebResource.accept方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testSendHeartbeat

import com.sun.jersey.api.client.WebResource; //導入方法依賴的package包/類
@Test
public void testSendHeartbeat() throws InterruptedException {
    ZSession session = createSession("2");
    
    Thread.sleep(1000);
    WebResource wr = sessionsr.path(session.id);
    Builder b = wr.accept(MediaType.APPLICATION_JSON);
    
    ClientResponse cr = b.put(ClientResponse.class, null);
    assertEquals(ClientResponse.Status.OK, cr.getClientResponseStatus());
    
    Thread.sleep(1500);
    assertTrue(ZooKeeperService.isConnected(CONTEXT_PATH, session.id));
    
    Thread.sleep(1000);
    assertFalse(ZooKeeperService.isConnected(CONTEXT_PATH, session.id));
}
 
開發者ID:maoling,項目名稱:fuck_zookeeper,代碼行數:18,代碼來源:SessionTest.java

示例2: testCreate

import com.sun.jersey.api.client.WebResource; //導入方法依賴的package包/類
@Test
public void testCreate() throws Exception {
    LOG.info("STARTING " + getName());
    
    String path = "/";
    String name = "roottest-create";
    byte[] data = "foo".getBytes();

    WebResource wr = znodesr.path(path).queryParam("dataformat", "utf8")
        .queryParam("name", name);
    Builder builder = wr.accept(MediaType.APPLICATION_JSON);

    ClientResponse cr;
    cr = builder.post(ClientResponse.class, data);
    assertEquals(ClientResponse.Status.CREATED, cr.getClientResponseStatus());

    ZPath zpath = cr.getEntity(ZPath.class);
    assertEquals(new ZPath(path + name), zpath);
    assertEquals(znodesr.path(path).toString(), zpath.uri);

    // use out-of-band method to verify
    byte[] rdata = zk.getData(zpath.path, false, new Stat());
    assertTrue(new String(rdata) + " == " + new String(data),
            Arrays.equals(rdata, data));
}
 
開發者ID:l294265421,項目名稱:ZooKeeper,代碼行數:26,代碼來源:RootTest.java

示例3: testCreateEphemeralZNode

import com.sun.jersey.api.client.WebResource; //導入方法依賴的package包/類
@Test
public void testCreateEphemeralZNode() 
throws KeeperException, InterruptedException, IOException {
    ZSession session = createSession("30");
    
    WebResource wr = znodesr.path("/")
        .queryParam("op", "create")
        .queryParam("name", "ephemeral-test")
        .queryParam("ephemeral", "true")
        .queryParam("session", session.id)
        .queryParam("null", "true");
    
    Builder b = wr.accept(MediaType.APPLICATION_JSON);
    ClientResponse cr = b.post(ClientResponse.class);
    assertEquals(ClientResponse.Status.CREATED, cr.getClientResponseStatus());
    
    Stat stat = new Stat();
    zk.getData("/ephemeral-test", false, stat);
    
    ZooKeeper sessionZK = ZooKeeperService.getClient(CONTEXT_PATH, session.id);
    assertEquals(stat.getEphemeralOwner(), sessionZK.getSessionId());
}
 
開發者ID:maoling,項目名稱:fuck_zookeeper,代碼行數:23,代碼來源:SessionTest.java

示例4: testSendHeartbeat

import com.sun.jersey.api.client.WebResource; //導入方法依賴的package包/類
@Test
public void testSendHeartbeat() throws InterruptedException {
    ZSession session = createSession("2");
    
    Thread.sleep(1000);
    WebResource wr = sessionsr.path(session.id);
    Builder b = wr.accept(MediaType.APPLICATION_JSON);
    
    ClientResponse cr = b.put(ClientResponse.class, null);
    Assert.assertEquals(ClientResponse.Status.OK, cr.getClientResponseStatus());
    
    Thread.sleep(1500);
    Assert.assertTrue(ZooKeeperService.isConnected(CONTEXT_PATH, session.id));
    
    Thread.sleep(1000);
    Assert.assertFalse(ZooKeeperService.isConnected(CONTEXT_PATH, session.id));
}
 
開發者ID:didichuxing2,項目名稱:https-github.com-apache-zookeeper,代碼行數:18,代碼來源:SessionTest.java

示例5: testCreateEphemeralZNode

import com.sun.jersey.api.client.WebResource; //導入方法依賴的package包/類
@Test
public void testCreateEphemeralZNode() 
throws KeeperException, InterruptedException, IOException {
    ZSession session = createSession("30");
    
    WebResource wr = znodesr.path("/")
        .queryParam("op", "create")
        .queryParam("name", "ephemeral-test")
        .queryParam("ephemeral", "true")
        .queryParam("session", session.id)
        .queryParam("null", "true");
    
    Builder b = wr.accept(MediaType.APPLICATION_JSON);
    ClientResponse cr = b.post(ClientResponse.class);
    Assert.assertEquals(ClientResponse.Status.CREATED, cr.getClientResponseStatus());
    
    Stat stat = new Stat();
    zk.getData("/ephemeral-test", false, stat);
    
    ZooKeeper sessionZK = ZooKeeperService.getClient(CONTEXT_PATH, session.id);
    Assert.assertEquals(stat.getEphemeralOwner(), sessionZK.getSessionId());
}
 
開發者ID:didichuxing2,項目名稱:https-github.com-apache-zookeeper,代碼行數:23,代碼來源:SessionTest.java

示例6: testCreate

import com.sun.jersey.api.client.WebResource; //導入方法依賴的package包/類
@Test
public void testCreate() throws Exception {
    String path = "/";
    String name = "roottest-create";
    byte[] data = "foo".getBytes();

    WebResource wr = znodesr.path(path).queryParam("dataformat", "utf8")
        .queryParam("name", name);
    Builder builder = wr.accept(MediaType.APPLICATION_JSON);

    ClientResponse cr;
    cr = builder.post(ClientResponse.class, data);
    Assert.assertEquals(ClientResponse.Status.CREATED, cr.getClientResponseStatus());

    ZPath zpath = cr.getEntity(ZPath.class);
    Assert.assertEquals(new ZPath(path + name), zpath);
    Assert.assertEquals(znodesr.path(path).toString(), zpath.uri);

    // use out-of-band method to verify
    byte[] rdata = zk.getData(zpath.path, false, new Stat());
    Assert.assertTrue(new String(rdata) + " == " + new String(data),
            Arrays.equals(rdata, data));
}
 
開發者ID:didichuxing2,項目名稱:https-github.com-apache-zookeeper,代碼行數:24,代碼來源:RootTest.java

示例7: createSession

import com.sun.jersey.api.client.WebResource; //導入方法依賴的package包/類
private ZSession createSession(String expire) {
    WebResource wr = sessionsr.queryParam("op", "create")
        .queryParam("expire", expire);
    Builder b = wr.accept(MediaType.APPLICATION_JSON);

    ClientResponse cr = b.post(ClientResponse.class, null);
    assertEquals(ClientResponse.Status.CREATED, cr
            .getClientResponseStatus());

    return cr.getEntity(ZSession.class);
}
 
開發者ID:maoling,項目名稱:fuck_zookeeper,代碼行數:12,代碼來源:SessionTest.java

示例8: testDeleteSession

import com.sun.jersey.api.client.WebResource; //導入方法依賴的package包/類
@Test
public void testDeleteSession() {
    ZSession session = createSession("30");

    WebResource wr = sessionsr.path(session.id);
    Builder b = wr.accept(MediaType.APPLICATION_JSON);

    assertTrue(ZooKeeperService.isConnected(CONTEXT_PATH, session.id));
    ClientResponse cr = b.delete(ClientResponse.class, null);
    assertEquals(ClientResponse.Status.NO_CONTENT, 
            cr.getClientResponseStatus());

    assertFalse(ZooKeeperService.isConnected(CONTEXT_PATH, session.id));
}
 
開發者ID:maoling,項目名稱:fuck_zookeeper,代碼行數:15,代碼來源:SessionTest.java

示例9: createSession

import com.sun.jersey.api.client.WebResource; //導入方法依賴的package包/類
private ZSession createSession(String expire) {
    WebResource wr = sessionsr.queryParam("op", "create")
        .queryParam("expire", expire);
    Builder b = wr.accept(MediaType.APPLICATION_JSON);

    ClientResponse cr = b.post(ClientResponse.class, null);
    Assert.assertEquals(ClientResponse.Status.CREATED, cr
            .getClientResponseStatus());

    return cr.getEntity(ZSession.class);
}
 
開發者ID:didichuxing2,項目名稱:https-github.com-apache-zookeeper,代碼行數:12,代碼來源:SessionTest.java

示例10: testDeleteSession

import com.sun.jersey.api.client.WebResource; //導入方法依賴的package包/類
@Test
public void testDeleteSession() {
    ZSession session = createSession("30");

    WebResource wr = sessionsr.path(session.id);
    Builder b = wr.accept(MediaType.APPLICATION_JSON);

    Assert.assertTrue(ZooKeeperService.isConnected(CONTEXT_PATH, session.id));
    ClientResponse cr = b.delete(ClientResponse.class, null);
    Assert.assertEquals(ClientResponse.Status.NO_CONTENT,
            cr.getClientResponseStatus());

    Assert.assertFalse(ZooKeeperService.isConnected(CONTEXT_PATH, session.id));
}
 
開發者ID:didichuxing2,項目名稱:https-github.com-apache-zookeeper,代碼行數:15,代碼來源:SessionTest.java


注:本文中的com.sun.jersey.api.client.WebResource.accept方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。