[jboss-cvs] JBossAS SVN: r62301 - in projects/microcontainer/trunk/osgi-int: src/main/org/jboss/osgi/plugins/metadata and 9 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Apr 12 10:04:44 EDT 2007


Author: alesj
Date: 2007-04-12 10:04:44 -0400 (Thu, 12 Apr 2007)
New Revision: 62301

Added:
   projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/PathAttributeListValueCreator.java
   projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/QNameAttributeListValueCreator.java
   projects/microcontainer/trunk/osgi-int/src/resources/tests/
   projects/microcontainer/trunk/osgi-int/src/resources/tests/org/
   projects/microcontainer/trunk/osgi-int/src/resources/tests/org/jboss/
   projects/microcontainer/trunk/osgi-int/src/resources/tests/org/jboss/test/
   projects/microcontainer/trunk/osgi-int/src/resources/tests/org/jboss/test/bundle/
   projects/microcontainer/trunk/osgi-int/src/resources/tests/org/jboss/test/bundle/metadata/
   projects/microcontainer/trunk/osgi-int/src/resources/tests/org/jboss/test/bundle/metadata/IllegalManifest.mf
   projects/microcontainer/trunk/osgi-int/src/resources/tests/org/jboss/test/bundle/metadata/JavaCCManifest.mf
   projects/microcontainer/trunk/osgi-int/src/resources/tests/org/jboss/test/bundle/metadata/Manifest.mf
   projects/microcontainer/trunk/osgi-int/src/resources/tests/org/jboss/test/bundle/metadata/SimpleManifest.mf
   projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/metadata/AbstractManifestTestCase.java
   projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/metadata/HeaderValuesTestCase.java
Modified:
   projects/microcontainer/trunk/osgi-int/pom.xml
   projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractOSGiMetaData.java
   projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractParameter.java
   projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractVersionRange.java
   projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/HeaderValue.jj
   projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/ParameterizedAttributeListValueCreator.java
   projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/ParameterizedAttributeValueCreator.java
   projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/ValueCreatorUtil.java
   projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/BundleTestSuite.java
   projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/metadata/VersionRangeTestCase.java
Log:
OSGi manifest tests.

Modified: projects/microcontainer/trunk/osgi-int/pom.xml
===================================================================
--- projects/microcontainer/trunk/osgi-int/pom.xml	2007-04-12 12:02:09 UTC (rev 62300)
+++ projects/microcontainer/trunk/osgi-int/pom.xml	2007-04-12 14:04:44 UTC (rev 62301)
@@ -12,6 +12,16 @@
   <url>http://www.jboss.com/products/jbossmc</url>
   <description>JBoss Microcontainer</description>
   <build>
+     <resources>
+       <resource>
+         <directory>src/resources/main</directory>
+       </resource>
+     </resources>
+     <testResources>
+       <testResource>
+         <directory>src/resources/tests</directory>
+       </testResource>
+     </testResources>
     <plugins>
       <plugin>
 	    <groupId>org.codehaus.mojo</groupId>

