[webbeans-commits] Webbeans SVN: r3665 - in ri/branches/kabir-builder: tests/src/test/java/org/jboss/webbeans/test/unit/builder/sorter and 1 other directory.
webbeans-commits at lists.jboss.org
webbeans-commits at lists.jboss.org
Tue Sep 15 08:54:15 EDT 2009
Author: kabir.khan at jboss.com
Date: 2009-09-15 08:54:15 -0400 (Tue, 15 Sep 2009)
New Revision: 3665
Added:
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/builder/sorter/DoctorManager.java
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/builder/sorter/DoctorManagerImpl.java
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/builder/sorter/EmployeeManager.java
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/builder/sorter/EmployeeManagerImpl.java
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/builder/sorter/OrderedEjbDescriptors.java
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/builder/sorter/PlasticSurgeonManager.java
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/builder/sorter/PlasticSurgeonManagerImpl.java
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/builder/sorter/SurgeonManager.java
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/builder/sorter/SurgeonManagerImpl.java
Modified:
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/builder/sorter/EjbDeploymentItem.java
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/builder/sorter/SorterTest.java
Log:
Test EJB order
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/builder/sorter/EjbDeploymentItem.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/builder/sorter/EjbDeploymentItem.java 2009-09-15 00:18:59 UTC (rev 3664)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/builder/sorter/EjbDeploymentItem.java 2009-09-15 12:54:15 UTC (rev 3665)
@@ -53,13 +53,12 @@
{
//This needs revisiting
Class<?> superClass = getWBClass().getWBSuperclass().getJavaClass();
- for (InternalEjbDescriptor ejb : allDescriptors)
+ for (InternalEjbDescriptor<?> ejb : allDescriptors)
{
if (ejb.getBeanClass().equals(superClass))
{
DeploymentItem<InternalEjbDescriptor<?>> item = new EjbDeploymentItem(null, null, getWBClass().getWBSuperclass(), ejb);
return findDeploymentItem(item);
-
}
}
//TODO search wbclasses too?
Added: ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/builder/sorter/DoctorManager.java
===================================================================
--- ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/builder/sorter/DoctorManager.java (rev 0)
+++ ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/builder/sorter/DoctorManager.java 2009-09-15 12:54:15 UTC (rev 3665)
@@ -0,0 +1,35 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.webbeans.test.unit.builder.sorter;
+
+import javax.ejb.Local;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+ at Local
+public interface DoctorManager extends EmployeeManager
+{
+
+}
Added: ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/builder/sorter/DoctorManagerImpl.java
===================================================================
--- ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/builder/sorter/DoctorManagerImpl.java (rev 0)
+++ ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/builder/sorter/DoctorManagerImpl.java 2009-09-15 12:54:15 UTC (rev 3665)
@@ -0,0 +1,35 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.webbeans.test.unit.builder.sorter;
+
+import javax.ejb.Stateless;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+ at Stateless
+public class DoctorManagerImpl extends EmployeeManagerImpl implements DoctorManager
+{
+
+}
Added: ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/builder/sorter/EmployeeManager.java
===================================================================
--- ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/builder/sorter/EmployeeManager.java (rev 0)
+++ ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/builder/sorter/EmployeeManager.java 2009-09-15 12:54:15 UTC (rev 3665)
@@ -0,0 +1,35 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.webbeans.test.unit.builder.sorter;
+
+import javax.ejb.Local;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+ at Local
+public interface EmployeeManager
+{
+
+}
Added: ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/builder/sorter/EmployeeManagerImpl.java
===================================================================
--- ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/builder/sorter/EmployeeManagerImpl.java (rev 0)
+++ ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/builder/sorter/EmployeeManagerImpl.java 2009-09-15 12:54:15 UTC (rev 3665)
@@ -0,0 +1,35 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.webbeans.test.unit.builder.sorter;
+
+import javax.ejb.Stateless;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+ at Stateless
+public class EmployeeManagerImpl implements EmployeeManager
+{
+
+}
Added: ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/builder/sorter/OrderedEjbDescriptors.java
===================================================================
--- ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/builder/sorter/OrderedEjbDescriptors.java (rev 0)
+++ ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/builder/sorter/OrderedEjbDescriptors.java 2009-09-15 12:54:15 UTC (rev 3665)
@@ -0,0 +1,100 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.webbeans.test.unit.builder.sorter;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.Map;
+
+import org.jboss.webbeans.ejb.EjbDescriptors;
+import org.jboss.webbeans.ejb.InternalEjbDescriptor;
+import org.jboss.webbeans.ejb.spi.EjbDescriptor;
+
+/**
+ * Implementation of EjbDescriptors where we can rely on the order of the beans
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class OrderedEjbDescriptors extends EjbDescriptors
+{
+ // EJB name -> EJB descriptors map
+ private final Map<String, InternalEjbDescriptor<?>> ejbs;
+
+ private final Collection<Class<?>> ejbClasses;
+
+ public OrderedEjbDescriptors()
+ {
+ this.ejbs = new LinkedHashMap<String, InternalEjbDescriptor<?>>();
+ this.ejbClasses = new LinkedHashSet<Class<?>>();
+ }
+
+ public <T> InternalEjbDescriptor<T> get(String beanName)
+ {
+ return (InternalEjbDescriptor<T>) ejbs.get(beanName);
+ }
+
+ public <T> void add(EjbDescriptor<T> ejbDescriptor)
+ {
+ InternalEjbDescriptor<T> internalEjbDescriptor = new InternalEjbDescriptor<T>(ejbDescriptor);
+ ejbs.put(ejbDescriptor.getEjbName(), internalEjbDescriptor);
+ ejbClasses.add(ejbDescriptor.getBeanClass());
+ }
+
+ public boolean contains(String beanName)
+ {
+ return ejbs.containsKey(beanName);
+ }
+
+ public boolean contains(Class<?> beanClass)
+ {
+ return ejbClasses.contains(beanClass);
+ }
+
+ public void addAll(Iterable<EjbDescriptor<?>> ejbDescriptors)
+ {
+ for (EjbDescriptor<?> ejbDescriptor : ejbDescriptors)
+ {
+ add(ejbDescriptor);
+ }
+ }
+
+ public void clear()
+ {
+ ejbs.clear();
+ }
+
+ public Iterator<InternalEjbDescriptor<?>> iterator()
+ {
+ return ejbs.values().iterator();
+ }
+
+ public void cleanup() {}
+
+ public int size()
+ {
+ return ejbs.size();
+ }
+
+}
Added: ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/builder/sorter/PlasticSurgeonManager.java
===================================================================
--- ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/builder/sorter/PlasticSurgeonManager.java (rev 0)
+++ ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/builder/sorter/PlasticSurgeonManager.java 2009-09-15 12:54:15 UTC (rev 3665)
@@ -0,0 +1,35 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.webbeans.test.unit.builder.sorter;
+
+import javax.ejb.Local;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+ at Local
+public interface PlasticSurgeonManager extends SurgeonManager
+{
+
+}
Added: ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/builder/sorter/PlasticSurgeonManagerImpl.java
===================================================================
--- ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/builder/sorter/PlasticSurgeonManagerImpl.java (rev 0)
+++ ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/builder/sorter/PlasticSurgeonManagerImpl.java 2009-09-15 12:54:15 UTC (rev 3665)
@@ -0,0 +1,37 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.webbeans.test.unit.builder.sorter;
+
+import javax.ejb.Stateless;
+import javax.enterprise.inject.Specializes;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+ at Stateless
+ at Specializes
+public class PlasticSurgeonManagerImpl extends SurgeonManagerImpl implements PlasticSurgeonManager
+{
+
+}
Modified: ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/builder/sorter/SorterTest.java
===================================================================
--- ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/builder/sorter/SorterTest.java 2009-09-15 00:18:59 UTC (rev 3664)
+++ ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/builder/sorter/SorterTest.java 2009-09-15 12:54:15 UTC (rev 3665)
@@ -30,10 +30,10 @@
import org.jboss.webbeans.BeanManagerImpl;
import org.jboss.webbeans.builder.sorter.DeploymentItem;
import org.jboss.webbeans.builder.sorter.Sorter;
-import org.jboss.webbeans.ejb.EjbDescriptors;
import org.jboss.webbeans.introspector.WBClass;
import org.jboss.webbeans.introspector.jlr.WBClassImpl;
import org.jboss.webbeans.mock.MockEELifecycle;
+import org.jboss.webbeans.mock.MockEjbDescriptor;
import org.jboss.webbeans.resources.ClassTransformer;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
@@ -98,24 +98,68 @@
assertArrays(sortClasses(PlasticSurgeon.class, Employee.class, Surgeon.class, Doctor.class), Doctor.class, Surgeon.class, PlasticSurgeon.class, Employee.class);
}
+ @Test
+ public void testEjbSortNoDependencies()
+ {
+ assertArrays(sortClasses(createEjbDescriptors(DoctorManagerImpl.class, EmployeeManagerImpl.class)), DoctorManagerImpl.class, EmployeeManagerImpl.class);
+ assertArrays(sortClasses(createEjbDescriptors(EmployeeManagerImpl.class, DoctorManagerImpl.class)), EmployeeManagerImpl.class, DoctorManagerImpl.class);
+ }
+
+ @Test
+ public void testEjbSortSpecializedDependencies()
+ {
+ assertArrays(sortClasses(createEjbDescriptors(DoctorManagerImpl.class, SurgeonManagerImpl.class)), DoctorManagerImpl.class, SurgeonManagerImpl.class);
+ assertArrays(sortClasses(createEjbDescriptors(SurgeonManagerImpl.class, DoctorManagerImpl.class)), DoctorManagerImpl.class, SurgeonManagerImpl.class);
+
+ assertArrays(sortClasses(createEjbDescriptors(DoctorManagerImpl.class, SurgeonManagerImpl.class, PlasticSurgeonManagerImpl.class)), DoctorManagerImpl.class, SurgeonManagerImpl.class, PlasticSurgeonManagerImpl.class);
+ assertArrays(sortClasses(createEjbDescriptors(DoctorManagerImpl.class, PlasticSurgeonManagerImpl.class, SurgeonManagerImpl.class)), DoctorManagerImpl.class, SurgeonManagerImpl.class, PlasticSurgeonManagerImpl.class);
+ assertArrays(sortClasses(createEjbDescriptors(SurgeonManagerImpl.class, PlasticSurgeonManagerImpl.class, DoctorManagerImpl.class)), DoctorManagerImpl.class, SurgeonManagerImpl.class, PlasticSurgeonManagerImpl.class);
+ assertArrays(sortClasses(createEjbDescriptors(SurgeonManagerImpl.class, DoctorManagerImpl.class, PlasticSurgeonManagerImpl.class)), DoctorManagerImpl.class, SurgeonManagerImpl.class, PlasticSurgeonManagerImpl.class);
+ assertArrays(sortClasses(createEjbDescriptors(PlasticSurgeonManagerImpl.class, SurgeonManagerImpl.class, DoctorManagerImpl.class)), DoctorManagerImpl.class, SurgeonManagerImpl.class, PlasticSurgeonManagerImpl.class);
+ assertArrays(sortClasses(createEjbDescriptors(PlasticSurgeonManagerImpl.class, DoctorManagerImpl.class, SurgeonManagerImpl.class)), DoctorManagerImpl.class, SurgeonManagerImpl.class, PlasticSurgeonManagerImpl.class);
+
+ //TODO Not sure we can guarantee the order of Employee in these cases?
+ assertArrays(sortClasses(createEjbDescriptors(EmployeeManagerImpl.class, DoctorManagerImpl.class, SurgeonManagerImpl.class, PlasticSurgeonManagerImpl.class)), EmployeeManagerImpl.class, DoctorManagerImpl.class, SurgeonManagerImpl.class, PlasticSurgeonManagerImpl.class);
+ assertArrays(sortClasses(createEjbDescriptors(PlasticSurgeonManagerImpl.class, SurgeonManagerImpl.class, DoctorManagerImpl.class, EmployeeManagerImpl.class)), DoctorManagerImpl.class, SurgeonManagerImpl.class, PlasticSurgeonManagerImpl.class, EmployeeManagerImpl.class);
+ assertArrays(sortClasses(createEjbDescriptors(DoctorManagerImpl.class, SurgeonManagerImpl.class, EmployeeManagerImpl.class, PlasticSurgeonManagerImpl.class)), DoctorManagerImpl.class, SurgeonManagerImpl.class, EmployeeManagerImpl.class, PlasticSurgeonManagerImpl.class);
+ assertArrays(sortClasses(createEjbDescriptors(PlasticSurgeonManagerImpl.class, EmployeeManagerImpl.class, SurgeonManagerImpl.class, DoctorManagerImpl.class)), DoctorManagerImpl.class, SurgeonManagerImpl.class, PlasticSurgeonManagerImpl.class, EmployeeManagerImpl.class);
+ }
+
+
@Test
public void testDecoratorsFirst()
{
assertArrays(sortClasses(RedDecorator.class, BlueDecorator.class, Doctor.class, Surgeon.class), RedDecorator.class, BlueDecorator.class, Doctor.class, Surgeon.class);
assertArrays(sortClasses(RedDecorator.class, Doctor.class, Surgeon.class, BlueDecorator.class), RedDecorator.class, BlueDecorator.class, Doctor.class, Surgeon.class);
assertArrays(sortClasses(Surgeon.class, Doctor.class, RedDecorator.class, BlueDecorator.class), RedDecorator.class, BlueDecorator.class, Doctor.class, Surgeon.class);
-
+
+ assertArrays(sortClasses(createEjbDescriptors(DoctorManagerImpl.class, SurgeonManagerImpl.class), RedDecorator.class, BlueDecorator.class), RedDecorator.class, BlueDecorator.class, DoctorManagerImpl.class, SurgeonManagerImpl.class);
+ assertArrays(sortClasses(createEjbDescriptors(SurgeonManagerImpl.class, DoctorManagerImpl.class), RedDecorator.class, BlueDecorator.class), RedDecorator.class, BlueDecorator.class, DoctorManagerImpl.class, SurgeonManagerImpl.class);
}
- @Test
- public void testEjbs()
+ private OrderedEjbDescriptors createEjbDescriptors(Class<?>...classes)
{
- assert 1 == 0 : "NYI";
+ OrderedEjbDescriptors descriptors = new OrderedEjbDescriptors();
+ for (Class<?> clazz : classes)
+ {
+ descriptors.add(MockEjbDescriptor.of(clazz));
+ }
+ return descriptors;
}
-
+
private Class<?>[] sortClasses(Class<?>...classes)
{
- if (classes == null || classes.length == 0)
+ return sortClasses(createEjbDescriptors(), classes);
+ }
+
+ private Class<?>[] sortClasses(OrderedEjbDescriptors ejbDescriptors)
+ {
+ return sortClasses(ejbDescriptors, new Class[0]);
+ }
+
+ private Class<?>[] sortClasses(OrderedEjbDescriptors ejbDescriptors, Class<?>...classes)
+ {
+ if (classes.length == 0 && ejbDescriptors.size() == 0)
return new Class<?>[0];
ClassTransformer transformer = manager.getServices().get(ClassTransformer.class);
@@ -126,14 +170,12 @@
wbClasses.add(WBClassImpl.of(clazz, transformer));
}
- Sorter sorter = Sorter.createSorter(manager, wbClasses, new EjbDescriptors());
+ Sorter sorter = Sorter.createSorter(manager, wbClasses, ejbDescriptors);
List<DeploymentItem<?>> sorted = sorter.sort();
- System.out.println("======>" + sorted);
+ assert sorted.size() == classes.length + ejbDescriptors.size();
- assert sorted.size() == classes.length;
-
- Class<?>[] result = new Class<?>[classes.length];
+ Class<?>[] result = new Class<?>[classes.length + ejbDescriptors.size()];
int i = 0;
for (DeploymentItem<?> item : sorted)
@@ -143,7 +185,7 @@
return result;
}
-
+
private void assertArrays(Class<?>[] actual, Class<?>...expected)
{
assert Arrays.equals(expected, actual) : printArrays(expected, actual);
Added: ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/builder/sorter/SurgeonManager.java
===================================================================
--- ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/builder/sorter/SurgeonManager.java (rev 0)
+++ ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/builder/sorter/SurgeonManager.java 2009-09-15 12:54:15 UTC (rev 3665)
@@ -0,0 +1,35 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.webbeans.test.unit.builder.sorter;
+
+import javax.ejb.Local;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+ at Local
+public interface SurgeonManager extends DoctorManager
+{
+
+}
Added: ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/builder/sorter/SurgeonManagerImpl.java
===================================================================
--- ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/builder/sorter/SurgeonManagerImpl.java (rev 0)
+++ ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/builder/sorter/SurgeonManagerImpl.java 2009-09-15 12:54:15 UTC (rev 3665)
@@ -0,0 +1,37 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.webbeans.test.unit.builder.sorter;
+
+import javax.ejb.Stateless;
+import javax.enterprise.inject.Specializes;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+ at Stateless
+ at Specializes
+public class SurgeonManagerImpl extends DoctorManagerImpl implements SurgeonManager
+{
+
+}
More information about the weld-commits
mailing list