1 22 package org.jboss.test.xslt.test; 23 24 import java.util.Hashtable ; 25 import java.util.Iterator ; 26 import java.util.Map ; 27 28 import javax.management.ObjectName ; 29 30 import junit.framework.Test; 31 32 import org.jboss.test.JBossTestCase; 33 34 40 public class ScopedXalanUnitTestCase extends JBossTestCase 41 { 42 public static Test suite() throws Exception 43 { 44 return getDeploySetup(ScopedXalanUnitTestCase.class, "xalan-check-default.sar,xalan-check-scoped.sar"); 45 } 46 47 public ScopedXalanUnitTestCase(String name) 48 { 49 super(name); 50 } 51 52 public void testScopedXalanDeployment() throws Exception 53 { 54 getLog().info("+++ testScopedXalanDeployment"); 55 56 ObjectName defaultTarget = new ObjectName ("jboss.test:service=XalanCheckDefault"); 58 Hashtable defaultHashtable = (Hashtable )getServer().invoke(defaultTarget, "fetchXalanEnvironmentHash", new Object [] {}, new String [] {}); 59 logHashtable("XalanCheckDefault", defaultHashtable); 60 61 String defaultVersion = (String )getServer().getAttribute(defaultTarget, "XalanVersion"); 63 64 boolean defaultXalan25Bug15140; 66 try 67 { 68 getServer().invoke(defaultTarget, "testXalan25Bug15140", new Object [] {}, new String [] {}); 69 defaultXalan25Bug15140 = false; 70 } 71 catch (Exception e) 72 { 73 defaultXalan25Bug15140 = true; 74 } 75 76 ObjectName scopedTarget = new ObjectName ("jboss.test:service=XalanCheckScoped"); 78 Hashtable scopedHashtable = (Hashtable )getServer().invoke(scopedTarget, "fetchXalanEnvironmentHash", new Object [] {}, new String [] {}); 79 logHashtable("XalanCheckScoped", scopedHashtable); 80 81 String scopedVersion = (String )getServer().getAttribute(scopedTarget, "XalanVersion"); 83 84 boolean scopedXalan25Bug15140; 86 try 87 { 88 getServer().invoke(scopedTarget, "testXalan25Bug15140", new Object [] {}, new String [] {}); 89 scopedXalan25Bug15140 = false; 90 } 91 catch (Exception e) 92 { 93 scopedXalan25Bug15140 = true; 94 } 95 96 getLog().info("*******************************************************"); 97 getLog().info("Default deployment uses xalan version: " + defaultVersion); 98 getLog().info("Default deployment sees xalan v2.5.2 bug 15140: " + defaultXalan25Bug15140); 99 getLog().info("Scoped deployment uses xalan version : " + scopedVersion); 100 getLog().info("Scoped deployment sees xalan v2.5.2 bug 15140: " + scopedXalan25Bug15140); 101 getLog().info("*******************************************************"); 102 103 assertTrue("Expected scoped deployment using xalan version 'Xalan Java 2.5.2'", scopedVersion.equals("Xalan Java 2.5.2") == true); 105 assertTrue("Expected scoped deployment to have the xalan v2.5.2 bug 15140", scopedXalan25Bug15140 == true); 107 assertTrue("Expected default deployment NOT to see jdk1.4 xalan v2.4.1", defaultVersion.equals("Xalan Java 2.4.1") == false); 109 assertTrue("Expected default deployment NOT to have the xalan v2.5.2 bug 15140", defaultXalan25Bug15140 == false); 111 } 112 113 private void logHashtable(String name, Hashtable htab) 114 { 115 getLog().info("***" + name + "***"); 116 Iterator i = htab.entrySet().iterator(); 117 while (i.hasNext()) 118 { 119 Map.Entry entry = (Map.Entry )i.next(); 120 getLog().info(entry.getKey().toString() + '=' + entry.getValue()); 121 } 122 } 123 124 } 125 | Popular Tags |