[jboss-cvs] JBossAS SVN: r105240 - in projects/mc-script/trunk/src: test/java/org/jboss/test/beans and 7 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed May 26 05:53:37 EDT 2010
Author: alesj
Date: 2010-05-26 05:53:36 -0400 (Wed, 26 May 2010)
New Revision: 105240
Added:
projects/mc-script/trunk/src/test/java/org/jboss/test/beans/AllTestSuite.java
projects/mc-script/trunk/src/test/java/org/jboss/test/beans/mock/
projects/mc-script/trunk/src/test/java/org/jboss/test/beans/mock/AbstractMockTest.java
projects/mc-script/trunk/src/test/java/org/jboss/test/beans/mock/MockTestDelegate.java
projects/mc-script/trunk/src/test/java/org/jboss/test/beans/mock/MockTestSuite.java
projects/mc-script/trunk/src/test/java/org/jboss/test/beans/mock/support/
projects/mc-script/trunk/src/test/java/org/jboss/test/beans/mock/support/IBean.java
projects/mc-script/trunk/src/test/java/org/jboss/test/beans/mock/support/MockBean.java
projects/mc-script/trunk/src/test/java/org/jboss/test/beans/mock/test/
projects/mc-script/trunk/src/test/java/org/jboss/test/beans/mock/test/MockSmokeTestCase.java
projects/mc-script/trunk/src/test/resources/org/jboss/test/beans/mock/
projects/mc-script/trunk/src/test/resources/org/jboss/test/beans/mock/test/
projects/mc-script/trunk/src/test/resources/org/jboss/test/beans/mock/test/MockSmokeTestCase.xml
Modified:
projects/mc-script/trunk/src/main/java/org/jboss/beans/mock/MockMetaData.java
projects/mc-script/trunk/src/test/java/org/jboss/test/beans/script/AbstractScriptTest.java
Log:
Mock tests.
Modified: projects/mc-script/trunk/src/main/java/org/jboss/beans/mock/MockMetaData.java
===================================================================
--- projects/mc-script/trunk/src/main/java/org/jboss/beans/mock/MockMetaData.java 2010-05-26 07:23:48 UTC (rev 105239)
+++ projects/mc-script/trunk/src/main/java/org/jboss/beans/mock/MockMetaData.java 2010-05-26 09:53:36 UTC (rev 105240)
@@ -28,6 +28,7 @@
import javax.xml.bind.annotation.XmlType;
import java.util.Collections;
+import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -64,6 +65,11 @@
public List<BeanMetaData> getBeans()
{
Set<AnnotationMetaData> annotations = super.getAnnotations();
+ if (annotations == null)
+ {
+ annotations = new HashSet<AnnotationMetaData>();
+ setAnnotations(annotations);
+ }
AnnotationMetaData mock = new DirectAnnotationMetaData(new MockImpl(mockCode));
annotations.add(mock);
return Collections.singletonList((BeanMetaData)this);
Added: projects/mc-script/trunk/src/test/java/org/jboss/test/beans/AllTestSuite.java
===================================================================
--- projects/mc-script/trunk/src/test/java/org/jboss/test/beans/AllTestSuite.java (rev 0)
+++ projects/mc-script/trunk/src/test/java/org/jboss/test/beans/AllTestSuite.java 2010-05-26 09:53:36 UTC (rev 105240)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.beans;
+
+import org.jboss.test.beans.mock.MockTestSuite;
+import org.jboss.test.beans.script.ScriptTestSuite;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * All test suite.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class AllTestSuite extends TestSuite
+{
+ public static void main(String[] args)
+ {
+ TestRunner.run(suite());
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("All Tests");
+
+ suite.addTest(MockTestSuite.suite());
+ suite.addTest(ScriptTestSuite.suite());
+
+ return suite;
+ }
+}
\ No newline at end of file
Copied: projects/mc-script/trunk/src/test/java/org/jboss/test/beans/mock/AbstractMockTest.java (from rev 104079, projects/mc-script/trunk/src/test/java/org/jboss/test/beans/script/AbstractScriptTest.java)
===================================================================
--- projects/mc-script/trunk/src/test/java/org/jboss/test/beans/mock/AbstractMockTest.java (rev 0)
+++ projects/mc-script/trunk/src/test/java/org/jboss/test/beans/mock/AbstractMockTest.java 2010-05-26 09:53:36 UTC (rev 105240)
@@ -0,0 +1,53 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat Middleware LLC, and individual contributors
+* 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.beans.mock;
+
+import org.jboss.test.AbstractTestDelegate;
+import org.jboss.test.beans.script.ScriptTestDelegate;
+import org.jboss.test.kernel.junit.MicrocontainerTest;
+
+/**
+ * A mock test.
+ *
+ * @author <a href="ales.justin at jboss.org">Ales Justin</a>
+ */
+public abstract class AbstractMockTest extends MicrocontainerTest
+{
+ protected AbstractMockTest(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Default setup with security manager disabled
+ *
+ * @param clazz the class
+ * @return the delegate
+ * @throws Exception for any error
+ */
+ public static AbstractTestDelegate getDelegate(Class<?> clazz) throws Exception
+ {
+ AbstractTestDelegate delegate = new MockTestDelegate(clazz);
+ //delegate.enableSecurity = true;
+ return delegate;
+ }
+}
\ No newline at end of file
Copied: projects/mc-script/trunk/src/test/java/org/jboss/test/beans/mock/MockTestDelegate.java (from rev 104079, projects/mc-script/trunk/src/test/java/org/jboss/test/beans/script/ScriptTestDelegate.java)
===================================================================
--- projects/mc-script/trunk/src/test/java/org/jboss/test/beans/mock/MockTestDelegate.java (rev 0)
+++ projects/mc-script/trunk/src/test/java/org/jboss/test/beans/mock/MockTestDelegate.java 2010-05-26 09:53:36 UTC (rev 105240)
@@ -0,0 +1,52 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.beans.mock;
+
+import org.jboss.beans.mock.MockMetaData;
+import org.jboss.test.kernel.junit.MicrocontainerTestDelegate;
+import org.jboss.xb.binding.resolver.MutableSchemaResolver;
+import org.jboss.xb.binding.sunday.unmarshalling.SingletonSchemaResolverFactory;
+
+/**
+ * MockTestDelegate.
+ *
+ * @author <a href="ales.justin at jboss.org">Ales Justin</a>
+ */
+public class MockTestDelegate extends MicrocontainerTestDelegate
+{
+ static
+ {
+ MutableSchemaResolver resolver = SingletonSchemaResolverFactory.getInstance().getSchemaBindingResolver();
+ resolver.mapURIToClass("urn:jboss:bean-deployer:mock:2.0", MockMetaData.class);
+ }
+
+ /**
+ * Create a new ScriptTestDelegate.
+ *
+ * @param clazz the class
+ * @throws Exception for any error
+ */
+ public MockTestDelegate(Class<?> clazz) throws Exception
+ {
+ super(clazz);
+ }
+}
\ No newline at end of file
Copied: projects/mc-script/trunk/src/test/java/org/jboss/test/beans/mock/MockTestSuite.java (from rev 104079, projects/mc-script/trunk/src/test/java/org/jboss/test/beans/script/ScriptTestSuite.java)
===================================================================
--- projects/mc-script/trunk/src/test/java/org/jboss/test/beans/mock/MockTestSuite.java (rev 0)
+++ projects/mc-script/trunk/src/test/java/org/jboss/test/beans/mock/MockTestSuite.java 2010-05-26 09:53:36 UTC (rev 105240)
@@ -0,0 +1,51 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.beans.mock;
+
+import org.jboss.test.beans.mock.test.MockSmokeTestCase;
+import org.jboss.test.beans.script.test.*;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * Mock Test Suite.
+ *
+ * @author <a href="ales.justin at jboss.org">Ales Justin</a>
+ */
+public class MockTestSuite extends TestSuite
+{
+ public static void main(String[] args)
+ {
+ TestRunner.run(suite());
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("Mock Tests");
+
+ suite.addTest(MockSmokeTestCase.suite());
+
+ return suite;
+ }
+}
\ No newline at end of file
Added: projects/mc-script/trunk/src/test/java/org/jboss/test/beans/mock/support/IBean.java
===================================================================
--- projects/mc-script/trunk/src/test/java/org/jboss/test/beans/mock/support/IBean.java (rev 0)
+++ projects/mc-script/trunk/src/test/java/org/jboss/test/beans/mock/support/IBean.java 2010-05-26 09:53:36 UTC (rev 105240)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.beans.mock.support;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public interface IBean
+{
+ Object getValue();
+}
\ No newline at end of file
Added: projects/mc-script/trunk/src/test/java/org/jboss/test/beans/mock/support/MockBean.java
===================================================================
--- projects/mc-script/trunk/src/test/java/org/jboss/test/beans/mock/support/MockBean.java (rev 0)
+++ projects/mc-script/trunk/src/test/java/org/jboss/test/beans/mock/support/MockBean.java 2010-05-26 09:53:36 UTC (rev 105240)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.beans.mock.support;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class MockBean implements IBean
+{
+ private Object value;
+
+ public Object getValue()
+ {
+ return value;
+ }
+
+ public void setValue(Object value)
+ {
+ this.value = value;
+ }
+}
Added: projects/mc-script/trunk/src/test/java/org/jboss/test/beans/mock/test/MockSmokeTestCase.java
===================================================================
--- projects/mc-script/trunk/src/test/java/org/jboss/test/beans/mock/test/MockSmokeTestCase.java (rev 0)
+++ projects/mc-script/trunk/src/test/java/org/jboss/test/beans/mock/test/MockSmokeTestCase.java 2010-05-26 09:53:36 UTC (rev 105240)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.beans.mock.test;
+
+import org.jboss.test.beans.mock.AbstractMockTest;
+import org.jboss.test.beans.mock.support.IBean;
+
+import junit.framework.Test;
+
+/**
+ * Simple smoke tests.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class MockSmokeTestCase extends AbstractMockTest
+{
+ public MockSmokeTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return suite(MockSmokeTestCase.class);
+ }
+
+ public void testBasics() throws Exception
+ {
+ IBean bean = assertBean("bean", IBean.class);
+ assertNull(bean.getValue()); // by default injection is ignored
+ }
+}
Modified: projects/mc-script/trunk/src/test/java/org/jboss/test/beans/script/AbstractScriptTest.java
===================================================================
--- projects/mc-script/trunk/src/test/java/org/jboss/test/beans/script/AbstractScriptTest.java 2010-05-26 07:23:48 UTC (rev 105239)
+++ projects/mc-script/trunk/src/test/java/org/jboss/test/beans/script/AbstractScriptTest.java 2010-05-26 09:53:36 UTC (rev 105240)
@@ -30,9 +30,9 @@
* @author <a href="adrian at jboss.com">Adrian Brock</a>
* @version $Revision: 86846 $
*/
-public class AbstractScriptTest extends MicrocontainerTest
+public abstract class AbstractScriptTest extends MicrocontainerTest
{
- public AbstractScriptTest(String name)
+ protected AbstractScriptTest(String name)
{
super(name);
}
Added: projects/mc-script/trunk/src/test/resources/org/jboss/test/beans/mock/test/MockSmokeTestCase.xml
===================================================================
--- projects/mc-script/trunk/src/test/resources/org/jboss/test/beans/mock/test/MockSmokeTestCase.xml (rev 0)
+++ projects/mc-script/trunk/src/test/resources/org/jboss/test/beans/mock/test/MockSmokeTestCase.xml 2010-05-26 09:53:36 UTC (rev 105240)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+ <mock xmlns="urn:jboss:bean-deployer:mock:2.0" name="bean" class="org.jboss.test.beans.mock.support.MockBean">
+ <property name="value">otherValue</property>
+ </mock>
+</deployment>
More information about the jboss-cvs-commits
mailing list