[jboss-cvs] JBossAS SVN: r95475 - in projects/jboss-osgi/trunk/reactor/deployment/src: test/java/org/jboss/test/osgi/deployment/interceptor and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Oct 23 07:07:34 EDT 2009


Author: thomas.diesler at jboss.com
Date: 2009-10-23 07:07:33 -0400 (Fri, 23 Oct 2009)
New Revision: 95475

Added:
   projects/jboss-osgi/trunk/reactor/deployment/src/test/java/org/jboss/test/osgi/deployment/interceptor/InterceptorOrderTestCase.java
Removed:
   projects/jboss-osgi/trunk/reactor/deployment/src/test/java/org/jboss/test/osgi/deployment/interceptor/LifecycleInterceptorTestCase.java
Modified:
   projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/AbstractLifecycleInterceptor.java
Log:
Fix InterceptorOrderTestCase

Modified: projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/AbstractLifecycleInterceptor.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/AbstractLifecycleInterceptor.java	2009-10-23 10:01:27 UTC (rev 95474)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/main/java/org/jboss/osgi/deployment/interceptor/AbstractLifecycleInterceptor.java	2009-10-23 11:07:33 UTC (rev 95475)
@@ -34,6 +34,9 @@
  */
 public abstract class AbstractLifecycleInterceptor implements LifecycleInterceptor 
 {
+   /** The default relative order: 1000 */
+   public static final int RELATIVE_ORDER_DEFAULT = 1000;
+   
    private Set<Class<?>> input;
    private Set<Class<?>> output;
    
@@ -43,7 +46,7 @@
     */
    public int getRelativeOrder()
    {
-      return 1000;
+      return RELATIVE_ORDER_DEFAULT;
    }
 
    /**

Copied: projects/jboss-osgi/trunk/reactor/deployment/src/test/java/org/jboss/test/osgi/deployment/interceptor/InterceptorOrderTestCase.java (from rev 95471, projects/jboss-osgi/trunk/reactor/deployment/src/test/java/org/jboss/test/osgi/deployment/interceptor/LifecycleInterceptorTestCase.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/test/java/org/jboss/test/osgi/deployment/interceptor/InterceptorOrderTestCase.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/test/java/org/jboss/test/osgi/deployment/interceptor/InterceptorOrderTestCase.java	2009-10-23 11:07:33 UTC (rev 95475)
@@ -0,0 +1,123 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.osgi.deployment.interceptor;
+
+//$Id$
+
+import static org.jboss.osgi.deployment.interceptor.AbstractLifecycleInterceptor.RELATIVE_ORDER_DEFAULT;
+import static org.junit.Assert.assertEquals;
+
+import java.util.List;
+
+import org.jboss.osgi.deployment.common.Deployment;
+import org.jboss.osgi.deployment.interceptor.AbstractLifecycleInterceptor;
+import org.jboss.osgi.deployment.interceptor.LifecycleInterceptor;
+import org.jboss.osgi.deployment.interceptor.LifecycleInterceptorException;
+import org.jboss.osgi.deployment.interceptor.LifecycleInterceptorService;
+import org.jboss.osgi.deployment.internal.LifecycleInterceptorServiceImpl;
+import org.junit.Test;
+
+/**
+ * Test the {@link LifecycleInterceptorService}
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 19-Oct-2009
+ */
+public class InterceptorOrderTestCase
+{
+   static final int RELATIVE_ORDER = RELATIVE_ORDER_DEFAULT + 1000;
+   
+   @Test
+   public void testRelativeOrder()
+   {
+      LifecycleInterceptor rel0000 = new BasicLifecycleInterceptor();
+      LifecycleInterceptor rel2000 = new BasicLifecycleInterceptor()
+      {
+         public int getRelativeOrder()
+         {
+            return RELATIVE_ORDER;
+         }
+      };
+
+      // Add ordered
+      LifecycleInterceptorServiceImpl service = new LifecycleInterceptorServiceImpl(null);
+      service.addInterceptor(rel0000);
+      service.addInterceptor(rel2000);
+
+      List<LifecycleInterceptor> chain = service.getInterceptorChain();
+      assertEquals(2, chain.size());
+      assertEquals(RELATIVE_ORDER_DEFAULT, chain.get(0).getRelativeOrder());
+      assertEquals(RELATIVE_ORDER, chain.get(1).getRelativeOrder());
+
+      // Add unordered
+      service = new LifecycleInterceptorServiceImpl(null);
+      service.addInterceptor(rel2000);
+      service.addInterceptor(rel0000);
+
+      chain = service.getInterceptorChain();
+      assertEquals(2, chain.size());
+      assertEquals(RELATIVE_ORDER_DEFAULT, chain.get(0).getRelativeOrder());
+      assertEquals(RELATIVE_ORDER, chain.get(1).getRelativeOrder());
+   }
+
+   @Test
+   public void testInputOutput()
+   {
+      class A
+      {
+      }
+
+      AbstractLifecycleInterceptor inA = new BasicLifecycleInterceptor();
+      inA.addInput(A.class);
+
+      AbstractLifecycleInterceptor outA = new BasicLifecycleInterceptor();
+      outA.addOutput(A.class);
+
+      // Add ordered
+      LifecycleInterceptorServiceImpl service = new LifecycleInterceptorServiceImpl(null);
+      service.addInterceptor(outA);
+      service.addInterceptor(inA);
+
+      List<LifecycleInterceptor> chain = service.getInterceptorChain();
+      assertEquals(2, chain.size());
+      assertEquals(outA, chain.get(0));
+      assertEquals(inA, chain.get(1));
+
+      // Add unordered
+      service = new LifecycleInterceptorServiceImpl(null);
+      service.addInterceptor(inA);
+      service.addInterceptor(outA);
+
+      chain = service.getInterceptorChain();
+      assertEquals(2, chain.size());
+      assertEquals(outA, chain.get(0));
+      assertEquals(inA, chain.get(1));
+   }
+   
+   class BasicLifecycleInterceptor extends AbstractLifecycleInterceptor
+   {
+      public void invoke(int state, Deployment dep) throws LifecycleInterceptorException
+      {
+         // do nothing
+      }
+   }
+}

Deleted: projects/jboss-osgi/trunk/reactor/deployment/src/test/java/org/jboss/test/osgi/deployment/interceptor/LifecycleInterceptorTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/deployment/src/test/java/org/jboss/test/osgi/deployment/interceptor/LifecycleInterceptorTestCase.java	2009-10-23 10:01:27 UTC (rev 95474)
+++ projects/jboss-osgi/trunk/reactor/deployment/src/test/java/org/jboss/test/osgi/deployment/interceptor/LifecycleInterceptorTestCase.java	2009-10-23 11:07:33 UTC (rev 95475)
@@ -1,120 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.osgi.deployment.interceptor;
-
-//$Id$
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.List;
-
-import org.jboss.osgi.deployment.common.Deployment;
-import org.jboss.osgi.deployment.interceptor.LifecycleInterceptor;
-import org.jboss.osgi.deployment.interceptor.AbstractLifecycleInterceptor;
-import org.jboss.osgi.deployment.interceptor.LifecycleInterceptorException;
-import org.jboss.osgi.deployment.interceptor.LifecycleInterceptorService;
-import org.jboss.osgi.deployment.internal.LifecycleInterceptorServiceImpl;
-import org.junit.Test;
-
-/**
- * Test the {@link LifecycleInterceptorService}
- * 
- * @author thomas.diesler at jboss.com
- * @since 19-Oct-2009
- */
-public class LifecycleInterceptorTestCase
-{
-   @Test
-   public void testRelativeOrder()
-   {
-      LifecycleInterceptor rel000 = new BasicLifecycleInterceptor();
-      LifecycleInterceptor rel100 = new BasicLifecycleInterceptor()
-      {
-         public int getRelativeOrder()
-         {
-            return 100;
-         }
-      };
-
-      // Add ordered
-      LifecycleInterceptorServiceImpl service = new LifecycleInterceptorServiceImpl(null);
-      service.addInterceptor(rel000);
-      service.addInterceptor(rel100);
-
-      List<LifecycleInterceptor> chain = service.getInterceptorChain();
-      assertEquals(2, chain.size());
-      assertEquals(0, chain.get(0).getRelativeOrder());
-      assertEquals(100, chain.get(1).getRelativeOrder());
-
-      // Add unordered
-      service = new LifecycleInterceptorServiceImpl(null);
-      service.addInterceptor(rel100);
-      service.addInterceptor(rel000);
-
-      chain = service.getInterceptorChain();
-      assertEquals(2, chain.size());
-      assertEquals(0, chain.get(0).getRelativeOrder());
-      assertEquals(100, chain.get(1).getRelativeOrder());
-   }
-
-   @Test
-   public void testInputOutput()
-   {
-      class A
-      {
-      }
-
-      AbstractLifecycleInterceptor inA = new BasicLifecycleInterceptor();
-      inA.addInput(A.class);
-
-      AbstractLifecycleInterceptor outA = new BasicLifecycleInterceptor();
-      outA.addOutput(A.class);
-
-      // Add ordered
-      LifecycleInterceptorServiceImpl service = new LifecycleInterceptorServiceImpl(null);
-      service.addInterceptor(outA);
-      service.addInterceptor(inA);
-
-      List<LifecycleInterceptor> chain = service.getInterceptorChain();
-      assertEquals(2, chain.size());
-      assertEquals(outA, chain.get(0));
-      assertEquals(inA, chain.get(1));
-
-      // Add unordered
-      service = new LifecycleInterceptorServiceImpl(null);
-      service.addInterceptor(inA);
-      service.addInterceptor(outA);
-
-      chain = service.getInterceptorChain();
-      assertEquals(2, chain.size());
-      assertEquals(outA, chain.get(0));
-      assertEquals(inA, chain.get(1));
-   }
-   
-   class BasicLifecycleInterceptor extends AbstractLifecycleInterceptor
-   {
-      public void invoke(int state, Deployment dep) throws LifecycleInterceptorException
-      {
-         // do nothing
-      }
-   }
-}




More information about the jboss-cvs-commits mailing list