ws-commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sa...@apache.org
Subject svn commit: r473924 - in /webservices/commons/trunk/modules/neethi/src: main/java/org/apache/neethi/ test/java/org/ test/java/org/apache/neethi/ test/test3/org/apache/neethi/
Date Sun, 12 Nov 2006 11:14:21 GMT
Author: sanka
Date: Sun Nov 12 03:14:20 2006
New Revision: 473924

URL: http://svn.apache.org/viewvc?view=rev&rev=473924
Log:
Added the new testcases for the new Neethi code.


Added:
    webservices/commons/trunk/modules/neethi/src/test/java/org/
      - copied from r473916, webservices/commons/trunk/modules/neethi/src/test/test3/org/
Removed:
    webservices/commons/trunk/modules/neethi/src/test/java/org/apache/neethi/MergeTest.java
    webservices/commons/trunk/modules/neethi/src/test/test3/org/apache/neethi/MergeTest.java
Modified:
    webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/Constants.java
    webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyEngine.java
    webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyReference.java
    webservices/commons/trunk/modules/neethi/src/test/java/org/apache/neethi/PolicyTestCase.java
    webservices/commons/trunk/modules/neethi/src/test/test3/org/apache/neethi/PolicyTestCase.java

Modified: webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/Constants.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/Constants.java?view=diff&rev=473924&r1=473923&r2=473924
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/Constants.java
(original)
+++ webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/Constants.java
Sun Nov 12 03:14:20 2006
@@ -31,6 +31,8 @@
     public static final String ATTR_WSP = "wsp";
 
     public static final String ATTR_WSU = "wsu";
+    
+    public static final String ATTR_URI = "URI";
 
     public static final String URI_POLICY_NS = "http://schemas.xmlsoap.org/ws/2004/09/policy";
 
@@ -42,7 +44,7 @@
 
     public static final String ELEM_ALL = "All";
 
-    public static final String ELEM_POLICYREF = "PolicyReference";
+    public static final String ELEM_POLICY_REF = "PolicyReference";
 
     public static final short TYPE_POLICY = 0x1;
 