Modified: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractOSGiMetaData.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractOSGiMetaData.java	2007-04-12 12:02:09 UTC (rev 62300)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractOSGiMetaData.java	2007-04-12 14:04:44 UTC (rev 62301)
@@ -45,7 +45,7 @@
 {
    private static final long serialVersionUID = 1L;
 
-   protected Map<String, Object> cachedAttributes = new HashMap<String, Object>();
+   protected transient Map<String, Object> cachedAttributes = new HashMap<String, Object>();
 
    public AbstractOSGiMetaData()
    {
@@ -78,7 +78,7 @@
 
    public int getBundleManifestVersion()
    {
-      return get(BUNDLE_VERSION, INTEGER_VC, 1);
+      return get(BUNDLE_MANIFESTVERSION, INTEGER_VC, 1);
    }
 
    public String getBundleName()
@@ -88,7 +88,7 @@
 
    public List<ParameterizedAttribute> getBundleNativeCode()
    {
-      return get(BUNDLE_NATIVECODE, PARAM_ATTRIB_LIST_VC);
+      return get(BUNDLE_NATIVECODE, PATH_ATTRIB_LIST_VC);
    }
 
    public List<String> getRequiredExecutionEnvironment()
@@ -133,7 +133,7 @@
 
    public List<ParameterizedAttribute> getRequireBundles()
    {
-      return get(REQUIRE_BUNDLE, PARAM_ATTRIB_LIST_VC);
+      return get(REQUIRE_BUNDLE, QNAME_ATTRIB_LIST_VC);
    }
 
    @SuppressWarnings("unchecked")

Modified: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractParameter.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractParameter.java	2007-04-12 12:02:09 UTC (rev 62300)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractParameter.java	2007-04-12 14:04:44 UTC (rev 62301)
@@ -36,10 +36,22 @@
  *
  * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
  */
-class AbstractParameter extends JBossObject implements Parameter, Serializable
+public class AbstractParameter extends JBossObject implements Parameter, Serializable
 {
-   protected Collection<String> values = new HashSet<String>();
+   protected Collection<String> values;
 
+   public AbstractParameter()
+   {
+      super();
+      values = new HashSet<String>();
+   }
+
+   public AbstractParameter(String parameter)
+   {
+      this();
+      addValue(parameter);
+   }
+
    public void addValue(String value)
    {
       values.add(value);
@@ -60,6 +72,16 @@
       return values.size() > 1;
    }
 
+   protected int getHashCode()
+   {
+      return values.hashCode();
+   }
+
+   public boolean equals(Object obj)
+   {
+      return (obj instanceof AbstractParameter && values.equals(((AbstractParameter)obj).values));
+   }
+
    public void toShortString(JBossStringBuilder buffer)
    {
       buffer.append("value=" + getValue());

Modified: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractVersionRange.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractVersionRange.java	2007-04-12 12:02:09 UTC (rev 62300)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/AbstractVersionRange.java	2007-04-12 14:04:44 UTC (rev 62301)
@@ -26,6 +26,8 @@
 import java.util.StringTokenizer;
 
 import org.jboss.osgi.spi.metadata.VersionRange;
+import org.jboss.util.JBossObject;
+import org.jboss.util.JBossStringBuilder;
 import org.osgi.framework.Version;
 
 /**
@@ -39,7 +41,7 @@
  * @author Scott.Stark at jboss.org
  * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
  */
-public class AbstractVersionRange implements VersionRange, Serializable
+public class AbstractVersionRange extends JBossObject implements VersionRange, Serializable
 {
    private static final long serialVersionUID = 1l;
 
@@ -85,7 +87,7 @@
             ceilingIsLessThan = true;
          else if (token.equals(","))
             mid = true;
-         else
+         else if (token.equals("\"") == false)
          {
             // A version token
             if (floor == null)
@@ -153,9 +155,18 @@
       return isInRange;
    }
 
-   public String toString()
+   protected int getHashCode()
    {
-      StringBuilder tmp = new StringBuilder();
+      return rangeSpec.hashCode();
+   }
+
+   public boolean equals(Object obj)
+   {
+      return (obj instanceof AbstractVersionRange && rangeSpec.equals(((AbstractVersionRange)obj).rangeSpec));
+   }
+
+   protected void toString(JBossStringBuilder tmp)
+   {
       if (floor == null)
          tmp.append("0.0.0");
       else
@@ -173,7 +184,6 @@
          tmp.append("inf");
       else
          tmp.append(ceiling.toString());
-      return tmp.toString();
    }
 
    protected Object readResolve() throws ObjectStreamException

Modified: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/HeaderValue.jj
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/HeaderValue.jj	2007-04-12 12:02:09 UTC (rev 62300)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/HeaderValue.jj	2007-04-12 14:04:44 UTC (rev 62301)
@@ -74,6 +74,14 @@
       parseParameters(list);
    }
 
+   public void parsePaths(List<ParameterizedAttribute> list, boolean trace)
+      throws ParseException
+   {
+      // This will have no effect unless the debugging options are true
+      applyTracing(trace);
+      parsePaths(list);
+   }
+
    public static void parsePackages(String header, List<PackageAttribute> list, boolean trace)
       throws ParseException
    {
@@ -87,6 +95,13 @@
       HeaderValue parser = new HeaderValue(header);
       parser.parseParameters(list, trace);
    }
+
+   public static void parsePaths(String header, List<ParameterizedAttribute> list, boolean trace)
+      throws ParseException
+   {
+      HeaderValue parser = new HeaderValue(header);
+      parser.parsePaths(list, trace);
+   }
 }
 PARSER_END(HeaderValue)
 
@@ -107,6 +122,8 @@
 |
   <#DIGIT: ["0" - "9"] >
 |
+  <STAR: "*" >
+|
   <NUMBER: (<DIGIT>)+ >
 |
   <DECIMAL_NUMBER: <NUMBER> ( "." <NUMBER> )? >
@@ -121,7 +138,7 @@
 |
   <#JLETTER_OR_DIGIT: <JLETTER> | <DIGIT> >
 |
-  <QNAME: <JLETTER> (<JLETTER_OR_DIGIT>)* ("." <JLETTER> (<JLETTER_OR_DIGIT>)*)* >
+  <QNAME: <JLETTER> (<JLETTER_OR_DIGIT>)* ("." <JLETTER> (<JLETTER_OR_DIGIT>)*)* (".*")? >
 |
   <QUOTED_STRING: "\"" ( ~["\"", "\\", "\r", "\n", "\u0000"] | "\\\"")* "\"" >
 |
@@ -130,6 +147,14 @@
   <ATTRIBUTE: <TOKN> "=" <ARGUMENT> >
 |
   <DIRECTIVE: <TOKN> ":=" <ARGUMENT> >
+|
+  <PATH_ELEMENT: (~["/", "\"", "\n", "\r", "\u0000", ";", ","])+ >
+|
+  <PATH_SEP: "/" >
+|
+  <#PATH_UNQUOTED: <PATH_SEP> | (<PATH_SEP>)? <PATH_ELEMENT> (<PATH_SEP> <PATH_ELEMENT>)* >
+|
+  <PATH: <PATH_UNQUOTED> | "\"" <PATH_UNQUOTED> "\"" >
 }
 
 /** Start of the grammar */
@@ -153,6 +178,15 @@
   }
 }
 
