Package com.groupon.odo.client

Examples of com.groupon.odo.client.Client


     * Demonstrates how to create a new path
     */
    public static void createPath() throws Exception {
        // First argument is the existing profile name
        // Second argument indicates if a new client should be created "true" or use the profile default "false"
        Client client = new Client("ProfileName", false);

        // createPath takes three arguments
        // 1. pathName: friendly name of the new path
        // 2. pathValue: regular expression to compare to request path
        // 3. requestType: GET, POST, PUT, DELETE
        client.createPath("Test Path", "/test", "GET");
    }
View Full Code Here


    /**
     * Demonstrates how to add an override to an existing path
     */
    public static void addOverrideToPath() throws Exception {
        Client client = new Client("ProfileName", false);

        // Use the fully qualified name for a plugin override.
        client.addMethodToResponseOverride("Test Path", "com.groupon.odo.sample.Common.delay");

        // The third argument is the ordinal - the nth instance of this override added to this path
        // The final arguments count and type are determined by the override. "delay" used in this sample
        // has a single int argument - # of milliseconds delay to simulate
        client.setMethodArguments("Test Path", "com.groupon.odo.sample.Common.delay", 1, "100");
    }
View Full Code Here

        Client.setCustomResponseForDefaultClient("ProfileName", "Test path", "test response data");
    }

    public static void mockPath4() throws Exception{
        // This demonstrates how to mock a path for a specific profile and non-default client
        Client client = new Client("ProfileName", true);
        client.setCustomResponse("Test Path", "test response data");

        // Since a new client is generated, we'll call destroy to remote the clientId generated from the profile
        client.destroy();
    }
View Full Code Here

    /**
     * By default, the client assumes Odo is running on localhost. This demonstrates how to
     * configure client to target an Odo instance on a remote host.
     */
    public static void targetRemoteHost() throws Exception{
        Client client = new Client("ProfileName", false);
        client.setHostName("RemoteHostName");
    }
View Full Code Here

    /**
     * Demonstrates obtaining the request history data from a test run
     */
    public static void getHistory() throws Exception{
        Client client = new Client("ProfileName", false);

        // Obtain the 100 history entries starting from offset 0
        History[] history = client.refreshHistory(100, 0);

        client.clearHistory();
    }
View Full Code Here

        }
    }

    @Test
    public void testRedirect() throws Exception {
        Client client = new Client("Consumer API", false);
        client.toggleProfile(true);
        client.addServerMapping("localhost", "127.0.0.1:8080", null);

        String response = HttpUtils.doProxyGet("http://localhost/", null);
        System.out.println(response);
        HttpExchangeInfo info = testServer.getLastExchange();
        System.out.println(info.getRequestBody());
View Full Code Here

    @Test
    public void testRedirectCustomOverride() throws Exception {
        String overrideResponse = "overridden";
        testServer.setLastExchange(null);

        Client client = new Client("Consumer API", false);
        client.toggleProfile(true);
        client.addServerMapping("localhost", "127.0.0.1:8080", null);
        client.setCustomResponse("Global", overrideResponse);
        client.toggleResponseOverride("Global", true);

        String response = HttpUtils.doProxyGet("http://localhost/", null);
        System.out.println(response);
        HttpExchangeInfo info = testServer.getLastExchange();
        assertNull(info);
View Full Code Here

            resetDatabase();
            Profile profile = ProfileService.getInstance().add("Consumer API");
            int id = profile.getId();
            int pathId = PathOverrideService.getInstance().addPathnameToProfile(id, "Global", "/");
            PathOverrideService.getInstance().addPathToRequestResponseTable(id, "-1", pathId);
            client = new Client("Consumer API", false);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
View Full Code Here

        assertFalse(client == null);
    }

    @Test
    public void createClient() throws Exception {
        Client newClient = new Client("Consumer API", true);
        assertFalse(newClient == null);
        newClient.destroy();
    }
View Full Code Here

    }

    @Test
    public void createInvalidClient() throws Exception {
        try {
            Client newClient = new Client("Fake PROFILE", true);
            assertFalse(client == newClient);
        } catch (Exception e) {
            assertTrue(e != null);
        }
    }
View Full Code Here

TOP

Related Classes of com.groupon.odo.client.Client

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.