Examples of WebClient


Examples of org.apache.cxf.jaxrs.client.WebClient

                               "application/xml", 200);
    }
   
    @Test
    public void testGetBookSimple222() throws Exception {
        WebClient wc = WebClient.create("http://localhost:" + PORT + "/simplebooks/222");
        Book book = wc.get(Book.class);
        assertEquals(222L, book.getId());
    }
View Full Code Here

Examples of org.apache.cxf.jaxrs.client.WebClient

        assertEquals(222L, book.getId());
    }
   
    @Test
    public void testGetBookLowCaseHeader() throws Exception {
        WebClient wc = WebClient.create("http://localhost:" + PORT + "/bookstore/booksecho3");
        wc.type("text/plain").accept("text/plain").header("CustomHeader", "custom");
        String name = wc.post("book", String.class);
        assertEquals("book", name);
        assertEquals("custom", wc.getResponse().getHeaderString("CustomHeader"));
    }
View Full Code Here

Examples of org.apache.cxf.jaxrs.client.WebClient

        assertEquals("custom", wc.getResponse().getHeaderString("CustomHeader"));
    }
   
    @Test
    public void testGetBookSimple() throws Exception {
        WebClient wc = WebClient.create("http://localhost:" + PORT + "/simplebooks/simple");
        Book book = wc.get(Book.class);
        assertEquals(444L, book.getId());
    }
View Full Code Here

Examples of org.apache.cxf.jaxrs.client.WebClient

    public void testEmptyJAXB() {
        doTestEmptyResponse("application/xml");
    }
   
    private void doTestEmptyResponse(String mt) {
        WebClient wc = WebClient.create("http://localhost:" + PORT + "/bookstore/emptybook");
        WebClient.getConfig(wc).getInInterceptors().add(new ReplaceStatusInterceptor());
        wc.accept(mt);
        wc.get(Book.class);
    }
View Full Code Here

Examples of org.apache.cxf.jaxrs.client.WebClient

        assertNull(store.getEmptyBookNullable());
    }
   
    @Test
    public void testDropJSONRootDynamically() {
        WebClient wc = WebClient.create("http://localhost:" + PORT + "/bookstore/dropjsonroot");
        wc.accept("application/json");
        String response = wc.get(String.class);
        // with root: {"Book":{"id":123,"name":"CXF in Action"}}
        assertEquals("{\"id\":123,\"name\":\"CXF in Action\"}", response);
    }
View Full Code Here

Examples of org.eclipse.rap.rwt.client.WebClient

    assertNotNull( webPage.getControl() );
  }

  @Test
  public void testSetTitle_rendersTitle() {
    WebClient webClient = mock( WebClient.class );
    JavaScriptExecutor javaScriptExecutor = mock( JavaScriptExecutor.class );
    when( webClient.getService( JavaScriptExecutor.class ) ).thenReturn( javaScriptExecutor );
    environment.setClient( webClient );

    webPage.setTitle( "foo" );

    verify( javaScriptExecutor ).execute( eq( "document.title = \"foo\";" ) );
View Full Code Here

Examples of org.fcrepo.common.http.WebClient

                    + "to authenticate to GSearch service");
        }

        // finally, init the http client we'll use
        _webClientConfig = getServer().getWebClientConfig();
        _webClient = new WebClient(_webClientConfig);
    }
View Full Code Here

Examples of org.jvnet.hudson.test.JenkinsRule.WebClient

    }

    @Test
    @PresetData(DataSet.ANONYMOUS_READONLY)
    public void testPresetData() throws Exception {
        WebClient wc = rule.createWebClient();
        try {
            wc.goTo("loginError");
            fail("Expecting a 401 error");
        } catch (FailingHttpStatusCodeException e) {
            e.printStackTrace();
            assertEquals(SC_UNAUTHORIZED,e.getStatusCode());
        }

        // but not once the user logs in.
        verifyNotError(wc.login("alice"));
    }
View Full Code Here

Examples of org.vietspider.net.client.WebClient

*          nhudinhthuan@yahoo.com
* Nov 2, 2008
*/
public class GmailLogin {
  public static void main(String[] args) throws Exception {
    WebClient webClient = new WebClient();

    String homepage  = "http://mail.google.com/";
    webClient.setURL(homepage, new URL(homepage));

    HttpHost httpHost = webClient.createHttpHost(homepage);
    HttpGet httpGet = webClient.createGetMethod(homepage, "http://www.google.com");

    HttpResponse response = webClient.execute(httpHost, httpGet);
    HttpEntity entity = response.getEntity();

    System.out.println("Login form get: " + response.getStatusLine());
    if (entity != null) entity.consumeContent();

    System.out.println("Initial set of cookies:");
    DefaultHttpClient httpClient = (DefaultHttpClient) webClient.getHttpClient();
    List<Cookie> cookies = httpClient.getCookieStore().getCookies();
    if (cookies.isEmpty()) {
      System.out.println("None");
    } else {
      for (int i = 0; i < cookies.size(); i++) {
        System.out.println("- " + cookies.get(i).toString());
      }
    }

    HttpSessionUtils httpSession = new HttpSessionUtils(webClient, "ERROR");

    StringBuilder builder = new StringBuilder("https://www.google.com/accounts/ServiceLogin?service=mail&passive=true&rm=false&continue=http%3A%2F%2Fmail.google.com%2Fmail%2F%3Fui%3Dhtml%26zy%3Dl&bsv=1k96igf4806cy&ltmpl=default&ltmplcache=2");
    builder.append('\n').append("your_username:your_password");

    httpSession.login(builder.toString(), "utf-8", new URL(homepage), homepage);

    httpGet = webClient.createGetMethod("http://mail.google.com/mail/", "http://gmail.com");
    response = webClient.execute(httpHost, httpGet);
    entity = response.getEntity();

    HttpResponseReader httpResponseReader = new HttpResponseReader();
    byte [] bytes = httpResponseReader.readBody(response);
    new DataWriter().save(new File("google_mail.html"), bytes);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.