Modified: webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyEngine.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyEngine.java?view=diff&rev=473924&r1=473923&r2=473924
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyEngine.java
(original)
+++ webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyEngine.java
Sun Nov 12 03:14:20 2006
@@ -113,7 +113,7 @@
     public static PolicyReference getPolicyReference(OMElement element) {
 
         if (!(Constants.URI_POLICY_NS.equals(element.getNamespace()
-                .getNamespaceURI()) && Constants.ELEM_POLICYREF.equals(element
+                .getNamespaceURI()) && Constants.ELEM_POLICY_REF.equals(element
                 .getLocalName()))) {
 
             throw new RuntimeException(
@@ -190,7 +190,7 @@
                         .getLocalName())) {
                     operator.addPolicyComponent(getAllOperator(childElement));
 
-                } else if (Constants.ELEM_POLICYREF.equals(childElement
+                } else if (Constants.ELEM_POLICY_REF.equals(childElement
                         .getLocalName())) {
                     operator
                             .addPolicyComponent(getPolicyReference(childElement));

Modified: webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyReference.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyReference.java?view=diff&rev=473924&r1=473923&r2=473924
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyReference.java
(original)
+++ webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyReference.java
Sun Nov 12 03:14:20 2006
@@ -15,8 +15,6 @@
  */
 package org.apache.neethi;
 
-import org.apache.ws.policy.PolicyConstants;
-
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamWriter;
 
@@ -64,24 +62,25 @@
 
     public void serialize(XMLStreamWriter writer) throws XMLStreamException {
 
-        String writerPrefix = writer
-                .getPrefix(PolicyConstants.POLICY_NAMESPACE_URI);
-        if (writerPrefix != null) {
-            writer.writeStartElement(PolicyConstants.POLICY_NAMESPACE_URI,
-                    PolicyConstants.POLICY_REFERENCE);
-        } else {
-
-            writer.writeStartElement(PolicyConstants.POLICY_PREFIX,
-                    PolicyConstants.POLICY_REFERENCE,
-                    PolicyConstants.POLICY_NAMESPACE_URI);
-            writer.writeNamespace(PolicyConstants.POLICY_PREFIX,
-                    PolicyConstants.POLICY_NAMESPACE_URI);
-            writer.setPrefix(PolicyConstants.POLICY_PREFIX,
-                    PolicyConstants.POLICY_NAMESPACE_URI);
-
+        String wspPrefix = writer.getPrefix(Constants.URI_POLICY_NS);
+        
+        if (wspPrefix == null) {
+            wspPrefix = Constants.ATTR_WSP;
+            writer.setPrefix(wspPrefix, Constants.URI_POLICY_NS);
         }
-        writer.writeAttribute("URI", uri);
-
+        
+        String wsuPrefix = writer.getPrefix(Constants.URI_WSU_NS);
+        if (wsuPrefix == null) {
+            wsuPrefix = Constants.ATTR_WSU;
+            writer.setPrefix(wsuPrefix, Constants.URI_WSU_NS);
+        }
+        
+        writer.writeStartElement(wspPrefix, Constants.ELEM_POLICY_REF, Constants.URI_POLICY_NS);
+        
+        writer.writeAttribute(Constants.ATTR_URI, getURI());
+        
         writer.writeEndElement();
+        
+        
     }
 }

Modified: webservices/commons/trunk/modules/neethi/src/test/java/org/apache/neethi/PolicyTestCase.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/test/java/org/apache/neethi/PolicyTestCase.java?view=diff&rev=473924&r1=473916&r2=473924
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/test/java/org/apache/neethi/PolicyTestCase.java
(original)
+++ webservices/commons/trunk/modules/neethi/src/test/java/org/apache/neethi/PolicyTestCase.java
Sun Nov 12 03:14:20 2006
@@ -15,20 +15,44 @@
  */
 package org.apache.neethi;
 
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
 import java.io.InputStream;
 
 import javax.xml.stream.XMLInputFactory;
 
+import junit.framework.TestCase;
+
 import org.apache.axiom.om.OMAbstractFactory;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.impl.llom.factory.OMXMLBuilderFactory;
 
 
-public class PolicyTestCase extends org.apache.ws.policy.PolicyTestCase {
+public class PolicyTestCase extends TestCase{
+    
+    protected String baseDir = System.getProperty("basedir");
+    protected String testResourceDir = "src" + File.separator + "test" + File.separator +
"test-resources";
+    
     public PolicyTestCase(String name) {
         super(name);
+        if (baseDir == null) {
+            baseDir = (String) new File(".").getAbsolutePath();
+        }
     }
 
+    public InputStream getResource(String name) {
+        String filePath = new File(testResourceDir, name).getAbsolutePath(); 
+
+        try {
+            FileInputStream fis = new FileInputStream(filePath);
+            return fis;
+        } catch (FileNotFoundException e) {
+            fail("Cannot get resource: " + e.getMessage());
+            throw new RuntimeException();
+        }
+    }
+    
     public OMElement getResourceAsElement(String name) {
         try {
             InputStream in = getResource(name);

Modified: webservices/commons/trunk/modules/neethi/src/test/test3/org/apache/neethi/PolicyTestCase.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/test/test3/org/apache/neethi/PolicyTestCase.java?view=diff&rev=473924&r1=473923&r2=473924
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/test/test3/org/apache/neethi/PolicyTestCase.java
(original)
+++ webservices/commons/trunk/modules/neethi/src/test/test3/org/apache/neethi/PolicyTestCase.java
Sun Nov 12 03:14:20 2006
@@ -15,20 +15,44 @@
  */
 package org.apache.neethi;
 
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
 import java.io.InputStream;
 
 import javax.xml.stream.XMLInputFactory;
 
+import junit.framework.TestCase;
+
 import org.apache.axiom.om.OMAbstractFactory;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.impl.llom.factory.OMXMLBuilderFactory;
 
 
-public class PolicyTestCase extends org.apache.ws.policy.PolicyTestCase {
+public class PolicyTestCase extends TestCase{
+    
+    protected String baseDir = System.getProperty("basedir");
+    protected String testResourceDir = "src" + File.separator + "test" + File.separator +
"test-resources";
+    
     public PolicyTestCase(String name) {
         super(name);
+        if (baseDir == null) {
+            baseDir = (String) new File(".").getAbsolutePath();
+        }
     }
 
+    public InputStream getResource(String name) {
+        String filePath = new File(testResourceDir, name).getAbsolutePath(); 
+
+        try {
+            FileInputStream fis = new FileInputStream(filePath);
+            return fis;
+        } catch (FileNotFoundException e) {
+            fail("Cannot get resource: " + e.getMessage());
+            throw new RuntimeException();
+        }
+    }
+    
     public OMElement getResourceAsElement(String name) {
         try {
             InputStream in = getResource(name);



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: commons-dev-help@ws.apache.org


Mime
View raw message