[Jboss-cvs] JBossAS SVN: r56296 - in branches/Branch_4_0/testsuite/src/main/org/jboss/test/deployers: . jbas2904 jbas2904/sar jbas2904/sar/mbean1 jbas2904/sar/mbean2 jbas2904/test
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sat Aug 26 08:47:22 EDT 2006
Author: vicky.kak at jboss.com
Date: 2006-08-26 08:47:16 -0400 (Sat, 26 Aug 2006)
New Revision: 56296
Added:
branches/Branch_4_0/testsuite/src/main/org/jboss/test/deployers/jbas2904/
branches/Branch_4_0/testsuite/src/main/org/jboss/test/deployers/jbas2904/sar/
branches/Branch_4_0/testsuite/src/main/org/jboss/test/deployers/jbas2904/sar/mbean1/
branches/Branch_4_0/testsuite/src/main/org/jboss/test/deployers/jbas2904/sar/mbean1/MBean1.java
branches/Branch_4_0/testsuite/src/main/org/jboss/test/deployers/jbas2904/sar/mbean1/MBean1MBean.java
branches/Branch_4_0/testsuite/src/main/org/jboss/test/deployers/jbas2904/sar/mbean2/
branches/Branch_4_0/testsuite/src/main/org/jboss/test/deployers/jbas2904/sar/mbean2/MBean2.java
branches/Branch_4_0/testsuite/src/main/org/jboss/test/deployers/jbas2904/sar/mbean2/MBean2MBean.java
branches/Branch_4_0/testsuite/src/main/org/jboss/test/deployers/jbas2904/test/
branches/Branch_4_0/testsuite/src/main/org/jboss/test/deployers/jbas2904/test/EARDeploymentUnitTestCase.java
Log:
Changes done for JBAS-2904
Added: branches/Branch_4_0/testsuite/src/main/org/jboss/test/deployers/jbas2904/sar/mbean1/MBean1.java
===================================================================
--- branches/Branch_4_0/testsuite/src/main/org/jboss/test/deployers/jbas2904/sar/mbean1/MBean1.java 2006-08-26 12:45:48 UTC (rev 56295)
+++ branches/Branch_4_0/testsuite/src/main/org/jboss/test/deployers/jbas2904/sar/mbean1/MBean1.java 2006-08-26 12:47:16 UTC (rev 56296)
@@ -0,0 +1,30 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.test.deployers.jbas2904.sar.mbean1;
+
+import org.jboss.system.ServiceMBeanSupport;
+
+public class MBean1 extends ServiceMBeanSupport implements MBean1MBean
+{
+ public long lastDeployed;
+ public long getLastDeployed(){
+ return lastDeployed;
+ }
+ public void setLastDeployed(long lastDeployed){
+ this.lastDeployed = lastDeployed;
+ }
+ protected void startService(){
+ try{
+ Thread.sleep(5);
+ }
+ catch(InterruptedException e){
+
+ }
+ this.lastDeployed = System.currentTimeMillis();
+ System.out.println("Atestdeployerorder-jbas2904.sar deployed at :"+lastDeployed);
+ }
+}
Added: branches/Branch_4_0/testsuite/src/main/org/jboss/test/deployers/jbas2904/sar/mbean1/MBean1MBean.java
===================================================================
--- branches/Branch_4_0/testsuite/src/main/org/jboss/test/deployers/jbas2904/sar/mbean1/MBean1MBean.java 2006-08-26 12:45:48 UTC (rev 56295)
+++ branches/Branch_4_0/testsuite/src/main/org/jboss/test/deployers/jbas2904/sar/mbean1/MBean1MBean.java 2006-08-26 12:47:16 UTC (rev 56296)
@@ -0,0 +1,15 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.test.deployers.jbas2904.sar.mbean1;
+
+import org.jboss.system.ServiceMBean;
+
+public interface MBean1MBean extends ServiceMBean
+{
+ public long getLastDeployed();
+ public void setLastDeployed(long lastDeployed);
+}
Added: branches/Branch_4_0/testsuite/src/main/org/jboss/test/deployers/jbas2904/sar/mbean2/MBean2.java
===================================================================
--- branches/Branch_4_0/testsuite/src/main/org/jboss/test/deployers/jbas2904/sar/mbean2/MBean2.java 2006-08-26 12:45:48 UTC (rev 56295)
+++ branches/Branch_4_0/testsuite/src/main/org/jboss/test/deployers/jbas2904/sar/mbean2/MBean2.java 2006-08-26 12:47:16 UTC (rev 56296)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.test.deployers.jbas2904.sar.mbean2;
+
+import org.jboss.system.ServiceMBeanSupport;
+
+public class MBean2 extends ServiceMBeanSupport implements MBean2MBean
+{
+ public long lastDeployed;
+ public long getLastDeployed(){
+ return lastDeployed;
+ }
+ public void setLastDeployed(long lastDeployed){
+ this.lastDeployed = lastDeployed;
+ }
+ protected void startService(){
+
+ try{
+ Thread.sleep(5);
+ }
+ catch(InterruptedException e){
+
+ }
+ this.lastDeployed = System.currentTimeMillis();
+ System.out.println("Btestdeployerorder-jbas2904.sar deployed at :"+lastDeployed);
+ }
+
+}
Added: branches/Branch_4_0/testsuite/src/main/org/jboss/test/deployers/jbas2904/sar/mbean2/MBean2MBean.java
===================================================================
--- branches/Branch_4_0/testsuite/src/main/org/jboss/test/deployers/jbas2904/sar/mbean2/MBean2MBean.java 2006-08-26 12:45:48 UTC (rev 56295)
+++ branches/Branch_4_0/testsuite/src/main/org/jboss/test/deployers/jbas2904/sar/mbean2/MBean2MBean.java 2006-08-26 12:47:16 UTC (rev 56296)
@@ -0,0 +1,15 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.test.deployers.jbas2904.sar.mbean2;
+
+import org.jboss.system.ServiceMBean;
+
+public interface MBean2MBean extends ServiceMBean
+{
+ public long getLastDeployed();
+ public void setLastDeployed(long lastDeployed);
+}
Added: branches/Branch_4_0/testsuite/src/main/org/jboss/test/deployers/jbas2904/test/EARDeploymentUnitTestCase.java
===================================================================
--- branches/Branch_4_0/testsuite/src/main/org/jboss/test/deployers/jbas2904/test/EARDeploymentUnitTestCase.java 2006-08-26 12:45:48 UTC (rev 56295)
+++ branches/Branch_4_0/testsuite/src/main/org/jboss/test/deployers/jbas2904/test/EARDeploymentUnitTestCase.java 2006-08-26 12:47:16 UTC (rev 56296)
@@ -0,0 +1,131 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.test.deployers.jbas2904.test;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.StringTokenizer;
+
+import java.io.InputStream;
+import java.io.File;
+import java.io.FileInputStream;
+
+import java.net.URL;
+
+import junit.framework.Test;
+
+import org.jboss.deployment.DeploymentInfo;
+
+import org.jboss.test.deployers.AbstractDeploymentTest;
+
+import javax.management.ObjectName;
+
+/**
+ * A test for JBAB2904
+ *
+ * @author <a href="vicky.kak at jboss.com">Vicky Kak</a>
+ * @version $Revision: 1.0 $
+ */
+public class EARDeploymentUnitTestCase extends AbstractDeploymentTest
+{
+
+ public EARDeploymentUnitTestCase(String test)
+ {
+ super(test);
+ }
+
+ public static Test suite() throws Exception
+ {
+ return getDeploySetup(EARDeploymentUnitTestCase.class, "testdeployers-jbas2904.ear");
+ }
+
+ public void testEARDeployment() throws Exception{
+ DeploymentInfo topInfo = assertDeployed("testdeployers-jbas2904.ear");
+ //Expected ordering of the subdeployments
+ Object actualModules[] = (topInfo.subDeployments).toArray();
+ ArrayList expectedList = new ArrayList(actualModules.length);
+ System.out.println("Expected Deployment Ordering -------> ");
+ for(int count = 0;count<actualModules.length;count++){
+ DeploymentInfo child = (DeploymentInfo)actualModules[count];
+ URL url = child.url;
+ String moduleName = getModuleDeployed(url.toString());
+ expectedList.add(moduleName);
+ System.out.println(" "+moduleName+" lastDeployed :"+child.lastDeployed);
+ }
+ //Expected Deployment Ordering Array
+ Object expectedModules[] = expectedList.toArray();
+
+
+ Deployments deployment1 = new Deployments("Atestdeployerorder-jbas2904.sar",getMBeanLastDeployment(new ObjectName("jboss.jbas2904.test.deployers:service=MBean1")));
+ Deployments deployment2 = new Deployments("Btestdeployerorder-jbas2904.sar",getMBeanLastDeployment(new ObjectName("jboss.jbas2904.test.deployers:service=MBean2")));
+ ArrayList precisionDeployments = new ArrayList();
+ precisionDeployments.add(deployment1);
+ precisionDeployments.add(deployment2);
+ DeploymentInfoComparator comparator = new DeploymentInfoComparator();
+ Collections.sort(precisionDeployments,comparator);
+ //Actual Deployment Ordering Array
+ Object preciseModulesExpected[] = precisionDeployments.toArray();
+ assertEquals(expectedModules.length,preciseModulesExpected.length);
+
+ System.out.println("Final Deployment Ordering ------->");
+ for(int count = 0;count<preciseModulesExpected.length;count++)
+ {
+ Deployments deployment = (Deployments)preciseModulesExpected[count];
+ System.out.println(" "+deployment.getDuName()+" : "+deployment.getLastDeployed());
+ String expectedModule = ((Deployments)preciseModulesExpected[count]).getDuName();
+ assertEquals(expectedModules[count],expectedModule);
+ }
+ }
+
+ private String getModuleDeployed(String tempUrl){
+ StringTokenizer st = new StringTokenizer(tempUrl,"/");
+ String moduleName = "";
+ while (st.hasMoreTokens()) {
+ moduleName = st.nextToken();
+ }
+ return moduleName;
+ }
+
+private long getMBeanLastDeployment(ObjectName objName) throws Exception {
+ String method = "getLastDeployed";
+ Object args[] = {};
+ String[] sig = {};
+ Long lastDeployed = (Long)invoke(objName,method,args,sig);
+ return lastDeployed.longValue();
+ }
+}
+class Deployments
+{
+ private String duName;
+ private long lastDeployed;
+ public Deployments(String duName,long lastDeployed){
+ this.duName=duName;
+ this.lastDeployed=lastDeployed;
+ }
+ public String getDuName(){
+ return duName;
+ }
+ public long getLastDeployed(){
+ return lastDeployed;
+ }
+}
+class DeploymentInfoComparator implements Comparator {
+ public int compare(Object o1, Object o2) {
+ long deployedTime1 = ((Deployments)o1).getLastDeployed();
+ long deployedTime2 = ((Deployments)o2).getLastDeployed();
+ long timediff = deployedTime1 - deployedTime2;
+ int retVal = 0;
+ if(timediff == 0)
+ retVal = retVal;
+ else if(timediff <0)
+ retVal = -1;
+ else
+ retVal = 1;
+ return retVal;
+ }
+}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list