Package slash.navigation.rest

Examples of slash.navigation.rest.Post


    protected Post createUser(String userName, String password,
                              String firstName, String lastName, String email,
                              String authenticationUserName, String authenticationPassword) throws IOException, JAXBException {
        String xml = createUserXml(userName, password, firstName, lastName, email);
        Post request = new Post(POST_USERS_URL, new SimpleCredentials(authenticationUserName, authenticationPassword));
        request.addFile("file", xml.getBytes());
        return request;
    }
View Full Code Here


    }


    protected Post createFile(String fileName,
                              String authenticationUserName, String authenticationPassword) throws IOException {
        Post request = new Post(FILES_URL, new SimpleCredentials(authenticationUserName, authenticationPassword));
        File file = new File(TEST_PATH + fileName);
        assertTrue(file.exists());
        request.addFile("file", file);
        return request;
    }
View Full Code Here

        return deleteRoute(key, USERNAME, PASSWORD);
    }

    @Test
    public void testCreateFromJAXB() throws Exception {
        Post request1 = createFile("filestest.gpx");
        request1.executeAsString();
        assertTrue(request1.isSuccessful());
        int key = parseFileKey(request1.getLocation());

        Post request2 = createRoute("Upload", key, "Description/" + key);
        String result = request2.executeAsString();
        assertTrue(result.contains("route"));
        assertTrue(result.contains("created"));
        String location = request2.getLocation();
        assertTrue(location.contains("/catalog/routes/"));
        assertEquals(201, request2.getStatusCode());
        assertTrue(request2.isSuccessful());
    }
View Full Code Here

        assertTrue(request2.isSuccessful());
    }

    @Test
    public void testCreateWithInvalidCategory() throws Exception {
        Post request1 = createRoute("Invalid category " + System.currentTimeMillis(), -1, "Description");
        String result = request1.executeAsString();
        assertTrue(result.contains("no"));
        assertTrue(result.contains("valid"));
        assertTrue(result.contains("category"));
        assertEquals(412, request1.getStatusCode());
        assertFalse(request1.isSuccessful());
    }
View Full Code Here

        assertFalse(request1.isSuccessful());
    }

    @Test
    public void testRead() throws Exception {
        Post request1 = createFile("filestest.gpx");
        request1.executeAsString();
        int fileKey = parseFileKey(request1.getLocation());

        Post request2 = createRoute("Upload", fileKey, "Description" + fileKey);
        request2.executeAsString();
        int routeKey = parseRouteKey(request2.getLocation());

        HttpRequest request3 = readRoute(routeKey);
        String result2 = request3.executeAsString();
        assertEquals(200, request3.getStatusCode());
        assertTrue(request3.isSuccessful());
View Full Code Here

        assertEquals(FILES_URL + fileKey, rteType.getLink().get(0).getHref());
    }

    @Test
    public void testUpdate() throws Exception {
        Post request0 = createFile("filestest.gpx");
        request0.executeAsString();
        int fileKey = parseFileKey(request0.getLocation());

        Post request1 = createRoute("Upload", fileKey, "Description");
        request1.executeAsString();
        int routeKey = parseRouteKey(request1.getLocation());
        HttpRequest request2 = updateRoute(routeKey, "Upload", -2, "Updated description", USERNAME, PASSWORD);
        String result2 = request2.executeAsString();
        assertEquals("route " + routeKey + " updated", result2);
        assertEquals(200, request2.getStatusCode());
        assertTrue(request2.isSuccessful());
View Full Code Here

        assertNotNull(gpxType);
    }

    @Test
    public void testUpdateWithWrongPassword() throws Exception {
        Post request0 = createFile("filestest.gpx");
        request0.executeAsString();
        int fileKey = parseFileKey(request0.getLocation());

        Post request1 = createRoute("Upload", fileKey, "Description");
        request1.executeAsString();
        int routeKey = parseRouteKey(request1.getLocation());
        HttpRequest request2 = updateRoute(routeKey, "Upload", -2, "Updated description", "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", "toop", "Ali", "Top", "ali@top.org", USERNAME, PASSWORD).executeAsString();

        Post request0 = createFile("filestest.gpx");
        request0.executeAsString();
        int fileKey = parseFileKey(request0.getLocation());

        Post request1 = createRoute("Upload", fileKey, "Description");
        request1.executeAsString();
        int routeKey = parseRouteKey(request1.getLocation());
        HttpRequest request2 = updateRoute(routeKey, "Upload", -2, "Updated description", "alif", "toop");
        request2.executeAsString();
        assertEquals(403, request2.getStatusCode());
        assertFalse(request2.isSuccessful());
        assertTrue(request2.isForbidden());
View Full Code Here

        assertTrue(request2.isForbidden());
    }

    @Test
    public void testUpdateWithoutFile() throws Exception {
        Post request0 = createFile("filestest.gpx");
        request0.executeAsString();
        int fileKey = parseFileKey(request0.getLocation());

        Post request1 = createRoute("Upload", fileKey, "Description");
        String result1 = request1.executeAsString();
        assertTrue(result1.contains("route"));
        assertTrue(result1.contains("created"));
        int routeKey = parseRouteKey(request1.getLocation());
        HttpRequest request2 = updateRoute(routeKey, "Upload", null, "Updated description");
        String result2 = request2.executeAsString();
        assertTrue(result2.contains("no"));
        assertTrue(result2.contains("url"));
        assertTrue(result2.contains("given"));
View Full Code Here

        assertFalse(request2.isSuccessful());
    }

    @Test
    public void testUpdateWithoutCategory() throws Exception {
        Post request0 = createFile("filestest.gpx");
        request0.executeAsString();
        int fileKey = parseFileKey(request0.getLocation());

        Post request1 = createRoute("Upload", fileKey, "Description");
        String result1 = request1.executeAsString();
        assertTrue(result1.contains("route"));
        assertTrue(result1.contains("created"));
        int routeKey = parseRouteKey(request1.getLocation());
        HttpRequest request2 = updateRoute(routeKey, null, fileKey, "Updated description");
        String result2 = request2.executeAsString();
        assertTrue(result2.contains("no"));
        assertTrue(result2.contains("category"));
        assertTrue(result2.contains("given"));
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.