Package slash.navigation.rest

Examples of slash.navigation.rest.HttpRequest


    @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());

        GpxType gpxType = GpxUtil.unmarshal11(result2);
        assertNotNull(gpxType);
        assertEquals(key, gpxType.getMetadata().getName());
        assertNull(gpxType.getMetadata().getDesc());
View Full Code Here


    @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());
        HttpRequest request3 = readUser("alif");
        String result3 = request3.executeAsString();
        assertEquals(200, request3.getStatusCode());
        assertTrue(request3.isSuccessful());

        GpxType gpxType = GpxUtil.unmarshal11(result3);
        assertNotNull(gpxType);
        assertEquals("alif", gpxType.getMetadata().getName());
        assertNull(gpxType.getMetadata().getDesc());
View Full Code Here

    @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

    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

    @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());
        HttpRequest request3 = readUser(key);
        String result3 = request3.executeAsString();
        assertNotNull(result3);
        assertEquals(404, request3.getStatusCode());
        assertFalse(request3.isSuccessful());
    }
View Full Code Here

    @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

    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

        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());

        GpxType gpxType = GpxUtil.unmarshal11(result2);
        assertNotNull(gpxType);
        assertEquals(Integer.toString(routeKey), gpxType.getMetadata().getName());
        assertEquals(USERNAME, gpxType.getMetadata().getAuthor().getName());
View Full Code Here

        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());
        HttpRequest request3 = readRoute(routeKey);
        String result3 = request3.executeAsString();
        assertEquals(200, request3.getStatusCode());
        assertTrue(request3.isSuccessful());
        GpxType gpxType = GpxUtil.unmarshal11(result3);
        assertNotNull(gpxType);
    }
View Full Code Here

        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

TOP

Related Classes of slash.navigation.rest.HttpRequest

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.