Author: timothyjward
Date: Mon Aug 8 08:40:19 2011
New Revision: 1154869
URL: http://svn.apache.org/viewvc?rev=1154869&view=rev
Log:
ARIES-718 iTests for EJB modelling using OpenEJB
Added:
aries/trunk/ejb/ejb-modeller-itest/
aries/trunk/ejb/ejb-modeller-itest/pom.xml
aries/trunk/ejb/ejb-modeller-itest/src/
aries/trunk/ejb/ejb-modeller-itest/src/test/
aries/trunk/ejb/ejb-modeller-itest/src/test/java/
aries/trunk/ejb/ejb-modeller-itest/src/test/java/beans/
aries/trunk/ejb/ejb-modeller-itest/src/test/java/beans/StatefulSessionBean.java
aries/trunk/ejb/ejb-modeller-itest/src/test/java/beans/StatelessSessionBean.java
aries/trunk/ejb/ejb-modeller-itest/src/test/java/org/
aries/trunk/ejb/ejb-modeller-itest/src/test/java/org/apache/
aries/trunk/ejb/ejb-modeller-itest/src/test/java/org/apache/aries/
aries/trunk/ejb/ejb-modeller-itest/src/test/java/org/apache/aries/ejb/
aries/trunk/ejb/ejb-modeller-itest/src/test/java/org/apache/aries/ejb/container/
aries/trunk/ejb/ejb-modeller-itest/src/test/java/org/apache/aries/ejb/container/itest/
aries/trunk/ejb/ejb-modeller-itest/src/test/java/org/apache/aries/ejb/container/itest/EJBModellingTest.java
aries/trunk/ejb/ejb-modeller-itest/src/test/resources/
aries/trunk/ejb/ejb-modeller-itest/src/test/resources/MANIFEST_1.MF
aries/trunk/ejb/ejb-modeller-itest/src/test/resources/MANIFEST_2.MF
aries/trunk/ejb/ejb-modeller-itest/src/test/resources/MANIFEST_3.MF
aries/trunk/ejb/ejb-modeller-itest/src/test/resources/MANIFEST_4.MF
aries/trunk/ejb/ejb-modeller-itest/src/test/resources/ejb-jar.xml
aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/IDirectoryFinder.java
Modified:
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/pom.xml
Added: aries/trunk/ejb/ejb-modeller-itest/pom.xml
URL:
http://svn.apache.org/viewvc/aries/trunk/ejb/ejb-modeller-itest/pom.xml?rev=1154869&view=auto
==============================================================================
--- aries/trunk/ejb/ejb-modeller-itest/pom.xml (added)
+++ aries/trunk/ejb/ejb-modeller-itest/pom.xml Mon Aug 8 08:40:19 2011
@@ -0,0 +1,421 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.apache.aries</groupId>
+ <artifactId>java5-parent</artifactId>
+ <version>0.4.1-SNAPSHOT</version>
+ <relativePath />
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.aries.ejb</groupId>
+ <artifactId>org.apache.aries.ejb.modeller.itest</artifactId>
+ <version>0.1-SNAPSHOT</version>
+ <name>Aries EJB Modelling iTests</name>
+
+ <scm>
+
<connection>scm:svn:http://svn.apache.org/repos/asf/aries/trunk/ejb/ejb-modeller-itest</connection>
+
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/aries/trunk/ejb/ejb-modeller-itest</developerConnection>
+
<url>http://svn.apache.org/viewvc/aries/trunk/ejb/ejb-modeller-itest</url>
+ </scm>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.logging</groupId>
+ <artifactId>pax-logging-api</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.logging</groupId>
+ <artifactId>pax-logging-service</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.runner</groupId>
+ <artifactId>pax-runner-no-jcl</artifactId>
+ <version>1.7.3</version>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-container-default</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.aries</groupId>
+ <artifactId>org.apache.aries.util</artifactId>
+ <version>0.4-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.aries.proxy</groupId>
+ <artifactId>org.apache.aries.proxy</artifactId>
+ <version>0.4-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>asm</groupId>
+ <artifactId>asm-all</artifactId>
+ <version>3.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.aries.blueprint</groupId>
+ <artifactId>org.apache.aries.blueprint</artifactId>
+ <version>0.3.2-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.url</groupId>
+ <artifactId>pax-url-mvn</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.aries.testsupport</groupId>
+ <artifactId>org.apache.aries.testsupport.unit</artifactId>
+ <version>0.3.1-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.aries.application</groupId>
+ <artifactId>org.apache.aries.application.api</artifactId>
+ <version>0.3.1-SNAPSHOT</version>
+ <type>bundle</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.aries.application</groupId>
+ <artifactId>org.apache.aries.application.modeller</artifactId>
+ <version>0.3.1-SNAPSHOT</version>
+ <type>pom</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.aries.application</groupId>
+ <artifactId>org.apache.aries.application.utils</artifactId>
+ <version>0.3.1-SNAPSHOT</version>
+ <type>bundle</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.aries.ejb</groupId>
+ <artifactId>org.apache.aries.ejb.modeller</artifactId>
+ <version>0.1-SNAPSHOT</version>
+ <type>bundle</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ <type>jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-api</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ <type>jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-javaagent</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ <type>jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-jee</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ <type>pom</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-loader</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ <type>pom</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicemix.bundles</groupId>
+ <artifactId>org.apache.servicemix.bundles.javassist</artifactId>
+ <version>3.12.1.ga_1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-annotation_1.1_spec</artifactId>
+ <version>1.0.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-ejb_3.1_spec</artifactId>
+ <version>1.0.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jcdi_1.0_spec</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-el_2.2_spec</artifactId>
+ <version>1.0.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jta_1.1_spec</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jaxrpc_1.1_spec</artifactId>
+ <version>2.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-atinject_1.0_spec</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-servlet_3.0_spec</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jsp_2.2_spec</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-interceptor_1.1_spec</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-saaj_1.3_spec</artifactId>
+ <version>1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-activation_1.1_spec</artifactId>
+ <version>1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-j2ee-management_1.1_spec</artifactId>
+ <version>1.0.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jpa_2.0_spec</artifactId>
+ <version>1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-j2ee-connector_1.6_spec</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jacc_1.4_spec</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-validation_1.0_spec</artifactId>
+ <version>1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jaxrs_1.1_spec</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicemix.bundles</groupId>
+
<artifactId>org.apache.servicemix.bundles.wsdl4j-1.6.1</artifactId>
+ <version>4.0-m1</version>
+ <type>bundle</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-cli</groupId>
+ <artifactId>commons-cli</artifactId>
+ <version>1.2</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>2.6</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.components</groupId>
+ <artifactId>geronimo-connector</artifactId>
+ <version>3.0</version>
+ <type>bundle</type>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.components</groupId>
+ <artifactId>geronimo-transaction</artifactId>
+ <version>3.0</version>
+ <type>bundle</type>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.openwebbeans</groupId>
+ <artifactId>openwebbeans-spi</artifactId>
+ <version>1.1.1-SNAPSHOT</version>
+ <type>jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openwebbeans</groupId>
+ <artifactId>openwebbeans-impl</artifactId>
+ <version>1.1.1-SNAPSHOT</version>
+ <type>jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openwebbeans</groupId>
+ <artifactId>openwebbeans-ee</artifactId>
+ <version>1.1.1-SNAPSHOT</version>
+ <type>jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openwebbeans</groupId>
+ <artifactId>openwebbeans-ejb</artifactId>
+ <version>1.1.1-SNAPSHOT</version>
+ <type>jar</type>
+ <scope>test-SNAPSHOT</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openwebbeans</groupId>
+ <artifactId>openwebbeans-web</artifactId>
+ <version>1.1.1-SNAPSHOT</version>
+ <type>jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.bundles</groupId>
+ <artifactId>scannotation</artifactId>
+ <version>1.0.2_1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.xbean</groupId>
+ <artifactId>xbean-asm-shaded</artifactId>
+ <version>3.8-SNAPSHOT</version>
+ <type>bundle</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.xbean</groupId>
+ <artifactId>xbean-finder-shaded</artifactId>
+ <version>3.8-SNAPSHOT</version>
+ <type>bundle</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.xbean</groupId>
+ <artifactId>xbean-naming</artifactId>
+ <version>3.8-SNAPSHOT</version>
+ <type>bundle</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.xbean</groupId>
+ <artifactId>xbean-reflect</artifactId>
+ <version>3.8-SNAPSHOT</version>
+ <type>bundle</type>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.servicemix.tooling</groupId>
+ <artifactId>depends-maven-plugin</artifactId>
+ <version>1.2</version>
+ <executions>
+ <execution>
+ <id>generate-depends-file</id>
+ <goals>
+ <goal>generate-depends-file</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>ci-build-profile</id>
+ <activation>
+ <property>
+ <name>maven.repo.local</name>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <!--
+ when the local repo location has been specified,
we need
+ to pass on this information to PAX mvn url
+ -->
+
<argLine>-Dorg.ops4j.pax.url.mvn.localRepository=${maven.repo.local}
+ </argLine>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+</project>
Added:
aries/trunk/ejb/ejb-modeller-itest/src/test/java/beans/StatefulSessionBean.java
URL:
http://svn.apache.org/viewvc/aries/trunk/ejb/ejb-modeller-itest/src/test/java/beans/StatefulSessionBean.java?rev=1154869&view=auto
==============================================================================
---
aries/trunk/ejb/ejb-modeller-itest/src/test/java/beans/StatefulSessionBean.java
(added)
+++
aries/trunk/ejb/ejb-modeller-itest/src/test/java/beans/StatefulSessionBean.java
Mon Aug 8 08:40:19 2011
@@ -0,0 +1,24 @@
+/**
+ * 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 beans;
+
+import javax.ejb.Stateful;
+
+@Stateful(name="Stateful")
+public class StatefulSessionBean {
+
+}
Added:
aries/trunk/ejb/ejb-modeller-itest/src/test/java/beans/StatelessSessionBean.java
URL:
http://svn.apache.org/viewvc/aries/trunk/ejb/ejb-modeller-itest/src/test/java/beans/StatelessSessionBean.java?rev=1154869&view=auto
==============================================================================
---
aries/trunk/ejb/ejb-modeller-itest/src/test/java/beans/StatelessSessionBean.java
(added)
+++
aries/trunk/ejb/ejb-modeller-itest/src/test/java/beans/StatelessSessionBean.java
Mon Aug 8 08:40:19 2011
@@ -0,0 +1,24 @@
+/**
+ * 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 beans;
+
+import javax.ejb.Stateless;
+
+@Stateless(name="Annotated")
+public class StatelessSessionBean {
+
+}
Added:
aries/trunk/ejb/ejb-modeller-itest/src/test/java/org/apache/aries/ejb/container/itest/EJBModellingTest.java
URL:
http://svn.apache.org/viewvc/aries/trunk/ejb/ejb-modeller-itest/src/test/java/org/apache/aries/ejb/container/itest/EJBModellingTest.java?rev=1154869&view=auto
==============================================================================
---
aries/trunk/ejb/ejb-modeller-itest/src/test/java/org/apache/aries/ejb/container/itest/EJBModellingTest.java
(added)
+++
aries/trunk/ejb/ejb-modeller-itest/src/test/java/org/apache/aries/ejb/container/itest/EJBModellingTest.java
Mon Aug 8 08:40:19 2011
@@ -0,0 +1,434 @@
+/* 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 org.apache.aries.ejb.container.itest;
+
+import static org.apache.aries.itest.ExtraOptions.mavenBundle;
+import static org.apache.aries.itest.ExtraOptions.paxLogging;
+import static org.apache.aries.itest.ExtraOptions.testOptions;
+import static org.apache.aries.itest.ExtraOptions.transactionBootDelegation;
+import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.vmOption;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.ops4j.pax.exam.CoreOptions.equinox;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+import org.apache.aries.application.modelling.ExportedService;
+import org.apache.aries.application.modelling.ModelledResource;
+import org.apache.aries.application.modelling.ModelledResourceManager;
+import org.apache.aries.application.modelling.ModellerException;
+import org.apache.aries.application.modelling.ModellingManager;
+import org.apache.aries.application.modelling.ServiceModeller;
+import org.apache.aries.itest.AbstractIntegrationTest;
+import org.apache.aries.util.filesystem.FileSystem;
+import org.apache.aries.util.filesystem.ICloseableDirectory;
+import org.apache.aries.util.io.IOUtils;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+
+@RunWith(JUnit4TestRunner.class)
+public class EJBModellingTest extends AbstractIntegrationTest {
+
+ private ModelledResourceManager mrm;
+ private ModellingManager mm;
+
+ @Before
+ public void setup() {
+ mrm = context().getService(ModelledResourceManager.class);
+ mm = context().getService(ModellingManager.class);
+ }
+
+ @Test
+ public void modelBasicEJBBundleWithXML() throws Exception {
+ context().getService(ServiceModeller.class);
+ ModelledResource mr = null;
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ZipOutputStream zos = new ZipOutputStream(baos);
+ addToZip(zos, "MANIFEST_1.MF", "META-INF/MANIFEST.MF");
+ addToZip(zos, "ejb-jar.xml", "META-INF/ejb-jar.xml");
+ zos.close();
+ mr = model(baos.toByteArray());
+
+ Collection<? extends ExportedService> services =
+ mr.getExportedServices();
+
+ assertEquals("Wrong number of services", 2, services.size());
+
+ assertTrue(services.containsAll(getXMLservices()));
+ assertTrue(Collections.disjoint(services, getAnnotatedservices()));
+ }
+
+ @Test
+ public void testEJBJARAndAnnotatedInZip() throws Exception {
+ context().getService(ServiceModeller.class);
+ ModelledResource mr = null;
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ZipOutputStream zos = new ZipOutputStream(baos);
+ addToZip(zos, "MANIFEST_1.MF", "META-INF/MANIFEST.MF");
+ addToZip(zos, "ejb-jar.xml", "META-INF/ejb-jar.xml");
+ addToZip(zos, "beans/StatelessSessionBean.class");
+ addToZip(zos, "beans/StatefulSessionBean.class");
+ zos.close();
+
+ mr = model(baos.toByteArray());
+
+ Collection<? extends ExportedService> services =
+ mr.getExportedServices();
+
+ assertEquals("Wrong number of services", 3, services.size());
+
+ assertTrue(services.containsAll(getXMLservices()));
+ assertTrue(services.containsAll(getAnnotatedservices()));
+ }
+
+ @Test
+ public void testAnnotatedOnlyInZip() throws Exception {
+ context().getService(ServiceModeller.class);
+ ModelledResource mr = null;
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ZipOutputStream zos = new ZipOutputStream(baos);
+ addToZip(zos, "MANIFEST_1.MF", "META-INF/MANIFEST.MF");
+ addToZip(zos, "beans/StatelessSessionBean.class");
+ addToZip(zos, "beans/StatefulSessionBean.class");
+ zos.close();
+
+ mr = model(baos.toByteArray());
+
+ Collection<? extends ExportedService> services =
+ mr.getExportedServices();
+
+ assertEquals("Wrong number of services", 1, services.size());
+
+ assertTrue(Collections.disjoint(services, getXMLservices()));
+ assertTrue(services.containsAll(getAnnotatedservices()));
+ }
+
+ @Test
+ public void testEJBJARAndAnnotatedNotOnClasspathInZip() throws Exception {
+
+ context().getService(ServiceModeller.class);
+ ModelledResource mr = null;
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ZipOutputStream zos = new ZipOutputStream(baos);
+ addToZip(zos, "MANIFEST_2.MF", "META-INF/MANIFEST.MF");
+ addToZip(zos, "ejb-jar.xml", "META-INF/ejb-jar.xml");
+ addToZip(zos, "beans/StatelessSessionBean.class",
"no/beans/StatelessSessionBean.class");
+ addToZip(zos, "beans/StatefulSessionBean.class",
"no/beans/StatefulSessionBean.class");
+ zos.close();
+
+ mr = model(baos.toByteArray());
+
+ Collection<? extends ExportedService> services =
+ mr.getExportedServices();
+
+ assertEquals("Wrong number of services", 2, services.size());
+
+ assertTrue(services.containsAll(getXMLservices()));
+ assertTrue(Collections.disjoint(services, getAnnotatedservices()));
+ }
+
+ @Test
+ public void testEJBJARAndAnnotatedOnClasspathInZip() throws Exception {
+
+ context().getService(ServiceModeller.class);
+ ModelledResource mr = null;
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ZipOutputStream zos = new ZipOutputStream(baos);
+ addToZip(zos, "MANIFEST_2.MF", "META-INF/MANIFEST.MF");
+ addToZip(zos, "ejb-jar.xml", "META-INF/ejb-jar.xml");
+ addToZip(zos, "beans/StatelessSessionBean.class",
"yes/beans/StatelessSessionBean.class");
+ addToZip(zos, "beans/StatefulSessionBean.class",
"yes/beans/StatefulSessionBean.class");
+ zos.close();
+
+ mr = model(baos.toByteArray());
+
+ Collection<? extends ExportedService> services =
+ mr.getExportedServices();
+
+ assertEquals("Wrong number of services", 3, services.size());
+
+ assertTrue(services.containsAll(getXMLservices()));
+ assertTrue(services.containsAll(getAnnotatedservices()));
+ }
+
+ @Test
+ public void testEJBJARInWebZip() throws Exception {
+
+ context().getService(ServiceModeller.class);
+ ModelledResource mr = null;
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ZipOutputStream zos = new ZipOutputStream(baos);
+ addToZip(zos, "MANIFEST_3.MF", "META-INF/MANIFEST.MF");
+ addToZip(zos, "ejb-jar.xml", "WEB-INF/ejb-jar.xml");
+ zos.close();
+
+ mr = model(baos.toByteArray());
+
+ Collection<? extends ExportedService> services =
+ mr.getExportedServices();
+
+ assertEquals("Wrong number of services", 2, services.size());
+
+ assertTrue(services.containsAll(getXMLservices()));
+ assertTrue(Collections.disjoint(services, getAnnotatedservices()));
+ }
+
+ @Test
+ public void testEJBJARInWrongPlaceWebZip() throws Exception {
+
+ context().getService(ServiceModeller.class);
+ ModelledResource mr = null;
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ZipOutputStream zos = new ZipOutputStream(baos);
+ addToZip(zos, "MANIFEST_3.MF", "META-INF/MANIFEST.MF");
+ addToZip(zos, "ejb-jar.xml", "META-INF/ejb-jar.xml");
+ zos.close();
+
+ mr = model(baos.toByteArray());
+
+ Collection<? extends ExportedService> services =
+ mr.getExportedServices();
+
+ assertEquals("Wrong number of services", 0, services.size());
+ }
+
+ @Test
+ public void testEJBJARAndAnnotatedInWebZip() throws Exception {
+
+ context().getService(ServiceModeller.class);
+ ModelledResource mr = null;
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ZipOutputStream zos = new ZipOutputStream(baos);
+ addToZip(zos, "MANIFEST_3.MF", "META-INF/MANIFEST.MF");
+ addToZip(zos, "ejb-jar.xml", "WEB-INF/ejb-jar.xml");
+ addToZip(zos, "beans/StatelessSessionBean.class");
+ addToZip(zos, "beans/StatefulSessionBean.class");
+ zos.close();
+
+ mr = model(baos.toByteArray());
+
+ Collection<? extends ExportedService> services =
+ mr.getExportedServices();
+
+ assertEquals("Wrong number of services", 3, services.size());
+
+ assertTrue(services.containsAll(getXMLservices()));
+ assertTrue(services.containsAll(getAnnotatedservices()));
+ }
+
+ @Test
+ public void testAnnotatedOnlyInWebZip() throws Exception {
+
+ context().getService(ServiceModeller.class);
+ ModelledResource mr = null;
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ZipOutputStream zos = new ZipOutputStream(baos);
+ addToZip(zos, "MANIFEST_3.MF", "META-INF/MANIFEST.MF");
+ addToZip(zos, "beans/StatelessSessionBean.class");
+ addToZip(zos, "beans/StatefulSessionBean.class");
+ zos.close();
+
+ mr = model(baos.toByteArray());
+
+ Collection<? extends ExportedService> services =
+ mr.getExportedServices();
+
+ assertEquals("Wrong number of services", 1, services.size());
+
+ assertTrue(Collections.disjoint(services, getXMLservices()));
+ assertTrue(services.containsAll(getAnnotatedservices()));
+ }
+
+ @Test
+ public void testEJBJARAndAnnotatedNotOnClasspathInWebZip() throws Exception {
+
+ context().getService(ServiceModeller.class);
+ ModelledResource mr = null;
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ZipOutputStream zos = new ZipOutputStream(baos);
+ addToZip(zos, "MANIFEST_4.MF", "META-INF/MANIFEST.MF");
+ addToZip(zos, "ejb-jar.xml", "WEB-INF/ejb-jar.xml");
+ addToZip(zos, "beans/StatelessSessionBean.class",
"no/beans/StatelessSessionBean.class");
+ addToZip(zos, "beans/StatefulSessionBean.class",
"no/beans/StatefulSessionBean.class");
+ zos.close();
+
+ mr = model(baos.toByteArray());
+
+ Collection<? extends ExportedService> services =
+ mr.getExportedServices();
+
+ assertEquals("Wrong number of services", 2, services.size());
+
+ assertTrue(services.containsAll(getXMLservices()));
+ assertTrue(Collections.disjoint(services, getAnnotatedservices()));
+ }
+
+ @Test
+ public void testEJBJARAndAnnotatedOnClasspathInWebZip() throws Exception {
+
+ context().getService(ServiceModeller.class);
+ ModelledResource mr = null;
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ZipOutputStream zos = new ZipOutputStream(baos);
+ addToZip(zos, "MANIFEST_4.MF", "META-INF/MANIFEST.MF");
+ addToZip(zos, "ejb-jar.xml", "WEB-INF/ejb-jar.xml");
+ addToZip(zos, "beans/StatelessSessionBean.class",
"yes/beans/StatelessSessionBean.class");
+ addToZip(zos, "beans/StatefulSessionBean.class",
"yes/beans/StatefulSessionBean.class");
+ zos.close();
+
+ mr = model(baos.toByteArray());
+
+ Collection<? extends ExportedService> services =
+ mr.getExportedServices();
+
+ assertEquals("Wrong number of services", 3, services.size());
+
+ assertTrue(services.containsAll(getXMLservices()));
+ assertTrue(services.containsAll(getAnnotatedservices()));
+ }
+
+ private ModelledResource model(byte[] bytes) throws ModellerException {
+ ICloseableDirectory dir = null;
+ try {
+ dir = FileSystem.getFSRoot(
+ new ByteArrayInputStream(bytes));
+ return mrm.getModelledResource(dir);
+ } finally {
+ IOUtils.close(dir);
+ }
+ }
+
+ private Collection<ExportedService> getXMLservices() {
+ Map<String, Object> serviceProperties = new HashMap<String, Object>();
+ serviceProperties.put("ejb.name", "XML");
+ serviceProperties.put("ejb.type", "Singleton");
+ serviceProperties.put("service.exported.interfaces", "remote.Iface");
+
+ Map<String, Object> serviceProperties2 = new HashMap<String, Object>();
+ serviceProperties2.put("ejb.name", "XML");
+ serviceProperties2.put("ejb.type", "Singleton");
+
+ return Arrays.asList(mm.getExportedService("XML", 0,
+ Arrays.asList("remote.Iface"), serviceProperties),
mm.getExportedService(
+ "XML", 0, Arrays.asList("local.Iface"), serviceProperties2));
+ }
+
+ private Collection<ExportedService> getAnnotatedservices() {
+ Map<String, Object> serviceProperties = new HashMap<String, Object>();
+ serviceProperties.put("ejb.name", "Annotated");
+ serviceProperties.put("ejb.type", "Stateless");
+
+ return Arrays.asList(mm.getExportedService("Annotated", 0,
+ Arrays.asList("beans.StatelessSessionBean"), serviceProperties));
+ }
+
+ private void addToZip(ZipOutputStream zos, String src) throws IOException {
+ addToZip(zos, src, src);
+ }
+
+ private void addToZip(ZipOutputStream zos, String src, String outLocation)
throws IOException {
+ zos.putNextEntry(new ZipEntry(outLocation));
+ IOUtils.copy(getClass().getClassLoader().
+ getResourceAsStream(src), zos);
+ zos.closeEntry();
+ }
+
+ @org.ops4j.pax.exam.junit.Configuration
+ public static Option[] configuration() {
+ return testOptions(
+ paxLogging("DEBUG"),
+ transactionBootDelegation(),
+ vmOption("-Dorg.osgi.framework.system.packages.extra=sun.misc"),
+ // Bundles
+ mavenBundle("org.apache.aries", "org.apache.aries.util"),
+ mavenBundle("org.apache.aries.blueprint",
"org.apache.aries.blueprint"),
+ mavenBundle("asm", "asm-all"),
+ mavenBundle("org.apache.aries.proxy", "org.apache.aries.proxy"),
+ mavenBundle("org.osgi", "org.osgi.compendium"),
+ mavenBundle("org.apache.aries.application",
"org.apache.aries.application.api"),
+ mavenBundle("org.apache.aries.application",
"org.apache.aries.application.modeller"),
+ mavenBundle("org.apache.aries.application",
"org.apache.aries.application.utils"),
+ mavenBundle("org.apache.aries.ejb", "org.apache.aries.ejb.modeller"),
+ mavenBundle("org.apache.openejb", "openejb-core"),
+ mavenBundle("org.apache.openejb", "openejb-api"),
+ mavenBundle("org.apache.openejb", "openejb-javaagent"),
+ mavenBundle("org.apache.openejb", "openejb-jee"),
+ mavenBundle("org.apache.openejb", "openejb-loader"),
+ mavenBundle("org.apache.openwebbeans", "openwebbeans-impl"),
+ mavenBundle("org.apache.openwebbeans", "openwebbeans-spi"),
+ mavenBundle("org.apache.openwebbeans", "openwebbeans-ee"),
+ mavenBundle("org.apache.openwebbeans", "openwebbeans-ejb"),
+ mavenBundle("org.apache.openwebbeans", "openwebbeans-web"),
+ mavenBundle("org.apache.servicemix.bundles",
"org.apache.servicemix.bundles.javassist"),
+ mavenBundle("org.apache.servicemix.bundles",
"org.apache.servicemix.bundles.wsdl4j-1.6.1"),
+ mavenBundle("org.apache.geronimo.specs",
"geronimo-annotation_1.1_spec"),
+ mavenBundle("org.apache.geronimo.specs", "geronimo-ejb_3.1_spec"),
+ mavenBundle("org.apache.geronimo.specs", "geronimo-jcdi_1.0_spec"),
+ mavenBundle("org.apache.geronimo.specs", "geronimo-el_2.2_spec"),
+ mavenBundle("org.apache.geronimo.specs", "geronimo-jta_1.1_spec"),
+ mavenBundle("org.apache.geronimo.specs", "geronimo-jaxrpc_1.1_spec"),
+ mavenBundle("org.apache.geronimo.specs", "geronimo-atinject_1.0_spec"),
+ mavenBundle("org.apache.geronimo.specs", "geronimo-servlet_3.0_spec"),
+ mavenBundle("org.apache.geronimo.specs", "geronimo-jsp_2.2_spec"),
+ mavenBundle("org.apache.geronimo.specs",
"geronimo-interceptor_1.1_spec"),
+ mavenBundle("org.apache.geronimo.specs", "geronimo-saaj_1.3_spec"),
+ mavenBundle("org.apache.geronimo.specs",
"geronimo-activation_1.1_spec"),
+ mavenBundle("org.apache.geronimo.specs",
"geronimo-j2ee-management_1.1_spec"),
+ mavenBundle("org.apache.geronimo.specs", "geronimo-jpa_2.0_spec"),
+ mavenBundle("org.apache.geronimo.specs",
"geronimo-j2ee-connector_1.6_spec"),
+ mavenBundle("org.apache.geronimo.specs", "geronimo-jacc_1.4_spec"),
+ mavenBundle("org.apache.geronimo.specs",
"geronimo-validation_1.0_spec"),
+ mavenBundle("org.apache.geronimo.specs", "geronimo-jaxrs_1.1_spec"),
+ mavenBundle("commons-cli", "commons-cli"),
+ mavenBundle("commons-lang", "commons-lang"),
+ mavenBundle("org.apache.geronimo.components", "geronimo-connector"),
+ mavenBundle("org.apache.geronimo.components", "geronimo-transaction"),
+ mavenBundle("org.apache.geronimo.bundles", "scannotation"),
+ mavenBundle("org.apache.xbean", "xbean-asm-shaded"),
+ mavenBundle("org.apache.xbean", "xbean-finder-shaded"),
+ mavenBundle("org.apache.xbean", "xbean-naming"),
+ mavenBundle("org.apache.xbean", "xbean-reflect"),
+// vmOption
("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5006"),
+// waitForFrameworkStartup(),
+
+
+ equinox().version("3.5.0"));
+ }
+
+}
Added: aries/trunk/ejb/ejb-modeller-itest/src/test/resources/MANIFEST_1.MF
URL:
http://svn.apache.org/viewvc/aries/trunk/ejb/ejb-modeller-itest/src/test/resources/MANIFEST_1.MF?rev=1154869&view=auto
==============================================================================
--- aries/trunk/ejb/ejb-modeller-itest/src/test/resources/MANIFEST_1.MF (added)
+++ aries/trunk/ejb/ejb-modeller-itest/src/test/resources/MANIFEST_1.MF Mon Aug
8 08:40:19 2011
@@ -0,0 +1,4 @@
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: foo
+Export-EJB: ALL
+
Added: aries/trunk/ejb/ejb-modeller-itest/src/test/resources/MANIFEST_2.MF
URL:
http://svn.apache.org/viewvc/aries/trunk/ejb/ejb-modeller-itest/src/test/resources/MANIFEST_2.MF?rev=1154869&view=auto
==============================================================================
--- aries/trunk/ejb/ejb-modeller-itest/src/test/resources/MANIFEST_2.MF (added)
+++ aries/trunk/ejb/ejb-modeller-itest/src/test/resources/MANIFEST_2.MF Mon Aug
8 08:40:19 2011
@@ -0,0 +1,5 @@
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: foo
+Bundle-ClassPath: yes
+Export-EJB: ALL
+
Added: aries/trunk/ejb/ejb-modeller-itest/src/test/resources/MANIFEST_3.MF
URL:
http://svn.apache.org/viewvc/aries/trunk/ejb/ejb-modeller-itest/src/test/resources/MANIFEST_3.MF?rev=1154869&view=auto
==============================================================================
--- aries/trunk/ejb/ejb-modeller-itest/src/test/resources/MANIFEST_3.MF (added)
+++ aries/trunk/ejb/ejb-modeller-itest/src/test/resources/MANIFEST_3.MF Mon Aug
8 08:40:19 2011
@@ -0,0 +1,5 @@
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: foo
+Export-EJB: ALL
+Web-ContextPath: test
+
Added: aries/trunk/ejb/ejb-modeller-itest/src/test/resources/MANIFEST_4.MF
URL:
http://svn.apache.org/viewvc/aries/trunk/ejb/ejb-modeller-itest/src/test/resources/MANIFEST_4.MF?rev=1154869&view=auto
==============================================================================
--- aries/trunk/ejb/ejb-modeller-itest/src/test/resources/MANIFEST_4.MF (added)
+++ aries/trunk/ejb/ejb-modeller-itest/src/test/resources/MANIFEST_4.MF Mon Aug
8 08:40:19 2011
@@ -0,0 +1,6 @@
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: foo
+Bundle-ClassPath: yes
+Export-EJB: ALL
+Web-ContextPath: test
+
Added: aries/trunk/ejb/ejb-modeller-itest/src/test/resources/ejb-jar.xml
URL:
http://svn.apache.org/viewvc/aries/trunk/ejb/ejb-modeller-itest/src/test/resources/ejb-jar.xml?rev=1154869&view=auto
==============================================================================
--- aries/trunk/ejb/ejb-modeller-itest/src/test/resources/ejb-jar.xml (added)
+++ aries/trunk/ejb/ejb-modeller-itest/src/test/resources/ejb-jar.xml Mon Aug
8 08:40:19 2011
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+ <!--
+ 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.
+ -->
+<ejb-jar version="3.1" xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+
http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd">
+
+<enterprise-beans>
+ <session>
+ <ejb-name>XML</ejb-name>
+ <business-local>local.Iface</business-local>
+ <business-remote>remote.Iface</business-remote>
+ <ejb-class>test.xml</ejb-class>
+ <session-type>Singleton</session-type>
+ </session>
+</enterprise-beans>
+</ejb-jar>
\ No newline at end of file
Added:
aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/IDirectoryFinder.java
URL:
http://svn.apache.org/viewvc/aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/IDirectoryFinder.java?rev=1154869&view=auto
==============================================================================
---
aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/IDirectoryFinder.java
(added)
+++
aries/trunk/ejb/ejb-modeller/src/main/java/org/apache/aries/ejb/modelling/impl/IDirectoryFinder.java
Mon Aug 8 08:40:19 2011
@@ -0,0 +1,97 @@
+package org.apache.aries.ejb.modelling.impl;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.List;
+
+import org.apache.aries.application.modelling.ModellerException;
+import org.apache.aries.util.filesystem.IDirectory;
+import org.apache.aries.util.filesystem.IFile;
+import org.apache.aries.util.io.IOUtils;
+import org.apache.xbean.finder.AbstractFinder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class IDirectoryFinder extends AbstractFinder {
+
+ private static final Logger logger =
LoggerFactory.getLogger(IDirectoryFinder.class);
+
+ private final List<IDirectory> cpEntries;
+
+ private final ClassLoader loader;
+
+ public IDirectoryFinder(ClassLoader parent, List<IDirectory> cp) throws
ModellerException {
+ cpEntries = cp;
+ loader = new ResourceClassLoader(parent, cpEntries);
+
+ for(IDirectory entry : cpEntries) {
+ for(IFile f : entry.listAllFiles()) {
+ if(f.getName().endsWith(".class")) {
+ try {
+ readClassDef(f.open());
+ } catch (Exception e) {
+ throw new ModellerException(e);
+ }
+ }
+ }
+ }
+ }
+
+ @Override
+ protected URL getResource(String arg0) {
+ return loader.getResource(arg0);
+ }
+
+ @Override
+ protected Class<?> loadClass(String arg0) throws ClassNotFoundException {
+ return loader.loadClass(arg0);
+ }
+
+
+ /**
+ * A ClassLoader used by OpenEJB in annotation scanning
+ */
+ public static class ResourceClassLoader extends ClassLoader {
+
+ private final List<IDirectory> classpath;
+ public ResourceClassLoader(ClassLoader cl, List<IDirectory> cpEntries) {
+ super(cl);
+ classpath = cpEntries;
+ }
+
+ @Override
+ protected URL findResource(String resName) {
+ for(IDirectory id : classpath) {
+ IFile f = id.getFile(resName);
+ if(f != null)
+ try {
+ return f.toURL();
+ } catch (MalformedURLException e) {
+ logger.error("Error getting URL for file " + f, e);
+ }
+ }
+ return null;
+ }
+
+ @Override
+ protected Class<?> findClass(String className)
+ throws ClassNotFoundException {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ try {
+ InputStream is = getResourceAsStream(
+ className.replace('.', '/') + ".class");
+ if(is == null)
+ throw new ClassNotFoundException(className);
+ IOUtils.copy(is, baos);
+
+ return defineClass(className, baos.toByteArray(), 0, baos.size());
+ } catch (IOException e) {
+ throw new ClassNotFoundException(className, e);
+ }
+ }
+ }
+}
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=1154869&r1=1154868&r2=1154869&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
Mon Aug 8 08:40:19 2011
@@ -16,14 +16,18 @@
*/
package org.apache.aries.ejb.modelling.impl;
+import java.io.IOException;
+import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
import org.apache.aries.application.modelling.ModellerException;
import org.apache.aries.ejb.modelling.EJBLocator;
import org.apache.aries.ejb.modelling.EJBRegistry;
+import org.apache.aries.util.filesystem.ICloseableDirectory;
import org.apache.aries.util.filesystem.IDirectory;
import org.apache.aries.util.filesystem.IFile;
import org.apache.aries.util.manifest.BundleManifest;
@@ -36,48 +40,113 @@ import org.apache.openejb.config.ReadDes
import org.apache.openejb.jee.EjbJar;
import org.apache.openejb.jee.EnterpriseBean;
import org.apache.openejb.jee.SessionBean;
-import org.apache.xbean.finder.ClassFinder;
import org.osgi.framework.Constants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* An {@link EJBLocator} that uses OpenEJB to find EJBs
- * @author Tim
*
*/
public class OpenEJBLocator implements EJBLocator {
private static final Logger logger =
LoggerFactory.getLogger(OpenEJBLocator.class);
-
- /**
- * A ClassLoader used by OpenEJB in annotation scanning
- */
- public static class ResourceClassLoader extends ClassLoader {
- private final List<IDirectory> classpath;
- public ResourceClassLoader(List<IDirectory> cpEntries) {
- classpath = cpEntries;
- }
-
- @Override
- protected URL findResource(String resName) {
- for(IDirectory id : classpath) {
- IFile f = id.getFile(resName);
- if(f != null)
- try {
- return f.toURL();
- } catch (MalformedURLException e) {
- logger.error("Error getting URL for file " + f, e);
- }
+ public class ClasspathIDirectory implements IDirectory {
+
+ private final IDirectory parent;
+ private final String entry;
+
+ public ClasspathIDirectory(IDirectory parent, String name) {
+ this.parent = parent;
+ this.entry = (name.endsWith("/")) ? name : name + "/";
+ }
+
+ public IDirectory convert() {
+ return parent.convert();
+ }
+
+ public IDirectory convertNested() {
+ return parent.convertNested();
+ }
+
+ public IFile getFile(String arg0) {
+ return parent.getFile(entry + arg0);
+ }
+
+ public long getLastModified() {
+ return parent.getLastModified();
+ }
+
+ public String getName() {
+ return parent.getName() + entry;
+ }
+
+ public IDirectory getParent() {
+ return parent.getParent();
+ }
+
+ public IDirectory getRoot() {
+ return parent.getRoot();
+ }
+
+ public long getSize() {
+ return parent.getSize();
+ }
+
+ public boolean isDirectory() {
+ return parent.isDirectory();
+ }
+
+ public boolean isFile() {
+ return parent.isFile();
+ }
+
+ public boolean isRoot() {
+ return parent.isRoot();
+ }
+
+ public Iterator<IFile> iterator() {
+ return parent.iterator();
+ }
+
+ public List<IFile> listAllFiles() {
+ List<IFile> files = new ArrayList<IFile>();
+ for(IFile f : parent.listAllFiles()) {
+ if(f.getName().startsWith(entry))
+ files.add(f);
+ }
+ return files;
+ }
+
+ public List<IFile> listFiles() {
+ List<IFile> files = new ArrayList<IFile>();
+ for(IFile f : parent.listFiles()) {
+ if(f.getName().startsWith(entry))
+ files.add(f);
}
- return null;
+ return files;
+ }
+
+ public InputStream open() throws IOException,
UnsupportedOperationException {
+ return parent.open();
+ }
+
+ public ICloseableDirectory toCloseable() {
+ return parent.toCloseable();
+ }
+
+ public URL toURL() throws MalformedURLException {
+ return parent.toURL();
}
}
public void findEJBs(BundleManifest manifest, IDirectory bundle,
EJBRegistry registry) throws ModellerException {
+ logger.debug("Scanning " + manifest.getSymbolicName() + "_" +
manifest.getManifestVersion() +
+ " for EJBs");
+
String ejbJarLocation = (manifest.getRawAttributes().getValue(
"Web-ContextPath") == null) ? "META-INF/ejb-jar.xml" :
"WEB-INF/ejb-jar.xml";
@@ -88,14 +157,9 @@ public class OpenEJBLocator implements E
EjbModule module = new EjbModule(ejbJar);
- //Find our classpath so we can scan the module
- List<IDirectory> cpEntries = getClassPathLocations(manifest, bundle);
-
- ClassLoader cl = new ResourceClassLoader(cpEntries);
- module.setClassLoader(cl);
-
//We build our own because we can't trust anyone to get the classpath
right otherwise!
- module.setFinder(new ClassFinder(cl, getClassPathURLs(cpEntries)));
+ module.setFinder(new
IDirectoryFinder(AnnotationDeployer.class.getClassLoader(),
+ getClassPathLocations(manifest, bundle)));
//Scan our app for annotated EJBs
AppModule app = new AppModule(module);
@@ -116,21 +180,6 @@ public class OpenEJBLocator implements E
}
/**
- * Get URLs for creating a {@link ClassFinder}
- * @param cpEntries
- * @return
- * @throws MalformedURLException
- */
- private List<URL> getClassPathURLs(List<IDirectory> cpEntries) throws
MalformedURLException {
- List<URL> result = new ArrayList<URL>();
-
- for(IDirectory id : cpEntries) {
- result.add(id.toURL());
- }
- return result;
- }
-
- /**
* Find the classpath entries for our bundle
*
* @param manifest
@@ -143,24 +192,41 @@ public class OpenEJBLocator implements E
String rawCp =
manifest.getRawAttributes().getValue(Constants.BUNDLE_CLASSPATH);
+ logger.debug("Classpath is " + rawCp);
+
if(rawCp == null || rawCp.trim() == "")
result.add(bundle);
else {
List<NameValuePair> splitCp =
ManifestHeaderProcessor.parseExportString(rawCp);
+ List<IFile> allFiles = null;
+
for(NameValuePair nvp : splitCp) {
String name = nvp.getName().trim();
- if(".".equals(name))
+ if(".".equals(name)) {
result.add(bundle);
+ }
else {
IFile f = bundle.getFile(name);
- if(f==null)
- continue;
-
- IDirectory converted = f.convertNested();
- if(converted != null)
- result.add(converted);
+ if(f==null) {
+ //This possibly just means no directory entries in a
+ //Zip. Check to make sure
+ if(allFiles == null)
+ allFiles = bundle.listAllFiles();
+
+ for(IFile file : allFiles) {
+ if(file.getName().startsWith(name)) {
+ result.add(new ClasspathIDirectory(bundle, name));
+ break;
+ }
+ }
+
+ } else {
+ IDirectory converted = f.convertNested();
+ if(converted != null)
+ result.add(converted);
+ }
}
}
}
@@ -177,6 +243,8 @@ public class OpenEJBLocator implements E
String name = sb.getEjbName();
String type = sb.getSessionType().toString();
+ logger.debug("Found EJB " + name + " of type " + type);
+
boolean added = false;
for(String iface : sb.getBusinessLocal()) {
@@ -213,4 +281,4 @@ public class OpenEJBLocator implements E
registry.addEJBView(name, type, sb.getEjbClass(), false);
}
}
-}
+}
\ No newline at end of file
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=1154869&r1=1154868&r2=1154869&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
Mon Aug 8 08:40:19 2011
@@ -108,6 +108,21 @@ public class EJBLocatorTest {
assertAnnotation(false);
}
+ @Test
+ public void testEJBJARAndAnnotatedOnClasspathInZip() throws Exception {
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ZipOutputStream zos = new ZipOutputStream(baos);
+ addToZip(zos, "ejb-jar.xml", "META-INF/ejb-jar.xml");
+ addToZip(zos, "test/ejbs/StatelessSessionBean.class",
"yes/test/ejb/StatelessSessionBean.class");
+ addToZip(zos, "test/ejbs/StatefulSessionBean.class",
"yes/test/ejb/StatefulSessionBean.class");
+ zos.close();
+
+ runTest(baos.toByteArray(), "MANIFEST_2.MF");
+
+ assertXML(true);
+ assertAnnotation(true);
+ }
@Test
public void testEJBJARInWebZip() throws Exception {
@@ -183,6 +198,23 @@ public class EJBLocatorTest {
assertXML(true);
assertAnnotation(false);
}
+
+ @Test
+ public void testEJBJARAndAnnotatedOnClasspathInWebZip() 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",
"yes/test/ejb/StatelessSessionBean.class");
+ addToZip(zos, "test/ejbs/StatefulSessionBean.class",
"yes/test/ejb/StatefulSessionBean.class");
+ zos.close();
+
+ runTest(baos.toByteArray(), "MANIFEST_4.MF");
+
+ assertXML(true);
+ assertAnnotation(true);
+ }
+
private void runTest(byte[] zip, String manifest) throws ModellerException,
IOException {
ICloseableDirectory icd = FileSystem.getFSRoot(new
Modified: aries/trunk/ejb/pom.xml
URL:
http://svn.apache.org/viewvc/aries/trunk/ejb/pom.xml?rev=1154869&r1=1154868&r2=1154869&view=diff
==============================================================================
--- aries/trunk/ejb/pom.xml (original)
+++ aries/trunk/ejb/pom.xml Mon Aug 8 08:40:19 2011
@@ -32,6 +32,7 @@
<modules>
<module>ejb-modeller</module>
+ <module>ejb-modeller-itest</module>
</modules>
</project>