incubator-imperius-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From daw...@apache.org
Subject svn commit: r820060 [3/3] - in /incubator/imperius/trunk: ./ imperius-javaspl/src/main/java/org/apache/imperius/javaspl/ imperius-splcore/ imperius-splcore/src/main/java/org/apache/imperius/spl/datastore/ imperius-splcore/src/main/java/org/apache/imper...
Date Tue, 29 Sep 2009 18:29:48 GMT
Added: incubator/imperius/trunk/javaspl-samples/src/main/java/org/apache/imperius/javaspl/samples/bugfix/RunBugFixTest.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/javaspl-samples/src/main/java/org/apache/imperius/javaspl/samples/bugfix/RunBugFixTest.java?rev=820060&view=auto
==============================================================================
--- incubator/imperius/trunk/javaspl-samples/src/main/java/org/apache/imperius/javaspl/samples/bugfix/RunBugFixTest.java
(added)
+++ incubator/imperius/trunk/javaspl-samples/src/main/java/org/apache/imperius/javaspl/samples/bugfix/RunBugFixTest.java
Tue Sep 29 18:29:44 2009
@@ -0,0 +1,182 @@
+package org.apache.imperius.javaspl.samples.bugfix;
+
+import java.io.BufferedReader;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.imperius.javaspl.Java_SPLPolicyRuleProvider;
+import org.apache.imperius.javaspl.samples.bugfix.Bar;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+
+/**
+ * @author xwang
+ *
+ */
+public class RunBugFixTest {
+
+    public static String policyFolder = "resources/samples/bugfix/policies/";
+
+	public static void testImperius20(){
+		String policyName = "Imperius20";
+        
+		Map objMap = new Hashtable();
+		StringBuilder sb = new StringBuilder(); 
+        objMap.put("stringBuilder", sb);
+        
+        testPolicy(policyName, objMap);
+	}
+
+	public static void testImperius22(){
+		String policyName = "Imperius22";
+        
+		Map objMap = new Hashtable();
+		Properties pList = new Properties(); 
+		pList.put("bar", "abc");
+		pList.put("foo", "def");
+        objMap.put("props", pList);
+        
+        testPolicy(policyName, objMap);
+	}
+
+	public static void testImperius23(){
+		String policyName = "Imperius23";
+        
+		Map objMap = new Hashtable();
+		Properties pList = new Properties(); 
+		pList.put("bar", "abc");
+		pList.put("foo", "def");
+        objMap.put("props", pList);
+        
+        testPolicy(policyName, objMap);
+	}
+	
+	public static void testImperius24(){
+		String policyName = "Imperius24";
+        
+		Map objMap = new Hashtable();
+		Properties pList = new Properties(); 
+		pList.put("bar", "abc");
+		pList.put("foo", "def");
+        objMap.put("props", pList);
+        
+        SimpleBean1 sb1 = new SimpleBean1();
+        SimpleBean2 sb2 = new SimpleBean2();
+  
+		objMap.put("b1", sb1);
+		objMap.put("b2", sb2);
+ 
+        
+        testPolicy(policyName, objMap);
+	}
+	
+	public static void testImperius25(){
+		String policyName = "Imperius25";
+        
+		Map objMap = new Hashtable();
+		ArrayList pList = new MyList(); 
+        objMap.put("list1", pList);
+        
+        testPolicy(policyName, objMap);
+	}
+	
+	public static void testImperius26(){
+		String policyName = "Imperius26";
+        
+		Map objMap = new Hashtable();
+		Properties props = new Properties();
+		Bar bar = new Bar();
+		props.put("Foo", bar);
+        objMap.put("list1", props);
+        
+        testPolicy(policyName, objMap);
+	}
+	
+	public static void testImperius27(){
+		String policyName = "Imperius27";
+        
+		Map objMap = new Hashtable();
+		Properties pList = new Properties(); 
+		pList.put("bar", "abc");
+        objMap.put("list1", pList);
+        
+        testPolicy(policyName, objMap);
+	}
+
+	public static void testImperius28(){
+		String policyName = "Imperius28";
+
+		Map objMap = new Hashtable();
+	    byte array[] = {0, 1};
+	    ByteArrayFactory baf = new ByteArrayFactory(array);
+	    objMap.put("baf", baf);
+
+        testPolicy(policyName, objMap);
+	}
+
+    public static void testPolicy(String policyName, Map objMap)
+    {
+        try 
+        {
+            Java_SPLPolicyRuleProvider jspl = Java_SPLPolicyRuleProvider.getInstance();
+            String aFile = policyFolder + policyName + ".spl";
+            StringBuffer contents = new StringBuffer();
+            BufferedReader input = null;
+            try
+            {
+                input = new BufferedReader( new FileReader(aFile) );
+                String line = null; 
+                while (( line = input.readLine()) != null)
+                {
+                    contents.append(line);
+                    contents.append(System.getProperty("line.separator"));
+                }
+                input.close();
+            }
+            catch (FileNotFoundException ex) 
+            {
+            	ex.printStackTrace();
+            }
+            catch (IOException ex){
+            	ex.printStackTrace();
+            }
+            try
+            {
+                jspl.deletePolicy(policyName);
+            }
+            catch(Exception e)
+            {
+                
+            }
+            
+            boolean createReturn = jspl.createPolicy(policyName, contents.toString());
+            System.out.println("Policy Created : " + policyName + " " + createReturn);
+
+            System.out.println("");
+            
+            Object result = jspl.executePolicy(policyName, objMap);
+            System.out.println("Result is " + result);
+        }   
+        catch (SPLException e) 
+        {
+            e.printStackTrace();
+        }  
+        
+    }
+    
+    public static void test(String pFolder) {
+        policyFolder = pFolder;
+
+        testImperius20();
+        testImperius22();
+        testImperius23();
+        testImperius24();
+        testImperius25();
+        testImperius26();
+        testImperius28();
+    }
+}

