aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From timothyjw...@apache.org
Subject svn commit: r1153489 - in /aries/trunk/ejb/ejb-modeller: ./ src/main/java/org/apache/aries/ejb/modelling/impl/ src/test/java/org/apache/aries/ejb/modelling/impl/ src/test/java/test/ejbs/ src/test/resources/
Date Wed, 03 Aug 2011 13:48:52 GMT
Author: timothyjward
Date: Wed Aug  3 13:48:50 2011
New Revision: 1153489

URL: http://svn.apache.org/viewvc?rev=1153489&view=rev
Log:
ARIES-718: model EJB services from Web apps

Added:
    aries/trunk/ejb/ejb-modeller/src/test/resources/MANIFEST_3.MF
    aries/trunk/ejb/ejb-modeller/src/test/resources/MANIFEST_4.MF
Modified:
    aries/trunk/ejb/ejb-modeller/   (props changed)
    aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/OpenEJBLocator.java
    aries/trunk/ejb/ejb-modeller/src/test/java/org/apache/aries/ejb/modelling/impl/EJBLocatorTest.java
    aries/trunk/ejb/ejb-modeller/src/test/java/test/ejbs/StatefulSessionBean.java
    aries/trunk/ejb/ejb-modeller/src/test/java/test/ejbs/StatelessSessionBean.java

Propchange: aries/trunk/ejb/ejb-modeller/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Aug  3 13:48:50 2011
@@ -0,0 +1 @@
+target