+void parsePaths(List<ParameterizedAttribute> list) :
+{
+}
+{
+  pathInfo(list) ( "," pathInfo(list) )*
+  {
+  }
+}
+
 void packageInfo(List<PackageAttribute> list) :
 {
    List<String> packages = new ArrayList<String>();
@@ -168,6 +202,21 @@
    }
 }
 
+void pathInfo(List<ParameterizedAttribute> list) :
+{
+   List<String> paths = new ArrayList<String>();
+   Map<String, Parameter> parameters = new HashMap<String, Parameter>();
+}
+{
+   pathNames(paths) ( ";" parsePathParameters(parameters) )+
+   {
+      for(String path : paths)
+      {
+         list.add(new AbstractPackageAttribute(path, parameters));
+      }
+   }
+}
+
 void parameterInfo(List<ParameterizedAttribute> list) :
 {
    Token t;
@@ -186,8 +235,18 @@
 }
 {
   t=<QNAME> {packages.add(t.image);} ( ";" packageNames(packages))*
+  |
+  t=<STAR> {packages.add(t.image);} ( ";" packageNames(packages))*
 }
 
+void pathNames(List<String> paths) :
+{
+	Token t;
+}
+{
+  t=<PATH> {paths.add(t.image);} ( ";" pathNames(paths))*
+}
+
 void parsePackageParameters(Map<String, Parameter> parameters) :
 {
    Token t;
@@ -230,3 +289,24 @@
    ( ";" parseAttributeParameters(parameters))*
 }
 
+void parsePathParameters(Map<String, Parameter> parameters) :
+{
+   Token t;
+}
+{
+   t = <DIRECTIVE>
+   {
+      String ts = t.toString();
+      String[] params = ts.split(":=");
+      addParameter(parameters, params[0], params[1]);
+   }
+|
+   t = <ATTRIBUTE>
+   {
+      String ts = t.toString();
+      String[] params = ts.split("=");
+      addParameter(parameters, params[0], params[1]);
+   }
+   ( ";" parsePathParameters(parameters))*
+}
+

Modified: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/ParameterizedAttributeListValueCreator.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/ParameterizedAttributeListValueCreator.java	2007-04-12 12:02:09 UTC (rev 62300)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/ParameterizedAttributeListValueCreator.java	2007-04-12 14:04:44 UTC (rev 62301)
@@ -27,23 +27,26 @@
 import org.jboss.osgi.spi.metadata.ParameterizedAttribute;
 
 /**
- * Create paramertized attribute list from string attribute.
+ * Create parameterized attribute list from string attribute.
  *
  * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
  */
-class ParameterizedAttributeListValueCreator extends ListValueCreator<ParameterizedAttribute>
+abstract class ParameterizedAttributeListValueCreator extends ListValueCreator<ParameterizedAttribute>
 {
    public List<ParameterizedAttribute> useString(String attribute)
    {
       List<ParameterizedAttribute> list = new ArrayList<ParameterizedAttribute>();
-      try
-      {
-         HeaderValue.parseParameters(attribute, list, log.isTraceEnabled());
-      }
-      catch (ParseException e)
-      {
-         log.error("Exception parsing parameters.", e);
-      }
+      parseAttribute(attribute, list, log.isTraceEnabled());
       return list;
    }
+
+   /**
+    * Use appropriate JavaCC parsing util.
+    *
+    * @param attribute string value to parse
+    * @param list data holder list
+    * @param trace log trace
+    */
+   protected abstract void parseAttribute(String attribute, List<ParameterizedAttribute> list, boolean trace);
+
 }

