Package com.googlecode.sardine.impl

Examples of com.googlecode.sardine.impl.SardineImpl


   * @param password Use in authentication header credentials
   * @param proxy  Proxy configuration
   */
  public static Sardine begin(String username, String password, ProxySelector proxy)
  {
    return new SardineImpl(username, password, proxy);
  }
View Full Code Here


        assertEquals(1, r.getHeaders(HttpHeaders.CONTENT_ENCODING).length);
        assertEquals("gzip", r.getHeaders(HttpHeaders.CONTENT_ENCODING)[0].getValue());
        client.removeResponseInterceptorByClass(this.getClass());
      }
    });
    Sardine sardine = new SardineImpl(client);
    sardine.enableCompression();
//    final String url = "http://sardine.googlecode.com/svn/trunk/README.html";
    final String url = "http://sudo.ch/dav/anon/sardine/single/file";
    final InputStream in = sardine.get(url);
    assertNotNull(in);
    assertNotNull(in.read());
    try
    {
      in.close();
View Full Code Here

  @Test
  public void testPutRange() throws Exception
  {
    final DefaultHttpClient client = new DefaultHttpClient();
    Sardine sardine = new SardineImpl(client);
    // mod_dav supports Range headers for PUT
    final String url = "http://sudo.ch/dav/anon/sardine/" + UUID.randomUUID().toString();
    client.addResponseInterceptor(new HttpResponseInterceptor()
    {
      public void process(final HttpResponse r, final HttpContext context) throws HttpException, IOException
      {
        assertEquals(201, r.getStatusLine().getStatusCode());
        client.removeResponseInterceptorByClass(this.getClass());
      }
    });
    sardine.put(url, new ByteArrayInputStream("Te".getBytes("UTF-8")));

    try
    {
      // Append to existing file
      final Map<String, String> header = Collections.singletonMap(HttpHeaders.CONTENT_RANGE,
          "bytes " + 2 + "-" + 3 + "/" + 4);

      client.addRequestInterceptor(new HttpRequestInterceptor()
      {
        public void process(final HttpRequest r, final HttpContext context) throws HttpException, IOException
        {
          assertNotNull(r.getHeaders(HttpHeaders.CONTENT_RANGE));
          assertEquals(1, r.getHeaders(HttpHeaders.CONTENT_RANGE).length);
          client.removeRequestInterceptorByClass(this.getClass());
        }
      });
      client.addResponseInterceptor(new HttpResponseInterceptor()
      {
        public void process(final HttpResponse r, final HttpContext context) throws HttpException, IOException
        {
          assertEquals(204, r.getStatusLine().getStatusCode());
          client.removeResponseInterceptorByClass(this.getClass());
        }
      });
      sardine.put(url, new ByteArrayInputStream("st".getBytes("UTF-8")), header);

      assertEquals("Test", new BufferedReader(new InputStreamReader(sardine.get(url), "UTF-8")).readLine());
    }
    finally
    {
      sardine.delete(url);
    }
  }
View Full Code Here

        assertNotNull(r.getHeaders(HttpHeaders.CONTENT_RANGE));
        assertEquals(1, r.getHeaders(HttpHeaders.CONTENT_RANGE).length);
        client.removeResponseInterceptorByClass(this.getClass());
      }
    });
    Sardine sardine = new SardineImpl(client);
    // mod_dav supports Range headers for GET
    final String url = "http://sudo.ch/dav/anon/sardine/single/file";
    // Resume
    final Map<String, String> header = Collections.singletonMap(HttpHeaders.RANGE, "bytes=" + 1 + "-");
    final InputStream in = sardine.get(url, header);
    assertNotNull(in);
  }
View Full Code Here

            return "invalid";
          }
        };
      }
    });
    SardineImpl sardine = new SardineImpl(client);
    URI url = URI.create("http://sudo.ch/dav/basic/");
    //Send basic authentication header in initial request
    sardine.enablePreemptiveAuthentication(url.getHost());
    try
    {
      sardine.list(url.toString());
      fail("Expected authorization failure");
    }
    catch (SardineException e)
    {
      // Expect Authorization Failed
View Full Code Here

        assertNotNull(r.getHeaders(HttpHeaders.AUTHORIZATION));
        assertEquals(1, r.getHeaders(HttpHeaders.AUTHORIZATION).length);
        client.removeRequestInterceptorByClass(this.getClass());
      }
    });
    Sardine sardine = new SardineImpl(client);
    sardine.setCredentials("anonymous", null);
    // mod_dav supports Range headers for PUT
    final URI url = URI.create("http://sardine.googlecode.com/svn/trunk/README.html");
    sardine.enablePreemptiveAuthentication(url.getHost());
    assertTrue(sardine.exists(url.toString()));
  }
View Full Code Here

TOP

Related Classes of com.googlecode.sardine.impl.SardineImpl

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.