You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by sa...@apache.org on 2006/07/24 06:05:55 UTC

svn commit: r424896 - in /webservices/commons/trunk/modules/neethi: src/org/apache/neethi/ test3/org/apache/neethi/

Author: sanka
Date: Sun Jul 23 21:05:54 2006
New Revision: 424896

URL: http://svn.apache.org/viewvc?rev=424896&view=rev
Log:
Improved code documentation


Added:
    webservices/commons/trunk/modules/neethi/test3/org/apache/neethi/MergeTest.java
Modified:
    webservices/commons/trunk/modules/neethi/src/org/apache/neethi/AbstractPolicyOperator.java
    webservices/commons/trunk/modules/neethi/src/org/apache/neethi/All.java
    webservices/commons/trunk/modules/neethi/src/org/apache/neethi/AssertionBuilderFactory.java
    webservices/commons/trunk/modules/neethi/src/org/apache/neethi/Policy.java
    webservices/commons/trunk/modules/neethi/src/org/apache/neethi/PolicyEngine.java
    webservices/commons/trunk/modules/neethi/src/org/apache/neethi/PolicyOperator.java

Modified: webservices/commons/trunk/modules/neethi/src/org/apache/neethi/AbstractPolicyOperator.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/org/apache/neethi/AbstractPolicyOperator.java?rev=424896&r1=424895&r2=424896&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/org/apache/neethi/AbstractPolicyOperator.java (original)
+++ webservices/commons/trunk/modules/neethi/src/org/apache/neethi/AbstractPolicyOperator.java Sun Jul 23 21:05:54 2006
@@ -21,6 +21,10 @@
 
 import javax.xml.namespace.QName;
 
