[jboss-cvs] JBossAS SVN: r66759 - in projects/metadata/trunk/src: main/java/org/jboss/annotation/ear and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Nov 6 02:40:09 EST 2007
Author: scott.stark at jboss.org
Date: 2007-11-06 02:40:09 -0500 (Tue, 06 Nov 2007)
New Revision: 66759
Added:
projects/metadata/trunk/src/main/java/org/jboss/annotation/ear/
projects/metadata/trunk/src/main/java/org/jboss/annotation/ear/Ear.java
projects/metadata/trunk/src/main/java/org/jboss/annotation/ear/Module.java
projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/package-info.java
projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/repository/
projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/repository/MetaDataRepositoryUnitTestCase.java
Log:
Simple annotation tests
Added: projects/metadata/trunk/src/main/java/org/jboss/annotation/ear/Ear.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/annotation/ear/Ear.java (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/annotation/ear/Ear.java 2007-11-06 07:40:09 UTC (rev 66759)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, 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.annotation.ear;
+
+/**
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public @interface Ear
+{
+ String description() default "";
+ Module[] modules();
+ String libraryDirectory() default "";
+}
Property changes on: projects/metadata/trunk/src/main/java/org/jboss/annotation/ear/Ear.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Added: projects/metadata/trunk/src/main/java/org/jboss/annotation/ear/Module.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/annotation/ear/Module.java (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/annotation/ear/Module.java 2007-11-06 07:40:09 UTC (rev 66759)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, 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.annotation.ear;
+
+import org.jboss.metadata.ear.spec.ModuleMetaData.ModuleType;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public @interface Module
+{
+ /** The module archive file */
+ String fileName();
+ /** The optional module id */
+ String id() default "";
+ /** The type of module */
+ ModuleType type();
+}
Property changes on: projects/metadata/trunk/src/main/java/org/jboss/annotation/ear/Module.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Added: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/package-info.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/package-info.java (rev 0)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/package-info.java 2007-11-06 07:40:09 UTC (rev 66759)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, 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.
+ */
+ at Ear(description="An annotated ear",
+ modules={
+ @Module(id="connector0", fileName="rar0.rar", type=ModuleType.Connector),
+ @Module(id="ejb0", fileName="ejb0.jar", type=ModuleType.Ejb),
+ @Module(id="java0", fileName="client0.jar", type=ModuleType.Client),
+ @Module(id="web0", fileName="web0.war", type=ModuleType.Web),
+ @Module(id="sar0", fileName="sar0.rar", type=ModuleType.Service)
+ }
+)
+package org.jboss.test.metadata.annotation;
+
+import org.jboss.annotation.ear.Ear;
+import org.jboss.annotation.ear.Module;
+import org.jboss.metadata.ear.spec.ModuleMetaData.ModuleType;
Property changes on: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/package-info.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Added: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/repository/MetaDataRepositoryUnitTestCase.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/repository/MetaDataRepositoryUnitTestCase.java (rev 0)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/repository/MetaDataRepositoryUnitTestCase.java 2007-11-06 07:40:09 UTC (rev 66759)
@@ -0,0 +1,124 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, 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.metadata.annotation.repository;
+
+import java.lang.reflect.AnnotatedElement;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.jboss.metadata.annotation.creator.EjbJar30Creator;
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.annotation.finder.DefaultAnnotationFinder;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+import org.jboss.metadata.ejb.jboss.proxy.JBossMetaDataProxy;
+import org.jboss.metadata.ejb.spec.EjbJar30MetaData;
+import org.jboss.metadata.ejb.spec.EjbJarMetaData;
+import org.jboss.metadata.ejb.spec.EnterpriseBeanMetaData;
+import org.jboss.metadata.ejb.spec.SessionBeanMetaData;
+import org.jboss.metadata.ejb.spec.SessionType;
+import org.jboss.metadata.plugins.loader.memory.MemoryMetaDataLoader;
+import org.jboss.metadata.plugins.loader.reflection.AnnotatedElementMetaDataLoader;
+import org.jboss.metadata.plugins.repository.basic.BasicMetaDataRepository;
+import org.jboss.metadata.spi.MetaData;
+import org.jboss.metadata.spi.scope.CommonLevels;
+import org.jboss.metadata.spi.scope.ScopeKey;
+
+/**
+ * Tests of annotation/metadata interaction via the MetaDataRepository
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class MetaDataRepositoryUnitTestCase extends TestCase
+{
+ private static BasicMetaDataRepository repository = new BasicMetaDataRepository();
+
+ /**
+ * Test of how deployers would populate the MetaDataRepository
+ *
+ */
+ public void testMemoryMetaDataLoader()
+ throws Exception
+ {
+ Class[] beanClasses = {
+ Class.forName("org.jboss.test.metadata.annotation.ejb3.MyStatelessBean"),
+ Class.forName("org.jboss.test.metadata.annotation.ejb3.MyStatefulBean")
+ };
+ List<Class> classes = Arrays.asList(beanClasses);
+ createMetaDataFromAnnotations("ejb0.jar", classes);
+
+ ScopeKey jarKey = new ScopeKey(CommonLevels.DEPLOYMENT, "ejb0.jar");
+ MetaData md = repository.getMetaData(jarKey);
+ EjbJarMetaData jarMD = md.getMetaData(EjbJarMetaData.class);
+ assertNotNull(jarMD);
+ EnterpriseBeanMetaData beanMD = jarMD.getEnterpriseBean("MyStatelessBean");
+ assertNotNull(beanMD);
+ assertEquals(true, beanMD.isSession());
+ assertTrue(beanMD instanceof SessionBeanMetaData);
+ SessionBeanMetaData sbeanMD = (SessionBeanMetaData) beanMD;
+ assertEquals(SessionType.Stateless, sbeanMD.getSessionType());
+ }
+
+ /**
+ * Test of the jboss proxy view delegating to the MetaDataRepository
+ * annotation standard metadata
+ *
+ */
+ public void testAnnotationMetaData()
+ throws Exception
+ {
+ Class[] beanClasses = {
+ Class.forName("org.jboss.test.metadata.annotation.ejb3.MyStatelessBean"),
+ Class.forName("org.jboss.test.metadata.annotation.ejb3.MyStatefulBean")
+ };
+ List<Class> classes = Arrays.asList(beanClasses);
+ createMetaDataFromAnnotations("ejb0.jar", classes);
+
+ ScopeKey jarKey = new ScopeKey(CommonLevels.DEPLOYMENT, "ejb0.jar");
+ JBossMetaData xmlMetaData = new JBossMetaData();
+ JBossMetaDataProxy proxy = new JBossMetaDataProxy(xmlMetaData, repository, jarKey);
+ JBossEnterpriseBeanMetaData beanMD = proxy.getEnterpriseBean("MyStatelessBean");
+ assertNotNull(beanMD);
+ assertEquals(true, beanMD.isSession());
+ assertTrue(beanMD instanceof JBossSessionBeanMetaData);
+ JBossSessionBeanMetaData sbeanMD = (JBossSessionBeanMetaData) beanMD;
+ assertEquals(SessionType.Stateless, sbeanMD.getSessionType());
+ }
+
+ protected void createMetaDataFromAnnotations(String jarName, Collection<Class> classes)
+ {
+ ScopeKey jarKey = new ScopeKey(CommonLevels.DEPLOYMENT, jarName);
+ MemoryMetaDataLoader loader = new MemoryMetaDataLoader(jarKey);
+ repository.addMetaDataRetrieval(loader);
+
+ AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>();
+ EjbJar30Creator creator = new EjbJar30Creator(finder);
+ EjbJar30MetaData metaData = creator.create(classes);
+ loader.addMetaData(metaData, EjbJarMetaData.class);
+ repository.addMetaDataRetrieval(loader);
+ }
+}
Property changes on: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/repository/MetaDataRepositoryUnitTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
More information about the jboss-cvs-commits
mailing list