[jboss-cvs] JBossAS SVN: r65898 - in projects/microcontainer/trunk/kernel/src: resources/tests/org/jboss/test/kernel/inject/test and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sat Oct 6 15:48:31 EDT 2007
Author: alesj
Date: 2007-10-06 15:48:31 -0400 (Sat, 06 Oct 2007)
New Revision: 65898
Added:
projects/microcontainer/trunk/kernel/src/main/org/jboss/test/kernel/junit/WiredMicrocontainerTest.java
projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/WiredTestTestCase.xml
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/WiredTestTestCase.java
Modified:
projects/microcontainer/trunk/kernel/src/main/org/jboss/test/kernel/junit/MicrocontainerTest.java
Log:
Adding wired test.
The test itself is installed as a bean into underlying controller.
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/test/kernel/junit/MicrocontainerTest.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/test/kernel/junit/MicrocontainerTest.java 2007-10-06 18:48:59 UTC (rev 65897)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/test/kernel/junit/MicrocontainerTest.java 2007-10-06 19:48:31 UTC (rev 65898)
@@ -63,8 +63,18 @@
protected void setUp() throws Exception
{
super.setUp();
+ afterSetUp();
+ }
+
+ /**
+ * Configure after set up.
+ *
+ * @throws Exception for any error
+ */
+ protected void afterSetUp() throws Exception
+ {
configureLogging();
- // Validate everything deployed
+ // Validate everything deployed
getMCDelegate().validate();
}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/test/kernel/junit/WiredMicrocontainerTest.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/test/kernel/junit/WiredMicrocontainerTest.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/test/kernel/junit/WiredMicrocontainerTest.java 2007-10-06 19:48:31 UTC (rev 65898)
@@ -0,0 +1,100 @@
+/*
+* 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.junit;
+
+import java.util.UUID;
+
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+
+/**
+ * A Wired MicrocontainerTest.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 64256 $
+ */
+public abstract class WiredMicrocontainerTest extends MicrocontainerTest
+{
+ /** The bean name */
+ private String beanName = createTestBeanName();
+
+ /**
+ * Create a new Wired Microcontainer test
+ *
+ * @param name the test name
+ */
+ protected WiredMicrocontainerTest(String name)
+ {
+ super(name);
+ }
+
+ protected void afterSetUp() throws Exception
+ {
+ KernelController controller = getController();
+ try
+ {
+ controller.install(new AbstractBeanMetaData(beanName, getClass().getName()), this);
+ }
+ catch (Throwable t)
+ {
+ throw new Exception(t);
+ }
+ super.afterSetUp();
+ }
+
+ private KernelController getController()
+ {
+ MicrocontainerTestDelegate delegate = getMCDelegate();
+ Kernel kernel = delegate.kernel;
+ return kernel.getController();
+ }
+
+ protected void tearDown() throws Exception
+ {
+ KernelController controller = getController();
+ controller.uninstall(beanName);
+ super.tearDown();
+ }
+
+ /**
+ * Get the test's bean name.
+ * By default it's random uuid.
+ *
+ * @return test's bean name
+ */
+ protected String createTestBeanName()
+ {
+ return UUID.randomUUID().toString();
+ }
+
+ /**
+ * Get the test's bean name.
+ * By default it's what create method returns.
+ *
+ * @return test's bean name
+ */
+ protected String getTestBeanName()
+ {
+ return beanName;
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/WiredTestTestCase.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/WiredTestTestCase.xml (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/WiredTestTestCase.xml 2007-10-06 19:48:31 UTC (rev 65898)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_2_0.xsd"
+ xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="gso" class="org.jboss.test.kernel.inject.support.StringValueObject">
+ <constructor>
+ <parameter>SomeString</parameter>
+ </constructor>
+ </bean>
+
+ <bean name="tester1" class="org.jboss.test.kernel.inject.support.DuplicateTester"/>
+
+</deployment>
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/WiredTestTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/WiredTestTestCase.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/WiredTestTestCase.java 2007-10-06 19:48:31 UTC (rev 65898)
@@ -0,0 +1,74 @@
+/*
+* 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.inject.test;
+
+import org.jboss.test.kernel.junit.WiredMicrocontainerTest;
+import org.jboss.test.kernel.inject.support.TesterInterface;
+import org.jboss.test.kernel.inject.support.StringValueObject;
+import org.jboss.beans.metadata.api.annotations.Inject;
+import junit.framework.Test;
+
+/**
+ * Test wired test. :-)
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class WiredTestTestCase extends WiredMicrocontainerTest
+{
+ private TesterInterface tester;
+ private StringValueObject valueObject;
+ private boolean lifecycleExecuted = false;
+
+ public WiredTestTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return suite(WiredTestTestCase.class);
+ }
+
+ public void start()
+ {
+ lifecycleExecuted = true;
+ }
+
+ @Inject
+ public void setTester(TesterInterface tester)
+ {
+ this.tester = tester;
+ }
+
+ @Inject
+ public void setValueObject(StringValueObject valueObject)
+ {
+ this.valueObject = valueObject;
+ }
+
+ public void testWiredTest() throws Throwable
+ {
+ assertTrue(lifecycleExecuted);
+ assertNotNull(tester);
+ assertNotNull(valueObject);
+ }
+}
More information about the jboss-cvs-commits
mailing list