Search in sources :

Example 6 with ZSession

use of org.apache.zookeeper.server.jersey.jaxb.ZSession in project zookeeper by apache.

the class SessionTest method testCreateEphemeralZNode.

@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());
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) Stat(org.apache.zookeeper.data.Stat) ZooKeeper(org.apache.zookeeper.ZooKeeper) Builder(com.sun.jersey.api.client.WebResource.Builder) WebResource(com.sun.jersey.api.client.WebResource) ZSession(org.apache.zookeeper.server.jersey.jaxb.ZSession) Test(org.junit.Test)

Aggregations

ZSession (org.apache.zookeeper.server.jersey.jaxb.ZSession)6 Test (org.junit.Test)5 ClientResponse (com.sun.jersey.api.client.ClientResponse)3 WebResource (com.sun.jersey.api.client.WebResource)3 Builder (com.sun.jersey.api.client.WebResource.Builder)3 JSONWithPadding (com.sun.jersey.api.json.JSONWithPadding)1 IOException (java.io.IOException)1 URI (java.net.URI)1 POST (javax.ws.rs.POST)1 Produces (javax.ws.rs.Produces)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 ZooKeeper (org.apache.zookeeper.ZooKeeper)1 Stat (org.apache.zookeeper.data.Stat)1 ZError (org.apache.zookeeper.server.jersey.jaxb.ZError)1