Package slash.navigation.rest

Examples of slash.navigation.rest.Post


        assertNotNull(gpxType);
    }

    @Test
    public void testUpdateWithWrongPassword() throws Exception {
        Post request1 = createCategory("Upload", "Interesting");
        request1.executeAsString();
        String key = parseCategoryKey(request1.getLocation());
        HttpRequest request2 = updateCategory(key, "Interesting" + System.currentTimeMillis(), "user-does-not-exist", "password-is-wrong");
        assertNull(request2.executeAsString());
        assertEquals(401, request2.getStatusCode());
        assertFalse(request2.isSuccessful());
        assertTrue(request2.isUnAuthorized());
View Full Code Here


    }

    @Test
    public void testUpdateNotMyUser() throws Exception {
        createUser("alif", "topr", "Ali", "Top", "ali@top.org", USERNAME, PASSWORD).executeAsString();
        Post request1 = createCategory("Upload", "Interesting");
        request1.executeAsString();
        String key = parseCategoryKey(request1.getLocation());
        HttpRequest request2 = updateCategory(key, "Interesting" + System.currentTimeMillis(), "alif", "topr");
        request2.executeAsString();
        assertEquals(403, request2.getStatusCode());
        assertFalse(request2.isSuccessful());
        assertTrue(request2.isForbidden());
View Full Code Here

        assertTrue(request2.isForbidden());
    }

    @Test
    public void testDelete() throws Exception {
        Post request1 = createCategory("Upload", "Interesting");
        request1.executeAsString();
        String key = parseCategoryKey(request1.getLocation());
        HttpRequest request2 = deleteCategory(key);
        String result2 = request2.executeAsString();
        assertEquals("category /" + key + " deleted", result2);
        assertEquals(200, request2.getStatusCode());
        assertTrue(request2.isSuccessful());
View Full Code Here

        assertFalse(request3.isSuccessful());
    }

    @Test
    public void testDeleteWithWrongPassword() throws Exception {
        Post request1 = createCategory("Upload", "Interesting");
        request1.executeAsString();
        String key = parseCategoryKey(request1.getLocation());
        HttpRequest request2 = deleteCategory(key, "user-does-not-exist", "password-is-wrong");
        assertNull(request2.executeAsString());
        assertEquals(401, request2.getStatusCode());
        assertFalse(request2.isSuccessful());
        assertTrue(request2.isUnAuthorized());
View Full Code Here

    }

    @Test
    public void testDeleteNotMyUser() throws Exception {
        createUser("alif", "toup", "Ali", "Top", "ali@top.org", USERNAME, PASSWORD).executeAsString();
        Post request1 = createCategory("Upload", "Interesting");
        request1.executeAsString();
        String key = parseCategoryKey(request1.getLocation());
        HttpRequest request2 = deleteCategory(key, "alif", "toup");
        request2.executeAsString();
        assertEquals(403, request2.getStatusCode());
        assertFalse(request2.isSuccessful());
        assertTrue(request2.isForbidden());
View Full Code Here

    }

    public String addUser(String userName, String password, String firstName, String lastName, String email) throws IOException {
        log.fine("Adding " + userName + "," + firstName + "," + lastName + "," + email);
        String xml = createUserXml(userName, password, firstName, lastName, email);
        Post request = new Post(getUsersUrl(), credentials);
        request.addFile("file", xml.getBytes());

        String result = request.executeAsString();
        if (request.isUnAuthorized())
            throw new UnAuthorizedException("Cannot add user " + userName, getUsersUrl());
        if (request.isForbidden())
            throw new DuplicateNameException("Cannot add user " + userName, getUsersUrl());
        if (!request.isSuccessful())
            throw new IOException("POST on " + getUsersUrl() + " with payload " + userName + "," + firstName + "," + lastName + "," + email + " not successful: " + result);
        return request.getLocation();
    }
View Full Code Here

    }

    public String sendErrorReport(String logOutput, String description, java.io.File file) throws IOException {
        log.fine("Sending error report with log \"" + logOutput + "\", description \"" + description + "\"" +
                (file != null ? ", file " + file.getAbsolutePath() : ""));
        Post request = new Post(getErrorReportUrl(), credentials);
        request.addString("log", logOutput);
        request.addString("description", description);
        if (file != null)
            request.addFile("file", file);

        String result = request.executeAsString();
        if (request.isUnAuthorized())
            throw new UnAuthorizedException("Cannot send error report " + (file != null ? ", file " + file.getAbsolutePath() : ""), getErrorReportUrl());
        if (!request.isSuccessful())
            throw new IOException("POST on " + getErrorReportUrl() + " with log " + logOutput.length() + " characters" +
                    ", description \"" + description + "\", file " + file + " not successful: " + result);
        return request.getLocation();
    }
View Full Code Here

    }


    @Test
    public void testCreateFromFile() throws Exception {
        Post request = createUser("userstest.gpx");
        String result = request.executeAsString();
        assertTrue(result.contains("user"));
        assertTrue(result.contains("created"));
        String location = request.getLocation();
        assertTrue(location.contains("/catalog/users/"));
        assertEquals(201, request.getStatusCode());
        assertTrue(request.isSuccessful());
    }
View Full Code Here

        assertTrue(request.isSuccessful());
    }

    @Test
    public void testCreateFromJAXB() throws Exception {
        Post request = createUser("ivan", "secret", "Ivan", "Secret", "ivan@secret.org", USERNAME, PASSWORD);
        String result = request.executeAsString();
        assertTrue(result.contains("user"));
        assertTrue(result.contains("created"));
        String location = request.getLocation();
        assertTrue(location.contains("/catalog/users/"));
        assertEquals(201, request.getStatusCode());
        assertTrue(request.isSuccessful());
    }
View Full Code Here

        assertFalse(request2.isSuccessful());
    }

    @Test
    public void testRead() throws Exception {
        Post request1 = createUser("userstest.gpx");
        request1.executeAsString();
        String key = parseUserKey(request1.getLocation());
        HttpRequest request2 = readUser(key);
        String result2 = request2.executeAsString();
        assertEquals(200, request2.getStatusCode());
        assertTrue(request2.isSuccessful());
View Full Code Here

TOP

Related Classes of slash.navigation.rest.Post

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.