[jboss-osgi-commits] JBoss-OSGI SVN: r88821 - in projects/jboss-osgi/trunk/bundle/blueprint/src: main/resources/schema and 1 other directories.
jboss-osgi-commits at lists.jboss.org
jboss-osgi-commits at lists.jboss.org
Wed May 13 11:35:14 EDT 2009
Author: thomas.diesler at jboss.com
Date: 2009-05-13 11:35:13 -0400 (Wed, 13 May 2009)
New Revision: 88821
Added:
projects/jboss-osgi/trunk/bundle/blueprint/src/main/java/org/jboss/osgi/blueprint/model/Availability.java
Modified:
projects/jboss-osgi/trunk/bundle/blueprint/src/main/java/org/jboss/osgi/blueprint/model/BlueprintType.java
projects/jboss-osgi/trunk/bundle/blueprint/src/main/java/org/jboss/osgi/blueprint/model/TserviceReference.java
projects/jboss-osgi/trunk/bundle/blueprint/src/main/resources/schema/blueprint-jbxb.xsd
projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/parser/ParserTestCase.java
Log:
Test blueprint parser defaults
Added: projects/jboss-osgi/trunk/bundle/blueprint/src/main/java/org/jboss/osgi/blueprint/model/Availability.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/src/main/java/org/jboss/osgi/blueprint/model/Availability.java (rev 0)
+++ projects/jboss-osgi/trunk/bundle/blueprint/src/main/java/org/jboss/osgi/blueprint/model/Availability.java 2009-05-13 15:35:13 UTC (rev 88821)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.blueprint.model;
+
+/**
+ * Defines an availability attribute type. This is used in this
+ * schema by the <blueprint> default-availability attribute and the
+ * <reference>, <ref-set>, and <ref-list> availability attribute.
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 13-May-2009
+ */
+public enum Availability
+{
+ MANDATORY("mandatory"),
+ OPTIONAL("optional");
+
+ private final String value;
+
+ Availability(String v)
+ {
+ value = v;
+ }
+
+ public String value()
+ {
+ return value;
+ }
+
+ public static Availability fromValue(String v)
+ {
+ for (Availability c : Availability.values())
+ {
+ if (c.value.equals(v))
+ {
+ return c;
+ }
+ }
+ throw new IllegalArgumentException(v);
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/bundle/blueprint/src/main/java/org/jboss/osgi/blueprint/model/Availability.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: projects/jboss-osgi/trunk/bundle/blueprint/src/main/java/org/jboss/osgi/blueprint/model/BlueprintType.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/src/main/java/org/jboss/osgi/blueprint/model/BlueprintType.java 2009-05-13 15:25:44 UTC (rev 88820)
+++ projects/jboss-osgi/trunk/bundle/blueprint/src/main/java/org/jboss/osgi/blueprint/model/BlueprintType.java 2009-05-13 15:35:13 UTC (rev 88821)
@@ -28,6 +28,8 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+
+import javax.xml.bind.JAXBElement;
import javax.xml.namespace.QName;
/**
@@ -63,11 +65,6 @@
*/
public class BlueprintType
{
- public enum Availability
- {
- mandatory, optional
- };
-
protected Tdescription description;
protected TtypeConverters typeConverters;
protected List<Object> serviceOrRefListOrRefSet;
@@ -75,7 +72,7 @@
protected String defaultInitMethod;
protected String defaultDestroyMethod;
protected BigInteger defaultTimeout;
- protected String defaultAvailability = Availability.mandatory.toString();
+ protected Availability defaultAvailability;
private Map<QName, String> otherAttributes = new HashMap<QName, String>();
/**
@@ -221,9 +218,6 @@
/**
* Gets the value of the defaultTimeout property.
- *
- * @return possible object is {@link BigInteger }
- *
*/
public BigInteger getDefaultTimeout()
{
@@ -239,9 +233,6 @@
/**
* Sets the value of the defaultTimeout property.
- *
- * @param value allowed object is {@link BigInteger }
- *
*/
public void setDefaultTimeout(BigInteger value)
{
@@ -254,9 +245,16 @@
* @return possible object is {@link Tavailability }
*
*/
- public String getDefaultAvailability()
+ public Availability getDefaultAvailability()
{
- return defaultAvailability;
+ if (defaultAvailability == null)
+ {
+ return Availability.MANDATORY;
+ }
+ else
+ {
+ return defaultAvailability;
+ }
}
/**
@@ -265,7 +263,7 @@
* @param value allowed object is {@link Tavailability }
*
*/
- public void setDefaultAvailability(String value)
+ public void setDefaultAvailability(Availability value)
{
this.defaultAvailability = value;
}
@@ -285,5 +283,4 @@
{
return otherAttributes;
}
-
}
Modified: projects/jboss-osgi/trunk/bundle/blueprint/src/main/java/org/jboss/osgi/blueprint/model/TserviceReference.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/src/main/java/org/jboss/osgi/blueprint/model/TserviceReference.java 2009-05-13 15:25:44 UTC (rev 88820)
+++ projects/jboss-osgi/trunk/bundle/blueprint/src/main/java/org/jboss/osgi/blueprint/model/TserviceReference.java 2009-05-13 15:35:13 UTC (rev 88821)
@@ -11,9 +11,9 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+
import javax.xml.namespace.QName;
-import org.jboss.osgi.blueprint.model.BlueprintType.Availability;
import org.w3c.dom.Element;
/**
Modified: projects/jboss-osgi/trunk/bundle/blueprint/src/main/resources/schema/blueprint-jbxb.xsd
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/src/main/resources/schema/blueprint-jbxb.xsd 2009-05-13 15:25:44 UTC (rev 88820)
+++ projects/jboss-osgi/trunk/bundle/blueprint/src/main/resources/schema/blueprint-jbxb.xsd 2009-05-13 15:35:13 UTC (rev 88821)
@@ -589,6 +589,9 @@
<xsd:simpleType name="Tavailability">
<xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:class impl="org.jboss.osgi.blueprint.model.Availability"></jbxb:class>
+ </xsd:appinfo>
<xsd:documentation>
<![CDATA[
Tlazy-init defines an availability attribute type. This is used in this
Modified: projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/parser/ParserTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/parser/ParserTestCase.java 2009-05-13 15:25:44 UTC (rev 88820)
+++ projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/parser/ParserTestCase.java 2009-05-13 15:35:13 UTC (rev 88821)
@@ -23,8 +23,11 @@
//$Id$
+import java.math.BigInteger;
import java.net.URL;
+import org.jboss.osgi.blueprint.model.Availability;
+import org.jboss.osgi.blueprint.model.BlueprintType;
import org.jboss.osgi.blueprint.parser.BlueprintParser;
import org.jboss.osgi.spi.testing.OSGiTest;
@@ -36,10 +39,14 @@
*/
public class ParserTestCase extends OSGiTest
{
- public void testBlueprintBasic() throws Exception
+ public void testBlueprintDefaults() throws Exception
{
URL xmlURL = getResourceURL("parser/blueprint-basic.xml");
- BlueprintParser parser = new BlueprintParser();
- parser.parse(xmlURL);
+ BlueprintType blueprint = new BlueprintParser().parse(xmlURL);
+
+ assertEquals(Availability.MANDATORY, blueprint.getDefaultAvailability());
+ assertNull(blueprint.getDefaultDestroyMethod());
+ assertNull(blueprint.getDefaultInitMethod());
+ assertEquals(new BigInteger("300000"), blueprint.getDefaultTimeout());
}
}
\ No newline at end of file
More information about the jboss-osgi-commits
mailing list