Return-Path: X-Original-To: apmail-aries-commits-archive@www.apache.org Delivered-To: apmail-aries-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0C94F115C5 for ; Mon, 30 Jun 2014 16:56:35 +0000 (UTC) Received: (qmail 52261 invoked by uid 500); 30 Jun 2014 16:56:35 -0000 Delivered-To: apmail-aries-commits-archive@aries.apache.org Received: (qmail 52191 invoked by uid 500); 30 Jun 2014 16:56:34 -0000 Mailing-List: contact commits-help@aries.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@aries.apache.org Delivered-To: mailing list commits@aries.apache.org Received: (qmail 52180 invoked by uid 99); 30 Jun 2014 16:56:34 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 30 Jun 2014 16:56:34 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 30 Jun 2014 16:56:21 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id F07C02388C02; Mon, 30 Jun 2014 16:55:25 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1606837 [10/27] - in /aries/branches/subsystemsR6: ./ application/ application/application-api/ application/application-bundle/ application/application-converters/ application/application-default-local-platform/ application/application-dep... Date: Mon, 30 Jun 2014 16:55:06 -0000 To: commits@aries.apache.org From: tjwatson@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140630165525.F07C02388C02@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: aries/branches/subsystemsR6/ejb/openejb-extender-itest/src/test/java/org/apache/aries/ejb/openejb/extender/itest/EJBBundleTest.java URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/ejb/openejb-extender-itest/src/test/java/org/apache/aries/ejb/openejb/extender/itest/EJBBundleTest.java?rev=1606837&r1=1606836&r2=1606837&view=diff ============================================================================== --- aries/branches/subsystemsR6/ejb/openejb-extender-itest/src/test/java/org/apache/aries/ejb/openejb/extender/itest/EJBBundleTest.java (original) +++ aries/branches/subsystemsR6/ejb/openejb-extender-itest/src/test/java/org/apache/aries/ejb/openejb/extender/itest/EJBBundleTest.java Mon Jun 30 16:54:57 2014 @@ -17,379 +17,364 @@ package org.apache.aries.ejb.openejb.ext import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNotSame; import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.lang.reflect.Method; import java.util.zip.ZipOutputStream; -import javax.transaction.TransactionSynchronizationRegistry; -import javax.transaction.UserTransaction; - import org.junit.Test; import org.junit.runner.RunWith; -import org.ops4j.pax.exam.junit.JUnit4TestRunner; +import org.ops4j.pax.exam.junit.PaxExam; +import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy; +import org.ops4j.pax.exam.spi.reactors.PerClass; import org.osgi.framework.Bundle; import org.osgi.framework.ServiceReference; import beans.StatelessSessionBean; -import beans.integration.Tx; import beans.xml.LocalIface; import beans.xml.RemoteIface; -@RunWith(JUnit4TestRunner.class) +@RunWith(PaxExam.class) +@ExamReactorStrategy(PerClass.class) public class EJBBundleTest extends AbstractOpenEJBTest { - private void assertXML(Bundle test, boolean exists) throws Exception { - ServiceReference[] local = context().getAllServiceReferences(LocalIface.class.getName(), - "(&(ejb.name=XML)(ejb.type=Singleton))"); - if(exists) { - assertNotNull(local); - assertEquals(1, local.length); - Object svc = context().getService(local[0]); - assertNotNull(svc); - assertEquals("A Local Call", svc.getClass().getMethod("getLocalString").invoke(svc)); - } else { - assertNull(local); - } - - ServiceReference[] remote = context().getAllServiceReferences(RemoteIface.class.getName(), - "(&(ejb.name=XML)(ejb.type=Singleton))"); - if(exists) { - assertNotNull(remote); - assertEquals(1, remote.length); - Object svc = context().getService(remote[0]); - assertNotNull(svc); - assertEquals("A Remote Call", svc.getClass().getMethod("getRemoteString").invoke(svc)); - } else { - assertNull(remote); - } - } - - private void assertAnnotations(Bundle test, boolean exists) throws Exception { - ServiceReference[] stateless = context().getAllServiceReferences(StatelessSessionBean.class.getName(), - "(&(ejb.name=Annotated)(ejb.type=Stateless))"); - if(exists) { - assertNotNull(stateless); - assertEquals(1, stateless.length); - Object svc = context().getService(stateless[0]); - assertNotNull(svc); - assertEquals("A Stateless Call", svc.getClass().getMethod("getStatelessString").invoke(svc)); - } else { - assertNull(stateless); - } - } - - @Test - public void testEJBJARInZip() throws Exception { - - 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/xml/LocalIface.class"); - addToZip(zos, "beans/xml/RemoteIface.class"); - addToZip(zos, "beans/xml/XMLBean.class"); - zos.close(); - - Bundle test = context().installBundle("", new ByteArrayInputStream(baos.toByteArray())); - - try { - test.start(); - assertXML(test, true); - test.stop(); - assertXML(test, false); - - } finally { - test.uninstall(); - } - } - - @Test - public void testEJBJARAndAnnotatedInZip() throws Exception { - - 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/xml/LocalIface.class"); - addToZip(zos, "beans/xml/RemoteIface.class"); - addToZip(zos, "beans/xml/XMLBean.class"); - addToZip(zos, "beans/StatelessSessionBean.class"); - addToZip(zos, "beans/StatefulSessionBean.class"); - zos.close(); - - Bundle test = context().installBundle("", new ByteArrayInputStream(baos.toByteArray())); - - try { - test.start(); - assertXML(test, true); - assertAnnotations(test, true); - test.stop(); - assertXML(test, false); - assertAnnotations(test, false); - - } finally { - test.uninstall(); - } - } - - @Test - public void testAnnotatedOnlyInZip() throws Exception { - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - ZipOutputStream zos = new ZipOutputStream(baos); - addToZip(zos, "MANIFEST_1.MF", "META-INF/MANIFEST.MF"); - addToZip(zos, "beans/xml/LocalIface.class"); - addToZip(zos, "beans/xml/RemoteIface.class"); - addToZip(zos, "beans/xml/XMLBean.class"); - addToZip(zos, "beans/StatelessSessionBean.class"); - addToZip(zos, "beans/StatefulSessionBean.class"); - zos.close(); - - Bundle test = context().installBundle("", new ByteArrayInputStream(baos.toByteArray())); - - try { - test.start(); - assertXML(test, false); - assertAnnotations(test, true); - test.stop(); - assertXML(test, false); - assertAnnotations(test, false); - - } finally { - test.uninstall(); - } - } - - @Test - public void testEJBJARAndAnnotatedNotOnClasspathInZip() throws Exception { - - 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/xml/LocalIface.class", "yes/beans/xml/LocalIface.class"); - addToZip(zos, "beans/xml/RemoteIface.class", "yes/beans/xml/RemoteIface.class"); - addToZip(zos, "beans/xml/XMLBean.class", "yes/beans/xml/XMLBean.class"); - addToZip(zos, "beans/StatelessSessionBean.class", "no/beans/StatelessSessionBean.class"); - addToZip(zos, "beans/StatefulSessionBean.class", "no/beans/StatefulSessionBean.class"); - zos.close(); - - Bundle test = context().installBundle("", new ByteArrayInputStream(baos.toByteArray())); - - try { - test.start(); - assertXML(test, true); - assertAnnotations(test, false); - test.stop(); - assertXML(test, false); - assertAnnotations(test, false); - - } finally { - test.uninstall(); - } - } - - @Test - public void testEJBJARAndAnnotatedOnClasspathInZip() throws Exception { - - 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/xml/LocalIface.class", "yes/beans/xml/LocalIface.class"); - addToZip(zos, "beans/xml/RemoteIface.class", "yes/beans/xml/RemoteIface.class"); - addToZip(zos, "beans/xml/XMLBean.class", "yes/beans/xml/XMLBean.class"); - addToZip(zos, "beans/StatelessSessionBean.class", "yes/beans/StatelessSessionBean.class"); - addToZip(zos, "beans/StatefulSessionBean.class", "yes/beans/StatefulSessionBean.class"); - zos.close(); - - Bundle test = context().installBundle("", new ByteArrayInputStream(baos.toByteArray())); - - try { - test.start(); - assertXML(test, true); - assertAnnotations(test, true); - test.stop(); - assertXML(test, false); - assertAnnotations(test, false); - - } finally { - test.uninstall(); - } - } - - @Test - public void testEJBJARInWebZip() throws Exception { - - 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/xml/LocalIface.class"); - addToZip(zos, "beans/xml/RemoteIface.class"); - addToZip(zos, "beans/xml/XMLBean.class"); - zos.close(); - - Bundle test = context().installBundle("", new ByteArrayInputStream(baos.toByteArray())); - - try { - test.start(); - assertXML(test, true); - assertAnnotations(test, false); - test.stop(); - assertXML(test, false); - assertAnnotations(test, false); - - } finally { - test.uninstall(); - } - } - - @Test - public void testEJBJARInWrongPlaceWebZip() throws Exception { - - 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"); - addToZip(zos, "beans/xml/LocalIface.class"); - addToZip(zos, "beans/xml/RemoteIface.class"); - addToZip(zos, "beans/xml/XMLBean.class"); - zos.close(); - - Bundle test = context().installBundle("", new ByteArrayInputStream(baos.toByteArray())); - - try { - test.start(); - assertXML(test, false); - assertAnnotations(test, false); - test.stop(); - assertXML(test, false); - assertAnnotations(test, false); - - } finally { - test.uninstall(); - } - } - - @Test - public void testEJBJARAndAnnotatedInWebZip() throws Exception { - - - 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/xml/LocalIface.class"); - addToZip(zos, "beans/xml/RemoteIface.class"); - addToZip(zos, "beans/xml/XMLBean.class"); - addToZip(zos, "beans/StatelessSessionBean.class"); - addToZip(zos, "beans/StatefulSessionBean.class"); - zos.close(); - - Bundle test = context().installBundle("", new ByteArrayInputStream(baos.toByteArray())); - - try { - test.start(); - assertXML(test, true); - assertAnnotations(test, true); - test.stop(); - assertXML(test, false); - assertAnnotations(test, false); - - } finally { - test.uninstall(); - } - } - - @Test - public void testAnnotatedOnlyInWebZip() throws Exception { - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - ZipOutputStream zos = new ZipOutputStream(baos); - addToZip(zos, "MANIFEST_3.MF", "META-INF/MANIFEST.MF"); - addToZip(zos, "beans/xml/LocalIface.class"); - addToZip(zos, "beans/xml/RemoteIface.class"); - addToZip(zos, "beans/xml/XMLBean.class"); - addToZip(zos, "beans/StatelessSessionBean.class"); - addToZip(zos, "beans/StatefulSessionBean.class"); - zos.close(); - - Bundle test = context().installBundle("", new ByteArrayInputStream(baos.toByteArray())); - - try { - test.start(); - assertXML(test, false); - assertAnnotations(test, true); - test.stop(); - assertXML(test, false); - assertAnnotations(test, false); - - } finally { - test.uninstall(); - } - } - - @Test - public void testEJBJARAndAnnotatedNotOnClasspathInWebZip() throws Exception { - - 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/xml/LocalIface.class", "yes/beans/xml/LocalIface.class"); - addToZip(zos, "beans/xml/RemoteIface.class", "yes/beans/xml/RemoteIface.class"); - addToZip(zos, "beans/xml/XMLBean.class", "yes/beans/xml/XMLBean.class"); - addToZip(zos, "beans/StatelessSessionBean.class", "no/beans/StatelessSessionBean.class"); - addToZip(zos, "beans/StatefulSessionBean.class", "no/beans/StatefulSessionBean.class"); - zos.close(); - - Bundle test = context().installBundle("", new ByteArrayInputStream(baos.toByteArray())); - - try { - test.start(); - assertXML(test, true); - assertAnnotations(test, false); - test.stop(); - assertXML(test, false); - assertAnnotations(test, false); - - } finally { - test.uninstall(); - } - } - - @Test - public void testEJBJARAndAnnotatedOnClasspathInWebZip() throws Exception { - - 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/xml/LocalIface.class", "yes/beans/xml/LocalIface.class"); - addToZip(zos, "beans/xml/RemoteIface.class", "yes/beans/xml/RemoteIface.class"); - addToZip(zos, "beans/xml/XMLBean.class", "yes/beans/xml/XMLBean.class"); - addToZip(zos, "beans/StatelessSessionBean.class", "yes/beans/StatelessSessionBean.class"); - addToZip(zos, "beans/StatefulSessionBean.class", "yes/beans/StatefulSessionBean.class"); - zos.close(); - - Bundle test = context().installBundle("", new ByteArrayInputStream(baos.toByteArray())); - - try { - test.start(); - assertXML(test, true); - assertAnnotations(test, true); - test.stop(); - assertXML(test, false); - assertAnnotations(test, false); - - } finally { - test.uninstall(); + private void assertXML(Bundle test, boolean exists) throws Exception { + ServiceReference[] local = context().getAllServiceReferences(LocalIface.class.getName(), + "(&(ejb.name=XML)(ejb.type=Singleton))"); + if (exists) { + assertNotNull(local); + assertEquals(1, local.length); + Object svc = context().getService(local[0]); + assertNotNull(svc); + assertEquals("A Local Call", svc.getClass().getMethod("getLocalString").invoke(svc)); + } else { + assertNull(local); + } + + ServiceReference[] remote = context().getAllServiceReferences(RemoteIface.class.getName(), + "(&(ejb.name=XML)(ejb.type=Singleton))"); + if (exists) { + assertNotNull(remote); + assertEquals(1, remote.length); + Object svc = context().getService(remote[0]); + assertNotNull(svc); + assertEquals("A Remote Call", svc.getClass().getMethod("getRemoteString").invoke(svc)); + } else { + assertNull(remote); + } + } + + private void assertAnnotations(Bundle test, boolean exists) throws Exception { + ServiceReference[] stateless = context().getAllServiceReferences(StatelessSessionBean.class.getName(), + "(&(ejb.name=Annotated)(ejb.type=Stateless))"); + if (exists) { + assertNotNull(stateless); + assertEquals(1, stateless.length); + Object svc = context().getService(stateless[0]); + assertNotNull(svc); + assertEquals("A Stateless Call", svc.getClass().getMethod("getStatelessString").invoke(svc)); + } else { + assertNull(stateless); + } + } + + @Test + public void testEJBJARInZip() throws Exception { + 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/xml/LocalIface.class"); + addToZip(zos, "beans/xml/RemoteIface.class"); + addToZip(zos, "beans/xml/XMLBean.class"); + zos.close(); + + Bundle test = context().installBundle("", new ByteArrayInputStream(baos.toByteArray())); + + try { + test.start(); + assertXML(test, true); + test.stop(); + assertXML(test, false); + + } finally { + test.uninstall(); + } + } + + @Test + public void testEJBJARAndAnnotatedInZip() throws Exception { + 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/xml/LocalIface.class"); + addToZip(zos, "beans/xml/RemoteIface.class"); + addToZip(zos, "beans/xml/XMLBean.class"); + addToZip(zos, "beans/StatelessSessionBean.class"); + addToZip(zos, "beans/StatefulSessionBean.class"); + zos.close(); + + Bundle test = context().installBundle("", new ByteArrayInputStream(baos.toByteArray())); + + try { + test.start(); + assertXML(test, true); + assertAnnotations(test, true); + test.stop(); + assertXML(test, false); + assertAnnotations(test, false); + + } finally { + test.uninstall(); + } + } + + @Test + public void testAnnotatedOnlyInZip() throws Exception { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ZipOutputStream zos = new ZipOutputStream(baos); + addToZip(zos, "MANIFEST_1.MF", "META-INF/MANIFEST.MF"); + addToZip(zos, "beans/xml/LocalIface.class"); + addToZip(zos, "beans/xml/RemoteIface.class"); + addToZip(zos, "beans/xml/XMLBean.class"); + addToZip(zos, "beans/StatelessSessionBean.class"); + addToZip(zos, "beans/StatefulSessionBean.class"); + zos.close(); + + Bundle test = context().installBundle("", new ByteArrayInputStream(baos.toByteArray())); + + try { + test.start(); + assertXML(test, false); + assertAnnotations(test, true); + test.stop(); + assertXML(test, false); + assertAnnotations(test, false); + + } finally { + test.uninstall(); + } + } + + @Test + public void testEJBJARAndAnnotatedNotOnClasspathInZip() throws Exception { + 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/xml/LocalIface.class", "yes/beans/xml/LocalIface.class"); + addToZip(zos, "beans/xml/RemoteIface.class", "yes/beans/xml/RemoteIface.class"); + addToZip(zos, "beans/xml/XMLBean.class", "yes/beans/xml/XMLBean.class"); + addToZip(zos, "beans/StatelessSessionBean.class", "no/beans/StatelessSessionBean.class"); + addToZip(zos, "beans/StatefulSessionBean.class", "no/beans/StatefulSessionBean.class"); + zos.close(); + + Bundle test = context().installBundle("", new ByteArrayInputStream(baos.toByteArray())); + + try { + test.start(); + assertXML(test, true); + assertAnnotations(test, false); + test.stop(); + assertXML(test, false); + assertAnnotations(test, false); + + } finally { + test.uninstall(); + } + } + + @Test + public void testEJBJARAndAnnotatedOnClasspathInZip() throws Exception { + 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/xml/LocalIface.class", "yes/beans/xml/LocalIface.class"); + addToZip(zos, "beans/xml/RemoteIface.class", "yes/beans/xml/RemoteIface.class"); + addToZip(zos, "beans/xml/XMLBean.class", "yes/beans/xml/XMLBean.class"); + addToZip(zos, "beans/StatelessSessionBean.class", "yes/beans/StatelessSessionBean.class"); + addToZip(zos, "beans/StatefulSessionBean.class", "yes/beans/StatefulSessionBean.class"); + zos.close(); + + Bundle test = context().installBundle("", new ByteArrayInputStream(baos.toByteArray())); + + try { + test.start(); + assertXML(test, true); + assertAnnotations(test, true); + test.stop(); + assertXML(test, false); + assertAnnotations(test, false); + + } finally { + test.uninstall(); + } + } + + @Test + public void testEJBJARInWebZip() throws Exception { + 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/xml/LocalIface.class"); + addToZip(zos, "beans/xml/RemoteIface.class"); + addToZip(zos, "beans/xml/XMLBean.class"); + zos.close(); + + Bundle test = context().installBundle("", new ByteArrayInputStream(baos.toByteArray())); + + try { + test.start(); + assertXML(test, true); + assertAnnotations(test, false); + test.stop(); + assertXML(test, false); + assertAnnotations(test, false); + + } finally { + test.uninstall(); + } + } + + @Test + public void testEJBJARInWrongPlaceWebZip() throws Exception { + 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"); + addToZip(zos, "beans/xml/LocalIface.class"); + addToZip(zos, "beans/xml/RemoteIface.class"); + addToZip(zos, "beans/xml/XMLBean.class"); + zos.close(); + + Bundle test = context().installBundle("", new ByteArrayInputStream(baos.toByteArray())); + + try { + test.start(); + assertXML(test, false); + assertAnnotations(test, false); + test.stop(); + assertXML(test, false); + assertAnnotations(test, false); + + } finally { + test.uninstall(); + } + } + + @Test + public void testEJBJARAndAnnotatedInWebZip() throws Exception { + 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/xml/LocalIface.class"); + addToZip(zos, "beans/xml/RemoteIface.class"); + addToZip(zos, "beans/xml/XMLBean.class"); + addToZip(zos, "beans/StatelessSessionBean.class"); + addToZip(zos, "beans/StatefulSessionBean.class"); + zos.close(); + + Bundle test = context().installBundle("", new ByteArrayInputStream(baos.toByteArray())); + + try { + test.start(); + assertXML(test, true); + assertAnnotations(test, true); + test.stop(); + assertXML(test, false); + assertAnnotations(test, false); + + } finally { + test.uninstall(); + } + } + + @Test + public void testAnnotatedOnlyInWebZip() throws Exception { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ZipOutputStream zos = new ZipOutputStream(baos); + addToZip(zos, "MANIFEST_3.MF", "META-INF/MANIFEST.MF"); + addToZip(zos, "beans/xml/LocalIface.class"); + addToZip(zos, "beans/xml/RemoteIface.class"); + addToZip(zos, "beans/xml/XMLBean.class"); + addToZip(zos, "beans/StatelessSessionBean.class"); + addToZip(zos, "beans/StatefulSessionBean.class"); + zos.close(); + + Bundle test = context().installBundle("", new ByteArrayInputStream(baos.toByteArray())); + + try { + test.start(); + assertXML(test, false); + assertAnnotations(test, true); + test.stop(); + assertXML(test, false); + assertAnnotations(test, false); + + } finally { + test.uninstall(); + } + } + + @Test + public void testEJBJARAndAnnotatedNotOnClasspathInWebZip() throws Exception { + 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/xml/LocalIface.class", "yes/beans/xml/LocalIface.class"); + addToZip(zos, "beans/xml/RemoteIface.class", "yes/beans/xml/RemoteIface.class"); + addToZip(zos, "beans/xml/XMLBean.class", "yes/beans/xml/XMLBean.class"); + addToZip(zos, "beans/StatelessSessionBean.class", "no/beans/StatelessSessionBean.class"); + addToZip(zos, "beans/StatefulSessionBean.class", "no/beans/StatefulSessionBean.class"); + zos.close(); + + Bundle test = context().installBundle("", new ByteArrayInputStream(baos.toByteArray())); + + try { + test.start(); + assertXML(test, true); + assertAnnotations(test, false); + test.stop(); + assertXML(test, false); + assertAnnotations(test, false); + + } finally { + test.uninstall(); + } + } + + @Test + public void testEJBJARAndAnnotatedOnClasspathInWebZip() throws Exception { + 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/xml/LocalIface.class", "yes/beans/xml/LocalIface.class"); + addToZip(zos, "beans/xml/RemoteIface.class", "yes/beans/xml/RemoteIface.class"); + addToZip(zos, "beans/xml/XMLBean.class", "yes/beans/xml/XMLBean.class"); + addToZip(zos, "beans/StatelessSessionBean.class", "yes/beans/StatelessSessionBean.class"); + addToZip(zos, "beans/StatefulSessionBean.class", "yes/beans/StatefulSessionBean.class"); + zos.close(); + + Bundle test = context().installBundle("", new ByteArrayInputStream(baos.toByteArray())); + + try { + test.start(); + assertXML(test, true); + assertAnnotations(test, true); + test.stop(); + assertXML(test, false); + assertAnnotations(test, false); + + } finally { + test.uninstall(); + } } - } + } Modified: aries/branches/subsystemsR6/ejb/openejb-extender/pom.xml URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/ejb/openejb-extender/pom.xml?rev=1606837&r1=1606836&r2=1606837&view=diff ============================================================================== --- aries/branches/subsystemsR6/ejb/openejb-extender/pom.xml (original) +++ aries/branches/subsystemsR6/ejb/openejb-extender/pom.xml Mon Jun 30 16:54:57 2014 @@ -1,58 +1,62 @@ + + 4.0.0 + org.apache.aries - java5-parent - 1.0.0 - + parent + 2.0.0-SNAPSHOT + ../../parent/pom.xml - 4.0.0 + org.apache.aries.ejb org.apache.aries.ejb.openejb.extender bundle Aries OpenEJB Runtime Extender 1.0.1-SNAPSHOT - - scm:svn:http://svn.apache.org/repos/asf/aries/trunk/ejb/openejb-extender - scm:svn:https://svn.apache.org/repos/asf/aries/trunk/ejb/openejb-extender - http://svn.apache.org/viewvc/aries/trunk/ejb/openejb-extender - + + scm:svn:http://svn.apache.org/repos/asf/aries/trunk/ejb/openejb-extender + scm:svn:https://svn.apache.org/repos/asf/aries/trunk/ejb/openejb-extender + http://svn.apache.org/viewvc/aries/trunk/ejb/openejb-extender + - org.apache.aries.jpa.container.context;resolution:=optional, - org.apache.aries.proxy;provide:=true, - org.apache.openejb.config;provide:=true, - org.apache.openejb.persistence;provide:=true, - org.apache.openejb.util.proxy;provide:=true, - * + org.apache.aries.jpa.container.context;resolution:=optional, + org.apache.aries.proxy;provide:=true, + org.apache.openejb.config;provide:=true, + org.apache.openejb.persistence;provide:=true, + org.apache.openejb.util.proxy;provide:=true, + * - org.apache.aries.ejb.* + org.apache.aries.ejb.* - org.apache.aries.ejb.openejb.extender.EJBExtender + org.apache.aries.ejb.openejb.extender.EJBExtender + 1.0.0 @@ -79,7 +83,6 @@ org.osgi org.osgi.core - 4.3.0 provided @@ -150,7 +153,6 @@ org.apache.aries.versioning org.apache.aries.versioning.plugin - 0.1.0 default-verify @@ -158,9 +160,6 @@ version-check - - org.apache.aries.ejb:org.apache.aries.ejb.openejb.extender:1.0.0 - Modified: aries/branches/subsystemsR6/ejb/openejb-extender/src/main/java/org/apache/aries/ejb/openejb/extender/EJBServiceFactory.java URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/ejb/openejb-extender/src/main/java/org/apache/aries/ejb/openejb/extender/EJBServiceFactory.java?rev=1606837&r1=1606836&r2=1606837&view=diff ============================================================================== --- aries/branches/subsystemsR6/ejb/openejb-extender/src/main/java/org/apache/aries/ejb/openejb/extender/EJBServiceFactory.java (original) +++ aries/branches/subsystemsR6/ejb/openejb-extender/src/main/java/org/apache/aries/ejb/openejb/extender/EJBServiceFactory.java Mon Jun 30 16:54:57 2014 @@ -16,8 +16,6 @@ */ package org.apache.aries.ejb.openejb.extender; -import java.lang.reflect.Method; - import org.apache.openejb.BeanContext.BusinessLocalBeanHome; import org.apache.openejb.BeanContext.BusinessLocalHome; import org.apache.openejb.BeanContext.BusinessRemoteHome; @@ -27,7 +25,7 @@ import org.osgi.framework.Bundle; import org.osgi.framework.ServiceFactory; import org.osgi.framework.ServiceRegistration; -public class EJBServiceFactory implements ServiceFactory{ +public class EJBServiceFactory implements ServiceFactory { private static enum Type {LOCAL, LOCAL_NO_IFACE, REMOTE;} Modified: aries/branches/subsystemsR6/ejb/pom.xml URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/ejb/pom.xml?rev=1606837&r1=1606836&r2=1606837&view=diff ============================================================================== --- aries/branches/subsystemsR6/ejb/pom.xml (original) +++ aries/branches/subsystemsR6/ejb/pom.xml Mon Jun 30 16:54:57 2014 @@ -1,30 +1,33 @@ + + 4.0.0 + - java5-parent org.apache.aries - 1.0.0 - + parent + 2.0.0-SNAPSHOT + ../parent/pom.xml - 4.0.0 + org.apache.aries.ejb 1.0.0-SNAPSHOT ejb Modified: aries/branches/subsystemsR6/esa-maven-plugin/pom.xml URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/esa-maven-plugin/pom.xml?rev=1606837&r1=1606836&r2=1606837&view=diff ============================================================================== --- aries/branches/subsystemsR6/esa-maven-plugin/pom.xml (original) +++ aries/branches/subsystemsR6/esa-maven-plugin/pom.xml Mon Jun 30 16:54:57 2014 @@ -1,38 +1,36 @@ - - + 4.0.0 org.apache.aries - java5-parent - 1.0.0 - + parent + 2.0.0-SNAPSHOT + ../parent/pom.xml esa-maven-plugin 0.1-SNAPSHOT maven-plugin - Aries Maven ESA Plugin Builds an esa (Enterprise Subsystem Archive) from the project for deployment to an aries server. @@ -140,4 +138,5 @@ under the License. + Modified: aries/branches/subsystemsR6/esa-maven-plugin/src/main/java/org/apache/aries/plugin/esa/EsaMojo.java URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/esa-maven-plugin/src/main/java/org/apache/aries/plugin/esa/EsaMojo.java?rev=1606837&r1=1606836&r2=1606837&view=diff ============================================================================== --- aries/branches/subsystemsR6/esa-maven-plugin/src/main/java/org/apache/aries/plugin/esa/EsaMojo.java (original) +++ aries/branches/subsystemsR6/esa-maven-plugin/src/main/java/org/apache/aries/plugin/esa/EsaMojo.java Mon Jun 30 16:54:57 2014 @@ -21,7 +21,6 @@ package org.apache.aries.plugin.esa; import org.apache.maven.archiver.PomPropertiesUtil; import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.project.MavenProject; @@ -29,14 +28,12 @@ import org.codehaus.plexus.archiver.Arch import org.codehaus.plexus.archiver.zip.ZipArchiver; import org.codehaus.plexus.util.DirectoryScanner; import org.codehaus.plexus.util.FileUtils; -import org.apache.maven.shared.osgi.DefaultMaven2OsgiConverter; -import org.apache.maven.shared.osgi.Maven2OsgiConverter; -import aQute.lib.osgi.Analyzer; import java.io.File; import java.io.IOException; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.LinkedHashSet; +import java.util.HashSet; import java.util.Map; import java.util.Set; @@ -52,29 +49,23 @@ public class EsaMojo extends AbstractMojo { - public enum EsaContent {none, all, content}; + public enum EsaContent {none, all, content}; - public static final String SUBSYSTEM_MF_URI = "OSGI-INF/SUBSYSTEM.MF"; + public static final String SUBSYSTEM_MF_URI = "OSGI-INF/SUBSYSTEM.MF"; private static final String[] DEFAULT_INCLUDES = {"**/**"}; - /* - * Subsystem manifest headers - */ - private static final String SUBSYSTEM_MANIFESTVERSION = "Subsystem-ManifestVersion"; - private static final String SUBSYSTEM_SYMBOLICNAME = "Subsystem-SymbolicName"; - private static final String SUBSYSTEM_VERSION = "Subsystem-Version"; - private static final String SUBSYSTEM_NAME = "Subsystem-Name"; - private static final String SUBSYSTEM_DESCRIPTION = "Subsystem-Description"; - private static final String SUBSYSTEM_CONTENT = "Subsystem-Content"; - private static final String SUBSYSTEM_USEBUNDLE = "Use-Bundle"; - private static final String SUBSYSTEM_TYPE = "Subsystem-Type"; - - /** - * Coverter for maven pom values to OSGi manifest values (pulled in from the maven-bundle-plugin) - */ - private Maven2OsgiConverter maven2OsgiConverter = new DefaultMaven2OsgiConverter(); - + private static final Set SKIP_INSTRUCTIONS = new HashSet(); + + static { + SKIP_INSTRUCTIONS.add(Constants.SUBSYSTEM_MANIFESTVERSION); + SKIP_INSTRUCTIONS.add(Constants.SUBSYSTEM_SYMBOLICNAME); + SKIP_INSTRUCTIONS.add(Constants.SUBSYSTEM_VERSION); + SKIP_INSTRUCTIONS.add(Constants.SUBSYSTEM_NAME); + SKIP_INSTRUCTIONS.add(Constants.SUBSYSTEM_DESCRIPTION); + SKIP_INSTRUCTIONS.add(Constants.SUBSYSTEM_CONTENT); + } + /** * Single directory for extra files to include in the esa. * @@ -159,7 +150,7 @@ public class EsaMojo * * @parameter */ - private Map instructions = new LinkedHashMap();; + private Map instructions = new LinkedHashMap(); /** * Adding pom.xml and pom.properties to the archive. @@ -212,7 +203,7 @@ public class EsaMojo Set artifacts = null; switch (EsaContent.valueOf(archiveContent)) { case none: - getLog().info("archiveContent=none: subsystem arvhive will not contain any bundles."); + getLog().info("archiveContent=none: subsystem archive will not contain any bundles."); break; case content: // only include the direct dependencies in the archive @@ -227,15 +218,26 @@ public class EsaMojo } if (artifacts != null) { + // Explicitly add self to bundle set (used when pom packaging + // type != "esa" AND a file is present (no point to add to + // zip archive without file) + final Artifact selfArtifact = project.getArtifact(); + if (!"esa".equals(selfArtifact.getType()) && selfArtifact.getFile() != null) { + getLog().info("Explicitly adding artifact[" + selfArtifact.getGroupId() + ", " + selfArtifact.getId() + ", " + selfArtifact.getScope() + "]"); + artifacts.add(project.getArtifact()); + } + artifacts = selectArtifacts(artifacts); - for (Artifact artifact : artifacts) { - + int cnt = 0; + for (Artifact artifact : artifacts) { if (!artifact.isOptional() /*&& filter.include(artifact)*/) { getLog().info("Copying artifact[" + artifact.getGroupId() + ", " + artifact.getId() + ", " + artifact.getScope() + "]"); zipArchiver.addFile(artifact.getFile(), artifact.getArtifactId() + "-" + artifact.getVersion() + "." + (artifact.getType() == null ? "jar" : artifact.getType())); + cnt++; } } + getLog().info(String.format("Added %s artifacts to subsystem subsystem archive.", cnt)); } } catch ( ArchiverException e ) @@ -391,14 +393,16 @@ public class EsaMojo try { // TODO: add support for dependency version ranges. Need to pick // them up from the pom and convert them to OSGi version ranges. - FileUtils.fileAppend(fileName, SUBSYSTEM_MANIFESTVERSION + ": " + "1" + "\n"); - FileUtils.fileAppend(fileName, SUBSYSTEM_SYMBOLICNAME + ": " + FileUtils.fileAppend(fileName, Constants.SUBSYSTEM_MANIFESTVERSION + ": " + "1" + "\n"); + FileUtils.fileAppend(fileName, Constants.SUBSYSTEM_SYMBOLICNAME + ": " + getSubsystemSymbolicName(project.getArtifact()) + "\n"); - FileUtils.fileAppend(fileName, SUBSYSTEM_VERSION + ": " + FileUtils.fileAppend(fileName, Constants.SUBSYSTEM_VERSION + ": " + getSubsystemVersion() + "\n"); - FileUtils.fileAppend(fileName, SUBSYSTEM_NAME + ": " + project.getName() + "\n"); - FileUtils.fileAppend(fileName, SUBSYSTEM_DESCRIPTION + ": " - + project.getDescription() + "\n"); + FileUtils.fileAppend(fileName, Constants.SUBSYSTEM_NAME + ": " + getSubsystemName() + "\n"); + String description = getSubsystemDescription(); + if (description != null) { + FileUtils.fileAppend(fileName, Constants.SUBSYSTEM_DESCRIPTION + ": " + description + "\n"); + } // Write the SUBSYSTEM-CONTENT // TODO: check that the dependencies are bundles (currently, the converter @@ -410,46 +414,36 @@ public class EsaMojo artifacts = selectArtifacts(artifacts); Iterator iter = artifacts.iterator(); - FileUtils.fileAppend(fileName, SUBSYSTEM_CONTENT + ": "); - int order = 1; - if (iter.hasNext()) { - Artifact artifact = iter.next(); - String entry = new String( - maven2OsgiConverter.getBundleSymbolicName(artifact) - + ";version=\"" - + Analyzer.cleanupVersion(artifact.getVersion()) - + "\""); - if ("dependencies".equals(startOrder)) { - entry += ";start-order=\"" + order + "\""; - } - FileUtils.fileAppend(fileName, entry); - } + FileUtils.fileAppend(fileName, Constants.SUBSYSTEM_CONTENT + ": "); + int order = 0; while (iter.hasNext()) { Artifact artifact = iter.next(); order++; - String entry = new String(",\n " - + maven2OsgiConverter.getBundleSymbolicName(artifact) - + ";version=\"" - + Analyzer.cleanupVersion(artifact.getVersion()) - + "\""); + ContentInfo info = ContentInfo.create(artifact, getLog()); + if (info == null) { + continue; + } + String entry = info.getContentLine(); if ("dependencies".equals(startOrder)) { - entry += ";start-order=\"" + order + "\""; + entry += ";start-order=\"" + order + "\""; + } + if (iter.hasNext()) { + entry += ",\n "; } FileUtils.fileAppend(fileName, entry); } FileUtils.fileAppend(fileName, "\n"); - // Add any use bundle entry - if (instructions.containsKey(SUBSYSTEM_USEBUNDLE)) { - FileUtils.fileAppend(fileName, SUBSYSTEM_USEBUNDLE + ": " - + instructions.get(SUBSYSTEM_USEBUNDLE) + "\n"); - } - - // Add any subsystem type - if (instructions.containsKey(SUBSYSTEM_TYPE)) { - FileUtils.fileAppend(fileName, SUBSYSTEM_TYPE + ": " - + instructions.get(SUBSYSTEM_TYPE) + "\n"); + Iterator> instructionIter = instructions.entrySet().iterator(); + while(instructionIter.hasNext()) { + Map.Entry entry = instructionIter.next(); + String header = entry.getKey().toString(); + if (SKIP_INSTRUCTIONS.contains(header)) { + continue; + } + getLog().debug("Adding header: " + header); + FileUtils.fileAppend(fileName, header + ": " + entry.getValue() + "\n"); } } catch (Exception e) { @@ -458,23 +452,37 @@ public class EsaMojo } } - + // The maven2OsgiConverter assumes the artifact is a jar so we need our own // This uses the same fallback scheme as the converter private String getSubsystemSymbolicName(Artifact artifact) { - if (instructions.containsKey(SUBSYSTEM_SYMBOLICNAME)) { - return instructions.get(SUBSYSTEM_SYMBOLICNAME).toString(); + if (instructions.containsKey(Constants.SUBSYSTEM_SYMBOLICNAME)) { + return instructions.get(Constants.SUBSYSTEM_SYMBOLICNAME).toString(); } return artifact.getGroupId() + "." + artifact.getArtifactId(); } private String getSubsystemVersion() { - if (instructions.containsKey(SUBSYSTEM_VERSION)) { - return instructions.get(SUBSYSTEM_VERSION).toString(); + if (instructions.containsKey(Constants.SUBSYSTEM_VERSION)) { + return instructions.get(Constants.SUBSYSTEM_VERSION).toString(); } return aQute.lib.osgi.Analyzer.cleanupVersion(project.getVersion()); } + private String getSubsystemName() { + if (instructions.containsKey(Constants.SUBSYSTEM_NAME)) { + return instructions.get(Constants.SUBSYSTEM_NAME).toString(); + } + return project.getName(); + } + + private String getSubsystemDescription() { + if (instructions.containsKey(Constants.SUBSYSTEM_DESCRIPTION)) { + return instructions.get(Constants.SUBSYSTEM_DESCRIPTION).toString(); + } + return project.getDescription(); + } + private File getBuildDir() { if (buildDir == null) { buildDir = new File(workDirectory); Modified: aries/branches/subsystemsR6/esa-maven-plugin/src/test/java/org/apache/aries/plugin/esa/EsaMojoTest.java URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/esa-maven-plugin/src/test/java/org/apache/aries/plugin/esa/EsaMojoTest.java?rev=1606837&r1=1606836&r2=1606837&view=diff ============================================================================== --- aries/branches/subsystemsR6/esa-maven-plugin/src/test/java/org/apache/aries/plugin/esa/EsaMojoTest.java (original) +++ aries/branches/subsystemsR6/esa-maven-plugin/src/test/java/org/apache/aries/plugin/esa/EsaMojoTest.java Mon Jun 30 16:54:57 2014 @@ -21,17 +21,23 @@ package org.apache.aries.plugin.esa; import java.io.BufferedReader; import java.io.File; +import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Enumeration; import java.util.List; import java.util.Iterator; +import java.util.Map; +import java.util.jar.Attributes; +import java.util.jar.Manifest; import org.apache.maven.plugin.testing.AbstractMojoTestCase; import org.codehaus.plexus.archiver.zip.ZipEntry; import org.codehaus.plexus.archiver.zip.ZipFile; import org.codehaus.plexus.util.FileUtils; +import aQute.lib.osgi.Analyzer; + /** * @author Allan Ramirez */ @@ -52,8 +58,20 @@ public class EsaMojoTest public void testBasicEsa() throws Exception { + testBasicEsa( "target/test-classes/unit/basic-esa-test/plugin-config.xml", null ); + } + + public void testBasicEsaPgkType() + throws Exception + { + testBasicEsa( "target/test-classes/unit/basic-esa-test-with-pgk-type/plugin-config.xml", "maven-esa-test-1.0-SNAPSHOT.jar" ); + } + + private void testBasicEsa(String path, String extraExpectedFiles) + throws Exception + { File testPom = new File( getBasedir(), - "target/test-classes/unit/basic-esa-test/plugin-config.xml" ); + path ); EsaMojo mojo = ( EsaMojo ) lookupMojo( "esa", testPom ); @@ -83,6 +101,10 @@ public class EsaMojoTest expectedFiles.add( "META-INF/" ); expectedFiles.add( "maven-artifact01-1.0-SNAPSHOT.jar" ); expectedFiles.add( "maven-artifact02-1.0-SNAPSHOT.jar" ); + if (extraExpectedFiles != null) + { + expectedFiles.add( extraExpectedFiles ); + } ZipFile esa = new ZipFile( esaFile ); @@ -193,6 +215,22 @@ public class EsaMojoTest int missing = getSizeOfExpectedFiles(entries, expectedFiles); assertEquals("Missing files: " + expectedFiles, 0, missing); } + + private Manifest getSubsystemManifest(ZipFile esa) throws Exception { + ZipEntry entry = esa.getEntry("OSGI-INF/SUBSYSTEM.MF"); + + InputStream in = esa.getInputStream(entry); + Manifest mf = new Manifest(in); + + return mf; + } + + private Map> getHeader(Manifest mf, String header) { + Attributes attributes = mf.getMainAttributes(); + String value = attributes.getValue(header); + assertNotNull("Header " + header + " not found", value); + return Analyzer.parseHeader(value, null); + } private void testForHeader(ZipFile esa, String header, String exactEntry) throws Exception { @@ -215,27 +253,6 @@ public class EsaMojoTest assertTrue("Found " + header + ":", foundHeader); } - - private void testForLine(ZipFile esa, String exactEntry) throws Exception { - - Enumeration entries = esa.getEntries(); - - - // Test Use-Bundle & Subsytem-Type inclusion - ZipEntry entry = esa.getEntry("OSGI-INF/SUBSYSTEM.MF"); - BufferedReader br = new BufferedReader(new InputStreamReader(esa.getInputStream(entry))); - - Boolean foundEntry=false; - - String line; - while ((!foundEntry) && ((line = br.readLine()) != null)) { - if (line.equals(exactEntry)) { - foundEntry = true; - } - } - assertTrue("Found " + exactEntry + ":", foundEntry); - - } public void testSubsystemManifestGeneration() throws Exception @@ -332,11 +349,22 @@ public class EsaMojoTest int missing = getSizeOfExpectedFiles(entries, expectedFiles); assertEquals("Missing files: " + expectedFiles, 0, missing); - // Test for the Use-Bundle header - testForHeader(esa, "Subsystem-Content", "Subsystem-Content: maven-artifact02-1.0-SNAPSHOT;version=\"1.0.0.SNAPSHOT\";start-order=\"1\","); - - // Test for the Subsystem-Content header - testForLine(esa, " maven-artifact01-1.0-SNAPSHOT;version=\"1.0.0.SNAPSHOT\";start-order=\"2\""); + Manifest mf = getSubsystemManifest(esa); + Map> header = getHeader(mf, "Subsystem-Content"); + + Map attributes = null; + + attributes = header.get("maven-artifact01-1.0-SNAPSHOT"); + assertNotNull(attributes); + assertEquals("1.0.0.SNAPSHOT", attributes.get("version")); + assertEquals("1", attributes.get("start-order")); + assertNull(attributes.get("type")); + + attributes = header.get("maven-artifact02-1.0-SNAPSHOT"); + assertNotNull(attributes); + assertEquals("1.0.0.SNAPSHOT", attributes.get("version")); + assertEquals("2", attributes.get("start-order")); + assertNull(attributes.get("type")); } @@ -436,6 +464,124 @@ public class EsaMojoTest } + public void testCustomInstructions() + throws Exception + { + File testPom = new File( getBasedir(), + "target/test-classes/unit/basic-esa-custom-instructions/plugin-config.xml" ); + + EsaMojo mojo = ( EsaMojo ) lookupMojo( "esa", testPom ); + + assertNotNull( mojo ); + + String finalName = ( String ) getVariableValueFromObject( mojo, "finalName" ); + + String workDir = ( String ) getVariableValueFromObject( mojo, "workDirectory" ); + + String outputDir = ( String ) getVariableValueFromObject( mojo, "outputDirectory" ); + + mojo.execute(); + + + //check the generated esa file + File esaFile = new File( outputDir, finalName + ".esa" ); + + assertTrue( esaFile.exists() ); + + //expected files/directories inside the esa file + List expectedFiles = new ArrayList(); + + expectedFiles.add( "OSGI-INF/SUBSYSTEM.MF" ); + expectedFiles.add( "OSGI-INF/" ); + expectedFiles.add( "maven-artifact01-1.0-SNAPSHOT.jar" ); + expectedFiles.add( "maven-artifact02-1.0-SNAPSHOT.jar" ); + + ZipFile esa = new ZipFile( esaFile ); + + Enumeration entries = esa.getEntries(); + + assertTrue( entries.hasMoreElements() ); + + int missing = getSizeOfExpectedFiles(entries, expectedFiles); + assertEquals("Missing files: " + expectedFiles, 0, missing); + + // Test for the Foo header + testForHeader(esa, "Foo", "Foo: bar"); + + // Test for the MyHeader header + testForHeader(esa, "MyHeader", "MyHeader: myValue"); + + // Test for the Subsystem-Name header + testForHeader(esa, "Subsystem-Name", "Subsystem-Name: myName"); + } + + public void testSubsystemContentType() + throws Exception + { + File testPom = new File(getBasedir(), + "target/test-classes/unit/basic-esa-content-type/plugin-config.xml"); + + EsaMojo mojo = (EsaMojo) lookupMojo("esa", testPom); + + assertNotNull(mojo); + + String finalName = (String) getVariableValueFromObject(mojo, "finalName"); + + String workDir = (String) getVariableValueFromObject(mojo, "workDirectory"); + + String outputDir = (String) getVariableValueFromObject(mojo, "outputDirectory"); + + mojo.execute(); + + // check the generated esa file + File esaFile = new File(outputDir, finalName + ".esa"); + + assertTrue(esaFile.exists()); + + // expected files/directories inside the esa file + List expectedFiles = new ArrayList(); + + expectedFiles.add("OSGI-INF/SUBSYSTEM.MF"); + expectedFiles.add("OSGI-INF/"); + expectedFiles.add("maven-artifact01-1.0-SNAPSHOT.jar"); + expectedFiles.add("maven-artifact02-1.0-SNAPSHOT.jar"); + expectedFiles.add("maven-artifact03-1.1-SNAPSHOT.jar"); + + ZipFile esa = new ZipFile(esaFile); + + Enumeration entries = esa.getEntries(); + + assertTrue(entries.hasMoreElements()); + + int missing = getSizeOfExpectedFiles(entries, expectedFiles); + assertEquals("Missing files: " + expectedFiles, 0, missing); + + Manifest mf = getSubsystemManifest(esa); + Map> header = getHeader(mf, "Subsystem-Content"); + + Map attributes = null; + + attributes = header.get("maven-artifact01-1.0-SNAPSHOT"); + assertNotNull(attributes); + assertEquals("1.0.0.SNAPSHOT", attributes.get("version")); + assertNull(attributes.get("type")); + + attributes = header.get("maven-artifact02-1.0-SNAPSHOT"); + assertNotNull(attributes); + assertEquals("1.0.0.SNAPSHOT", attributes.get("version")); + assertNull(attributes.get("type")); + + attributes = header.get("maven-artifact03"); + assertNotNull(attributes); + assertEquals("1.1.0.SNAPSHOT.NNN", attributes.get("version")); + assertEquals("osgi.fragment", attributes.get("type")); + + attributes = header.get("maven-artifact04"); + assertNotNull(attributes); + assertEquals("1.2.0.SNAPSHOT", attributes.get("version")); + assertEquals("feature", attributes.get("type")); + } + private int getSizeOfExpectedFiles( Enumeration entries, List expectedFiles ) { while( entries.hasMoreElements() ) Modified: aries/branches/subsystemsR6/esa-maven-plugin/src/test/java/org/apache/aries/plugin/esa/stubs/EsaMavenProjectStub.java URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/esa-maven-plugin/src/test/java/org/apache/aries/plugin/esa/stubs/EsaMavenProjectStub.java?rev=1606837&r1=1606836&r2=1606837&view=diff ============================================================================== --- aries/branches/subsystemsR6/esa-maven-plugin/src/test/java/org/apache/aries/plugin/esa/stubs/EsaMavenProjectStub.java (original) +++ aries/branches/subsystemsR6/esa-maven-plugin/src/test/java/org/apache/aries/plugin/esa/stubs/EsaMavenProjectStub.java Mon Jun 30 16:54:57 2014 @@ -22,7 +22,7 @@ package org.apache.aries.plugin.esa.stub import java.io.File; import java.util.ArrayList; import java.util.Collections; -import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.List; import java.util.Set; @@ -110,7 +110,7 @@ public class EsaMavenProjectStub public Set getArtifacts() { - Set artifacts = new HashSet(); + Set artifacts = new LinkedHashSet(); artifacts.add( createArtifact( "org.apache.maven.test", "maven-artifact01", "1.0-SNAPSHOT", false ) ); artifacts.add( createArtifact( "org.apache.maven.test", "maven-artifact02", "1.0-SNAPSHOT", false ) ); @@ -134,6 +134,11 @@ public class EsaMavenProjectStub protected Artifact createArtifact( String groupId, String artifactId, String version, boolean optional ) { + return createArtifact(groupId, artifactId, version, "jar", optional); + } + + protected Artifact createArtifact( String groupId, String artifactId, String version, String type, boolean optional ) + { Artifact artifact = new EsaArtifactStub(); artifact.setGroupId( groupId ); @@ -146,7 +151,7 @@ public class EsaMavenProjectStub artifact.setFile( new File ( getBasedir() + "/src/test/remote-repo/" + artifact.getGroupId().replace( '.', '/' ) + "/" + artifact.getArtifactId() + "/" + artifact.getVersion() + - "/" + artifact.getArtifactId() + "-" + artifact.getVersion() + ".jar" ) ) ; + "/" + artifact.getArtifactId() + "-" + artifact.getVersion() + "." + type ) ) ; return artifact; } Modified: aries/branches/subsystemsR6/jmx/jmx-api/pom.xml URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jmx/jmx-api/pom.xml?rev=1606837&r1=1606836&r2=1606837&view=diff ============================================================================== --- aries/branches/subsystemsR6/jmx/jmx-api/pom.xml (original) +++ aries/branches/subsystemsR6/jmx/jmx-api/pom.xml Mon Jun 30 16:54:57 2014 @@ -1,26 +1,31 @@ + + 4.0.0 + org.apache.aries - java5-parent - 1.0.0 - + parent + 2.0.0-SNAPSHOT + ../../parent/pom.xml org.apache.aries.jmx @@ -32,14 +37,14 @@ This bundle contains the JMX 1.1.0 API - - scm:svn:http://svn.apache.org/repos/asf/aries/trunk/jmx/jmx-api - scm:svn:https://svn.apache.org/repos/asf/aries/trunk/jmx/jmx-api - http://svn.apache.org/viewvc/aries/trunk/jmx/jmx-api - + + scm:svn:http://svn.apache.org/repos/asf/aries/trunk/jmx/jmx-api + scm:svn:https://svn.apache.org/repos/asf/aries/trunk/jmx/jmx-api + http://svn.apache.org/viewvc/aries/trunk/jmx/jmx-api + + - org.osgi.jmx;uses:="javax.management.openmbean", org.osgi.jmx.framework;uses:="org.osgi.jmx,javax.management.openmbean", @@ -53,13 +58,14 @@ * + 1.1.0 + org.apache.aries.versioning org.apache.aries.versioning.plugin - 0.1.0 default-verify @@ -67,9 +73,6 @@ version-check - - org.apache.aries.jmx:org.apache.aries.jmx.api:1.1.0 - Modified: aries/branches/subsystemsR6/jmx/jmx-blueprint-api/pom.xml URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jmx/jmx-blueprint-api/pom.xml?rev=1606837&r1=1606836&r2=1606837&view=diff ============================================================================== --- aries/branches/subsystemsR6/jmx/jmx-blueprint-api/pom.xml (original) +++ aries/branches/subsystemsR6/jmx/jmx-blueprint-api/pom.xml Mon Jun 30 16:54:57 2014 @@ -1,26 +1,31 @@ + + 4.0.0 + org.apache.aries - java5-parent - 1.0.0 - + parent + 2.0.0-SNAPSHOT + ../../parent/pom.xml org.apache.aries.jmx @@ -32,11 +37,11 @@ This bundle contains the JMX Blueprint API - - scm:svn:http://svn.apache.org/repos/asf/aries/trunk/jmx/jmx-blueprint-api - scm:svn:https://svn.apache.org/repos/asf/aries/trunk/jmx/jmx-blueprint-api - http://svn.apache.org/viewvc/aries/trunk/jmx/jmx-blueprint-api - + + scm:svn:http://svn.apache.org/repos/asf/aries/trunk/jmx/jmx-blueprint-api + scm:svn:https://svn.apache.org/repos/asf/aries/trunk/jmx/jmx-blueprint-api + http://svn.apache.org/viewvc/aries/trunk/jmx/jmx-blueprint-api + @@ -44,6 +49,7 @@ org.apache.aries.jmx.blueprint + 1.1.0 @@ -51,7 +57,6 @@ org.apache.aries.versioning org.apache.aries.versioning.plugin - 0.1.0 default-verify @@ -59,12 +64,10 @@ version-check - - org.apache.aries.jmx:org.apache.aries.jmx.blueprint.api:1.1.0 - + Modified: aries/branches/subsystemsR6/jmx/jmx-blueprint-bundle/pom.xml URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jmx/jmx-blueprint-bundle/pom.xml?rev=1606837&r1=1606836&r2=1606837&view=diff ============================================================================== --- aries/branches/subsystemsR6/jmx/jmx-blueprint-bundle/pom.xml (original) +++ aries/branches/subsystemsR6/jmx/jmx-blueprint-bundle/pom.xml Mon Jun 30 16:54:57 2014 @@ -1,26 +1,31 @@ + + 4.0.0 + org.apache.aries - java5-parent - 1.0.0 - + parent + 2.0.0-SNAPSHOT + ../../parent/pom.xml org.apache.aries.jmx @@ -32,11 +37,11 @@ This bundle contains the standalone implementation of the along with the API. - - scm:svn:http://svn.apache.org/repos/asf/aries/trunk/jmx/jmx-blueprint-bundle - scm:svn:https://svn.apache.org/repos/asf/aries/trunk/jmx/jmx-blueprint-bundle - http://svn.apache.org/viewvc/aries/trunk/jmx/jmx-blueprint-bundle - + + scm:svn:http://svn.apache.org/repos/asf/aries/trunk/jmx/jmx-blueprint-bundle + scm:svn:https://svn.apache.org/repos/asf/aries/trunk/jmx/jmx-blueprint-bundle + http://svn.apache.org/viewvc/aries/trunk/jmx/jmx-blueprint-bundle + @@ -63,6 +68,7 @@ javax.management.MBeanServer + 1.1.1 @@ -191,7 +197,6 @@ org.apache.aries.versioning org.apache.aries.versioning.plugin - 0.1.0 default-verify @@ -199,9 +204,6 @@ version-check - - org.apache.aries.jmx:org.apache.aries.jmx.blueprint:1.1.0 - Modified: aries/branches/subsystemsR6/jmx/jmx-blueprint-core/pom.xml URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jmx/jmx-blueprint-core/pom.xml?rev=1606837&r1=1606836&r2=1606837&view=diff ============================================================================== --- aries/branches/subsystemsR6/jmx/jmx-blueprint-core/pom.xml (original) +++ aries/branches/subsystemsR6/jmx/jmx-blueprint-core/pom.xml Mon Jun 30 16:54:57 2014 @@ -1,26 +1,31 @@ + + 4.0.0 + org.apache.aries - java5-parent - 1.0.0 - + parent + 2.0.0-SNAPSHOT + ../../parent/pom.xml org.apache.aries.jmx @@ -32,11 +37,11 @@ This bundle contains the core implementation of the JMX Blueprint API - - scm:svn:http://svn.apache.org/repos/asf/aries/trunk/jmx/jmx-blueprint-core - scm:svn:https://svn.apache.org/repos/asf/aries/trunk/jmx/jmx-blueprint-core - http://svn.apache.org/viewvc/aries/trunk/jmx/jmx-blueprint-core - + + scm:svn:http://svn.apache.org/repos/asf/aries/trunk/jmx/jmx-blueprint-core + scm:svn:https://svn.apache.org/repos/asf/aries/trunk/jmx/jmx-blueprint-core + http://svn.apache.org/viewvc/aries/trunk/jmx/jmx-blueprint-core + @@ -52,6 +57,7 @@ javax.management.MBeanServer + 1.1.0 @@ -103,12 +109,12 @@ test + org.apache.aries.versioning org.apache.aries.versioning.plugin - 0.1.0 default-verify @@ -116,9 +122,6 @@ version-check - - org.apache.aries.jmx:org.apache.aries.jmx.blueprint.core:1.1.0 - Modified: aries/branches/subsystemsR6/jmx/jmx-bundle/pom.xml URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jmx/jmx-bundle/pom.xml?rev=1606837&r1=1606836&r2=1606837&view=diff ============================================================================== --- aries/branches/subsystemsR6/jmx/jmx-bundle/pom.xml (original) +++ aries/branches/subsystemsR6/jmx/jmx-bundle/pom.xml Mon Jun 30 16:54:57 2014 @@ -1,26 +1,31 @@ + + 4.0.0 + org.apache.aries - java5-parent - 1.0.0 - + parent + 2.0.0-SNAPSHOT + ../../parent/pom.xml org.apache.aries.jmx @@ -32,11 +37,12 @@ This bundle contains the standalone implementation of the along with the API. - - scm:svn:http://svn.apache.org/repos/asf/aries/trunk/jmx/jmx-bundle - scm:svn:https://svn.apache.org/repos/asf/aries/trunk/jmx/jmx-bundle - http://svn.apache.org/viewvc/aries/trunk/jmx/jmx-bundle - + + scm:svn:http://svn.apache.org/repos/asf/aries/trunk/jmx/jmx-bundle + scm:svn:https://svn.apache.org/repos/asf/aries/trunk/jmx/jmx-bundle + http://svn.apache.org/viewvc/aries/trunk/jmx/jmx-bundle + + org.apache.aries.jmx.Activator @@ -79,6 +85,7 @@ true + 1.1.1 @@ -208,7 +215,6 @@ org.apache.aries.versioning org.apache.aries.versioning.plugin - 0.1.0 default-verify @@ -216,9 +222,6 @@ version-check - - org.apache.aries.jmx:org.apache.aries.jmx:1.1.0 -