Package org.apache.abdera.protocol.client

Examples of org.apache.abdera.protocol.client.RequestOptions


            String pwd) {

        try {
            StringRequestEntity stringreq =
                    new StringRequestEntity(getRequest(id, pwd, service));
            RequestOptions options = client.getDefaultRequestOptions();
            options.setContentType("application/x-www-form-urlencoded");
            ClientResponse response = client.post(URI, stringreq, options);
            String auth = read(response.getInputStream());
            response.release();
            return auth.split("\n")[2].replaceAll("Auth=", "auth=");
        } catch (CarbonException e) {
View Full Code Here


            if (hostObject.authenticationType.compareToIgnoreCase("google") == 0) {
                String auth = GoogleLogin.getAuth(
                        hostObject.client, hostObject.serviceString, hostObject.usernameString,
                        hostObject.passwordString);

                RequestOptions options = hostObject.client.getDefaultRequestOptions();
                options.setAuthorization("GoogleLogin " + auth);

                hostObject.options = options;
            } else if (hostObject.authenticationType.compareToIgnoreCase("basic") == 0) {
                //Take basic authentication by default
                hostObject.client.addCredentials(uri, null, null, new UsernamePasswordCredentials(
View Full Code Here

        Element customerEl = factory.newElement(new QName("customer"));
        customerEl.setAttributeValue(new QName("name"), "Dan Diephouse");
        entry.setContent(customerEl);

        RequestOptions opts = new RequestOptions();
        opts.setContentType("application/atom+xml;type=entry");
        ClientResponse res = client.post(colUri.toString(), entry, opts);
        assertEquals(201, res.getStatus());

        IRI location = res.getLocation();
        assertEquals(basePath + "/customers/1001-Dan_Diephouse", location.toString());
View Full Code Here

    Content content = abdera.getFactory().newContent();
    content.setContentType(Content.Type.TEXT);
    content.setValue(customerName);
    entry.setContentElement(content);

    RequestOptions opts = new RequestOptions();
    final String contentType = "application/atom+xml; type=entry";
    opts.setContentType(contentType);
    // AtomTestCaseUtils.printRequestHeaders( "Post request headers", "   ", opts );
    IRI colUri = new IRI(providerURI).resolve("customer");
    // res = client.post(colUri.toString() + "?test=foo", entry, opts);
    ClientResponse res = client.post(colUri.toString(), entry, opts);
   
View Full Code Here

  }

  @Test
  public void testXMLEntryGet() throws Exception {
    System.out.println(">>>ContentNegotiationTest.testXMLEntryGet");
    RequestOptions opts = new RequestOptions();
    opts.setHeader( "Accept", "application/atom+xml" );
   
    IRI colUri = new IRI(providerURI).resolve("customer");
    ClientResponse res = client.get(colUri.toString() + "/" + lastId, opts);
      Assert.assertEquals(200, res.getStatus());
      String returnedContentType = res.getContentType().toString().trim();
View Full Code Here

  }

  @Test
  public void testJSONEntryGet() throws Exception {
    System.out.println(">>>ContentNegotiationTest.testJSONEntryGet");
    RequestOptions opts = new RequestOptions();
    opts.setHeader( "Accept", "application/json" );
   
    IRI colUri = new IRI(providerURI).resolve("customer");
    ClientResponse res = client.get(colUri.toString() + "/" + lastId, opts);
    try {
      Assert.assertEquals(200, res.getStatus());
View Full Code Here

  }

  @Test
    public void testXMLFeedGet() throws Exception {   
    System.out.println(">>>ContentNegotiationTest.testXMLFeedGet");
    RequestOptions opts = new RequestOptions();
    opts.setHeader( "Accept", "application/atom+xml" );
   
    // Atom feed request
    ClientResponse res = client.get(providerURI, opts);
    Assert.assertNotNull(res);
    try {
View Full Code Here

  }   

  @Test
    public void testJSONFeedGet() throws Exception {   
    System.out.println(">>>ContentNegotiationTest.testJSONFeedGet");
    RequestOptions opts = new RequestOptions();
    opts.setHeader( "Accept", "application/json" );
   
    // JSON feed request
    ClientResponse res = client.get(providerURI, opts);
    Assert.assertNotNull(res);
    try {
View Full Code Here

  @Test
    public void testUnmodifiedGetIfMatch() throws Exception {   
    System.out.println(">>>ProviderFeedEntityTagsTestCase.testFeedUnmodifiedGetIfMatch");
    // Feed request with predicates
    RequestOptions opts = new RequestOptions();
    final String contentType = "application/atom+xml";
    opts.setContentType(contentType);
    opts.setHeader( "If-Match", eTag);
   
    ClientResponse res = client.get(providerURI, opts);
    Assert.assertNotNull(res);
    try {
        String thisETag = res.getHeader("ETag");
View Full Code Here

  @Test
    public void testUnmodifiedGetIfNoneMatch() throws Exception {   
    System.out.println(">>>ProviderFeedEntityTagsTestCase.testFeedUnmodifiedGetIfNoneMatch");
    // Feed request with predicates
    RequestOptions opts = new RequestOptions();
    final String contentType = "application/atom+xml";
    opts.setContentType(contentType);
    opts.setHeader( "If-None-Match", eTag);
   
    ClientResponse res = client.get(providerURI, opts);
    Assert.assertNotNull(res);
    try {
      // Should return 304 - Feed not provided since it matches ETag.
View Full Code Here

TOP

Related Classes of org.apache.abdera.protocol.client.RequestOptions

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.