Package com.sun.jersey.api.client

Examples of com.sun.jersey.api.client.WebResource.post()


    public void testCreateAndDestroyRESTSession() throws Exception {
        Client c = Client.create();
        c.getProperties().put(ClientConfig.PROPERTY_FOLLOW_REDIRECTS, false);
        WebResource r = c.resource("http://localhost:8080/client/work");
        try {
            r.post(String.class, "");
            fail("We should have been redirected to a new workspace.");
        }
        catch (UniformInterfaceException e) {
            ClientResponse response = e.getResponse();
            URI location = response.getLocation();
View Full Code Here


            createAssociationD2T(c, w1, "distribution2target", "d2", "t5");
            createAssociationD2T(c, w1, "distribution2target", "d2", "t6");
            createTarget(c, w1, "t4", "test", "one");
            createTarget(c, w1, "t5", "test", "two");
            createTarget(c, w1, "t6", "test", "three");
            w1.post();
            w1.delete();
           
            /* TODO: temporarily disabled these checks, because between test methods nothing
             * is cleaned up right now and this part of the test does rely on that
            Gson gson = new Gson();
View Full Code Here

       
        WebResource w1 = createWorkspace(c);
        createBundle(c, w1, "a1", "b1", "1.0.0", b1.toURI().toURL().toString(), BundleHelper.MIMETYPE);
        createBundle(c, w1, "a2", "b2", "1.0.0", b2.toURI().toURL().toString(), BundleHelper.MIMETYPE);
        createTarget(c, w1, "t1");
        w1.post();
        w1.delete();
        for (int i = 0; i < nr; i++) {
            WebResource w = createWorkspace(c);
            createAssociationA2F(c, w, "artifact2feature", "a1", "feat-1-" + i);
            createAssociationA2F(c, w, "artifact2feature", "a2", "feat-2-" + i);
View Full Code Here

            createFeature(c, w, "feat-2-" + i);
            createAssociationF2D(c, w, "feature2distribution", "feat-1-" + i, "dist-" + i);
            createAssociationF2D(c, w, "feature2distribution", "feat-2-" + i, "dist-" + i);
            createDistribution(c, w, "dist-" + i);
            createAssociationD2T(c, w, "distribution2target", "dist-" + i, "t1");
            w.post();
            w.delete();
        }
        WebResource t1versions = c.resource("http://localhost:8080/deployment/t1/versions");
        assertEquals("1.0.0\n", t1versions.get(String.class));
    }   
View Full Code Here

    /** Creates a new workspace. */
    private WebResource createWorkspace(Client c) {
        WebResource r = c.resource("http://localhost:8080/client/work");
        try {
            r.post(String.class, "");
            fail("We should have been redirected to a new workspace.");
            return null; // to keep the compiler happy, it does not understand what fail() does
        }
        catch (UniformInterfaceException e) {
            return c.resource(e.getResponse().getLocation());
View Full Code Here

    /** Creates an entity. */
    private WebResource createEntity(Client c, WebResource work, String type, String data) throws IOException {
        WebResource entity = work.path(type);
        try {
            entity.post(String.class, data);
            throw new IOException("Could not create " + type + " with data " + data);
        }
        catch (UniformInterfaceException e2) {
            return c.resource(e2.getResponse().getLocation());
        }
View Full Code Here

    public void testCreateAndDestroyRESTSession() throws Exception {
        Client c = Client.create();
        c.getProperties().put(ClientConfig.PROPERTY_FOLLOW_REDIRECTS, false);
        WebResource r = c.resource("http://localhost:8080/client/work");
        try {
            r.post(String.class, "");
            fail("We should have been redirected to a new workspace.");
        }
        catch (UniformInterfaceException e) {
            ClientResponse response = e.getResponse();
            URI location = response.getLocation();
View Full Code Here

            createAssociationD2T(c, w1, "distribution2target", "d2", "t5");
            createAssociationD2T(c, w1, "distribution2target", "d2", "t6");
            createTarget(c, w1, "t4", "test", "one");
            createTarget(c, w1, "t5", "test", "two");
            createTarget(c, w1, "t6", "test", "three");
            w1.post();
            w1.delete();
           
            /* TODO: temporarily disabled these checks, because between test methods nothing
             * is cleaned up right now and this part of the test does rely on that
            Gson gson = new Gson();
View Full Code Here

       
        WebResource w1 = createWorkspace(c);
        createBundle(c, w1, "a1", "b1", "1.0.0", b1.toURI().toURL().toString(), BundleHelper.MIMETYPE);
        createBundle(c, w1, "a2", "b2", "1.0.0", b2.toURI().toURL().toString(), BundleHelper.MIMETYPE);
        createTarget(c, w1, "t1");
        w1.post();
        w1.delete();
        for (int i = 0; i < nr; i++) {
            WebResource w = createWorkspace(c);
            createAssociationA2F(c, w, "artifact2feature", "a1", "feat-1-" + i);
            createAssociationA2F(c, w, "artifact2feature", "a2", "feat-2-" + i);
View Full Code Here

            createFeature(c, w, "feat-2-" + i);
            createAssociationF2D(c, w, "feature2distribution", "feat-1-" + i, "dist-" + i);
            createAssociationF2D(c, w, "feature2distribution", "feat-2-" + i, "dist-" + i);
            createDistribution(c, w, "dist-" + i);
            createAssociationD2T(c, w, "distribution2target", "dist-" + i, "t1");
            w.post();
            w.delete();
        }
        WebResource t1versions = c.resource("http://localhost:8080/deployment/t1/versions");
        assertEquals("1.0.0\n", t1versions.get(String.class));
    }   
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.