Author: gnodet
Date: Wed Oct  4 02:56:52 2006
New Revision: 452814

URL: http://svn.apache.org/viewvc?view=rev&rev=452814
Log:
Fix unit test and pom

Added:
    
incubator/servicemix/trunk/servicemix-file/src/test/java/org/apache/servicemix/file/DynamicEndpointTest.java
Removed:
    
incubator/servicemix/trunk/servicemix-file/src/test/java/org/apache/servicemix/file/DynamicEndpointtTest.java
Modified:
    incubator/servicemix/trunk/servicemix-file/pom.xml

Modified: incubator/servicemix/trunk/servicemix-file/pom.xml
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-file/pom.xml?view=diff&rev=452814&r1=452813&r2=452814
==============================================================================
--- incubator/servicemix/trunk/servicemix-file/pom.xml (original)
+++ incubator/servicemix/trunk/servicemix-file/pom.xml Wed Oct  4 02:56:52 2006
@@ -35,6 +35,26 @@
   <name>ServiceMix File</name>
   <description>A File component</description>
 
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.servicemix</groupId>
+      <artifactId>servicemix-shared</artifactId>
+      <version>${servicemix-version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicemix</groupId>
+      <artifactId>servicemix-core</artifactId>
+      <version>${servicemix-version}</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
   <build>
     <plugins>
       <plugin>
@@ -64,45 +84,5 @@
       </plugin>
     </plugins>
   </build>
-  <repositories>
-    <repository>
-      <releases>
-        <enabled>false</enabled>
-      </releases>
-      <snapshots />
-      <id>apache.snapshots</id>
-      <name>Maven Central Plugins Development Repository</name>
-      <url>http://cvs.apache.org/maven-snapshot-repository</url>
-    </repository>
-  </repositories>
-  <pluginRepositories>
-    <pluginRepository>
-      <releases>
-        <enabled>false</enabled>
-      </releases>
-      <snapshots />
-      <id>apache.snapshots</id>
-      <name>Maven Central Plugins Development Repository</name>
-      <url>http://cvs.apache.org/maven-snapshot-repository</url>
-    </pluginRepository>
-  </pluginRepositories>
-  <dependencies>
-    <dependency>
-      <groupId>org.apache.servicemix</groupId>
-      <artifactId>servicemix-shared</artifactId>
-      <version>${servicemix-version}</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.servicemix</groupId>
-      <artifactId>servicemix-core</artifactId>
-      <version>${servicemix-version}</version>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <version>3.8.1</version>
-      <scope>test</scope>
-    </dependency>
-  </dependencies>
-</project>
\ No newline at end of file
+
+</project>

Added: 
incubator/servicemix/trunk/servicemix-file/src/test/java/org/apache/servicemix/file/DynamicEndpointTest.java
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/trunk/servicemix-file/src/test/java/org/apache/servicemix/file/DynamicEndpointTest.java?view=auto&rev=452814
==============================================================================
--- 
incubator/servicemix/trunk/servicemix-file/src/test/java/org/apache/servicemix/file/DynamicEndpointTest.java
 (added)
+++ 
incubator/servicemix/trunk/servicemix-file/src/test/java/org/apache/servicemix/file/DynamicEndpointTest.java
 Wed Oct  4 02:56:52 2006
@@ -0,0 +1,85 @@
+/**
+ *
+ * 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.servicemix.file;
+
+import org.apache.servicemix.client.DefaultServiceMixClient;
+import org.apache.servicemix.jbi.jaxp.SourceTransformer;
+import org.apache.servicemix.jbi.jaxp.StringSource;
+import org.apache.servicemix.jbi.resolver.URIResolver;
+import org.apache.servicemix.tck.SpringTestSupport;
+import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.w3c.dom.DocumentFragment;
+
+import javax.jbi.messaging.ExchangeStatus;
+import javax.jbi.messaging.InOnly;
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.servicedesc.ServiceEndpoint;
+
+import java.io.File;
+import java.net.URL;
+
+public class DynamicEndpointTest extends SpringTestSupport {
+    protected String dynamicURI = 
"file:target/dynamicEndpoint?file.tempFilePrefix=dynamicEp-";
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        new File("target/dynamicEndpoint").mkdirs();
+    }
+
+    public void testSendingToDynamicEndpoint() throws Exception {
+        // lets check the path is parsable first
+        URL url = new URL(dynamicURI);
+        String path = url.getPath();
+        assertEquals("target/dynamicEndpoint", path);
+
+
+        // now lets make a request on this endpoint
+        DefaultServiceMixClient client = new DefaultServiceMixClient(jbi);
+
+        DocumentFragment epr = URIResolver.createWSAEPR(dynamicURI);
+        ServiceEndpoint se = client.getContext().resolveEndpointReference(epr);
+        assertNotNull("We should find a service endpoint!", se);
+
+        InOnly exchange = client.createInOnlyExchange();
+        exchange.setEndpoint(se);
+        exchange.getInMessage().setContent(new 
StringSource("<hello>world</hello>"));
+        client.sendSync(exchange);
+
+        assertExchangeWorked(exchange);
+    }
+
+    protected void assertExchangeWorked(MessageExchange me) throws Exception {
+        if (me.getStatus() == ExchangeStatus.ERROR) {
+            if (me.getError() != null) {
+                throw me.getError();
+            }
+            else {
+                fail("Received ERROR status");
+            }
+        }
+        else if (me.getFault() != null) {
+            fail("Received fault: " + new 
SourceTransformer().toString(me.getFault().getContent()));
+        }
+    }
+
+    protected AbstractXmlApplicationContext createBeanFactory() {
+        return new ClassPathXmlApplicationContext("spring-no-endpoints.xml");
+    }
+
+}


Reply via email to