Package org.wiztools.restclient.bean

Examples of org.wiztools.restclient.bean.RequestBean


    @After
    public void tearDown() {
    }

    private RequestBean getDefaultRequestBean() throws MalformedURLException{
        RequestBean expResult = new RequestBean();
        expResult.setUrl(new URL("http://localhost:10101/"));
        expResult.setMethod(HTTPMethod.POST);
        expResult.addHeader("key1", "value1");
        ContentType contentType = new ContentTypeBean("text/plain", Charsets.UTF_8);
        expResult.setBody(new ReqEntityStringBean("Body Text", contentType));
       
        BasicAuthBean auth = new BasicAuthBean();
        auth.setPreemptive(true);
        auth.setRealm("realm");
        auth.setUsername("username");
        auth.setPassword("password".toCharArray());
        expResult.setAuth(auth);
       
        expResult.setFollowRedirect(true);
        return expResult;
    }
View Full Code Here


     * Test of writeRequestXML method, of class XMLUtil.
     */
    @Test
    public void testWriteRequestXML() throws Exception {
        System.out.println("writeRequestXML");
        RequestBean bean = getDefaultRequestBean();
        File f = File.createTempFile("prefix", ".rcq");
        XMLUtil.writeRequestXML(bean, f);
        Request expResult = XMLUtil.getRequestFromXMLFile(f);
        assertEquals(expResult, bean);
    }
View Full Code Here

    @Test
    public void testGetRequestFromXMLFile() throws Exception {
        System.out.println("getRequestFromXMLFile");
        File f = new File("src/test/resources/reqFromXml.rcq");

        RequestBean expResult = getDefaultRequestBean();
       
        Request result = XMLUtil.getRequestFromXMLFile(f);
        assertEquals(expResult, result);
    }
View Full Code Here

    public void tearDown() {
    }

    @Test
    public void testSsl()  throws Exception {
        RequestBean expResult = new RequestBean();
        expResult.setUrl(new URL("https://www.webshop.co.uk/"));
        expResult.setMethod(HTTPMethod.GET);
        expResult.setHttpVersion(HTTPVersion.HTTP_1_1);
        expResult.setFollowRedirect(true);
        SSLReqBean ssl = new SSLReqBean();
        ssl.setTrustSelfSignedCert(true);
        ssl.setHostNameVerifier(SSLHostnameVerifier.ALLOW_ALL);
        expResult.setSslReq(ssl);
       
        Request actual = XMLUtil.getRequestFromXMLFile(new File("src/test/resources/reqSsl.rcq"));
       
        assertEquals(expResult, actual);
    }
View Full Code Here

    @Test
    public void testAll() throws Exception {
        System.out.println("all");
        HistoryManagerImpl instance = new HistoryManagerImpl();
        for(int i=0; i<10; i++) {
            RequestBean request = new RequestBean();
            request.setUrl(new URL("http://localhost/" + i));
            instance.add(request);
        }
        assertTrue(instance.isMostRecent());
        System.out.println("Current after 10 additions: " + instance.current());
       
        for(int i=0; i<10; i++) {
            instance.back();
        }
        assertTrue(instance.isOldest());
        System.out.println("Current after 10 backs: " + instance.current());
       
        for(int i=0; i<5; i++) {
            instance.forward();
        }
        System.out.println("Current after 5 forwards: " + instance.current());
        System.out.println("Cursor position: " + instance.cursor());
       
        RequestBean request = new RequestBean();
        request.setUrl(new URL("http://localhost/NEW"));
        instance.add(request);
        assertEquals(7, instance.size());
       
        System.out.println(instance);
    }
View Full Code Here

    @Test
    public void testSetHistorySize() throws Exception {
        System.out.println("setHistorySize");
        HistoryManagerImpl instance = new HistoryManagerImpl();
        for(int i=0; i<10; i++) {
            RequestBean request = new RequestBean();
            request.setUrl(new URL("http://localhost/" + i));
            instance.add(request);
        }
        instance.setHistorySize(5);
        assertEquals(5, instance.size());
    }
View Full Code Here

    public void testMaxElements() throws Exception {
        System.out.println("maxElements");
        HistoryManagerImpl instance = new HistoryManagerImpl();
        instance.setHistorySize(9);
        for(int i=0; i<10; i++) {
            RequestBean request = new RequestBean();
            request.setUrl(new URL("http://localhost/" + i));
            instance.add(request);
        }
        System.out.println("Elements in History: " + instance);
        assertEquals(9, instance.size());
    }
View Full Code Here

TOP

Related Classes of org.wiztools.restclient.bean.RequestBean

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.