Added: incubator/imperius/trunk/javaspl-samples/src/main/java/org/apache/imperius/javaspl/samples/bugfix/SimpleBean1.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/javaspl-samples/src/main/java/org/apache/imperius/javaspl/samples/bugfix/SimpleBean1.java?rev=820060&view=auto
==============================================================================
--- incubator/imperius/trunk/javaspl-samples/src/main/java/org/apache/imperius/javaspl/samples/bugfix/SimpleBean1.java
(added)
+++ incubator/imperius/trunk/javaspl-samples/src/main/java/org/apache/imperius/javaspl/samples/bugfix/SimpleBean1.java
Tue Sep 29 18:29:44 2009
@@ -0,0 +1,6 @@
+package org.apache.imperius.javaspl.samples.bugfix;
+
+public class SimpleBean1 {
+	public int id;
+	
+}

Added: incubator/imperius/trunk/javaspl-samples/src/main/java/org/apache/imperius/javaspl/samples/bugfix/SimpleBean2.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/javaspl-samples/src/main/java/org/apache/imperius/javaspl/samples/bugfix/SimpleBean2.java?rev=820060&view=auto
==============================================================================
--- incubator/imperius/trunk/javaspl-samples/src/main/java/org/apache/imperius/javaspl/samples/bugfix/SimpleBean2.java
(added)
+++ incubator/imperius/trunk/javaspl-samples/src/main/java/org/apache/imperius/javaspl/samples/bugfix/SimpleBean2.java
Tue Sep 29 18:29:44 2009
@@ -0,0 +1,8 @@
+package org.apache.imperius.javaspl.samples.bugfix;
+
+public class SimpleBean2 {
+
+	public void print(int v) {
+		System.out.print(v);
+	}
+}

Modified: incubator/imperius/trunk/javaspl-samples/src/test/java/org/apache/imperius/javaspl/samples/simplepolicies/TestSimplePolicies.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/javaspl-samples/src/test/java/org/apache/imperius/javaspl/samples/simplepolicies/TestSimplePolicies.java?rev=820060&r1=820059&r2=820060&view=diff
==============================================================================
--- incubator/imperius/trunk/javaspl-samples/src/test/java/org/apache/imperius/javaspl/samples/simplepolicies/TestSimplePolicies.java
(original)
+++ incubator/imperius/trunk/javaspl-samples/src/test/java/org/apache/imperius/javaspl/samples/simplepolicies/TestSimplePolicies.java
Tue Sep 29 18:29:44 2009
@@ -17,6 +17,9 @@
  * under the License.  
  */
 package org.apache.imperius.javaspl.samples.simplepolicies;
+
+import org.apache.imperius.javaspl.samples.bugfix.RunBugFixTest;
+
 import junit.extensions.TestSetup;
 import junit.framework.Test;
 import junit.framework.TestCase;
@@ -51,13 +54,13 @@
 
 	
 	protected static void oneTimeSetUp() throws Exception {
+
 	}
 
 	protected static void oneTimeTearDown() throws Exception {
 
 	}
 	
-	
 	/**
 	 * @param args
 	 */
@@ -67,14 +70,10 @@
 		System.out.println("user dir is " + userDir);
 		RunSamples.test(userDir + "/resources/samples/simple/policies/");
 		
+		RunBugFixTest.test(userDir + "/resources/samples/bugfix/policies/");
 		
 	}
 
-
-
-
-	
-
 }
 
 



Mime
View raw message