Modified: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/ParameterizedAttributeValueCreator.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/ParameterizedAttributeValueCreator.java	2007-04-12 12:02:09 UTC (rev 62300)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/ParameterizedAttributeValueCreator.java	2007-04-12 14:04:44 UTC (rev 62301)
@@ -34,7 +34,7 @@
 {
    public ParameterizedAttribute useString(String attribute)
    {
-      ParameterizedAttributeListValueCreator palvc = new ParameterizedAttributeListValueCreator();
+      ParameterizedAttributeListValueCreator palvc = new QNameAttributeListValueCreator();
       List<ParameterizedAttribute> list = palvc.useString(attribute);
       return list.size() > 0 ? list.get(0) : null;
    }

Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/PathAttributeListValueCreator.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/PathAttributeListValueCreator.java	                        (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/PathAttributeListValueCreator.java	2007-04-12 14:04:44 UTC (rev 62301)
@@ -0,0 +1,46 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.osgi.plugins.metadata;
+
+import java.util.List;
+
+import org.jboss.osgi.spi.metadata.ParameterizedAttribute;
+
+/**
+ * Create path attribute list from string attribute.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+class PathAttributeListValueCreator extends ParameterizedAttributeListValueCreator
+{
+   protected void parseAttribute(String attribute, List<ParameterizedAttribute> list, boolean trace)
+   {
+      try
+      {
+         HeaderValue.parsePaths(attribute, list, trace);
+      }
+      catch (ParseException e)
+      {
+         log.error("Exception parsing parameters.", e);
+      }
+   }
+}

Added: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/QNameAttributeListValueCreator.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/QNameAttributeListValueCreator.java	                        (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/QNameAttributeListValueCreator.java	2007-04-12 14:04:44 UTC (rev 62301)
@@ -0,0 +1,46 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.osgi.plugins.metadata;
+
+import java.util.List;
+
+import org.jboss.osgi.spi.metadata.ParameterizedAttribute;
+
+/**
+ * Create [dynamic]qname attribute list from string attribute.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+class QNameAttributeListValueCreator extends ParameterizedAttributeListValueCreator
+{
+   protected void parseAttribute(String attribute, List<ParameterizedAttribute> list, boolean trace)
+   {
+      try
+      {
+         HeaderValue.parseParameters(attribute, list, trace);
+      }
+      catch (ParseException e)
+      {
+         log.error("Exception parsing parameters.", e);
+      }
+   }
+}

Modified: projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/ValueCreatorUtil.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/ValueCreatorUtil.java	2007-04-12 12:02:09 UTC (rev 62300)
+++ projects/microcontainer/trunk/osgi-int/src/main/org/jboss/osgi/plugins/metadata/ValueCreatorUtil.java	2007-04-12 14:04:44 UTC (rev 62301)
@@ -36,6 +36,7 @@
    static URLValueCreator URL_VC = new URLValueCreator();
    static StringListValueCreator STRING_LIST_VC = new StringListValueCreator();
    public static ParameterizedAttributeValueCreator PARAM_ATTRIB_VC = new ParameterizedAttributeValueCreator();
-   public static ParameterizedAttributeListValueCreator PARAM_ATTRIB_LIST_VC = new ParameterizedAttributeListValueCreator();
+   public static ParameterizedAttributeListValueCreator QNAME_ATTRIB_LIST_VC = new QNameAttributeListValueCreator();
+   public static ParameterizedAttributeListValueCreator PATH_ATTRIB_LIST_VC = new PathAttributeListValueCreator();
    public static PackageAttributeListValueCreator PACKAGE_LIST_VC = new PackageAttributeListValueCreator();
 }

Added: projects/microcontainer/trunk/osgi-int/src/resources/tests/org/jboss/test/bundle/metadata/IllegalManifest.mf
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/resources/tests/org/jboss/test/bundle/metadata/IllegalManifest.mf	                        (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/resources/tests/org/jboss/test/bundle/metadata/IllegalManifest.mf	2007-04-12 14:04:44 UTC (rev 62301)
@@ -0,0 +1,7 @@
+Manifest-Version: 1.0
+Ant-Version: Apache Ant 1.6.5
+Created-By: Ales Justin
+Implementation-Title: JBoss OSGi tests
+Implementation-Version: 2.0.0.beta2
+Implementation-Vendor: jboss.org
+

Added: projects/microcontainer/trunk/osgi-int/src/resources/tests/org/jboss/test/bundle/metadata/JavaCCManifest.mf
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/resources/tests/org/jboss/test/bundle/metadata/JavaCCManifest.mf	                        (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/resources/tests/org/jboss/test/bundle/metadata/JavaCCManifest.mf	2007-04-12 14:04:44 UTC (rev 62301)
@@ -0,0 +1,13 @@
+Manifest-Version: 1.0
+Ant-Version: Apache Ant 1.6.5
+Created-By: Ales Justin
+Implementation-Title: JBoss OSGi tests
+Implementation-Version: 2.0.0.beta2
+Implementation-Vendor: jboss.org
+Bundle-NativeCode: /lib/http.DLL;osname=QNX;osversion=3.1,/lib/tcp.DLL;/lib/iiop.DLL;osname=QWE;osversion=4.0
+DynamicImport-Package: org.jboss.test;user=alesj,com.acme.plugin.*;version=1.2.3.GA,*;test=test
+Export-Package: org.osgi.util.tracker;net.osgi.foo;version=1.3,org.jboss.test;version="[1.0,2.0)"
+Fragment-Host: org.eclipse.swt;bundle-version="[3.0.0,4.0.0)"
+Import-Package: org.osgi.util.tracker;org.osgi.service.io;version=1.4;name=osgi,org.jboss.test;version="[2.0,3.0)";resolution:=osgi-int
+Require-Bundle: com.acme.chess;visibility:=true,com.alesj.test;bundle-version=1.2
+

Added: projects/microcontainer/trunk/osgi-int/src/resources/tests/org/jboss/test/bundle/metadata/Manifest.mf
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/resources/tests/org/jboss/test/bundle/metadata/Manifest.mf	                        (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/resources/tests/org/jboss/test/bundle/metadata/Manifest.mf	2007-04-12 14:04:44 UTC (rev 62301)
@@ -0,0 +1,7 @@
+Manifest-Version: 1.0
+Ant-Version: Apache Ant 1.6.5
+Created-By: Ales Justin
+Implementation-Title: JBoss OSGi tests
+Implementation-Version: 2.0.0.beta2
+Implementation-Vendor: jboss.org
+

Added: projects/microcontainer/trunk/osgi-int/src/resources/tests/org/jboss/test/bundle/metadata/SimpleManifest.mf
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/resources/tests/org/jboss/test/bundle/metadata/SimpleManifest.mf	                        (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/resources/tests/org/jboss/test/bundle/metadata/SimpleManifest.mf	2007-04-12 14:04:44 UTC (rev 62301)
@@ -0,0 +1,16 @@
+Manifest-Version: 1.0
+Ant-Version: Apache Ant 1.6.5
+Created-By: Ales Justin
+Implementation-Title: JBoss OSGi tests
+Implementation-Version: 2.0.0.beta2
+Implementation-Vendor: jboss.org
+Bundle-Activator: org.jboss.test.bundle.metadata.BundleActivator
+Bundle-ClassPath: test.jar,mc.jar,seam.jar
+Bundle-Description: TestHeadersManifest
+Bundle-Localization: OSGI-INF/l10n/bundle
+Bundle-ManifestVersion: 2
+Bundle-Name: TestBundle
+Bundle-SymbolicName: UniqueName
+Bundle-UpdateLocation: file://test.jar
+Bundle-Version: 1.2.3.GA
+Bundle-RequiredExecutionEnvironment: ena,dva,tri

Modified: projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/BundleTestSuite.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/BundleTestSuite.java	2007-04-12 12:02:09 UTC (rev 62300)
+++ projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/BundleTestSuite.java	2007-04-12 14:04:44 UTC (rev 62301)
@@ -24,7 +24,7 @@
 import junit.framework.Test;
 import junit.framework.TestSuite;
 import junit.textui.TestRunner;
-import org.jboss.test.bundle.metadata.VersionRangeTestCase;
+import org.jboss.test.bundle.metadata.MetaDataTestSuite;
 
 /**
  * Bundle Test Suite.
@@ -42,7 +42,7 @@
    {
       TestSuite suite = new TestSuite("Bundle Tests");
 
-      suite.addTest(VersionRangeTestCase.suite());
+      suite.addTest(MetaDataTestSuite.suite());
 
       return suite;
    }

Added: projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/metadata/AbstractManifestTestCase.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/metadata/AbstractManifestTestCase.java	                        (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/metadata/AbstractManifestTestCase.java	2007-04-12 14:04:44 UTC (rev 62301)
@@ -0,0 +1,82 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.bundle.metadata;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.jar.Manifest;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.jboss.test.BaseTestCase;
+
+/**
+ * Uses Manifest.mf file for actual tests.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class AbstractManifestTestCase extends BaseTestCase
+{
+   protected AbstractManifestTestCase(String name)
+   {
+      super(name);
+   }
+
+   // todo - remove after jboss-test update
+   public static Test suite(Class<?> clazz)
+   {
+      return new TestSuite(clazz);
+   }
+
+   protected String createName(String prefix)
+   {
+      if (prefix == null)
+         prefix = "";
+      return prefix + "Manifest.mf";
+   }
+
+   protected Manifest getManifest(String name) throws IOException
+   {
+      InputStream is = getManifestInputStream(name);
+      try
+      {
+         return new Manifest(is);
+      }
+      finally
+      {
+         is.close();
+      }
+   }
+
+   protected InputStream getManifestInputStream(String name) throws IOException
+   {
+      URL url = getResource(name);
+      if (url == null)
+      {
+         log.warn("Name not found:" + name);
+         fail(name + " not found");
+      }
+      return url.openStream();
+   }
+
+}

Added: projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/metadata/HeaderValuesTestCase.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/metadata/HeaderValuesTestCase.java	                        (rev 0)
+++ projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/metadata/HeaderValuesTestCase.java	2007-04-12 14:04:44 UTC (rev 62301)
@@ -0,0 +1,240 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.bundle.metadata;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.jar.Manifest;
+
+import junit.framework.Test;
+import org.jboss.osgi.plugins.metadata.AbstractOSGiMetaData;
+import org.jboss.osgi.plugins.metadata.AbstractPackageAttribute;
+import org.jboss.osgi.plugins.metadata.AbstractParameter;
+import org.jboss.osgi.plugins.metadata.AbstractParameterizedAttribute;
+import org.jboss.osgi.plugins.metadata.OSGiParameters;
+import org.jboss.osgi.spi.metadata.OSGiMetaData;
+import org.jboss.osgi.spi.metadata.PackageAttribute;
+import org.jboss.osgi.spi.metadata.Parameter;
+import org.jboss.osgi.spi.metadata.ParameterizedAttribute;
+import org.jboss.osgi.spi.metadata.VersionRange;
+import org.osgi.framework.Version;
+
+/**
+ * Test OSGi header values.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class HeaderValuesTestCase extends AbstractManifestTestCase
+{
+   public HeaderValuesTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return suite(HeaderValuesTestCase.class);
+   }
+
+   public void testSerializable() throws Exception
+   {
+      Manifest manifest = getManifest(createName(null));
+      AbstractOSGiMetaData metaData = new AbstractOSGiMetaData(manifest);
+      byte[] bytes = serialize(metaData);
+      metaData = (AbstractOSGiMetaData)deserialize(bytes);
+      String vendor = metaData.getMainAttribute("Implementation-Vendor");
+      assertEquals("jboss.org", vendor);
+   }
+
+   public void testSimpleManifest() throws Exception
+   {
+      Manifest manifest = getManifest(createName("Simple"));
+      OSGiMetaData metaData = new AbstractOSGiMetaData(manifest);
+
+      assertEquals(metaData.getBundleActivator(), "org.jboss.test.bundle.metadata.BundleActivator");
+      List<String> classpath = Arrays.asList("test.jar", "mc.jar", "seam.jar");
+      assertEquals(metaData.getBundleClassPath(), classpath);
+      assertEquals(metaData.getBundleDescription(), "TestHeadersManifest");
+      assertEquals(metaData.getBundleLocalization(), "OSGI-INF/l10n/bundle");
+      assertEquals(metaData.getBundleManifestVersion(), 2);
+      assertEquals(metaData.getBundleName(), "TestBundle");
+      assertEquals(metaData.getBundleSymbolicName(), "UniqueName");
+      URL url = new URL("file://test.jar");
+      assertEquals(metaData.getBundleUpdateLocation(), url);
+      Version version = new Version("1.2.3.GA");
+      assertEquals(metaData.getBundleVersion(), version);
+      List<String> env = Arrays.asList("ena", "dva", "tri");
+      assertEquals(metaData.getRequiredExecutionEnvironment(), env);
+   }
+
+   public void testJavaccManifest() throws Exception
+   {
+      Manifest manifest = getManifest(createName("JavaCC"));
+      OSGiMetaData metaData = new AbstractOSGiMetaData(manifest);
+
+      List<ParameterizedAttribute> bundleNativeCode = new ArrayList<ParameterizedAttribute>();
+      Map<String, Parameter> bnc1 = new HashMap<String, Parameter>();
+      bnc1.put("osname", new AbstractParameter("QNX"));
+      bnc1.put("osversion", new AbstractParameter("3.1"));
+      bundleNativeCode.add(new AbstractPackageAttribute("/lib/http.DLL", bnc1));
+      Map<String, Parameter> bnc2 = new HashMap<String, Parameter>();
+      bnc2.put("osname", new AbstractParameter("QWE"));
+      bnc2.put("osversion", new AbstractParameter("4.0"));
+      bundleNativeCode.add(new AbstractPackageAttribute("/lib/tcp.DLL", bnc2));
+      bundleNativeCode.add(new AbstractPackageAttribute("/lib/iiop.DLL", bnc2));
+      List<ParameterizedAttribute> metadataBNC = metaData.getBundleNativeCode();
+      assertNotNull(metadataBNC);
+      assertEquals(bundleNativeCode.size(), metadataBNC.size());
+      for(int i=0; i < metadataBNC.size(); i++)
+      {
+         ParameterizedAttribute paMD = metadataBNC.get(i);
+         ParameterizedAttribute myPA = bundleNativeCode.get(i);
+         assertEquals(paMD.getAttribute(), myPA.getAttribute());
+         assertEquals(paMD.getParameters(), myPA.getParameters());
+      }
+
+      List<PackageAttribute> dynamicImports = new ArrayList<PackageAttribute>();
+      Map<String, Parameter> dyna1 = new HashMap<String, Parameter>();
+      dyna1.put("user", new AbstractParameter("alesj"));
+      dynamicImports.add(new AbstractPackageAttribute("org.jboss.test", dyna1));
+      Map<String, Parameter> dyna2 = new HashMap<String, Parameter>();
+      dyna2.put("version", new AbstractParameter("1.2.3.GA"));
+      dynamicImports.add(new AbstractPackageAttribute("com.acme.plugin.*", dyna2));
+      Map<String, Parameter> dyna3 = new HashMap<String, Parameter>();
+      dyna3.put("test", new AbstractParameter("test"));
+      dynamicImports.add(new AbstractPackageAttribute("*", dyna3));
+      List<PackageAttribute> metadataDyna = metaData.getDynamicImports();
+      assertNotNull(metadataDyna);
+      assertEquals(dynamicImports.size(), metadataDyna.size());
+      for(int i=0; i < metadataDyna.size(); i++)
+      {
+         PackageAttribute paMD = metadataDyna.get(i);
+         PackageAttribute myPA = dynamicImports.get(i);
+         assertEquals(paMD.getAttribute(), myPA.getAttribute());
+         assertEquals(paMD.getPackageInfo(), myPA.getPackageInfo());
+         assertEquals(paMD.getParameters(), myPA.getParameters());
+      }
+
+      List<PackageAttribute> exportPackages = new ArrayList<PackageAttribute>();
+      Map<String, Parameter> ep1 = new HashMap<String, Parameter>();
+      ep1.put("version", new AbstractParameter("1.3"));
+      exportPackages.add(new AbstractPackageAttribute("org.osgi.util.tracker", ep1));
+      exportPackages.add(new AbstractPackageAttribute("net.osgi.foo", ep1));
+      Map<String, Parameter> ep2 = new HashMap<String, Parameter>();
+      ep2.put("version", new AbstractParameter("\"[1.0,2.0)\""));
+      exportPackages.add(new AbstractPackageAttribute("org.jboss.test", ep2));
+      List<PackageAttribute> metadataExport = metaData.getExportPackages();
+      assertNotNull(metadataExport);
+      assertEquals(exportPackages.size(), metadataExport.size());
+      for(int i=0; i < metadataExport.size(); i++)
+      {
+         PackageAttribute paMD = metadataExport.get(i);
+         PackageAttribute myPA = exportPackages.get(i);
+         assertEquals(paMD.getAttribute(), myPA.getAttribute());
+         assertEquals(paMD.getPackageInfo(), myPA.getPackageInfo());
+         assertEquals(paMD.getParameters(), myPA.getParameters());
+         OSGiParameters o1 = new OSGiParameters(paMD.getParameters());
+         OSGiParameters o2 = new OSGiParameters(myPA.getParameters());
+         VersionRange v1 = o1.getVersion();
+         VersionRange v2 = o2.getVersion();
+         assertEquals(v1, v2);
+      }
+
+      Map<String, Parameter> parameters = new HashMap<String, Parameter>();
+      parameters.put("bundle-version", new AbstractParameter("\"[3.0.0,4.0.0)\""));
+      ParameterizedAttribute fragmentHost = new AbstractParameterizedAttribute("org.eclipse.swt", parameters);
+      ParameterizedAttribute metadataFragment = metaData.getFragmentHost();
+      assertNotNull(metadataFragment);
+      assertEquals(fragmentHost.getAttribute(), metadataFragment.getAttribute());
+      OSGiParameters o1 = new OSGiParameters(fragmentHost.getParameters());
+      OSGiParameters o2 = new OSGiParameters(metadataFragment.getParameters());
+      VersionRange v1 = o1.getBundleVersion();
+      VersionRange v2 = o2.getBundleVersion();
+      assertNotNull(v1);
+      assertNotNull(v2);
+      assertEquals(v1, v2);
+
+      List<PackageAttribute> importPackages = new ArrayList<PackageAttribute>();
+      Map<String, Parameter> ip1 = new HashMap<String, Parameter>();
+      ip1.put("version", new AbstractParameter("1.4"));
+      ip1.put("name", new AbstractParameter("osgi"));
+      importPackages.add(new AbstractPackageAttribute("org.osgi.util.tracker", ip1));
+      importPackages.add(new AbstractPackageAttribute("org.osgi.service.io", ip1));
+      Map<String, Parameter> ip2 = new HashMap<String, Parameter>();
+      ip2.put("version", new AbstractParameter("\"[2.0,3.0)\""));
+      ip2.put("resolution", new AbstractParameter("osgi-int"));
+      importPackages.add(new AbstractPackageAttribute("org.jboss.test", ip2));
+      List<PackageAttribute> metadataImport = metaData.getImportPackages();
+      assertNotNull(metadataImport);
+      assertEquals(importPackages.size(), metadataImport.size());
+      for(int i=0; i < metadataImport.size(); i++)
+      {
+         PackageAttribute paMD = metadataImport.get(i);
+         PackageAttribute myPA = importPackages.get(i);
+         assertEquals(paMD.getAttribute(), myPA.getAttribute());
+         assertEquals(paMD.getPackageInfo(), myPA.getPackageInfo());
+         assertEquals(paMD.getParameters(), myPA.getParameters());
+         OSGiParameters oi1 = new OSGiParameters(paMD.getParameters());
+         OSGiParameters oi2 = new OSGiParameters(myPA.getParameters());
+         VersionRange vi1 = oi1.getVersion();
+         VersionRange vi2 = oi2.getVersion();
+         assertEquals(vi1, vi2);
+      }
+
+      List<ParameterizedAttribute> requireBundles = new ArrayList<ParameterizedAttribute>();
+      Map<String, Parameter> rb1 = new HashMap<String, Parameter>();
+      rb1.put("visibility", new AbstractParameter("true"));
+      requireBundles.add(new AbstractParameterizedAttribute("com.acme.chess", rb1));
+      Map<String, Parameter> rb2 = new HashMap<String, Parameter>();
+      rb2.put("bundle-version", new AbstractParameter("1.2"));
+      requireBundles.add(new AbstractParameterizedAttribute("com.alesj.test", rb2));
+      List<ParameterizedAttribute> metadataRB = metaData.getRequireBundles();
+      assertNotNull(metadataRB);
+      assertEquals(requireBundles.size(), metadataRB.size());
+      for(int i=0; i < metadataRB.size(); i++)
+      {
+         ParameterizedAttribute paMD = metadataRB.get(i);
+         ParameterizedAttribute myPA = requireBundles.get(i);
+         assertEquals(paMD.getAttribute(), myPA.getAttribute());
+         assertEquals(paMD.getParameters(), myPA.getParameters());
+         OSGiParameters oi1 = new OSGiParameters(paMD.getParameters());
+         OSGiParameters oi2 = new OSGiParameters(myPA.getParameters());
+         String vis1 = oi1.getVisibility();
+         String vis2 = oi2.getVisibility();
+         assertEquals(vis1, vis2);
+         VersionRange vr1 = oi1.getBundleVersion();
+         VersionRange vr2 = oi2.getBundleVersion();
+         assertEquals(vr1, vr2);
+      }
+   }
+
+   public void testIllegalManifest() throws Exception
+   {
+      Manifest manifest = getManifest(createName("Illegal"));
+      // todo
+   }
+
+}

Modified: projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/metadata/VersionRangeTestCase.java
===================================================================
--- projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/metadata/VersionRangeTestCase.java	2007-04-12 12:02:09 UTC (rev 62300)
+++ projects/microcontainer/trunk/osgi-int/src/tests/org/jboss/test/bundle/metadata/VersionRangeTestCase.java	2007-04-12 14:04:44 UTC (rev 62301)
@@ -15,7 +15,7 @@
  * Tests of the version range comparision.
  * 
  * @author Scott.Stark at jboss.org
- * @author Ales.Justin at jboss.org
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
  */
 public class VersionRangeTestCase extends BaseTestCase
 {




More information about the jboss-cvs-commits mailing list