01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */
19:
20: package org.apache.synapse.transport.vfs;
21:
22: import org.apache.axis2.description.Parameter;
23: import org.apache.axis2.description.TransportInDescription;
24: import org.apache.axis2.description.TransportOutDescription;
25: import org.apache.synapse.transport.UtilsTransportServer;
26:
27: import java.util.ArrayList;
28: import java.util.List;
29: import java.io.File;
30:
31: /**
32: * A VFS enabled Axis2 server implementation for unit testing
33: */
34: public class UtilsVFSServer extends UtilsTransportServer {
35:
36: public void start() throws Exception {
37:
38: TransportOutDescription trpOutDesc = new TransportOutDescription(
39: VFSTransportListener.TRANSPORT_NAME);
40: trpOutDesc.setSender(new VFSTransportSender());
41:
42: TransportInDescription trpInDesc = new TransportInDescription(
43: VFSTransportListener.TRANSPORT_NAME);
44: trpInDesc.setReceiver(new VFSTransportListener());
45: super .start(trpInDesc, trpOutDesc);
46:
47: // create a temp directory for us to poll for the sample service
48: makeCleanPath("./target/vfs1/req");
49: makeCleanPath("./target/vfs1/res");
50:
51: makeCleanPath("./target/vfs2/req");
52: makeCleanPath("./target/vfs2/res");
53:
54: // Service1 - polls target/vfs1/req/request.xml, and writes the response to
55: // target/vfs1/res folder and deletes request on success. Polls every 2 secs
56: List parameters = new ArrayList();
57: parameters.add(new Parameter("transport.vfs.FileURI",
58: "vfs:file://" + new File(".").getAbsolutePath()
59: + File.separator + "target/vfs1/req"));
60: parameters.add(new Parameter("transport.vfs.FileNamePattern",
61: "request.xml"));
62: parameters.add(new Parameter("transport.vfs.ReplyFileURI",
63: "vfs:file://" + new File(".").getAbsolutePath()
64: + File.separator + "target/vfs1/res"));
65: parameters.add(new Parameter("transport.vfs.ContentType",
66: "text/xml"));
67: parameters.add(new Parameter("transport.PollInterval", "2"));
68:
69: parameters.add(new Parameter(
70: "transport.vfs.ActionAfterProcess", "DELETE"));
71: deployEchoService("Service1", parameters);
72:
73: // Service2 - polls target/vfs2/req/requests.jar, and writes the response to
74: // target/vfs/res folder and deletes request on success. Polls every 2 secs
75: parameters = new ArrayList();
76: parameters.add(new Parameter("transport.vfs.FileURI",
77: "vfs:file://" + new File(".").getAbsolutePath()
78: + File.separator
79: + "target/vfs2/req/requests.jar"));
80: //parameters.add(new Parameter("transport.vfs.FileNamePattern", "request.xml"));
81: parameters.add(new Parameter("transport.vfs.ReplyFileURI",
82: "vfs:file://" + new File(".").getAbsolutePath()
83: + File.separator + "target/vfs2/res"));
84: parameters.add(new Parameter("transport.vfs.ContentType",
85: "text/xml"));
86: parameters.add(new Parameter("transport.PollInterval", "2"));
87:
88: parameters.add(new Parameter(
89: "transport.vfs.ActionAfterProcess", "DELETE"));
90: deployEchoService("Service2", parameters);
91: }
92:
93: }
|