Author: hiranya
Date: Mon Aug 23 10:57:59 2010
New Revision: 988070

URL: http://svn.apache.org/viewvc?rev=988070&view=rev
Log:
Additional test case


Modified:
    
synapse/trunk/scratch/hiranya/urlrewrite/src/test/java/org/apache/synapse/mediators/URLRewriteTest.java
    synapse/trunk/scratch/hiranya/urlrewrite/src/test/resources/mediator.xml

Modified: 
synapse/trunk/scratch/hiranya/urlrewrite/src/test/java/org/apache/synapse/mediators/URLRewriteTest.java
URL: 
http://svn.apache.org/viewvc/synapse/trunk/scratch/hiranya/urlrewrite/src/test/java/org/apache/synapse/mediators/URLRewriteTest.java?rev=988070&r1=988069&r2=988070&view=diff
==============================================================================
--- 
synapse/trunk/scratch/hiranya/urlrewrite/src/test/java/org/apache/synapse/mediators/URLRewriteTest.java
 (original)
+++ 
synapse/trunk/scratch/hiranya/urlrewrite/src/test/java/org/apache/synapse/mediators/URLRewriteTest.java
 Mon Aug 23 10:57:59 2010
@@ -98,8 +98,31 @@ public class URLRewriteTest extends Test
         synMc.setTo(new 
EndpointReference("http://wso2.org:9763/services/MyService";));
 
         mediator.mediate(synMc);
-        System.out.println(synMc.getTo().getAddress());
-        System.out.println(synMc.getProperty("outputURL"));
+        assertEquals("https://wso2.com:9443/esb/services/StockQuoteService";, 
synMc.getProperty("outputURL"));
+    }
+
+    public void testMediateWithFactory2() throws Exception {
+        String xml =
+                "<rewrite 
xmlns=\"http://synapse.apache.org/ns/2010/04/configuration\"; 
outProperty=\"outputURL\">\n" +
+                        "    <rule>\n" +
+                        "        <action fragment=\"full\" 
value=\"http://www.test.org:8080\"/>\n" +
+                        "        <action fragment=\"path\" 
value=\"/services/TestService\"/>\n" +
+                        "        <action fragment=\"query\" 
value=\"foo=bar\"/>\n" +
+                        "        <action fragment=\"ref\" 
xpath=\"get-property('ref')\"/>\n" +
+                        "    </rule>    \n" +
+                        "</rewrite>";
+        URLRewriteMediatorFactory fac = new URLRewriteMediatorFactory();
+        Mediator mediator = fac.createMediator(AXIOMUtil.stringToOM(xml));
+
+        org.apache.axis2.context.MessageContext mc =
+                new org.apache.axis2.context.MessageContext();
+        SynapseConfiguration config = new SynapseConfiguration();
+        SynapseEnvironment env = new Axis2SynapseEnvironment(config);
+        MessageContext synMc = new Axis2MessageContext(mc, config, env);
+        synMc.setProperty("ref", "id");
+
+        mediator.mediate(synMc);
+        
assertEquals("http://www.test.org:8080/services/TestService?foo=bar#id";, 
synMc.getProperty("outputURL"));
     }
 
     public void testMediate() throws Exception {

Modified: 
synapse/trunk/scratch/hiranya/urlrewrite/src/test/resources/mediator.xml
URL: 
http://svn.apache.org/viewvc/synapse/trunk/scratch/hiranya/urlrewrite/src/test/resources/mediator.xml?rev=988070&r1=988069&r2=988070&view=diff
==============================================================================
--- synapse/trunk/scratch/hiranya/urlrewrite/src/test/resources/mediator.xml 
(original)
+++ synapse/trunk/scratch/hiranya/urlrewrite/src/test/resources/mediator.xml 
Mon Aug 23 10:57:59 2010
@@ -1,8 +1,8 @@
-<rewrite xmlns="http://synapse.apache.org/ns/2010/04/configuration";>
+<rewrite xmlns="http://synapse.apache.org/ns/2010/04/configuration"; 
outProperty="outputURL">
     <rule>
-        <condition>
-            <match type="url" fragment="host" regex="foo"/>
-        </condition>
-        <action fragment="host" value="bar"/>            
+        <action fragment="full" value="http://www.test.org:8080"/>
+        <action fragment="path" value="/services/TestServuce"/>
+        <action fragment="query" value="foo=bar"/>
+        <action fragment="ref" xpath="get-property('ref')"/>
     </rule>
-</rewrite>
\ No newline at end of file
+</rewrite>    
\ No newline at end of file


Reply via email to