Modified: aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/OpenEJBLocator.java
URL: http://svn.apache.org/viewvc/aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/OpenEJBLocator.java?rev=1153489&r1=1153488&r2=1153489&view=diff
==============================================================================
--- aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/OpenEJBLocator.java
(original)
+++ aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/OpenEJBLocator.java
Wed Aug  3 13:48:50 2011
@@ -78,9 +78,12 @@ public class OpenEJBLocator implements E
   public void findEJBs(BundleManifest manifest, IDirectory bundle,
       EJBRegistry registry) throws ModellerException {
 
+    String ejbJarLocation = (manifest.getRawAttributes().getValue(
+        "Web-ContextPath") == null) ? "META-INF/ejb-jar.xml" : "WEB-INF/ejb-jar.xml";
+    
     try {
       //If we have an ejb-jar.xml then parse it 
-      IFile file = bundle.getFile("META-INF/ejb-jar.xml");
+      IFile file = bundle.getFile(ejbJarLocation);
       EjbJar ejbJar = (file == null) ? new EjbJar() : ReadDescriptors.readEjbJar(file.toURL());
       
       EjbModule module = new EjbModule(ejbJar);

Modified: aries/trunk/ejb/ejb-modeller/src/test/java/org/apache/aries/ejb/modelling/impl/EJBLocatorTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/ejb/ejb-modeller/src/test/java/org/apache/aries/ejb/modelling/impl/EJBLocatorTest.java?rev=1153489&r1=1153488&r2=1153489&view=diff
==============================================================================
--- aries/trunk/ejb/ejb-modeller/src/test/java/org/apache/aries/ejb/modelling/impl/EJBLocatorTest.java
(original)
+++ aries/trunk/ejb/ejb-modeller/src/test/java/org/apache/aries/ejb/modelling/impl/EJBLocatorTest.java
Wed Aug  3 13:48:50 2011
@@ -98,8 +98,8 @@ public class EJBLocatorTest {
     ByteArrayOutputStream baos = new ByteArrayOutputStream();
     ZipOutputStream zos = new ZipOutputStream(baos);
     addToZip(zos, "ejb-jar.xml", "META-INF/ejb-jar.xml");
-    addToZip(zos, "test/ejb/StatelessSessionBean.class", "no/test/ejb/StatelessSessionBean.class");
-    addToZip(zos, "test/ejb/StatefulSessionBean.class", "no/test/ejb/StatefulSessionBean.class");
+    addToZip(zos, "test/ejbs/StatelessSessionBean.class", "no/test/ejb/StatelessSessionBean.class");
+    addToZip(zos, "test/ejbs/StatefulSessionBean.class", "no/test/ejb/StatefulSessionBean.class");
     zos.close();
     
     runTest(baos.toByteArray(), "MANIFEST_2.MF");
@@ -108,6 +108,81 @@ public class EJBLocatorTest {
     assertAnnotation(false);
   }
 
+  
+  @Test
+  public void testEJBJARInWebZip() throws Exception {
+
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    ZipOutputStream zos = new ZipOutputStream(baos);
+    addToZip(zos, "ejb-jar.xml", "WEB-INF/ejb-jar.xml");
+    zos.close();
+    
+    runTest(baos.toByteArray(), "MANIFEST_3.MF");
+    
+    assertXML(true);
+    assertAnnotation(false);
+  }
+
+  @Test
+  public void testEJBJARInWrongPlaceWebZip() throws Exception {
+
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    ZipOutputStream zos = new ZipOutputStream(baos);
+    addToZip(zos, "ejb-jar.xml", "META-INF/ejb-jar.xml");
+    zos.close();
+    
+    runTest(baos.toByteArray(), "MANIFEST_3.MF");
+    
+    assertXML(false);
+    assertAnnotation(false);
+  }
+  
+  @Test
+  public void testEJBJARAndAnnotatedInWebZip() throws Exception {
+
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    ZipOutputStream zos = new ZipOutputStream(baos);
+    addToZip(zos, "ejb-jar.xml", "WEB-INF/ejb-jar.xml");
+    addToZip(zos, "test/ejbs/StatelessSessionBean.class");
+    addToZip(zos, "test/ejbs/StatefulSessionBean.class");
+    zos.close();
+    
+    runTest(baos.toByteArray(), "MANIFEST_3.MF");
+    
+    assertXML(true);
+    assertAnnotation(true);
+  }
+  
+  @Test
+  public void testAnnotatedOnlyInWebZip() throws Exception {
+
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    ZipOutputStream zos = new ZipOutputStream(baos);
+    addToZip(zos, "test/ejbs/StatelessSessionBean.class");
+    addToZip(zos, "test/ejbs/StatefulSessionBean.class");
+    zos.close();
+    
+    runTest(baos.toByteArray(), "MANIFEST_3.MF");
+    
+    assertXML(false);
+    assertAnnotation(true);
+  }
+  
+  @Test
+  public void testEJBJARAndAnnotatedNotOnClasspathInWebZip() throws Exception {
+
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    ZipOutputStream zos = new ZipOutputStream(baos);
+    addToZip(zos, "ejb-jar.xml", "WEB-INF/ejb-jar.xml");
+    addToZip(zos, "test/ejbs/StatelessSessionBean.class", "no/test/ejb/StatelessSessionBean.class");
+    addToZip(zos, "test/ejbs/StatefulSessionBean.class", "no/test/ejb/StatefulSessionBean.class");
+    zos.close();
+    
+    runTest(baos.toByteArray(), "MANIFEST_4.MF");
+    
+    assertXML(true);
+    assertAnnotation(false);
+  }
   private void runTest(byte[] zip, String manifest) throws ModellerException,
       IOException {
     ICloseableDirectory icd = FileSystem.getFSRoot(new 
@@ -124,7 +199,7 @@ public class EJBLocatorTest {
   private void addToZip(ZipOutputStream zos, String src, String outLocation) throws IOException
{
     zos.putNextEntry(new ZipEntry(outLocation));
     IOUtils.copy(getClass().getClassLoader().
-        getResourceAsStream("ejb-jar.xml"), zos);
+        getResourceAsStream(src), zos);
     zos.closeEntry();
   }
   

Modified: aries/trunk/ejb/ejb-modeller/src/test/java/test/ejbs/StatefulSessionBean.java
URL: http://svn.apache.org/viewvc/aries/trunk/ejb/ejb-modeller/src/test/java/test/ejbs/StatefulSessionBean.java?rev=1153489&r1=1153488&r2=1153489&view=diff
==============================================================================
--- aries/trunk/ejb/ejb-modeller/src/test/java/test/ejbs/StatefulSessionBean.java (original)
+++ aries/trunk/ejb/ejb-modeller/src/test/java/test/ejbs/StatefulSessionBean.java Wed Aug
 3 13:48:50 2011
@@ -1,3 +1,19 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
 package test.ejbs;
 
 import javax.ejb.Stateful;

Modified: aries/trunk/ejb/ejb-modeller/src/test/java/test/ejbs/StatelessSessionBean.java
URL: http://svn.apache.org/viewvc/aries/trunk/ejb/ejb-modeller/src/test/java/test/ejbs/StatelessSessionBean.java?rev=1153489&r1=1153488&r2=1153489&view=diff
==============================================================================
--- aries/trunk/ejb/ejb-modeller/src/test/java/test/ejbs/StatelessSessionBean.java (original)
+++ aries/trunk/ejb/ejb-modeller/src/test/java/test/ejbs/StatelessSessionBean.java Wed Aug
 3 13:48:50 2011
@@ -1,3 +1,19 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
 package test.ejbs;
 
 import javax.ejb.Stateless;

Added: aries/trunk/ejb/ejb-modeller/src/test/resources/MANIFEST_3.MF
URL: http://svn.apache.org/viewvc/aries/trunk/ejb/ejb-modeller/src/test/resources/MANIFEST_3.MF?rev=1153489&view=auto
==============================================================================
--- aries/trunk/ejb/ejb-modeller/src/test/resources/MANIFEST_3.MF (added)
+++ aries/trunk/ejb/ejb-modeller/src/test/resources/MANIFEST_3.MF Wed Aug  3 13:48:50 2011
@@ -0,0 +1,4 @@
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: foo
+Web-ContextPath: test
+

Added: aries/trunk/ejb/ejb-modeller/src/test/resources/MANIFEST_4.MF
URL: http://svn.apache.org/viewvc/aries/trunk/ejb/ejb-modeller/src/test/resources/MANIFEST_4.MF?rev=1153489&view=auto
==============================================================================
--- aries/trunk/ejb/ejb-modeller/src/test/resources/MANIFEST_4.MF (added)
+++ aries/trunk/ejb/ejb-modeller/src/test/resources/MANIFEST_4.MF Wed Aug  3 13:48:50 2011
@@ -0,0 +1,5 @@
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: foo
+Bundle-ClassPath: yes
+Web-ContextPath: test
+



Mime
View raw message