Package org.apache.xmlrpc.client

Examples of org.apache.xmlrpc.client.XmlRpcClient


    public void initialize() throws QTasteException {
        TestBedConfiguration tb = TestBedConfiguration.getInstance();
        this.host = tb.getString("singleton_components.Windows.host");
        this.port = tb.getInt("singleton_components.Windows.port");
        this.client = new XmlRpcClient();
        try {
            XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
           
            config.setServerURL(new URL("http://" + host + ":" + port));
            client.setConfig(config);
View Full Code Here


            throw new XmlRpcException(pCode, "Message: " + pCode);
        }
    }

    private void testXMLRPC113(ClientProvider pProvider) throws Exception {
        XmlRpcClient client = pProvider.getClient();
        client.setConfig(getConfig(pProvider));
        XMLRPC113Handler handler = (XMLRPC113Handler) new ClientFactory(client).newInstance(XMLRPC113Handler.class);
        for (int i = 0;  i < 5;  i++) {
            try {
                client.execute(XMLRPC113Handler.class.getName() + ".throwCode", new Object[]{new Integer(i)});
                fail("Excpected exception");
            } catch (XmlRpcException e) {
                assertEquals(i, e.code);
            }
            try {
View Full Code Here

        }
    }

    private void testXMLRPC115(ClientProvider pProvider) throws Exception {
        if (pProvider instanceof SunHttpTransportProvider) {
            XmlRpcClient client = pProvider.getClient();
            client.setConfig(getConfig(pProvider));
            URL url = ((XmlRpcHttpClientConfig) client.getConfig()).getServerURL();
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            conn.setDoInput(true);
            conn.setDoOutput(true);
            conn.setRequestMethod("POST");
            conn.setRequestProperty("content-type", "text/xml");
            OutputStream ostream = conn.getOutputStream();
            Writer w = new OutputStreamWriter(ostream, "UTF-8");
            w.write("<methodCall><methodName>" + XMLRPC115Handler.class.getName() + ".ping"
                    + "</methodName></methodCall>");
            w.close();
            InputStream istream = conn.getInputStream();
            XmlRpcResponseParser parser = new XmlRpcResponseParser((XmlRpcStreamRequestConfig) client.getClientConfig(), client.getTypeFactory());
            XMLReader xr = SAXParsers.newXMLReader();
            xr.setContentHandler(parser);
            xr.parse(new InputSource(istream));
            istream.close();
            assertTrue(parser.getResult() instanceof Object[]);
View Full Code Here

            return sb.toString();
        }
    }

    private void testXMLRPC119(ClientProvider pProvider) throws Exception {
        XmlRpcClient client = pProvider.getClient();
        client.setConfig(getConfig(pProvider));
        for (int i = 0;  i < 100;  i+= 10) {
            String s = (String) client.execute(XMLRPC119Handler.class.getName() + ".getString", new Object[]{new Integer(i)});
            assertEquals(i*1024, s.length());
        }
    }
View Full Code Here

            iterations = pIterations;
            port = pPort;
        }
        public void run() {
            try {
                XmlRpcClient client = new XmlRpcClient();
                XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
                config.setServerURL(new URL("http://127.0.0.1:" + port + "/"));
                client.setConfig(config);
                for (int i = 0;  i < iterations;  i++) {
                    assertEquals(EIGHT, client.execute("Adder.add", new Object[]{THREE, FIVE}));
                }
            } catch (Throwable t) {
                t.printStackTrace();
            }
        }
View Full Code Here

            testAdder(providers[i]);
        }
    }

    private void testAdder(ClientProvider pProvider) throws Exception {
        XmlRpcClient client = pProvider.getClient();
        XmlRpcClientConfig config = getConfig(pProvider);
        client.setConfig(config);
        Object o = client.execute("Adder.add", new Object[]{new Integer(3), new Integer(5)});
        assertEquals(new Integer(8), o);
    }
View Full Code Here

            testListMethods(providers[i]);
        }
    }

    private void testListMethods(ClientProvider pProvider) throws Exception {
        XmlRpcClient client = pProvider.getClient();
        XmlRpcClientConfig config = getConfig(pProvider);
        client.setConfig(config);
        Object o = client.execute("system.listMethods", new Object[0]);
        Object[] methodList = (Object[]) o;
        Arrays.sort(methodList, Collator.getInstance(Locale.US));
        assertEquals(4, methodList.length);
        assertEquals("Adder.add", methodList[0]);
        assertEquals("system.listMethods", methodList[1]);
View Full Code Here

            testMethodHelp(providers[i]);
        }
    }

    private void testMethodHelp(ClientProvider pProvider) throws Exception {
        XmlRpcClient client = pProvider.getClient();
        XmlRpcClientConfig config = getConfig(pProvider);
        client.setConfig(config);
        String help = (String) client.execute("system.methodHelp", new Object[]{"Adder.add"});
        assertEquals("Invokes the method org.apache.xmlrpc.test.AuthenticationTest$AdderImpl.add(int, int).", help);
    }
View Full Code Here

            testMethodSignature(providers[i]);
        }
    }

    private void testMethodSignature(ClientProvider pProvider) throws Exception {
        XmlRpcClient client = pProvider.getClient();
        XmlRpcClientConfig config = getConfig(pProvider);
        client.setConfig(config);
        Object[] signatures = (Object[]) client.execute("system.methodSignature", new Object[]{"Adder.add"});
        assertEquals(signatures.length, 1);
        Object[] signature = (Object[]) signatures[0];
        assertEquals(3, signature.length);
        assertEquals("int", signature[0]);
        assertEquals("int", signature[1]);
View Full Code Here

            }
        };
    }

    private void testClientIpAddress(ClientProvider pProvider) throws Exception {
        final XmlRpcClient client = pProvider.getClient();
        client.setConfig(getConfig(pProvider));
        final String ip = (String) client.execute("getIpAddress", new Object[]{});
        assertEquals("127.0.0.1", ip);
    }
View Full Code Here

TOP

Related Classes of org.apache.xmlrpc.client.XmlRpcClient

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.