Package slash.navigation.rest

Examples of slash.navigation.rest.Post


        assertNull(extension.getPassword());
    }

    @Test
    public void testUpdate() throws Exception {
        Post request1 = createUser("userstest.gpx");
        request1.executeAsString();
        String key = parseUserKey(request1.getLocation());
        HttpRequest request2 = updateUser(key, "alif", "topf", "Ali", "Top", "ali@top.org", USERNAME, PASSWORD);
        String result2 = request2.executeAsString();
        assertEquals("user alif updated", result2);
        assertEquals(200, request2.getStatusCode());
        assertTrue(request2.isSuccessful());
View Full Code Here


        assertEquals("Top", extension.getLastname());
        assertNull(extension.getPassword());    }

    @Test
    public void testUpdateWithWrongPassword() throws Exception {
        Post request1 = createUser("userstest.gpx");
        request1.executeAsString();
        String key = parseUserKey(request1.getLocation());
        HttpRequest request2 = updateUser(key, "alif", "topf", "Ali", "Top", "ali@top.org", "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 = createUser("userstest.gpx");
        request1.executeAsString();
        String key = parseUserKey(request1.getLocation());
        HttpRequest request2 = updateUser(key, "userstest.gpx", "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 = createUser("userstest.gpx");
        request1.executeAsString();
        String key = parseUserKey(request1.getLocation());
        HttpRequest request2 = deleteUser(key);
        String result2 = request2.executeAsString();
        assertEquals("user ivan deleted", result2);
        assertEquals(200, request2.getStatusCode());
        assertTrue(request2.isSuccessful());
View Full Code Here

        assertFalse(request3.isSuccessful());
    }

    @Test
    public void testDeleteWithWrongPassword() throws Exception {
        Post request1 = createUser("userstest.gpx");
        request1.executeAsString();
        String key = parseUserKey(request1.getLocation());
        HttpRequest request2 = deleteUser(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", "stop", "Ali", "Top", "ali@top.org", USERNAME, PASSWORD).executeAsString();
        Post request1 = createUser("userstest.gpx");
        request1.executeAsString();
        String key = parseUserKey(request1.getLocation());
        HttpRequest request2 = deleteUser(key, "alif", "stop");
        request2.executeAsString();
        assertEquals(403, request2.getStatusCode());
        assertFalse(request2.isSuccessful());
        assertTrue(request2.isForbidden());
View Full Code Here

        assertFalse(request3.isSuccessful());
    }

    @Test
    public void testDeleteWithWrongPassword() throws Exception {
        Post request1 = createFile("filestest.gpx");
        request1.executeAsString();
        String result1 = request1.getLocation();
        int key = parseFileKey(result1);
        HttpRequest request2 = deleteFile(key, "user-does-not-exist", "password-is-wrong");
        assertNull(request2.executeAsString());
        assertEquals(401, request2.getStatusCode());
        assertFalse(request2.isSuccessful());
View Full Code Here

    }

    @Test
    public void testDeleteNotMyRoute() throws Exception {
        createUser("userstest.gpx").executeAsString();
        Post request1 = createFile("filestest.gpx");
        request1.executeAsString();
        String result1 = request1.getLocation();
        int key = parseFileKey(result1);
        HttpRequest request2 = deleteFile(key, "ivan", "secret");
        assertNotNull(request2.executeAsString());
        assertEquals(403, request2.getStatusCode());
        assertFalse(request2.isSuccessful());
View Full Code Here


    protected Post createRoute(String category, Integer fileKey, String description,
                               String authenticationUserName, String authenticationPassword) throws IOException, JAXBException {
        String xml = createRouteXml(category, fileKey, description);
        Post request = new Post(ROUTES_URL, new SimpleCredentials(authenticationUserName, authenticationPassword));
        request.addFile("file", xml.getBytes());
        return request;
    }
View Full Code Here

        return createRoute(category, fileKey, description, USERNAME, PASSWORD);
    }

    protected Post createUser(String fileName,
                              String authenticationUserName, String authenticationPassword) throws IOException {
        Post request = new Post(POST_USERS_URL, new SimpleCredentials(authenticationUserName, authenticationPassword));
        request.addFile("file", new File(TEST_PATH + fileName));
        return request;
    }
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.