[jboss-cvs] JBossAS SVN: r64649 - in projects/microcontainer/trunk/kernel/src: main/org/jboss/kernel/plugins/annotations and 10 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Aug 17 09:09:36 EDT 2007
Author: alesj
Date: 2007-08-17 09:09:36 -0400 (Fri, 17 Aug 2007)
New Revision: 64649
Added:
projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/annotations/test/FactoryMethodBadTestCase.xml
projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/annotations/
projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/annotations/test/
projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/annotations/test/override/
projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/annotations/test/override/testCallbackOverride.xml
projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/annotations/test/override/testConstructorOverride.xml
projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/annotations/test/override/testExternalOverride.xml
projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/annotations/test/override/testFactoryOverride.xml
projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/annotations/test/override/testInstallationOverride.xml
projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/annotations/test/override/testPropertyOverride.xml
projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/annotations/test/override/testSetsOverride.xml
projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/annotations/test/testFactoryMethod.xml
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/AnnotationTester.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/CallbackAnnotationTester.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/ConstructorAnnotationTester.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/ExternalAnnotationTester.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/FactoryAnnotationTester.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/FactoryMethodAnnotationTester.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/FactoryMethodBadAnnotationTester.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/FactoryTesterCreator.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/HolderAnnotationTester.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/InstallationAnnotationTester.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/LifecycleAnnotationTester.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/PropertyAnnotationTester.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/SetsAnnotationTester.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/AnnotationSupportTestSuite.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/FactoryMethodBadTestCase.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/FactoryMethodTestCase.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/FactoryMethodXMLTestCase.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/AbstractAnnotationOverrideTestCase.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/AnnotationsOverrideTestSuite.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/CallbackAnnotationOverrideTestCase.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/CallbackAnnotationOverrideXMLTestCase.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/ConstructorAnnotationOverrideTestCase.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/ConstructorAnnotationOverrideXMLTestCase.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/ExternalAnnotationOverrideTestCase.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/ExternalAnnotationOverrideXMLTestCase.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/FactoryAnnotationOverrideTestCase.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/InstallationAnnotationOverrideTestCase.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/InstallationAnnotationOverrideXMLTestCase.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/LifecycleAnnotationOverrideTestCase.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/LifecycleAnnotationOverrideXMLTestCase.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/PropertyAnnotationOverrideTestCase.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/PropertyAnnotationOverrideXMLTestCase.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/SetsAnnotationOverrideTestCase.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/SetsAnnotationOverrideXMLTestCase.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/AbstractOnDemandDeploymentTest.java
Removed:
projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/annotations/test/InjectAnnotationTestCase.xml
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/SimpleInject.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/InjectAnnotationTestCase.java
Modified:
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractDemandMetaData.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractDependencyMetaData.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractSupplyMetaData.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/CallbackAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/DemandsAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/DependsAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/FactoryMethodAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/InstallationParameterAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/MethodInstallCallbackAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/MethodUninstallCallbackAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/PropertyInstallCallbackAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/PropertyUninstallCallbackAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/SupplysAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/AnnotationsTestSuite.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/AbstractKernelConfigTest.java
Log:
Annotation override + additional features tests.
Added hash + equals to DemandMD, DependMD, SupplyMD.
Refactored equal compare on CallbackAnnotationPlugin.
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractDemandMetaData.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractDemandMetaData.java 2007-08-17 09:22:21 UTC (rev 64648)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractDemandMetaData.java 2007-08-17 13:09:36 UTC (rev 64649)
@@ -35,6 +35,7 @@
import org.jboss.kernel.spi.dependency.KernelControllerContext;
import org.jboss.util.JBossObject;
import org.jboss.util.JBossStringBuilder;
+import org.jboss.util.HashCode;
/**
* A demand.
@@ -132,6 +133,18 @@
buffer.append(demand);
}
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof AbstractDemandMetaData == false)
+ return false;
+ return equals(demand, ((AbstractDemandMetaData)obj).demand);
+ }
+
+ protected int getHashCode()
+ {
+ return HashCode.generate(demand);
+ }
+
/**
* Information about a demand dependency.
*/
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractDependencyMetaData.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractDependencyMetaData.java 2007-08-17 09:22:21 UTC (rev 64648)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractDependencyMetaData.java 2007-08-17 13:09:36 UTC (rev 64649)
@@ -33,6 +33,7 @@
import org.jboss.kernel.spi.dependency.KernelControllerContext;
import org.jboss.util.JBossObject;
import org.jboss.util.JBossStringBuilder;
+import org.jboss.util.HashCode;
/**
* A dependency.
@@ -112,6 +113,18 @@
buffer.append(dependency);
}
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof AbstractDependencyMetaData == false)
+ return false;
+ return equals(dependency, ((AbstractDependencyMetaData)obj).dependency);
+ }
+
+ protected int getHashCode()
+ {
+ return HashCode.generate(dependency);
+ }
+
/**
* A LifecycleDependencyItem.
*/
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractSupplyMetaData.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractSupplyMetaData.java 2007-08-17 09:22:21 UTC (rev 64648)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractSupplyMetaData.java 2007-08-17 13:09:36 UTC (rev 64649)
@@ -29,6 +29,7 @@
import org.jboss.beans.metadata.spi.SupplyMetaData;
import org.jboss.util.JBossObject;
import org.jboss.util.JBossStringBuilder;
+import org.jboss.util.HashCode;
/**
* A supply.
@@ -101,4 +102,17 @@
{
buffer.append(supply);
}
+
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof AbstractSupplyMetaData == false)
+ return false;
+ return equals(supply, ((AbstractSupplyMetaData)obj).supply);
+ }
+
+ protected int getHashCode()
+ {
+ return HashCode.generate(supply);
+ }
+
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/CallbackAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/CallbackAnnotationPlugin.java 2007-08-17 09:22:21 UTC (rev 64648)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/CallbackAnnotationPlugin.java 2007-08-17 13:09:36 UTC (rev 64649)
@@ -61,14 +61,14 @@
{
for(CallbackItem ci : callbacks)
{
- if (isNameEqual(info, ci.getAttributeName()))
+ if (isEqual(info, ci))
return true;
}
}
return false;
}
- protected abstract boolean isNameEqual(T info, String attributeName);
+ protected abstract boolean isEqual(T info, CallbackItem ci);
protected abstract Set<CallbackItem> getCallbacks(DependencyInfo dependency);
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/DemandsAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/DemandsAnnotationPlugin.java 2007-08-17 09:22:21 UTC (rev 64648)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/DemandsAnnotationPlugin.java 2007-08-17 13:09:36 UTC (rev 64649)
@@ -61,8 +61,8 @@
{
AbstractDemandMetaData admd = new AbstractDemandMetaData(demand.value());
admd.setWhenRequired(new ControllerState(demand.whenRequired()));
- demands.add(admd);
- nodes.add(admd);
+ if (demands.add(admd))
+ nodes.add(admd);
}
return nodes;
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/DependsAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/DependsAnnotationPlugin.java 2007-08-17 09:22:21 UTC (rev 64648)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/DependsAnnotationPlugin.java 2007-08-17 13:09:36 UTC (rev 64649)
@@ -58,8 +58,8 @@
for(String depends : annotation.value())
{
AbstractDependencyMetaData dependency = new AbstractDependencyMetaData(depends);
- dependencies.add(dependency);
- nodes.add(dependency);
+ if (dependencies.add(dependency))
+ nodes.add(dependency);
}
return nodes;
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/FactoryMethodAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/FactoryMethodAnnotationPlugin.java 2007-08-17 09:22:21 UTC (rev 64648)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/FactoryMethodAnnotationPlugin.java 2007-08-17 13:09:36 UTC (rev 64649)
@@ -50,6 +50,8 @@
protected boolean isMetaDataAlreadyPresent(MethodInfo info, FactoryMethod annotation, BeanMetaData beanMetaData)
{
+ if (info.isPublic() == false || info.isStatic() == false)
+ throw new IllegalArgumentException("Method marked as @FactoryMethod must be public and static");
return beanMetaData.getConstructor() != null;
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/InstallationParameterAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/InstallationParameterAnnotationPlugin.java 2007-08-17 09:22:21 UTC (rev 64648)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/InstallationParameterAnnotationPlugin.java 2007-08-17 13:09:36 UTC (rev 64649)
@@ -33,6 +33,8 @@
import org.jboss.beans.metadata.spi.MetaDataVisitorNode;
import org.jboss.reflect.spi.MethodInfo;
import org.jboss.reflect.spi.ParameterInfo;
+import org.jboss.reflect.spi.TypeInfo;
+import org.jboss.kernel.plugins.config.Configurator;
/**
* @param <C> annotation type
@@ -64,12 +66,22 @@
{
List<ParameterMetaData> parameters = install.getParameters();
ParameterInfo[] parameterInfos = info.getParameters();
- if (parameters != null && parameterInfos != null && parameters.size() == parameterInfos.length)
- return true;
if (parameters == null && parameterInfos != null && parameterInfos.length == 0)
return true;
if (parameters != null && parameters.size() == 0 && parameterInfos == null)
return true;
+ if (parameters != null && parameterInfos != null && parameters.size() == parameterInfos.length)
+ {
+ int n = parameters.size();
+ String[] typeNames = new String[n];
+ TypeInfo[] typeInfos = new TypeInfo[n];
+ for(int i = 0; i < n; i++)
+ {
+ typeNames[i] = parameters.get(i).getType();
+ typeInfos[i] = parameterInfos[i].getParameterType();
+ }
+ return Configurator.equals(typeNames, typeInfos);
+ }
}
}
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/MethodInstallCallbackAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/MethodInstallCallbackAnnotationPlugin.java 2007-08-17 09:22:21 UTC (rev 64648)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/MethodInstallCallbackAnnotationPlugin.java 2007-08-17 13:09:36 UTC (rev 64649)
@@ -23,6 +23,7 @@
import org.jboss.beans.metadata.plugins.AbstractCallbackMetaData;
import org.jboss.reflect.spi.MethodInfo;
+import org.jboss.dependency.spi.CallbackItem;
/**
* @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
@@ -34,9 +35,10 @@
super();
}
- protected boolean isNameEqual(MethodInfo info, String attributeName)
+ protected boolean isEqual(MethodInfo info, CallbackItem ci)
{
- return attributeName.equals(info.getName());
+ // todo - param matching
+ return info.getName().equals(ci.getAttributeName());
}
protected void applyInfo(AbstractCallbackMetaData callback, MethodInfo info)
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/MethodUninstallCallbackAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/MethodUninstallCallbackAnnotationPlugin.java 2007-08-17 09:22:21 UTC (rev 64648)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/MethodUninstallCallbackAnnotationPlugin.java 2007-08-17 13:09:36 UTC (rev 64649)
@@ -23,6 +23,7 @@
import org.jboss.reflect.spi.MethodInfo;
import org.jboss.beans.metadata.plugins.AbstractCallbackMetaData;
+import org.jboss.dependency.spi.CallbackItem;
/**
* @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
@@ -34,9 +35,10 @@
super();
}
- protected boolean isNameEqual(MethodInfo info, String attributeName)
+ protected boolean isEqual(MethodInfo info, CallbackItem ci)
{
- return attributeName.equals(info.getName());
+ // todo - param matching
+ return info.getName().equals(ci.getAttributeName());
}
protected void applyInfo(AbstractCallbackMetaData callback, MethodInfo info)
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/PropertyInstallCallbackAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/PropertyInstallCallbackAnnotationPlugin.java 2007-08-17 09:22:21 UTC (rev 64648)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/PropertyInstallCallbackAnnotationPlugin.java 2007-08-17 13:09:36 UTC (rev 64649)
@@ -23,6 +23,7 @@
import org.jboss.beans.info.spi.PropertyInfo;
import org.jboss.beans.metadata.plugins.AbstractCallbackMetaData;
+import org.jboss.dependency.spi.CallbackItem;
/**
* @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
@@ -34,9 +35,10 @@
super();
}
- protected boolean isNameEqual(PropertyInfo info, String attributeName)
+ protected boolean isEqual(PropertyInfo info, CallbackItem ci)
{
- return attributeName.equals(info.getName());
+ // todo - param matching
+ return info.getName().equals(ci.getAttributeName());
}
protected void applyInfo(AbstractCallbackMetaData callback, PropertyInfo info)
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/PropertyUninstallCallbackAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/PropertyUninstallCallbackAnnotationPlugin.java 2007-08-17 09:22:21 UTC (rev 64648)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/PropertyUninstallCallbackAnnotationPlugin.java 2007-08-17 13:09:36 UTC (rev 64649)
@@ -23,6 +23,7 @@
import org.jboss.beans.info.spi.PropertyInfo;
import org.jboss.beans.metadata.plugins.AbstractCallbackMetaData;
+import org.jboss.dependency.spi.CallbackItem;
/**
* @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
@@ -34,9 +35,10 @@
super();
}
- protected boolean isNameEqual(PropertyInfo info, String attributeName)
+ protected boolean isEqual(PropertyInfo info, CallbackItem ci)
{
- return attributeName.equals(info.getName());
+ // todo - param matching
+ return info.getName().equals(ci.getAttributeName());
}
protected void applyInfo(AbstractCallbackMetaData callback, PropertyInfo info)
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/SupplysAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/SupplysAnnotationPlugin.java 2007-08-17 09:22:21 UTC (rev 64648)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/SupplysAnnotationPlugin.java 2007-08-17 13:09:36 UTC (rev 64649)
@@ -56,8 +56,8 @@
for(String supply : annotation.value())
{
AbstractSupplyMetaData asmd = new AbstractSupplyMetaData(supply);
- supplies.add(asmd);
- nodes.add(asmd);
+ if (supplies.add(asmd))
+ nodes.add(asmd);
}
return nodes;
}
Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/annotations/test/FactoryMethodBadTestCase.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/annotations/test/FactoryMethodBadTestCase.xml (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/annotations/test/FactoryMethodBadTestCase.xml 2007-08-17 13:09:36 UTC (rev 64649)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="Tester" class="org.jboss.test.kernel.annotations.support.FactoryMethodBadAnnotationTester" mode="On Demand"/>
+
+</deployment>
Deleted: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/annotations/test/InjectAnnotationTestCase.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/annotations/test/InjectAnnotationTestCase.xml 2007-08-17 09:22:21 UTC (rev 64648)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/annotations/test/InjectAnnotationTestCase.xml 2007-08-17 13:09:36 UTC (rev 64649)
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<deployment xmlns="urn:jboss:bean-deployer:2.0">
-
- <bean name="SimpleBean" class="org.jboss.test.kernel.annotations.support.SimpleInject" />
-
- <bean name="testBean" class="org.jboss.test.kernel.annotations.support.TestBean" />
-
- <bean name="otherBean" class="org.jboss.test.kernel.annotations.support.TestBean" />
-
- <bean name="serviceBean" class="org.jboss.test.kernel.annotations.support.TestBean" />
-
- <bean name="valueBean" class="org.jboss.test.kernel.annotations.support.TestBean" />
-
- <bean name="lifecycleBean" class="org.jboss.test.kernel.annotations.support.TestBean" />
-
- <bean name="deployer1" class="org.jboss.test.kernel.annotations.support.MyDeployer" />
-
- <bean name="deployer2" class="org.jboss.test.kernel.annotations.support.MyDeployer" />
-
- <bean name="testconst" class="org.jboss.test.kernel.annotations.support.TestConstructorBean" />
-
-</deployment>
Added: projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/annotations/test/override/testCallbackOverride.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/annotations/test/override/testCallbackOverride.xml (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/annotations/test/override/testCallbackOverride.xml 2007-08-17 13:09:36 UTC (rev 64649)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="Tester" class="org.jboss.test.kernel.annotations.support.CallbackAnnotationTester">
+ <incallback method="addMyDeployer"/>
+ <uncallback method="removeMyDeployer"/>
+ </bean>
+
+ <bean name="deployer" class="org.jboss.test.kernel.annotations.support.MyDeployer"/>
+
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/annotations/test/override/testConstructorOverride.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/annotations/test/override/testConstructorOverride.xml (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/annotations/test/override/testConstructorOverride.xml 2007-08-17 13:09:36 UTC (rev 64649)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="Tester" class="org.jboss.test.kernel.annotations.support.ConstructorAnnotationTester">
+ <constructor>
+ <parameter>FromXML</parameter>
+ </constructor>
+ </bean>
+
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/annotations/test/override/testExternalOverride.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/annotations/test/override/testExternalOverride.xml (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/annotations/test/override/testExternalOverride.xml 2007-08-17 13:09:36 UTC (rev 64649)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="Tester" class="org.jboss.test.kernel.annotations.support.ExternalAnnotationTester">
+ <install bean="Holder" method="addTester">
+ <parameter><this/></parameter>
+ </install>
+ <uninstall bean="Holder" method="removeTester">
+ <parameter><this/></parameter>
+ </uninstall>
+ </bean>
+
+ <bean name="Holder" class="org.jboss.test.kernel.annotations.support.HolderAnnotationTester"/>
+
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/annotations/test/override/testFactoryOverride.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/annotations/test/override/testFactoryOverride.xml (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/annotations/test/override/testFactoryOverride.xml 2007-08-17 13:09:36 UTC (rev 64649)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="Tester" class="org.jboss.test.kernel.annotations.support.FactoryAnnotationTester">
+ <constructor factoryClass="org.jboss.test.kernel.annotations.support.FactoryTesterCreator" factoryMethod="fromXML" />
+ </bean>
+
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/annotations/test/override/testInstallationOverride.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/annotations/test/override/testInstallationOverride.xml (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/annotations/test/override/testInstallationOverride.xml 2007-08-17 13:09:36 UTC (rev 64649)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="Tester" class="org.jboss.test.kernel.annotations.support.InstallationAnnotationTester">
+ <install method="addMyDeployer"/>
+ <uninstall method="removeMyDeployer"/>
+ </bean>
+
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/annotations/test/override/testPropertyOverride.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/annotations/test/override/testPropertyOverride.xml (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/annotations/test/override/testPropertyOverride.xml 2007-08-17 13:09:36 UTC (rev 64649)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="Tester" class="org.jboss.test.kernel.annotations.support.PropertyAnnotationTester">
+ <property name="value">FromXML</property>
+ </bean>
+
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/annotations/test/override/testSetsOverride.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/annotations/test/override/testSetsOverride.xml (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/annotations/test/override/testSetsOverride.xml 2007-08-17 13:09:36 UTC (rev 64649)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="Tester" class="org.jboss.test.kernel.annotations.support.SetsAnnotationTester">
+ <demand>deployer</demand>
+ <depends>deployer</depends>
+ <supply>somesupply</supply>
+ </bean>
+
+ <bean name="deployer" class="org.jboss.test.kernel.annotations.support.MyDeployer"/>
+
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/annotations/test/testFactoryMethod.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/annotations/test/testFactoryMethod.xml (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/xml-test/org/jboss/test/kernel/annotations/test/testFactoryMethod.xml 2007-08-17 13:09:36 UTC (rev 64649)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="Tester" class="org.jboss.test.kernel.annotations.support.FactoryMethodAnnotationTester"/>
+
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/AnnotationTester.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/AnnotationTester.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/AnnotationTester.java 2007-08-17 13:09:36 UTC (rev 64649)
@@ -0,0 +1,30 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.annotations.support;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public interface AnnotationTester
+{
+ Object getValue();
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/CallbackAnnotationTester.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/CallbackAnnotationTester.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/CallbackAnnotationTester.java 2007-08-17 13:09:36 UTC (rev 64649)
@@ -0,0 +1,50 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.annotations.support;
+
+import org.jboss.beans.metadata.plugins.annotations.Install;
+import org.jboss.beans.metadata.plugins.annotations.Uninstall;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class CallbackAnnotationTester implements AnnotationTester
+{
+ private int counter;
+
+ @Install
+ public void addMyDeployer(MyDeployer deployer)
+ {
+ counter++;
+ }
+
+ @Uninstall
+ public void removeMyDeployer(MyDeployer deployer)
+ {
+ counter--;
+ }
+
+ public Object getValue()
+ {
+ return counter;
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/ConstructorAnnotationTester.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/ConstructorAnnotationTester.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/ConstructorAnnotationTester.java 2007-08-17 13:09:36 UTC (rev 64649)
@@ -0,0 +1,45 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.annotations.support;
+
+import org.jboss.beans.metadata.plugins.annotations.Constructor;
+import org.jboss.beans.metadata.plugins.annotations.StringValue;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ConstructorAnnotationTester implements AnnotationTester
+{
+ private String value;
+
+ @Constructor
+ public ConstructorAnnotationTester(@StringValue("FromAnnotations") String value)
+ {
+ this.value = value;
+ }
+
+ public String getValue()
+ {
+ return value;
+ }
+
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/ExternalAnnotationTester.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/ExternalAnnotationTester.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/ExternalAnnotationTester.java 2007-08-17 13:09:36 UTC (rev 64649)
@@ -0,0 +1,47 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.annotations.support;
+
+import org.jboss.beans.metadata.plugins.annotations.ExternalInstall;
+import org.jboss.beans.metadata.plugins.annotations.ExternalInstalls;
+import org.jboss.beans.metadata.plugins.annotations.ExternalUninstalls;
+import org.jboss.beans.metadata.plugins.annotations.ThisValue;
+import org.jboss.beans.metadata.plugins.annotations.Value;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+ at ExternalInstalls
+(
+ {@ExternalInstall(bean = "Holder", method = "addTester", parameters = {@Value(thisValue = @ThisValue)})}
+)
+ at ExternalUninstalls
+(
+ {@ExternalInstall(bean = "Holder", method = "removeTester", parameters = {@Value(thisValue = @ThisValue)})}
+)
+public class ExternalAnnotationTester implements AnnotationTester
+{
+ public Object getValue()
+ {
+ return null;
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/FactoryAnnotationTester.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/FactoryAnnotationTester.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/FactoryAnnotationTester.java 2007-08-17 13:09:36 UTC (rev 64649)
@@ -0,0 +1,43 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.annotations.support;
+
+import org.jboss.beans.metadata.plugins.annotations.Factory;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+ at Factory(factoryClass = "org.jboss.test.kernel.annotations.support.FactoryTesterCreator", factoryMethod = "fromAnnotations")
+public class FactoryAnnotationTester implements AnnotationTester
+{
+ private Object value;
+
+ public FactoryAnnotationTester(Object value)
+ {
+ this.value = value;
+ }
+
+ public Object getValue()
+ {
+ return value;
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/FactoryMethodAnnotationTester.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/FactoryMethodAnnotationTester.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/FactoryMethodAnnotationTester.java 2007-08-17 13:09:36 UTC (rev 64649)
@@ -0,0 +1,48 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.annotations.support;
+
+import org.jboss.beans.metadata.plugins.annotations.FactoryMethod;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class FactoryMethodAnnotationTester implements AnnotationTester
+{
+ private String value;
+
+ private FactoryMethodAnnotationTester(String value)
+ {
+ this.value = value;
+ }
+
+ public String getValue()
+ {
+ return value;
+ }
+
+ @FactoryMethod
+ public static AnnotationTester getTester()
+ {
+ return new FactoryMethodAnnotationTester("FromAnnotations");
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/FactoryMethodBadAnnotationTester.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/FactoryMethodBadAnnotationTester.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/FactoryMethodBadAnnotationTester.java 2007-08-17 13:09:36 UTC (rev 64649)
@@ -0,0 +1,48 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.annotations.support;
+
+import org.jboss.beans.metadata.plugins.annotations.FactoryMethod;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class FactoryMethodBadAnnotationTester implements AnnotationTester
+{
+ private String value;
+
+ private FactoryMethodBadAnnotationTester(String value)
+ {
+ this.value = value;
+ }
+
+ public String getValue()
+ {
+ return value;
+ }
+
+ @FactoryMethod
+ public AnnotationTester getTester()
+ {
+ return new FactoryMethodBadAnnotationTester("FromAnnotations");
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/FactoryTesterCreator.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/FactoryTesterCreator.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/FactoryTesterCreator.java 2007-08-17 13:09:36 UTC (rev 64649)
@@ -0,0 +1,38 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.annotations.support;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class FactoryTesterCreator
+{
+ public static AnnotationTester fromXML()
+ {
+ return new FactoryAnnotationTester("FromXML");
+ }
+
+ public static AnnotationTester fromAnnotations()
+ {
+ return new FactoryAnnotationTester("FromAnnotations");
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/HolderAnnotationTester.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/HolderAnnotationTester.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/HolderAnnotationTester.java 2007-08-17 13:09:36 UTC (rev 64649)
@@ -0,0 +1,45 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.annotations.support;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class HolderAnnotationTester implements AnnotationTester
+{
+ private int counter;
+
+ public void addTester(AnnotationTester tester)
+ {
+ counter++;
+ }
+
+ public void removeTester(AnnotationTester tester)
+ {
+ counter--;
+ }
+
+ public Object getValue()
+ {
+ return counter;
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/InstallationAnnotationTester.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/InstallationAnnotationTester.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/InstallationAnnotationTester.java 2007-08-17 13:09:36 UTC (rev 64649)
@@ -0,0 +1,50 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.annotations.support;
+
+import org.jboss.beans.metadata.plugins.annotations.InstallMethod;
+import org.jboss.beans.metadata.plugins.annotations.UninstallMethod;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class InstallationAnnotationTester implements AnnotationTester
+{
+ private int counter;
+
+ @InstallMethod
+ public void addMyDeployer()
+ {
+ counter++;
+ }
+
+ @UninstallMethod
+ public void removeMyDeployer()
+ {
+ counter--;
+ }
+
+ public Object getValue()
+ {
+ return counter;
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/LifecycleAnnotationTester.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/LifecycleAnnotationTester.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/LifecycleAnnotationTester.java 2007-08-17 13:09:36 UTC (rev 64649)
@@ -0,0 +1,89 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.annotations.support;
+
+import org.jboss.beans.metadata.plugins.annotations.Create;
+import org.jboss.beans.metadata.plugins.annotations.Start;
+import org.jboss.beans.metadata.plugins.annotations.Stop;
+import org.jboss.beans.metadata.plugins.annotations.Destroy;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class LifecycleAnnotationTester implements AnnotationTester
+{
+ private static String FROM_XML = "FromXML";
+ private Object[] value = new Object[4];
+
+ public void fromXMLCreate()
+ {
+ value[0] = FROM_XML;
+ }
+
+ public void fromXMLStart()
+ {
+ value[1] = FROM_XML;
+ }
+
+ public void fromXMLStop()
+ {
+ value[1] = null;
+ value[2] = FROM_XML;
+ }
+
+ public void fromXMLDestroy()
+ {
+ value[0] = null;
+ value[3] = FROM_XML;
+ }
+
+ @Create
+ public void fromAnnCreate()
+ {
+ value[0] = "dew";
+ }
+
+ @Start
+ public void fromAnnStart()
+ {
+ value[1] = "dewdew";
+ }
+
+ @Stop
+ public void fromAnnStop()
+ {
+ value[1] = null;
+ value[2] = "dewdwe";
+ }
+
+ @Destroy
+ public void fromAnnDestroy()
+ {
+ value[0] = null;
+ value[3] = "dwefwf";
+ }
+
+ public Object[] getValue()
+ {
+ return value;
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/PropertyAnnotationTester.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/PropertyAnnotationTester.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/PropertyAnnotationTester.java 2007-08-17 13:09:36 UTC (rev 64649)
@@ -0,0 +1,46 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.annotations.support;
+
+import org.jboss.beans.metadata.plugins.annotations.StringValue;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class PropertyAnnotationTester implements AnnotationTester
+{
+ private String value;
+
+ public String getValue()
+ {
+ return value;
+ }
+
+ @StringValue("FromAnnotation")
+ public void setValue(Object value)
+ {
+ if (value == null)
+ throw new IllegalArgumentException("Null value.");
+ this.value = value.toString();
+ }
+
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/SetsAnnotationTester.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/SetsAnnotationTester.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/SetsAnnotationTester.java 2007-08-17 13:09:36 UTC (rev 64649)
@@ -0,0 +1,41 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.annotations.support;
+
+import org.jboss.beans.metadata.plugins.annotations.Demands;
+import org.jboss.beans.metadata.plugins.annotations.Demand;
+import org.jboss.beans.metadata.plugins.annotations.Depends;
+import org.jboss.beans.metadata.plugins.annotations.Supplys;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+ at Demands({@Demand("deployer")})
+ at Depends({"deployer"})
+ at Supplys({"somesupply"})
+public class SetsAnnotationTester implements AnnotationTester
+{
+ public Object getValue()
+ {
+ return null;
+ }
+}
Deleted: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/SimpleInject.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/SimpleInject.java 2007-08-17 09:22:21 UTC (rev 64648)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/SimpleInject.java 2007-08-17 13:09:36 UTC (rev 64649)
@@ -1,133 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, 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.kernel.annotations.support;
-
-import java.util.Set;
-import java.util.HashSet;
-import java.util.List;
-
-import org.jboss.beans.metadata.plugins.annotations.Aliases;
-import org.jboss.beans.metadata.plugins.annotations.Demands;
-import org.jboss.beans.metadata.plugins.annotations.Depends;
-import org.jboss.beans.metadata.plugins.annotations.FactoryMethod;
-import org.jboss.beans.metadata.plugins.annotations.Inject;
-import org.jboss.beans.metadata.plugins.annotations.StringValue;
-import org.jboss.beans.metadata.plugins.annotations.Supplys;
-import org.jboss.beans.metadata.plugins.annotations.ValueFactory;
-import org.jboss.beans.metadata.plugins.annotations.Install;
-import org.jboss.beans.metadata.plugins.annotations.Uninstall;
-import org.jboss.beans.metadata.plugins.annotations.Start;
-import org.jboss.beans.metadata.plugins.annotations.InstallMethod;
-import org.jboss.beans.metadata.plugins.annotations.ThisValue;
-import org.jboss.beans.metadata.plugins.annotations.NullValue;
-import org.jboss.beans.metadata.plugins.annotations.UninstallMethod;
-import org.jboss.beans.metadata.plugins.annotations.ListValue;
-import org.jboss.beans.metadata.plugins.annotations.Value;
-import org.jboss.beans.metadata.plugins.annotations.Demand;
-
-/**
- * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
- */
- at Aliases({"al", "test"})
- at Demands({@Demand("otherBean")})
- at Depends({"serviceBean"})
- at Supplys({"txBean"})
-public class SimpleInject
-{
- private int intVF;
- private TestBean testBean;
- private Set<MyDeployer> deployers;
- private List<TestBean> testers;
-
- public int getVf()
- {
- return intVF;
- }
-
- @FactoryMethod
- public static SimpleInject getInstance(@NullValue Object someNull)
- {
- return new SimpleInject();
- }
-
- @Start
- public void startMeUp(@Inject(bean = "lifecycleBean") TestBean bean, @ValueFactory(bean="valueBean", method = "getValue", parameter = "123") int value)
- {
- intVF =- value;
- }
-
- @StringValue("123")
- public void setVf(int vf)
- {
- this.intVF = vf;
- }
-
- @Install
- public void addDeployer(MyDeployer deployer)
- {
- if (deployers == null)
- deployers = new HashSet<MyDeployer>();
- deployers.add(deployer);
- }
-
- @Uninstall
- public void removeDeployer(MyDeployer deployer)
- {
- deployers.remove(deployer);
- }
-
- @InstallMethod
- public void whenInstalled(@ThisValue SimpleInject me, @NullValue Object plainNull)
- {
- System.out.println(me == this);
- System.out.println("plainNull = " + plainNull);
- }
-
- @UninstallMethod
- public void withUninstall(@ThisValue SimpleInject me, @NullValue Object plainNull)
- {
- System.out.println(me == this);
- System.out.println("plainNull = " + plainNull);
- }
-
- public TestBean getTestBean()
- {
- return testBean;
- }
-
- @Inject(bean = "testBean")
- public void setTestBean(TestBean bean)
- {
- this.testBean = bean;
- }
-
- public List<TestBean> getTesters()
- {
- return testers;
- }
-
- @ListValue({@Value(inject = @Inject(bean = "valueBean")), @Value(inject = @Inject(bean = "valueBean"))})
- public void setTesters(List<TestBean> testers)
- {
- this.testers = testers;
- }
-}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/AnnotationSupportTestSuite.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/AnnotationSupportTestSuite.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/AnnotationSupportTestSuite.java 2007-08-17 13:09:36 UTC (rev 64649)
@@ -0,0 +1,50 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.annotations.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * Additional annotation features tests.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class AnnotationSupportTestSuite extends TestSuite
+{
+ public static void main(String[] args)
+ {
+ TestRunner.run(suite());
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("Annotation Support Tests");
+
+ suite.addTest(FactoryMethodTestCase.suite());
+ suite.addTest(FactoryMethodXMLTestCase.suite());
+ suite.addTest(FactoryMethodBadTestCase.suite());
+
+ return suite;
+ }
+}
Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/AnnotationsTestSuite.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/AnnotationsTestSuite.java 2007-08-17 09:22:21 UTC (rev 64648)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/AnnotationsTestSuite.java 2007-08-17 13:09:36 UTC (rev 64649)
@@ -24,8 +24,11 @@
import junit.framework.TestSuite;
import junit.framework.Test;
import junit.textui.TestRunner;
+import org.jboss.test.kernel.annotations.test.override.AnnotationsOverrideTestSuite;
/**
+ * Annotations tests.
+ *
* @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
*/
public class AnnotationsTestSuite extends TestSuite
@@ -38,7 +41,10 @@
public static Test suite()
{
TestSuite suite = new TestSuite("Annotations Tests");
- suite.addTest(InjectAnnotationTestCase.suite());
+
+ suite.addTest(AnnotationSupportTestSuite.suite());
+ suite.addTest(AnnotationsOverrideTestSuite.suite());
+
return suite;
}
}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/FactoryMethodBadTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/FactoryMethodBadTestCase.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/FactoryMethodBadTestCase.java 2007-08-17 13:09:36 UTC (rev 64649)
@@ -0,0 +1,52 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.annotations.test;
+
+import junit.framework.Test;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.test.kernel.deployment.test.AbstractOnDemandDeploymentTest;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class FactoryMethodBadTestCase extends AbstractOnDemandDeploymentTest
+{
+ public FactoryMethodBadTestCase(String name) throws Throwable
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return suite(FactoryMethodBadTestCase.class);
+ }
+
+ public void testFactoryMethodBad() throws Throwable
+ {
+ KernelControllerContext context = getControllerContext("Tester", null);
+ change(context, ControllerState.INSTALLED);
+ assertEquals(ControllerState.ERROR, context.getState());
+ assertNotNull(context.getError());
+ assertInstanceOf(context.getError(), IllegalArgumentException.class);
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/FactoryMethodTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/FactoryMethodTestCase.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/FactoryMethodTestCase.java 2007-08-17 13:09:36 UTC (rev 64649)
@@ -0,0 +1,63 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.annotations.test;
+
+import junit.framework.Test;
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.test.kernel.annotations.support.AnnotationTester;
+import org.jboss.test.kernel.annotations.support.FactoryMethodAnnotationTester;
+import org.jboss.test.kernel.config.test.AbstractKernelConfigTest;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class FactoryMethodTestCase extends AbstractKernelConfigTest
+{
+ public FactoryMethodTestCase(String name) throws Throwable
+ {
+ super(name);
+ }
+
+ public FactoryMethodTestCase(String name, boolean xmltest)
+ {
+ super(name, xmltest);
+ }
+
+ public static Test suite()
+ {
+ return suite(FactoryMethodTestCase.class);
+ }
+
+ public void testFactoryMethod() throws Throwable
+ {
+ AnnotationTester tester = getTester();
+ assertEquals("FromAnnotations", tester.getValue());
+ }
+
+ protected AnnotationTester getTester() throws Throwable
+ {
+ Object tester = instantiate(new AbstractBeanMetaData("Tester", FactoryMethodAnnotationTester.class.getName()));
+ assertNotNull(tester);
+ assertInstanceOf(tester, AnnotationTester.class);
+ return (AnnotationTester)tester;
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/FactoryMethodXMLTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/FactoryMethodXMLTestCase.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/FactoryMethodXMLTestCase.java 2007-08-17 13:09:36 UTC (rev 64649)
@@ -0,0 +1,50 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.annotations.test;
+
+import org.jboss.test.kernel.annotations.support.AnnotationTester;
+import org.jboss.test.kernel.config.support.XMLUtil;
+import junit.framework.Test;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class FactoryMethodXMLTestCase extends FactoryMethodTestCase
+{
+ public FactoryMethodXMLTestCase(String name) throws Throwable
+ {
+ super(name, true);
+ }
+
+ public static Test suite()
+ {
+ return suite(FactoryMethodXMLTestCase.class);
+ }
+
+ protected AnnotationTester getTester() throws Throwable
+ {
+ XMLUtil util = bootstrapXML(true);
+ Object tester = util.getBean("Tester");
+ assertInstanceOf(tester, AnnotationTester.class, false);
+ return (AnnotationTester)tester;
+ }
+}
Deleted: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/InjectAnnotationTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/InjectAnnotationTestCase.java 2007-08-17 09:22:21 UTC (rev 64648)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/InjectAnnotationTestCase.java 2007-08-17 13:09:36 UTC (rev 64649)
@@ -1,49 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, 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.kernel.annotations.test;
-
-import junit.framework.Test;
-import org.jboss.test.kernel.deployment.test.AbstractDeploymentTest;
-import org.jboss.dependency.spi.ControllerContext;
-
-/**
- * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
- */
-public class InjectAnnotationTestCase extends AbstractDeploymentTest
-{
- public InjectAnnotationTestCase(String name) throws Throwable
- {
- super(name);
- }
-
- public static Test suite()
- {
- return suite(InjectAnnotationTestCase.class);
- }
-
- public void testInjection() throws Throwable
- {
- ControllerContext context = getControllerContext("SimpleBean");
- assertNotNull(context);
- System.out.println("context = " + context);
- }
-}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/AbstractAnnotationOverrideTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/AbstractAnnotationOverrideTestCase.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/AbstractAnnotationOverrideTestCase.java 2007-08-17 13:09:36 UTC (rev 64649)
@@ -0,0 +1,109 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.annotations.test.override;
+
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.test.kernel.annotations.support.AnnotationTester;
+import org.jboss.test.kernel.config.test.AbstractKernelConfigTest;
+import org.jboss.test.kernel.config.support.XMLUtil;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class AbstractAnnotationOverrideTestCase extends AbstractKernelConfigTest
+{
+ protected static final String FROM_XML = "FromXML";
+
+ protected AbstractAnnotationOverrideTestCase(String name) throws Throwable
+ {
+ super(name);
+ }
+
+ protected AbstractAnnotationOverrideTestCase(String name, boolean xmltest)
+ {
+ super(name, xmltest);
+ }
+
+ protected abstract void addMetaData(AbstractBeanMetaData beanMetaData);
+
+ protected abstract String getType();
+
+ protected String getClasName()
+ {
+ String name = AnnotationTester.class.getName();
+ int p = name.lastIndexOf(".") + 1;
+ return new StringBuilder(name).insert(p, getType()).toString();
+ }
+
+ protected Object getBean(String name, ControllerState state) throws Throwable
+ {
+ if (xmltest)
+ {
+ XMLUtil util = bootstrapXML(true);
+ return util.getBean(name);
+ }
+ else
+ {
+ AbstractBeanMetaData bean = new AbstractBeanMetaData("Tester", getClasName());
+ addMetaData(bean);
+ return instantiate(bean, state);
+ }
+ }
+
+ protected String getTesterName()
+ {
+ return "Tester";
+ }
+
+ protected AnnotationTester getTester() throws Throwable
+ {
+ return getTester(getTesterName());
+ }
+
+ protected AnnotationTester getTester(String name) throws Throwable
+ {
+ return getTester(name, null);
+ }
+
+ protected AnnotationTester getTester(String name, ControllerState state) throws Throwable
+ {
+ Object tester = getBean(name, state);
+ assertNotNull(tester);
+ assertInstanceOf(tester, AnnotationTester.class, false);
+ Class<?> clazz = Class.forName(getClasName());
+ assertInstanceOf(tester, clazz);
+ return (AnnotationTester)tester;
+ }
+
+ protected void assertOverride(Object value)
+ {
+ assertEquals("Should be from xml.", FROM_XML, value);
+ }
+
+ // simple check
+ protected void checkOverride() throws Throwable
+ {
+ AnnotationTester tester = getTester();
+ assertOverride(tester.getValue());
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/AnnotationsOverrideTestSuite.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/AnnotationsOverrideTestSuite.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/AnnotationsOverrideTestSuite.java 2007-08-17 13:09:36 UTC (rev 64649)
@@ -0,0 +1,64 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.annotations.test.override;
+
+import junit.textui.TestRunner;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * Testing XML override of annotations.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class AnnotationsOverrideTestSuite extends TestSuite
+{
+ public static void main(String[] args)
+ {
+ TestRunner.run(suite());
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("Annotation Override tests");
+
+ suite.addTest(PropertyAnnotationOverrideTestCase.suite());
+ suite.addTest(PropertyAnnotationOverrideXMLTestCase.suite());
+ suite.addTest(ConstructorAnnotationOverrideTestCase.suite());
+ suite.addTest(ConstructorAnnotationOverrideXMLTestCase.suite());
+ suite.addTest(LifecycleAnnotationOverrideTestCase.suite());
+ suite.addTest(LifecycleAnnotationOverrideXMLTestCase.suite());
+ suite.addTest(CallbackAnnotationOverrideTestCase.suite());
+ suite.addTest(CallbackAnnotationOverrideXMLTestCase.suite());
+ suite.addTest(InstallationAnnotationOverrideTestCase.suite());
+ suite.addTest(InstallationAnnotationOverrideXMLTestCase.suite());
+ suite.addTest(SetsAnnotationOverrideTestCase.suite());
+ suite.addTest(SetsAnnotationOverrideXMLTestCase.suite());
+ suite.addTest(FactoryAnnotationOverrideTestCase.suite());
+ suite.addTest(FactoryAnnotationOverrideXMLTestCase.suite());
+ suite.addTest(ExternalAnnotationOverrideTestCase.suite());
+ suite.addTest(ExternalAnnotationOverrideXMLTestCase.suite());
+
+ return suite;
+ }
+}
+
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/CallbackAnnotationOverrideTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/CallbackAnnotationOverrideTestCase.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/CallbackAnnotationOverrideTestCase.java 2007-08-17 13:09:36 UTC (rev 64649)
@@ -0,0 +1,112 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.annotations.test.override;
+
+import java.util.List;
+import java.util.ArrayList;
+
+import org.jboss.dependency.spi.Controller;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.plugins.InstallCallbackMetaData;
+import org.jboss.beans.metadata.plugins.UninstallCallbackMetaData;
+import org.jboss.beans.metadata.spi.CallbackMetaData;
+import org.jboss.test.kernel.annotations.support.AnnotationTester;
+import org.jboss.test.kernel.annotations.support.MyDeployer;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import junit.framework.Test;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class CallbackAnnotationOverrideTestCase extends AbstractAnnotationOverrideTestCase
+{
+ private Controller controller;
+ private ControllerContext context;
+
+ public CallbackAnnotationOverrideTestCase(String name) throws Throwable
+ {
+ super(name);
+ }
+
+ public CallbackAnnotationOverrideTestCase(String name, boolean xmltest)
+ {
+ super(name, xmltest);
+ }
+
+ public static Test suite()
+ {
+ return suite(CallbackAnnotationOverrideTestCase.class);
+ }
+
+ protected String getType()
+ {
+ return "Callback";
+ }
+
+ protected void addMetaData(AbstractBeanMetaData beanMetaData)
+ {
+ List<CallbackMetaData> installs = new ArrayList<CallbackMetaData>();
+ InstallCallbackMetaData in = new InstallCallbackMetaData();
+ in.setMethodName("addMyDeployer");
+ installs.add(in);
+ List<CallbackMetaData> uninstalls = new ArrayList<CallbackMetaData>();
+ UninstallCallbackMetaData un = new UninstallCallbackMetaData();
+ un.setMethodName("removeMyDeployer");
+ uninstalls.add(un);
+ beanMetaData.setInstallCallbacks(installs);
+ beanMetaData.setUninstallCallbacks(uninstalls);
+ }
+
+ public void testCallbackOverride() throws Throwable
+ {
+ AnnotationTester tester = getTester();
+ Object val = tester.getValue();
+ assertInstanceOf(val, Integer.class);
+ Integer count = (Integer)val;
+ assertNotNull(count);
+ assertEquals(1, count.intValue());
+
+ doUndeploy();
+
+ val = tester.getValue();
+ assertInstanceOf(val, Integer.class);
+ count = (Integer)val;
+ assertNotNull(count);
+ assertEquals(0, count.intValue());
+ }
+
+ protected void afterInstall(KernelController controller, KernelControllerContext context) throws Throwable
+ {
+ controller.install(new AbstractBeanMetaData("deployer", MyDeployer.class.getName()));
+ this.controller = controller;
+ this.context = context;
+ }
+
+ protected void doUndeploy()
+ {
+ controller.uninstall("deployer");
+ controller = null;
+ context = null;
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/CallbackAnnotationOverrideXMLTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/CallbackAnnotationOverrideXMLTestCase.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/CallbackAnnotationOverrideXMLTestCase.java 2007-08-17 13:09:36 UTC (rev 64649)
@@ -0,0 +1,60 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.annotations.test.override;
+
+import org.jboss.test.kernel.config.support.XMLUtil;
+import org.jboss.test.kernel.annotations.support.AnnotationTester;
+import org.jboss.kernel.spi.dependency.KernelController;
+import junit.framework.Test;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class CallbackAnnotationOverrideXMLTestCase extends CallbackAnnotationOverrideTestCase
+{
+ private XMLUtil util;
+
+ public CallbackAnnotationOverrideXMLTestCase(String name) throws Throwable
+ {
+ super(name, true);
+ }
+
+ public static Test suite()
+ {
+ return suite(CallbackAnnotationOverrideXMLTestCase.class);
+ }
+
+ protected AnnotationTester getTester() throws Throwable
+ {
+ util = bootstrapXML(true);
+ Object tester = util.getBean(getTesterName());
+ assertInstanceOf(tester, AnnotationTester.class, false);
+ return (AnnotationTester)tester;
+ }
+
+ protected void doUndeploy()
+ {
+ KernelController kc = util.getKernel().getController();
+ kc.uninstall("deployer");
+ util = null;
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/ConstructorAnnotationOverrideTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/ConstructorAnnotationOverrideTestCase.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/ConstructorAnnotationOverrideTestCase.java 2007-08-17 13:09:36 UTC (rev 64649)
@@ -0,0 +1,71 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.annotations.test.override;
+
+import java.util.List;
+import java.util.ArrayList;
+
+import junit.framework.Test;
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.plugins.AbstractConstructorMetaData;
+import org.jboss.beans.metadata.plugins.AbstractParameterMetaData;
+import org.jboss.beans.metadata.spi.ParameterMetaData;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ConstructorAnnotationOverrideTestCase extends AbstractAnnotationOverrideTestCase
+{
+ public ConstructorAnnotationOverrideTestCase(String name) throws Throwable
+ {
+ super(name);
+ }
+
+ public ConstructorAnnotationOverrideTestCase(String name, boolean xmltest)
+ {
+ super(name, xmltest);
+ }
+
+ public static Test suite()
+ {
+ return suite(ConstructorAnnotationOverrideTestCase.class);
+ }
+
+ protected String getType()
+ {
+ return "Constructor";
+ }
+
+ protected void addMetaData(AbstractBeanMetaData beanMetaData)
+ {
+ AbstractConstructorMetaData constructorMetaData = new AbstractConstructorMetaData();
+ List<ParameterMetaData> parameters = new ArrayList<ParameterMetaData>();
+ parameters.add(new AbstractParameterMetaData("FromXML"));
+ constructorMetaData.setParameters(parameters);
+ beanMetaData.setConstructor(constructorMetaData);
+ }
+
+ public void testConstructorOverride() throws Throwable
+ {
+ checkOverride();
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/ConstructorAnnotationOverrideXMLTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/ConstructorAnnotationOverrideXMLTestCase.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/ConstructorAnnotationOverrideXMLTestCase.java 2007-08-17 13:09:36 UTC (rev 64649)
@@ -0,0 +1,41 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.annotations.test.override;
+
+import junit.framework.Test;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ConstructorAnnotationOverrideXMLTestCase extends ConstructorAnnotationOverrideTestCase
+{
+ public ConstructorAnnotationOverrideXMLTestCase(String name) throws Throwable
+ {
+ super(name, true);
+ }
+
+ public static Test suite()
+ {
+ return suite(ConstructorAnnotationOverrideXMLTestCase.class);
+ }
+
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/ExternalAnnotationOverrideTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/ExternalAnnotationOverrideTestCase.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/ExternalAnnotationOverrideTestCase.java 2007-08-17 13:09:36 UTC (rev 64649)
@@ -0,0 +1,129 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.annotations.test.override;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Collections;
+
+import junit.framework.Test;
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.plugins.AbstractInstallMetaData;
+import org.jboss.beans.metadata.plugins.AbstractParameterMetaData;
+import org.jboss.beans.metadata.plugins.ThisValueMetaData;
+import org.jboss.beans.metadata.spi.InstallMetaData;
+import org.jboss.beans.metadata.spi.ParameterMetaData;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.test.kernel.annotations.support.AnnotationTester;
+import org.jboss.test.kernel.annotations.support.HolderAnnotationTester;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ExternalAnnotationOverrideTestCase extends AbstractAnnotationOverrideTestCase
+{
+ private KernelController controller;
+
+ public ExternalAnnotationOverrideTestCase(String name) throws Throwable
+ {
+ super(name);
+ }
+
+ public ExternalAnnotationOverrideTestCase(String name, boolean xmltest)
+ {
+ super(name, xmltest);
+ }
+
+ public static Test suite()
+ {
+ return suite(ExternalAnnotationOverrideTestCase.class);
+ }
+
+ protected String getType()
+ {
+ return "External";
+ }
+
+ protected void addMetaData(AbstractBeanMetaData beanMetaData)
+ {
+ ParameterMetaData parameter = new AbstractParameterMetaData(new ThisValueMetaData());
+ List<InstallMetaData> installs = new ArrayList<InstallMetaData>();
+ AbstractInstallMetaData in = new AbstractInstallMetaData();
+ in.setBean("Holder");
+ in.setMethodName("addTester");
+ in.setParameters(Collections.singletonList(parameter));
+ installs.add(in);
+ List<InstallMetaData> uninstalls = new ArrayList<InstallMetaData>();
+ AbstractInstallMetaData un = new AbstractInstallMetaData();
+ un.setBean("Holder");
+ un.setMethodName("removeTester");
+ un.setParameters(Collections.singletonList(parameter));
+ uninstalls.add(un);
+ beanMetaData.setInstalls(installs);
+ beanMetaData.setUninstalls(uninstalls);
+ }
+
+ public void testExternalOverride() throws Throwable
+ {
+ getTester(getTesterName(), ControllerState.START);
+
+ AnnotationTester holder = getHolder();
+
+ Object val = holder.getValue();
+ assertInstanceOf(val, Integer.class);
+ Integer count = (Integer)val;
+ assertNotNull(count);
+ assertEquals(1, count.intValue());
+
+ doUndeploy();
+
+ val = holder.getValue();
+ assertInstanceOf(val, Integer.class);
+ count = (Integer)val;
+ assertNotNull(count);
+ assertEquals(0, count.intValue());
+ }
+
+ protected void afterInstall(KernelController controller, KernelControllerContext context) throws Throwable
+ {
+ controller.install(new AbstractBeanMetaData("Holder", HolderAnnotationTester.class.getName()));
+ this.controller = controller;
+ }
+
+ protected AnnotationTester getHolder() throws Throwable
+ {
+ ControllerContext context = controller.getInstalledContext("Holder");
+ assertNotNull(context);
+ Object target = context.getTarget();
+ assertInstanceOf(target, HolderAnnotationTester.class);
+ return (AnnotationTester)target;
+ }
+
+ protected void doUndeploy()
+ {
+ controller.uninstall(getTesterName());
+ controller = null;
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/ExternalAnnotationOverrideXMLTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/ExternalAnnotationOverrideXMLTestCase.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/ExternalAnnotationOverrideXMLTestCase.java 2007-08-17 13:09:36 UTC (rev 64649)
@@ -0,0 +1,67 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.annotations.test.override;
+
+import org.jboss.test.kernel.config.support.XMLUtil;
+import org.jboss.test.kernel.annotations.support.AnnotationTester;
+import org.jboss.test.kernel.annotations.support.HolderAnnotationTester;
+import org.jboss.dependency.spi.ControllerState;
+import junit.framework.Test;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ExternalAnnotationOverrideXMLTestCase extends ExternalAnnotationOverrideTestCase
+{
+ private XMLUtil util;
+
+ public ExternalAnnotationOverrideXMLTestCase(String name) throws Throwable
+ {
+ super(name, true);
+ }
+
+ public static Test suite()
+ {
+ return suite(ExternalAnnotationOverrideXMLTestCase.class);
+ }
+
+ protected AnnotationTester getTester(String name, ControllerState state) throws Throwable
+ {
+ util = bootstrapXML(true);
+ Object tester = util.getBean(getTesterName());
+ assertInstanceOf(tester, AnnotationTester.class, false);
+ return (AnnotationTester)tester;
+ }
+
+ protected AnnotationTester getHolder() throws Throwable
+ {
+ Object holder = util.getBean("Holder");
+ assertInstanceOf(holder, HolderAnnotationTester.class);
+ return (AnnotationTester)holder;
+ }
+
+ protected void doUndeploy()
+ {
+ util.undeploy();
+ util = null;
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/FactoryAnnotationOverrideTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/FactoryAnnotationOverrideTestCase.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/FactoryAnnotationOverrideTestCase.java 2007-08-17 13:09:36 UTC (rev 64649)
@@ -0,0 +1,66 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.annotations.test.override;
+
+import junit.framework.Test;
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.plugins.AbstractConstructorMetaData;
+import org.jboss.test.kernel.annotations.support.FactoryTesterCreator;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class FactoryAnnotationOverrideTestCase extends AbstractAnnotationOverrideTestCase
+{
+ public FactoryAnnotationOverrideTestCase(String name) throws Throwable
+ {
+ super(name);
+ }
+
+ public FactoryAnnotationOverrideTestCase(String name, boolean xmltest)
+ {
+ super(name, xmltest);
+ }
+
+ public static Test suite()
+ {
+ return suite(FactoryAnnotationOverrideTestCase.class);
+ }
+
+ protected String getType()
+ {
+ return "Factory";
+ }
+
+ protected void addMetaData(AbstractBeanMetaData beanMetaData)
+ {
+ AbstractConstructorMetaData constructor = new AbstractConstructorMetaData();
+ constructor.setFactoryClass(FactoryTesterCreator.class.getName());
+ constructor.setFactoryMethod("fromXML");
+ beanMetaData.setConstructor(constructor);
+ }
+
+ public void testFactoryOverride() throws Throwable
+ {
+ checkOverride();
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/InstallationAnnotationOverrideTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/InstallationAnnotationOverrideTestCase.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/InstallationAnnotationOverrideTestCase.java 2007-08-17 13:09:36 UTC (rev 64649)
@@ -0,0 +1,109 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.annotations.test.override;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Test;
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.plugins.AbstractInstallMetaData;
+import org.jboss.beans.metadata.spi.InstallMetaData;
+import org.jboss.dependency.spi.Controller;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.test.kernel.annotations.support.AnnotationTester;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class InstallationAnnotationOverrideTestCase extends AbstractAnnotationOverrideTestCase
+{
+ private Controller controller;
+ private ControllerContext context;
+
+ public InstallationAnnotationOverrideTestCase(String name) throws Throwable
+ {
+ super(name);
+ }
+
+ public InstallationAnnotationOverrideTestCase(String name, boolean xmltest)
+ {
+ super(name, xmltest);
+ }
+
+ public static Test suite()
+ {
+ return suite(InstallationAnnotationOverrideTestCase.class);
+ }
+
+ protected String getType()
+ {
+ return "Installation";
+ }
+
+ protected void addMetaData(AbstractBeanMetaData beanMetaData)
+ {
+ List<InstallMetaData> installs = new ArrayList<InstallMetaData>();
+ AbstractInstallMetaData in = new AbstractInstallMetaData();
+ in.setMethodName("addMyDeployer");
+ installs.add(in);
+ List<InstallMetaData> uninstalls = new ArrayList<InstallMetaData>();
+ AbstractInstallMetaData un = new AbstractInstallMetaData();
+ un.setMethodName("removeMyDeployer");
+ uninstalls.add(un);
+ beanMetaData.setInstalls(installs);
+ beanMetaData.setUninstalls(uninstalls);
+ }
+
+ public void testCallbackOverride() throws Throwable
+ {
+ AnnotationTester tester = getTester();
+ Object val = tester.getValue();
+ assertInstanceOf(val, Integer.class);
+ Integer count = (Integer)val;
+ assertNotNull(count);
+ assertEquals(1, count.intValue());
+
+ doUndeploy();
+
+ val = tester.getValue();
+ assertInstanceOf(val, Integer.class);
+ count = (Integer)val;
+ assertNotNull(count);
+ assertEquals(0, count.intValue());
+ }
+
+ protected void afterInstall(KernelController controller, KernelControllerContext context) throws Throwable
+ {
+ this.controller = controller;
+ this.context = context;
+ }
+
+ protected void doUndeploy()
+ {
+ controller.uninstall(context.getName());
+ controller = null;
+ context = null;
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/InstallationAnnotationOverrideXMLTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/InstallationAnnotationOverrideXMLTestCase.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/InstallationAnnotationOverrideXMLTestCase.java 2007-08-17 13:09:36 UTC (rev 64649)
@@ -0,0 +1,58 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.annotations.test.override;
+
+import junit.framework.Test;
+import org.jboss.test.kernel.annotations.support.AnnotationTester;
+import org.jboss.test.kernel.config.support.XMLUtil;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class InstallationAnnotationOverrideXMLTestCase extends InstallationAnnotationOverrideTestCase
+{
+ private XMLUtil util;
+
+ public InstallationAnnotationOverrideXMLTestCase(String name) throws Throwable
+ {
+ super(name, true);
+ }
+
+ public static Test suite()
+ {
+ return suite(InstallationAnnotationOverrideXMLTestCase.class);
+ }
+
+ protected AnnotationTester getTester() throws Throwable
+ {
+ util = bootstrapXML(true);
+ Object tester = util.getBean(getTesterName());
+ assertInstanceOf(tester, AnnotationTester.class, false);
+ return (AnnotationTester)tester;
+ }
+
+ protected void doUndeploy()
+ {
+ util.undeploy();
+ util = null;
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/LifecycleAnnotationOverrideTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/LifecycleAnnotationOverrideTestCase.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/LifecycleAnnotationOverrideTestCase.java 2007-08-17 13:09:36 UTC (rev 64649)
@@ -0,0 +1,93 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.annotations.test.override;
+
+import junit.framework.Test;
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.plugins.AbstractLifecycleMetaData;
+import org.jboss.test.kernel.annotations.support.AnnotationTester;
+import org.jboss.dependency.spi.Controller;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class LifecycleAnnotationOverrideTestCase extends AbstractAnnotationOverrideTestCase
+{
+ private Controller controller;
+ private ControllerContext context;
+
+ public LifecycleAnnotationOverrideTestCase(String name) throws Throwable
+ {
+ super(name);
+ }
+
+ public LifecycleAnnotationOverrideTestCase(String name, boolean xmltest)
+ {
+ super(name, xmltest);
+ }
+
+ public static Test suite()
+ {
+ return suite(LifecycleAnnotationOverrideTestCase.class);
+ }
+
+ protected String getType()
+ {
+ return "Lifecycle";
+ }
+
+ protected void addMetaData(AbstractBeanMetaData beanMetaData)
+ {
+ beanMetaData.setCreate(new AbstractLifecycleMetaData("fromXMLCreate"));
+ beanMetaData.setStart(new AbstractLifecycleMetaData("fromXMLStart"));
+ beanMetaData.setStop(new AbstractLifecycleMetaData("fromXMLStop"));
+ beanMetaData.setDestroy(new AbstractLifecycleMetaData("fromXMLDestroy"));
+ }
+
+ public void testLifecycleOverride() throws Throwable
+ {
+ AnnotationTester tester = getTester();
+ Object[] values = (Object[])tester.getValue();
+ assertEquals(new Object[]{FROM_XML, FROM_XML, null, null}, values);
+
+ doUndeploy();
+
+ values = (Object[])tester.getValue();
+ assertEquals(new Object[]{null, null, FROM_XML, FROM_XML}, values);
+ }
+
+ protected void afterInstall(KernelController controller, KernelControllerContext context)
+ {
+ this.controller = controller;
+ this.context = context;
+ }
+
+ protected void doUndeploy()
+ {
+ controller.uninstall(context.getName());
+ controller = null;
+ context = null;
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/LifecycleAnnotationOverrideXMLTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/LifecycleAnnotationOverrideXMLTestCase.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/LifecycleAnnotationOverrideXMLTestCase.java 2007-08-17 13:09:36 UTC (rev 64649)
@@ -0,0 +1,58 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.annotations.test.override;
+
+import junit.framework.Test;
+import org.jboss.test.kernel.config.support.XMLUtil;
+import org.jboss.test.kernel.annotations.support.AnnotationTester;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class LifecycleAnnotationOverrideXMLTestCase extends LifecycleAnnotationOverrideTestCase
+{
+ private XMLUtil util;
+
+ public LifecycleAnnotationOverrideXMLTestCase(String name) throws Throwable
+ {
+ super(name, true);
+ }
+
+ public static Test suite()
+ {
+ return suite(LifecycleAnnotationOverrideXMLTestCase.class);
+ }
+
+ protected AnnotationTester getTester() throws Throwable
+ {
+ util = bootstrapXML(true);
+ Object tester = util.getBean(getTesterName());
+ assertInstanceOf(tester, AnnotationTester.class, false);
+ return (AnnotationTester)tester;
+ }
+
+ protected void doUndeploy()
+ {
+ util.undeploy();
+ util = null;
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/PropertyAnnotationOverrideTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/PropertyAnnotationOverrideTestCase.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/PropertyAnnotationOverrideTestCase.java 2007-08-17 13:09:36 UTC (rev 64649)
@@ -0,0 +1,62 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.annotations.test.override;
+
+import junit.framework.Test;
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.plugins.AbstractPropertyMetaData;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class PropertyAnnotationOverrideTestCase extends AbstractAnnotationOverrideTestCase
+{
+ public PropertyAnnotationOverrideTestCase(String name) throws Throwable
+ {
+ super(name);
+ }
+
+ public PropertyAnnotationOverrideTestCase(String name, boolean xmltest)
+ {
+ super(name, xmltest);
+ }
+
+ public static Test suite()
+ {
+ return suite(PropertyAnnotationOverrideTestCase.class);
+ }
+
+ protected String getType()
+ {
+ return "Property";
+ }
+
+ protected void addMetaData(AbstractBeanMetaData beanMetaData)
+ {
+ beanMetaData.addProperty(new AbstractPropertyMetaData("value", "FromXML"));
+ }
+
+ public void testPropertyOverride() throws Throwable
+ {
+ checkOverride();
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/PropertyAnnotationOverrideXMLTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/PropertyAnnotationOverrideXMLTestCase.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/PropertyAnnotationOverrideXMLTestCase.java 2007-08-17 13:09:36 UTC (rev 64649)
@@ -0,0 +1,40 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.annotations.test.override;
+
+import junit.framework.Test;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class PropertyAnnotationOverrideXMLTestCase extends PropertyAnnotationOverrideTestCase
+{
+ public PropertyAnnotationOverrideXMLTestCase(String name) throws Throwable
+ {
+ super(name, true);
+ }
+
+ public static Test suite()
+ {
+ return suite(PropertyAnnotationOverrideXMLTestCase.class);
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/SetsAnnotationOverrideTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/SetsAnnotationOverrideTestCase.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/SetsAnnotationOverrideTestCase.java 2007-08-17 13:09:36 UTC (rev 64649)
@@ -0,0 +1,105 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.annotations.test.override;
+
+import java.util.Collections;
+import java.util.Set;
+import java.util.HashSet;
+
+import junit.framework.Test;
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.plugins.AbstractDemandMetaData;
+import org.jboss.beans.metadata.plugins.AbstractDependencyMetaData;
+import org.jboss.beans.metadata.plugins.AbstractSupplyMetaData;
+import org.jboss.beans.metadata.spi.DemandMetaData;
+import org.jboss.beans.metadata.spi.DependencyMetaData;
+import org.jboss.beans.metadata.spi.SupplyMetaData;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.test.kernel.annotations.support.MyDeployer;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class SetsAnnotationOverrideTestCase extends AbstractAnnotationOverrideTestCase
+{
+ private KernelControllerContext context;
+
+ public SetsAnnotationOverrideTestCase(String name) throws Throwable
+ {
+ super(name);
+ }
+
+ public SetsAnnotationOverrideTestCase(String name, boolean xmltest)
+ {
+ super(name, xmltest);
+ }
+
+ public static Test suite()
+ {
+ return suite(SetsAnnotationOverrideTestCase.class);
+ }
+
+ protected String getType()
+ {
+ return "Sets";
+ }
+
+ protected void addMetaData(AbstractBeanMetaData beanMetaData)
+ {
+ Set<DemandMetaData> demands = Collections.singleton((DemandMetaData)new AbstractDemandMetaData("deployer"));
+ beanMetaData.setDemands(new HashSet<DemandMetaData>(demands));
+
+ Set<DependencyMetaData> depends = Collections.singleton((DependencyMetaData)new AbstractDependencyMetaData("deployer"));
+ beanMetaData.setDepends(new HashSet<DependencyMetaData>(depends));
+
+ Set<SupplyMetaData> supplys = Collections.singleton((SupplyMetaData)new AbstractSupplyMetaData("somesupply"));
+ beanMetaData.setSupplies(new HashSet<SupplyMetaData>(supplys));
+ }
+
+ public void testSetsOverride() throws Throwable
+ {
+ getTester();
+ BeanMetaData beanMetaData = getBeanMetaData();
+ assertSet(beanMetaData.getDemands());
+ assertSet(beanMetaData.getDepends());
+ assertSet(beanMetaData.getSupplies());
+ }
+
+ protected BeanMetaData getBeanMetaData()
+ {
+ return context.getBeanMetaData();
+ }
+
+ protected void assertSet(Set set)
+ {
+ assertNotNull(set);
+ assertEquals(1, set.size());
+ }
+
+ protected void afterInstall(KernelController controller, KernelControllerContext context) throws Throwable
+ {
+ controller.install(new AbstractBeanMetaData("deployer", MyDeployer.class.getName()));
+ this.context = context;
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/SetsAnnotationOverrideXMLTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/SetsAnnotationOverrideXMLTestCase.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/override/SetsAnnotationOverrideXMLTestCase.java 2007-08-17 13:09:36 UTC (rev 64649)
@@ -0,0 +1,63 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.annotations.test.override;
+
+import junit.framework.Test;
+import org.jboss.test.kernel.annotations.support.AnnotationTester;
+import org.jboss.test.kernel.config.support.XMLUtil;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class SetsAnnotationOverrideXMLTestCase extends SetsAnnotationOverrideTestCase
+{
+ private XMLUtil util;
+
+ public SetsAnnotationOverrideXMLTestCase(String name) throws Throwable
+ {
+ super(name, true);
+ }
+
+ public static Test suite()
+ {
+ return suite(SetsAnnotationOverrideXMLTestCase.class);
+ }
+
+ protected AnnotationTester getTester() throws Throwable
+ {
+ util = bootstrapXML(true);
+ Object tester = util.getBean(getTesterName());
+ assertInstanceOf(tester, AnnotationTester.class, false);
+ return (AnnotationTester)tester;
+ }
+
+ protected BeanMetaData getBeanMetaData()
+ {
+ KernelController kc = util.getKernel().getController();
+ KernelControllerContext context = (KernelControllerContext)kc.getInstalledContext(getTesterName());
+ assertNotNull(context);
+ return context.getBeanMetaData();
+ }
+}
Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/AbstractKernelConfigTest.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/AbstractKernelConfigTest.java 2007-08-17 09:22:21 UTC (rev 64648)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/config/test/AbstractKernelConfigTest.java 2007-08-17 13:09:36 UTC (rev 64649)
@@ -114,9 +114,14 @@
KernelControllerContext kernelControllerContext = controller.install(metaData);
if (expectedState != null)
assertEquals(expectedState, kernelControllerContext.getState());
+ afterInstall(controller, kernelControllerContext);
return kernelControllerContext.getTarget();
}
+ protected void afterInstall(KernelController controller, KernelControllerContext context) throws Throwable
+ {
+ }
+
protected Object instantiate(KernelConfigurator configurator, BeanMetaData metaData) throws Throwable
{
Joinpoint joinPoint = configurator.getConstructorJoinPoint(metaData);
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/AbstractOnDemandDeploymentTest.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/AbstractOnDemandDeploymentTest.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/AbstractOnDemandDeploymentTest.java 2007-08-17 13:09:36 UTC (rev 64649)
@@ -0,0 +1,55 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.deployment.test;
+
+import org.jboss.test.kernel.junit.MicrocontainerTest;
+import org.jboss.test.kernel.junit.MicrocontainerTestDelegate;
+import org.jboss.test.AbstractTestDelegate;
+import org.jboss.dependency.spi.ControllerMode;
+
+/**
+ * Abstract Deployment Test Case.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class AbstractOnDemandDeploymentTest extends MicrocontainerTest
+{
+ public AbstractOnDemandDeploymentTest(String name)
+ {
+ super(name);
+ }
+
+ public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
+ {
+ MicrocontainerTestDelegate delegate = (MicrocontainerTestDelegate) MicrocontainerTest.getDelegate(clazz);
+ delegate.setDefaultMode(ControllerMode.ON_DEMAND);
+ delegate.enableSecurity = true;
+ return delegate;
+ }
+
+ protected void configureLogging()
+ {
+ //enableTrace("org.jboss.dependency");
+ //enableTrace("org.jboss.kernel.plugins.dependency");
+ //enableTrace("org.jboss.kernel.plugins.deployment");
+ }
+}
More information about the jboss-cvs-commits
mailing list