Package org.switchyard.component.test.mixins.http

Examples of org.switchyard.component.test.mixins.http.HTTPMixIn


            System.out.println("\t CamelCxfRsBindingClient add 1 1 10");
            System.out.println("\t CamelCxfRsBindingClient del 1 3");
            return;
        } else {
            command = args[0];
            HTTPMixIn http = new HTTPMixIn();
            http.initialize();
            if (command.equals("new")) {
                String response = http.sendString(baseUrl + "/inventory", "", HTTPMixIn.HTTP_GET);
                if (response.equals("false")) {
                    http.sendString(baseUrl + "/inventory/create", "", HTTPMixIn.HTTP_OPTIONS);
                }
                System.out.println(http.sendString(baseUrl + "/order", "", HTTPMixIn.HTTP_POST));
            } else if (command.equals("get")) {
                if (args.length != 2) {
                    System.out.println("No orderId found!");
                    System.out.println("Usage: get <orderId>");
                }
                System.out.println(http.sendString(baseUrl + "/order/" + args[1], "", HTTPMixIn.HTTP_GET));
            } else if (command.equals("add")) {
                if (args.length < 2) {
                    System.out.println("No orderId found!");
                    System.out.println("Usage: get <orderId> <itemId> <quantity>");
                }
                if (args.length < 3) {
                    System.out.println("No itemId found!");
                    System.out.println("Usage: get <orderId> <itemId> <quantity>");
                }
                if (args.length < 4) {
                    System.out.println("No quantity found!");
                    System.out.println("Usage: get <orderId> <itemId> <quantity>");
                }
                String order = "<order>"
                    + "    <orderId>" + args[1] + "</orderId>"
                    + "    <orderItem>"
                    + "        <item>"
                    + "            <itemId>" + args[2] + "</itemId>"
                    + "         </item>"
                    + "         <quantity>" + args[3] + "</quantity>"
                    + "     </orderItem>"
                    + "</order>";
                System.out.println(http.sendString(baseUrl + "/order/item", order, HTTPMixIn.HTTP_PUT));
            } else if (command.equals("del")) {
                if (args.length < 2) {
                    System.out.println("No orderId found!");
                    System.out.println("Usage: get <orderId> <itemId>");
                }
                if (args.length < 3) {
                    System.out.println("No itemId found!");
                    System.out.println("Usage: get <orderId> <itemId>");
                }
                System.out.println(http.sendString(baseUrl + "/order/" + args[1] + ":" + args[2], "", HTTPMixIn.HTTP_DELETE));
            }
        }
    }
View Full Code Here


    private static void invokeWorkService(String scheme, int port, String context, String binarySecurityToken) throws Exception {
        String soapRequest = new StringPuller().pull("/xml/soap-request.xml").replaceAll("WORK_CMD", "CMD-" + System.currentTimeMillis());
        if (binarySecurityToken != null) {
            soapRequest = soapRequest.replaceFirst("<!-- BinarySecurityToken -->", binarySecurityToken);
        }
        HTTPMixIn http = new HTTPMixIn();
        http.initialize();
        try {
            String endpoint = String.format("%s://localhost:%s/%s/WorkService", scheme, port, context);
            //LOGGER.info(String.format("Invoking work service at endpoint: %s with request: %s", endpoint, soapRequest));
            LOGGER.info(String.format("Invoking work service at endpoint: %s", endpoint));
            String soapResponse = http.postString(endpoint, soapRequest);
            //LOGGER.info(String.format("Received work service response: %s", soapResponse));
            if (soapResponse.toLowerCase().contains("fault")) {
                throw new Exception("Error invoking work service (check server log)");
            }
        } finally {
            http.uninitialize();
        }
    }
View Full Code Here

     * @param ignored not used.
     * @throws Exception if something goes wrong.
     */
    public static void main(final String[] ignored) throws Exception {

        HTTPMixIn soapMixIn = new HTTPMixIn();
        soapMixIn.initialize();

        try {
            String port = System.getProperty("org.switchyard.component.soap.client.port", "8080");
            String url = "http://localhost:" + port + "/quickstart-transform-xslt/OrderService";
            String result = soapMixIn.postFile(url, XML);
            System.out.println("SOAP Reply:\n" + result);
        } finally {
            soapMixIn.uninitialize();
        }
    }
View Full Code Here

        if (signencrypt) {
            soapRequest = new StringPuller().pull("/xml/secure-request.xml");
        } else {
            soapRequest = new StringPuller().pull("/xml/insecure-request.xml").replaceAll("WORK_CMD", "CMD-" + System.currentTimeMillis());
        }
        HTTPMixIn http = new HTTPMixIn();
        http.initialize();
        try {
            String endpoint = String.format("%s://localhost:%s/%s/WorkService", scheme, port, context);
            //LOGGER.info(String.format("Invoking work service at endpoint: %s with request: %s", endpoint, soapRequest));
            LOGGER.info(String.format("Invoking work service at endpoint: %s", endpoint));
            String soapResponse = http.postString(endpoint, soapRequest);
            //LOGGER.info(String.format("Received work service response: %s", soapResponse));
            if (soapResponse.toLowerCase().contains("fault")) {
                throw new Exception("Error invoking work service (check server log)");
            }
        } finally {
            http.uninitialize();
        }
    }
