Author: veithen
Date: Sat Sep 6 05:51:27 2008
New Revision: 692647
URL: http://svn.apache.org/viewvc?rev=692647&view=rev
Log:
VFS transport tests: Added tests for request-response and removed old test
cases.
Added:
synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSAsyncClient.java
synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSAsyncFileChannel.java
synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSRequestResponseClient.java
synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSRequestResponseFileChannel.java
synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSTestUtils.java
Removed:
synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/UtilsVFSServer.java
synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSEchoRawXMLTest.java
Modified:
synapse/trunk/java/modules/transports/pom.xml
synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSClient.java
synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSFileChannel.java
synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSMockAsyncEndpoint.java
synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSTransportTest.java
Modified: synapse/trunk/java/modules/transports/pom.xml
URL:
http://svn.apache.org/viewvc/synapse/trunk/java/modules/transports/pom.xml?rev=692647&r1=692646&r2=692647&view=diff
==============================================================================
--- synapse/trunk/java/modules/transports/pom.xml (original)
+++ synapse/trunk/java/modules/transports/pom.xml Sat Sep 6 05:51:27 2008
@@ -141,42 +141,6 @@
</plugins>
</build>
- <profiles>
- <!-- excludes the VFS test on windows because it is failing due to a
file locking failure -->
- <profile>
- <id>windows-test</id>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <version>2.3</version>
- <configuration>
- <systemProperties>
- <property>
- <name>log4j.configuration</name>
- <value>file:log4j.properties</value>
- </property>
- </systemProperties>
- <excludes>
- <exclude>**/VFSEchoRawXMLTest.java</exclude>
- <exclude>**/MailEchoRawXMLTest.java</exclude>
-
<exclude>**/AbstractTransportTest.java</exclude>
-
<exclude>org/apache/synapse/transport/mail/Test*.java</exclude>
-
<exclude>org/apache/synapse/transport/testkit/**/*.java</exclude>
- </excludes>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <activation>
- <os>
- <family>Windows</family>
- </os>
- </activation>
- </profile>
- </profiles>
-
<dependencies>
<dependency>
<groupId>org.apache.synapse</groupId>
Added:
synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSAsyncClient.java
URL:
http://svn.apache.org/viewvc/synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSAsyncClient.java?rev=692647&view=auto
==============================================================================
---
synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSAsyncClient.java
(added)
+++
synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSAsyncClient.java
Sat Sep 6 05:51:27 2008
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.synapse.transport.vfs;
+
+import javax.mail.internet.ContentType;
+
+import org.apache.synapse.transport.testkit.client.AsyncTestClient;
+import org.apache.synapse.transport.testkit.client.ClientOptions;
+
+public class VFSAsyncClient extends VFSClient implements
AsyncTestClient<byte[]> {
+ public void sendMessage(ClientOptions options, ContentType contentType,
byte[] message) throws Exception {
+ send(message);
+ }
+}
Added:
synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSAsyncFileChannel.java
URL:
http://svn.apache.org/viewvc/synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSAsyncFileChannel.java?rev=692647&view=auto
==============================================================================
---
synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSAsyncFileChannel.java
(added)
+++
synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSAsyncFileChannel.java
Sat Sep 6 05:51:27 2008
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.synapse.transport.vfs;
+
+import org.apache.synapse.transport.testkit.listener.AsyncChannel;
+
+public class VFSAsyncFileChannel extends VFSFileChannel implements
AsyncChannel {
+ public VFSAsyncFileChannel(String path) {
+ super(path);
+ }
+}
Modified:
synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSClient.java
URL:
http://svn.apache.org/viewvc/synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSClient.java?rev=692647&r1=692646&r2=692647&view=diff
==============================================================================
---
synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSClient.java
(original)
+++
synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSClient.java
Sat Sep 6 05:51:27 2008
@@ -25,12 +25,12 @@
import javax.mail.internet.ContentType;
-import org.apache.synapse.transport.testkit.client.AsyncTestClient;
import org.apache.synapse.transport.testkit.client.ClientOptions;
+import org.apache.synapse.transport.testkit.client.TestClient;
import org.apache.synapse.transport.testkit.name.Name;
@Name("java.io")
-public class VFSClient implements AsyncTestClient<byte[]> {
+public class VFSClient implements TestClient {
private File requestFile;
@SuppressWarnings("unused")
@@ -42,7 +42,7 @@
return contentType;
}
- public void sendMessage(ClientOptions options, ContentType contentType,
byte[] message) throws Exception {
+ protected void send(byte[] message) throws Exception {
OutputStream out = new FileOutputStream(requestFile);
out.write(message);
out.close();
Modified:
synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSFileChannel.java
URL:
http://svn.apache.org/viewvc/synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSFileChannel.java?rev=692647&r1=692646&r2=692647&view=diff
==============================================================================
---
synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSFileChannel.java
(original)
+++
synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSFileChannel.java
Sat Sep 6 05:51:27 2008
@@ -23,10 +23,9 @@
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.description.AxisService;
-import org.apache.synapse.transport.testkit.listener.AsyncChannel;
import
org.apache.synapse.transport.testkit.server.axis2.AxisServiceConfigurator;
-public class VFSFileChannel implements AsyncChannel, AxisServiceConfigurator {
+public class VFSFileChannel implements AxisServiceConfigurator {
private final String path;
private File requestFile;
@@ -47,11 +46,16 @@
service.addParameter("transport.PollInterval", "50ms");
service.addParameter("transport.vfs.ActionAfterProcess", "DELETE");
}
-
+
+ protected static File preparePath(VFSTestEnvironment env, String path) {
+ File file = new File(env.getRootDir(), path);
+ file.getParentFile().mkdirs();
+ file.delete();
+ return file;
+ }
+
@SuppressWarnings("unused")
private void setUp(VFSTestEnvironment env) throws Exception {
- requestFile = new File(env.getRootDir(), path);
- requestFile.getParentFile().mkdirs();
- requestFile.delete();
+ requestFile = preparePath(env, path);
}
}
Modified:
synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSMockAsyncEndpoint.java
URL:
http://svn.apache.org/viewvc/synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSMockAsyncEndpoint.java?rev=692647&r1=692646&r2=692647&view=diff
==============================================================================
---
synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSMockAsyncEndpoint.java
(original)
+++
synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSMockAsyncEndpoint.java
Sat Sep 6 05:51:27 2008
@@ -19,20 +19,14 @@
package org.apache.synapse.transport.vfs;
-import java.io.File;
-import java.io.InputStream;
-
import javax.mail.internet.ContentType;
-import org.apache.commons.io.IOUtils;
import org.apache.synapse.transport.testkit.client.ClientOptions;
import org.apache.synapse.transport.testkit.client.TestClient;
import org.apache.synapse.transport.testkit.message.IncomingMessage;
import org.apache.synapse.transport.testkit.name.Name;
import org.apache.synapse.transport.testkit.server.AsyncEndpoint;
-import de.schlichtherle.io.FileInputStream;
-
@Name("mock")
public class VFSMockAsyncEndpoint implements AsyncEndpoint<byte[]> {
private VFSFileChannel channel;
@@ -45,19 +39,7 @@
}
public IncomingMessage<byte[]> waitForMessage(int timeout) throws
Throwable {
- long time = System.currentTimeMillis();
- File file = channel.getRequestFile();
- while (System.currentTimeMillis() < time + timeout) {
- if (file.exists()) {
- InputStream in = new FileInputStream(file);
- try {
- return new IncomingMessage<byte[]>(contentType,
IOUtils.toByteArray(in));
- } finally {
- in.close();
- }
- }
- Thread.sleep(100);
- }
- return null;
+ byte[] data = VFSTestUtils.waitForFile(channel.getRequestFile(),
timeout);
+ return data == null ? null : new IncomingMessage<byte[]>(contentType,
data);
}
}
Added:
synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSRequestResponseClient.java
URL:
http://svn.apache.org/viewvc/synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSRequestResponseClient.java?rev=692647&view=auto
==============================================================================
---
synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSRequestResponseClient.java
(added)
+++
synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSRequestResponseClient.java
Sat Sep 6 05:51:27 2008
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.synapse.transport.vfs;
+
+import java.io.File;
+
+import javax.mail.internet.ContentType;
+
+import org.apache.synapse.transport.testkit.client.ClientOptions;
+import org.apache.synapse.transport.testkit.client.RequestResponseTestClient;
+import org.apache.synapse.transport.testkit.message.IncomingMessage;
+
+public class VFSRequestResponseClient extends VFSClient implements
RequestResponseTestClient<byte[],byte[]> {
+ private File replyFile;
+
+ @SuppressWarnings("unused")
+ private void setUp(VFSRequestResponseFileChannel channel) {
+ replyFile = channel.getReplyFile();
+ }
+
+ public IncomingMessage<byte[]> sendMessage(ClientOptions options,
ContentType contentType, byte[] message) throws Exception {
+ send(message);
+ byte[] reply = VFSTestUtils.waitForFile(replyFile, 5000);
+ return reply == null ? null : new IncomingMessage<byte[]>(contentType,
reply);
+ }
+}
Added:
synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSRequestResponseFileChannel.java
URL:
http://svn.apache.org/viewvc/synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSRequestResponseFileChannel.java?rev=692647&view=auto
==============================================================================
---
synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSRequestResponseFileChannel.java
(added)
+++
synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSRequestResponseFileChannel.java
Sat Sep 6 05:51:27 2008
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.synapse.transport.vfs;
+
+import java.io.File;
+
+import org.apache.axis2.description.AxisService;
+import org.apache.synapse.transport.testkit.listener.RequestResponseChannel;
+
+public class VFSRequestResponseFileChannel extends VFSFileChannel implements
RequestResponseChannel {
+ private final String replyPath;
+ private File replyFile;
+
+ public VFSRequestResponseFileChannel(String path, String replyPath) {
+ super(path);
+ this.replyPath = replyPath;
+ }
+
+ public File getReplyFile() {
+ return replyFile;
+ }
+
+ @Override
+ public void setupService(AxisService service) throws Exception {
+ super.setupService(service);
+ service.addParameter("transport.vfs.ReplyFileURI", "vfs:" +
replyFile.toURL());
+ }
+
+ @SuppressWarnings("unused")
+ private void setUp(VFSTestEnvironment env) throws Exception {
+ replyFile = preparePath(env, replyPath);
+ }
+}
Added:
synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSTestUtils.java
URL:
http://svn.apache.org/viewvc/synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSTestUtils.java?rev=692647&view=auto
==============================================================================
---
synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSTestUtils.java
(added)
+++
synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSTestUtils.java
Sat Sep 6 05:51:27 2008
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.synapse.transport.vfs;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.commons.io.IOUtils;
+
+import de.schlichtherle.io.FileInputStream;
+
+public class VFSTestUtils {
+ private VFSTestUtils() {}
+
+ public static byte[] waitForFile(File file, int timeout) throws
IOException, InterruptedException {
+ long time = System.currentTimeMillis();
+ while (System.currentTimeMillis() < time + timeout) {
+ if (file.exists()) {
+ InputStream in = new FileInputStream(file);
+ try {
+ return IOUtils.toByteArray(in);
+ } finally {
+ in.close();
+ }
+ }
+ Thread.sleep(100);
+ }
+ return null;
+ }
+}
Modified:
synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSTransportTest.java
URL:
http://svn.apache.org/viewvc/synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSTransportTest.java?rev=692647&r1=692646&r2=692647&view=diff
==============================================================================
---
synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSTransportTest.java
(original)
+++
synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSTransportTest.java
Sat Sep 6 05:51:27 2008
@@ -30,6 +30,7 @@
import org.apache.synapse.transport.testkit.TransportTestSuiteBuilder;
import org.apache.synapse.transport.testkit.client.axis2.AxisAsyncTestClient;
import org.apache.synapse.transport.testkit.server.axis2.AxisAsyncEndpoint;
+import org.apache.synapse.transport.testkit.server.axis2.AxisEchoEndpoint;
import
org.apache.synapse.transport.testkit.server.axis2.ContentTypeServiceConfigurator;
/**
@@ -49,16 +50,24 @@
TransportTestSuiteBuilder builder = new
TransportTestSuiteBuilder(suite);
+ ContentTypeServiceConfigurator cfgtr = new
ContentTypeServiceConfigurator("transport.vfs.ContentType");
+
builder.addEnvironment(new VFSTestEnvironment(new
File("target/vfs3")), tdf);
- builder.addAsyncChannel(new VFSFileChannel("req/in"));
+ builder.addAsyncChannel(new VFSAsyncFileChannel("req/in"));
builder.addAxisAsyncTestClient(new AxisAsyncTestClient());
- builder.addByteArrayAsyncTestClient(new VFSClient());
+ builder.addByteArrayAsyncTestClient(new VFSAsyncClient());
- builder.addAxisAsyncEndpoint(new AxisAsyncEndpoint(), new
ContentTypeServiceConfigurator("transport.vfs.ContentType"));
+ builder.addAxisAsyncEndpoint(new AxisAsyncEndpoint(), cfgtr);
builder.addByteArrayAsyncEndpoint(new VFSMockAsyncEndpoint());
+ builder.addRequestResponseChannel(new
VFSRequestResponseFileChannel("req/in", "req/out"));
+
+ builder.addByteArrayRequestResponseTestClient(new
VFSRequestResponseClient());
+
+ builder.addEchoEndpoint(new AxisEchoEndpoint(), cfgtr);
+
builder.build();
// suite.addTest(new MinConcurrencyTest(server, new AsyncChannel[] {
new VFSFileChannel("req/in1"), new VFSFileChannel("req/in2") }, 1, true, env,
tdf));