]> git.argeo.org Git - lgpl/argeo-commons.git/blob - sandbox/runtime/org.argeo.sandbox.jackrabbit/src/main/java/webdav/WebDavTest.java
Improve Apache DS
[lgpl/argeo-commons.git] / sandbox / runtime / org.argeo.sandbox.jackrabbit / src / main / java / webdav / WebDavTest.java
1 package webdav;
2
3 import java.io.FileInputStream;
4
5 import org.apache.commons.httpclient.Credentials;
6 import org.apache.commons.httpclient.HostConfiguration;
7 import org.apache.commons.httpclient.HttpClient;
8 import org.apache.commons.httpclient.HttpConnectionManager;
9 import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
10 import org.apache.commons.httpclient.UsernamePasswordCredentials;
11 import org.apache.commons.httpclient.auth.AuthScope;
12 import org.apache.commons.httpclient.methods.InputStreamRequestEntity;
13 import org.apache.commons.httpclient.methods.RequestEntity;
14 import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
15 import org.apache.jackrabbit.webdav.client.methods.PutMethod;
16
17 public class WebDavTest {
18
19 /**
20 * @param args
21 */
22 public static void main(String[] args) {
23 try {
24 HostConfiguration hostConfig = new HostConfiguration();
25 hostConfig.setHost("localhost", 7070);
26 // hostConfig.
27 HttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
28 HttpConnectionManagerParams params = new HttpConnectionManagerParams();
29 int maxHostConnections = 20;
30 params.setMaxConnectionsPerHost(hostConfig, maxHostConnections);
31 connectionManager.setParams(params);
32 HttpClient client = new HttpClient(connectionManager);
33 Credentials creds = new UsernamePasswordCredentials("demo", "demo");
34 client.getState().setCredentials(AuthScope.ANY, creds);
35 client.setHostConfiguration(hostConfig);
36 // return client;
37
38 String fileName = "test.xml";
39 PutMethod pm = new PutMethod(
40 "http://localhost:7070/org.argeo.server.jackrabbit.webapp/default/"
41 + fileName);
42 // String text = "this is the document content";
43 RequestEntity requestEntity = new InputStreamRequestEntity(
44 new FileInputStream(fileName));
45 // pm.setRequestEntity(new StringRequestEntity(text, "text/plain",
46 // null));
47 // pm.setRequestBody(text);
48 pm.setRequestEntity(requestEntity);
49 client.executeMethod(pm);
50 } catch (Exception e) {
51 e.printStackTrace();
52 }
53 }
54
55 }