3 import java
.io
.FileInputStream
;
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
;
17 public class WebDavTest
{
22 public static void main(String
[] args
) {
24 HostConfiguration hostConfig
= new HostConfiguration();
25 hostConfig
.setHost("localhost", 7070);
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
);
38 String fileName
= "test.xml";
39 PutMethod pm
= new PutMethod(
40 "http://localhost:7070/org.argeo.server.jackrabbit.webapp/default/"
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",
47 // pm.setRequestBody(text);
48 pm
.setRequestEntity(requestEntity
);
49 client
.executeMethod(pm
);
50 } catch (Exception e
) {