+/**
+ * 
+ *
+ */
 public abstract class AbstractPolicyOperator implements PolicyOperator {
     protected ArrayList policyComponents = new ArrayList();
 
@@ -117,12 +121,11 @@
 
             for (; S.hasNext();) {
                 Sq = ((Assertion) S.next()).getName();
-
+                
                 if (Lq.equals(Sq)) {
                     found = true;
                     break;
                 }
-
             }
 
             if (!found) {

Modified: webservices/commons/trunk/modules/neethi/src/org/apache/neethi/All.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/org/apache/neethi/All.java?rev=424896&r1=424895&r2=424896&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/org/apache/neethi/All.java (original)
+++ webservices/commons/trunk/modules/neethi/src/org/apache/neethi/All.java Sun Jul 23 21:05:54 2006
@@ -21,6 +21,10 @@
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamWriter;
 
+/**
+ * 
+ *
+ */
 public class All extends AbstractPolicyOperator {
 
     public PolicyComponent normalize(boolean deep) {

Modified: webservices/commons/trunk/modules/neethi/src/org/apache/neethi/AssertionBuilderFactory.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/org/apache/neethi/AssertionBuilderFactory.java?rev=424896&r1=424895&r2=424896&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/org/apache/neethi/AssertionBuilderFactory.java (original)
+++ webservices/commons/trunk/modules/neethi/src/org/apache/neethi/AssertionBuilderFactory.java Sun Jul 23 21:05:54 2006
@@ -40,26 +40,12 @@
     
     public static final String ALL = "All";
     
-//    private final QName POLICY_ASSERTION_BUILDER = new QName(
-//            "http://schemas.xmlsoap.org/ws/2004/09/policy", "Policy");
-//
-//    private final QName EXACTLY_ONE_ASSERTION_BUILDER = new QName(
-//            "http://schemas.xmlsoap.org/ws/2004/09/policy", "ExactlyOne");
-//
-//    private final QName ALL_ASSERTION_BUILDER = new QName(
-//            "http://schemas.xmlsoap.org/ws/2004/09/policy", "All");
-
     private final QName XML_ASSERTION_BUILDER = new QName(
             "http://test.org/test", "test");
 
     private HashMap registeredBuilders = new HashMap();
 
     public AssertionBuilderFactory() {
-//        registerBuilder(POLICY_ASSERTION_BUILDER, new PolicyAssertionBuilder());
-//        registerBuilder(EXACTLY_ONE_ASSERTION_BUILDER,
-//                new ExactlyOneAssertionBuilder());
-//        registerBuilder(ALL_ASSERTION_BUILDER, new AllAssertionBuilder());
-//        registerBuilder(XML_ASSERTION_BUILDER, new XmlAssertionBuilder());
     }
 
     public void registerBuilder(QName key, AssertionBuilder builder) {

Modified: webservices/commons/trunk/modules/neethi/src/org/apache/neethi/Policy.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/org/apache/neethi/Policy.java?rev=424896&r1=424895&r2=424896&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/org/apache/neethi/Policy.java (original)
+++ webservices/commons/trunk/modules/neethi/src/org/apache/neethi/Policy.java Sun Jul 23 21:05:54 2006
@@ -130,9 +130,11 @@
         result.addPolicyComponent(alternative);
         
         ArrayList alternatives = new ArrayList();
+        
         policy = (Policy) policy.normalize(false);
+        alternatives.add(policy.getFirstPolicyComponent());
         
-        alternatives.add(this.getFirstPolicyComponent());
+        policy = (Policy) normalize(false);
         alternatives.add(policy.getFirstPolicyComponent());
         
         alternative.addPolicyComponents(crossProduct(alternatives, 0, false));

Modified: webservices/commons/trunk/modules/neethi/src/org/apache/neethi/PolicyEngine.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/org/apache/neethi/PolicyEngine.java?rev=424896&r1=424895&r2=424896&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/org/apache/neethi/PolicyEngine.java (original)
+++ webservices/commons/trunk/modules/neethi/src/org/apache/neethi/PolicyEngine.java Sun Jul 23 21:05:54 2006
@@ -28,11 +28,10 @@
 
 /**
  * PolicyEngine provides set of methods to create a Policy object from an
- * InputStream, OMElement, .. etc. It maintains a registry of AssertionBuilder
- * instances which can create a Domain Assertion out of an OMElement.
- * AssertionBuilder instances are used when a Policy object is constructed by
- * the PolicyEngine.
- * 
+ * InputStream, OMElement, .. etc. It maintains an instance of
+ * AssertionBuilderFactory that can return AssertionBuilders that can create a
+ * Domain Assertion out of an OMElement. These AssertionBuilders are used when
+ * constructing a Policy object.
  */
 public class PolicyEngine {
 
@@ -47,9 +46,10 @@
     private static AssertionBuilderFactory factory = new AssertionBuilderFactory();
 
     /**
-     * Registers an AssertionBuilder instances and associates it with a QName. PolicyManager
-     * or other AssertionBuilders instances can use this AssertionBuilder instance to process
-     * and build an Assertion from a OMElement with the specified QName.
+     * Registers an AssertionBuilder instances and associates it with a QName.
+     * PolicyManager or other AssertionBuilders instances can use this
+     * AssertionBuilder instance to process and build an Assertion from a
+     * OMElement with the specified QName.
      * 
      * @param qname
      * @param builder

Modified: webservices/commons/trunk/modules/neethi/src/org/apache/neethi/PolicyOperator.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/org/apache/neethi/PolicyOperator.java?rev=424896&r1=424895&r2=424896&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/org/apache/neethi/PolicyOperator.java (original)
+++ webservices/commons/trunk/modules/neethi/src/org/apache/neethi/PolicyOperator.java Sun Jul 23 21:05:54 2006
@@ -17,16 +17,46 @@
 
 import java.util.List;
 
-
+/**
+ * PolicyOperator is an interface that all Policy operators must implement.
+ * 
+ */
 public interface PolicyOperator extends PolicyComponent {
-    
+
     public static final String NAMESPACE = "http://schemas.xmlsoap.org/ws/2004/09/policy";
+
     public static final String PREFIX = "wsp";
+
     public static final String POLICY = "Policy";
+
     public static final String EXACTLYONE = "ExactlyOne";
+
     public static final String ALL = "All";
-    
+
+    /**
+     * Add a PolicyComponent to the PolicyOperator.
+     * 
+     * @param component
+     */
     public void addPolicyComponent(PolicyComponent component);
+
+    /**
+     * Returns a List of PolicyComponents which this PolicyOperator contains.
+     * 
+     * @return the List of PolicyComponents that this PolicyOperator contains.
+     */
     public List getPolicyComponents();
+
+    /**
+     * Returns a PolicyComponent which is the normalized format of this
+     * PolicyOperator.
+     * 
+     * @param deep
+     *            the deep flag indicates whether the assertion it contains
+     *            should be normalized or not. Merge and Intersect will use a
+     *            partial normalization since partial normalization is
+     *            sufficient for most high level processing of Policies will
+     * @return
+     */
     public PolicyComponent normalize(boolean deep);
 }

Added: webservices/commons/trunk/modules/neethi/test3/org/apache/neethi/MergeTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/test3/org/apache/neethi/MergeTest.java?rev=424896&view=auto
==============================================================================
--- webservices/commons/trunk/modules/neethi/test3/org/apache/neethi/MergeTest.java (added)
+++ webservices/commons/trunk/modules/neethi/test3/org/apache/neethi/MergeTest.java Sun Jul 23 21:05:54 2006
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed 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.neethi;
+
+import java.io.File;
+
+import org.apache.neethi.util.PolicyComparator;
+
+public class MergeTest extends PolicyTestCase {
+    
+    public MergeTest() {
+        super("MergeTest");
+    }
+
+    public void test() throws Exception {
+        String r1, r2, r3;
+        Policy p1, p2, p3, p4;
+
+        File samples2 = new File(testResourceDir, "merged");
+        File[] files = samples2.listFiles();
+
+        String f, f1, f2;
+
+        for (int i = 0; i < files.length; i++) {
+
+            if (files[i].isHidden()) {
+                continue;
+            }
+
+            f = files[i].getName();
+
+            f1 = f.substring(f.indexOf('y') + 1, f.indexOf('-'));
+            f2 = f.substring(f.indexOf('-') + 1, f.indexOf('.'));
+
+            r1 = "samples2" + File.separator + "Policy" + f1 + ".xml";
+            r2 = "samples2" + File.separator + "Policy" + f2 + ".xml";
+            r3 = "merged" + File.separator + f;
+
+            p1 = PolicyEngine.getPolicy(getResource(r1));
+            p2 = PolicyEngine.getPolicy(getResource(r2));
+            p3 = PolicyEngine.getPolicy(getResource(r3));
+
+            // result
+            p4 = (Policy) p1.merge(p2);
+
+            if (!PolicyComparator.compare(p4, p3)) {
+//                System.out.println("samples2" + File.separator + " Policy" + f1
+//                        + ".merge(Policy" + f2 + ") FAILED");
+                fail("samples2" + File.separator + " Policy" + f1
+                        + ".merge(Policy" + f2 + ") FAILED");
+            }
+        }
+    }
+
+}



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