View Full Code Here

     * @param ignored not used.
     * @throws Exception if something goes wrong.
     */
    public static void main(final String[] ignored) throws Exception {

        HTTPMixIn soapMixIn = new HTTPMixIn();
        soapMixIn.initialize();

        try {
            String port = System.getProperty("org.switchyard.component.soap.client.port", "8080");
            String url = "http://localhost:" + port + "/rules-interview-dtable/Interview";
            String result = soapMixIn.postFile(url, XML);
            System.out.println("SOAP Reply:\n" + result);
        } finally {
            soapMixIn.uninitialize();
        }
    }
View Full Code Here

    public static void main(String[] args) throws Exception {
        System.out.print("Give name for greeting: ");

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        HTTPMixIn http = new HTTPMixIn();
        http.initialize();

        String request = JAXBUtil.marshal(new GreetingRequest(reader.readLine()));
        System.out.println("Sending request\n" + request);
        String port = System.getProperty("org.switchyard.component.http.client.port", "8080");
        String reply = http.sendString("http://localhost:" + port + "/camel-binding", request, HTTPMixIn.HTTP_POST);
        System.out.println("Received response\n" + reply);
    }
View Full Code Here

     * @param ignored not used.
     * @throws Exception if something goes wrong.
     */
    public static void main(final String[] ignored) throws Exception {

        HTTPMixIn soapMixIn = new HTTPMixIn();
        soapMixIn.initialize();

        try {
            String port = System.getProperty("org.switchyard.component.soap.client.port", "8080");
            String url = "http://localhost:" + port + "/HelloGoodbyeService/HelloGoodbyeService";
            String result = soapMixIn.postFile(url, XML1);
            System.out.println("SOAP Reply:\n" + result);

            result = soapMixIn.postFile(url, XML2);
            System.out.println("SOAP Reply:\n" + result);
        } finally {
            soapMixIn.uninitialize();
        }
    }
View Full Code Here

     * @param ignored not used.
     * @throws Exception if something goes wrong.
     */
    public static void main(final String[] ignored) throws Exception {

        HTTPMixIn soapMixIn = new HTTPMixIn();
        soapMixIn.initialize();

        try {
            String port = System.getProperty("org.switchyard.component.soap.client.port", "8080");
            String url = "http://localhost:" + port + "/swydws/ProcessOrder";
            String result = soapMixIn.postFile(url, XML);
            System.out.println("SOAP Reply:\n" + result);
        } finally {
            soapMixIn.uninitialize();
        }
    }
View Full Code Here

    private static final String MAVEN_USAGE = String.format("Maven Usage: mvn exec:java -Dexec.args=\"%s %s %s\"", CONFIDENTIALITY, CLIENT_AUTHENTICATION, HELP);

    private static void invokeWorkService(String scheme, int port, String context, String[] userPass) throws Exception {
        String soapRequest = new StringPuller().pull("/xml/soap-request.xml").replaceAll("WORK_CMD", "CMD-" + System.currentTimeMillis());
        HTTPMixIn http = new HTTPMixIn();
        if (userPass != null && userPass.length == 2) {
            http.setRequestHeader("Authorization", "Basic " + Base64.encodeFromString(userPass[0] + ":" + userPass[1]));
        }
        http.initialize();
        try {
            String endpoint = String.format("%s://localhost:%s/%s/WorkService", scheme, port, context);
            //LOGGER.info(String.format("Invoking work service at endpoint: %s with request: %s", endpoint, soapRequest));
            LOGGER.info(String.format("Invoking work service at endpoint: %s", endpoint));
            String soapResponse = http.postString(endpoint, soapRequest);
            //LOGGER.info(String.format("Received work service response: %s", soapResponse));
            if (soapResponse.toLowerCase().contains("fault")) {
                throw new Exception("Error invoking work service (check server log)");
            }
        } finally {
            http.uninitialize();
        }
    }
View Full Code Here

     * @param ignored not used.
     * @throws Exception if something goes wrong.
     */
    public static void main(final String[] ignored) throws Exception {

        HTTPMixIn soapMixIn = new HTTPMixIn();
        soapMixIn.initialize();

        try {
            String port = System.getProperty("org.switchyard.component.soap.client.port", "8080");
            String url = "http://localhost:" + port + "/quickstart-transform-jaxb/OrderService";
            String result = soapMixIn.postFile(url, XML);
            System.out.println("SOAP Reply:\n" + result);
        } finally {
            soapMixIn.uninitialize();
        }
    }
View Full Code Here

TOP

Related Classes of org.switchyard.component.test.mixins.http.HTTPMixIn

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.