[Jboss-cvs] JBossAS SVN: r55165 - in trunk/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
Fri Aug 4 02:31:27 EDT 2006


Author: vicky.kak at jboss.com
Date: 2006-08-04 02:31:19 -0400 (Fri, 04 Aug 2006)
New Revision: 55165

Added:
   trunk/testsuite/src/main/org/jboss/test/deployers/jbas2904/
   trunk/testsuite/src/main/org/jboss/test/deployers/jbas2904/sar/
   trunk/testsuite/src/main/org/jboss/test/deployers/jbas2904/sar/mbean1/
   trunk/testsuite/src/main/org/jboss/test/deployers/jbas2904/sar/mbean1/MBean1.java
   trunk/testsuite/src/main/org/jboss/test/deployers/jbas2904/sar/mbean1/MBean1MBean.java
   trunk/testsuite/src/main/org/jboss/test/deployers/jbas2904/sar/mbean2/
   trunk/testsuite/src/main/org/jboss/test/deployers/jbas2904/sar/mbean2/MBean2.java
   trunk/testsuite/src/main/org/jboss/test/deployers/jbas2904/sar/mbean2/MBean2MBean.java
   trunk/testsuite/src/main/org/jboss/test/deployers/jbas2904/test/
   trunk/testsuite/src/main/org/jboss/test/deployers/jbas2904/test/EARDeploymentUnitTestCase.java
Log:
Changes done for JBAS-2194 

Added: trunk/testsuite/src/main/org/jboss/test/deployers/jbas2904/sar/mbean1/MBean1.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/deployers/jbas2904/sar/mbean1/MBean1.java	2006-08-04 06:28:07 UTC (rev 55164)
+++ trunk/testsuite/src/main/org/jboss/test/deployers/jbas2904/sar/mbean1/MBean1.java	2006-08-04 06:31:19 UTC (rev 55165)
@@ -0,0 +1,24 @@
+/*
+ * 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(){
+		this.lastDeployed = System.currentTimeMillis();
+		System.out.println("Atestdeployerorder-jbas2904.sar deployed at :"+lastDeployed);
+	}
+}

Added: trunk/testsuite/src/main/org/jboss/test/deployers/jbas2904/sar/mbean1/MBean1MBean.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/deployers/jbas2904/sar/mbean1/MBean1MBean.java	2006-08-04 06:28:07 UTC (rev 55164)
+++ trunk/testsuite/src/main/org/jboss/test/deployers/jbas2904/sar/mbean1/MBean1MBean.java	2006-08-04 06:31:19 UTC (rev 55165)
@@ -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: trunk/testsuite/src/main/org/jboss/test/deployers/jbas2904/sar/mbean2/MBean2.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/deployers/jbas2904/sar/mbean2/MBean2.java	2006-08-04 06:28:07 UTC (rev 55164)
+++ trunk/testsuite/src/main/org/jboss/test/deployers/jbas2904/sar/mbean2/MBean2.java	2006-08-04 06:31:19 UTC (rev 55165)
@@ -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: trunk/testsuite/src/main/org/jboss/test/deployers/jbas2904/sar/mbean2/MBean2MBean.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/deployers/jbas2904/sar/mbean2/MBean2MBean.java	2006-08-04 06:28:07 UTC (rev 55164)
+++ trunk/testsuite/src/main/org/jboss/test/deployers/jbas2904/sar/mbean2/MBean2MBean.java	2006-08-04 06:31:19 UTC (rev 55165)
@@ -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: trunk/testsuite/src/main/org/jboss/test/deployers/jbas2904/test/EARDeploymentUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/deployers/jbas2904/test/EARDeploymentUnitTestCase.java	2006-08-04 06:28:07 UTC (rev 55164)
+++ trunk/testsuite/src/main/org/jboss/test/deployers/jbas2904/test/EARDeploymentUnitTestCase.java	2006-08-04 06:31:19 UTC (rev 55165)
@@ -0,0 +1,134 @@
+/*
+ * 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 that tests the JBAB2904
+ * 
+ * build compile-classes-only
+ * build _jars-deployers
+ * build -Dtest=org.jboss.test.deployers.jbas2904.test.EARDeploymentUnitTestCase one-test
+ * @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