[jboss-cvs] JBossAS SVN: r70329 - in projects/microcontainer/trunk/kernel/src: main/org/jboss/beans/metadata/plugins/policy and 4 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Mar 3 12:24:37 EST 2008
Author: alesj
Date: 2008-03-03 12:24:36 -0500 (Mon, 03 Mar 2008)
New Revision: 70329
Added:
projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/BindingWithType.xml
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/AbstractPolicyTest.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/BindingJaxbTestCase.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/PolicyJaxbTestCase.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/ScopeJaxbTestCase.java
Modified:
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractPropertyMetaData.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/policy/AbstractBindingMetaData.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/policy/AbstractPolicyMetaData.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/policy/AbstractScopeMetaData.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/policy/BindingMetaData.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BindingHandler.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/BindingTestCase.java
projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/XMLTestSuite.java
Log:
Fix Policy to use jaxb.
TODO - one failing test.
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractPropertyMetaData.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractPropertyMetaData.java 2008-03-03 16:55:29 UTC (rev 70328)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractPropertyMetaData.java 2008-03-03 17:24:36 UTC (rev 70329)
@@ -213,11 +213,13 @@
if (valueMetaData instanceof StringValueMetaData)
{
((StringValueMetaData) valueMetaData).setValue(value);
- return;
}
- StringValueMetaData stringValue = new StringValueMetaData(value);
- stringValue.setType(getType());
- setValue(stringValue);
+ else
+ {
+ StringValueMetaData stringValue = new StringValueMetaData(value);
+ stringValue.setType(getType());
+ setValue(stringValue);
+ }
}
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/policy/AbstractBindingMetaData.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/policy/AbstractBindingMetaData.java 2008-03-03 16:55:29 UTC (rev 70328)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/policy/AbstractBindingMetaData.java 2008-03-03 17:24:36 UTC (rev 70329)
@@ -22,8 +22,16 @@
package org.jboss.beans.metadata.plugins.policy;
import java.io.Serializable;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlValue;
+import javax.xml.bind.annotation.XmlTransient;
+import javax.xml.bind.annotation.XmlAnyElement;
+import org.jboss.beans.metadata.plugins.StringValueMetaData;
import org.jboss.beans.metadata.plugins.ValueMetaDataAware;
+import org.jboss.beans.metadata.plugins.AbstractValueMetaData;
import org.jboss.beans.metadata.spi.ValueMetaData;
import org.jboss.beans.metadata.spi.policy.BindingMetaData;
import org.jboss.util.JBossObject;
@@ -34,11 +42,14 @@
*
* @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
*/
+ at XmlRootElement(name="binding")
+ at XmlType(name="bindingType")
public class AbstractBindingMetaData extends JBossObject implements BindingMetaData, ValueMetaDataAware, Serializable
{
- private static final long serialVersionUID = 1;
+ private static final long serialVersionUID = 2;
private String name;
+ private String type;
private ValueMetaData value;
public String getName()
@@ -46,21 +57,66 @@
return name;
}
+ public String getType()
+ {
+ return type;
+ }
+
public ValueMetaData getValue()
{
return value;
}
+ @XmlAttribute
public void setName(String name)
{
this.name = name;
}
+ @XmlAttribute(name = "class")
+ public void setType(String type)
+ {
+ this.type = type;
+ }
+
+ @XmlTransient
public void setValue(ValueMetaData value)
{
this.value = value;
}
+ @XmlAnyElement
+ public void setValueObject(Object value)
+ {
+ if (value == null)
+ setValue(null);
+ else if (value instanceof ValueMetaData)
+ setValue((ValueMetaData) value);
+ else
+ setValue(new AbstractValueMetaData(value));
+ }
+
+ @XmlValue
+ public void setValueString(String value)
+ {
+ if (value == null)
+ setValue(null);
+ else
+ {
+ ValueMetaData valueMetaData = getValue();
+ if (valueMetaData instanceof StringValueMetaData)
+ {
+ ((StringValueMetaData) valueMetaData).setValue(value);
+ }
+ else
+ {
+ StringValueMetaData stringValue = new StringValueMetaData(value);
+ stringValue.setType(getType());
+ setValue(stringValue);
+ }
+ }
+ }
+
public void toString(JBossStringBuilder buffer)
{
buffer.append("name=").append(name);
@@ -73,5 +129,4 @@
buffer.append('/');
buffer.append(value);
}
-
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/policy/AbstractPolicyMetaData.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/policy/AbstractPolicyMetaData.java 2008-03-03 16:55:29 UTC (rev 70328)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/policy/AbstractPolicyMetaData.java 2008-03-03 17:24:36 UTC (rev 70329)
@@ -25,22 +25,34 @@
import java.util.List;
import java.util.Set;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlNsForm;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlTransient;
+
import org.jboss.beans.metadata.spi.AnnotationMetaData;
import org.jboss.beans.metadata.spi.BeanMetaData;
import org.jboss.beans.metadata.spi.policy.BindingMetaData;
import org.jboss.beans.metadata.spi.policy.PolicyMetaData;
import org.jboss.beans.metadata.spi.policy.ScopeMetaData;
+import org.jboss.beans.metadata.plugins.AbstractAnnotationMetaData;
import org.jboss.util.JBossObject;
import org.jboss.util.JBossStringBuilder;
+import org.jboss.xb.annotations.JBossXmlSchema;
/**
* Meta data for policy.
*
* @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
*/
+ at JBossXmlSchema(namespace="urn:jboss:policy:1.0", elementFormDefault= XmlNsForm.QUALIFIED)
+ at XmlRootElement(name="policy")
+ at XmlType(name="policyType")
public class AbstractPolicyMetaData extends JBossObject implements PolicyMetaData, Serializable
{
- private static final long serialVersionUID = 1;
+ private static final long serialVersionUID = 2;
protected String name;
protected String ext;
@@ -73,31 +85,37 @@
return bindings;
}
+ @XmlTransient
public List<BeanMetaData> getBeans()
{
return null; // todo
}
+ @XmlAttribute
public void setName(String name)
{
this.name = name;
}
+ @XmlAttribute
public void setExtends(String ext)
{
this.ext = ext;
}
+ @XmlElement(name="scope", type=AbstractScopeMetaData.class)
public void setScope(ScopeMetaData scope)
{
this.scope = scope;
}
+ @XmlElement(name="annotation", type=AbstractAnnotationMetaData.class)
public void setAnnotations(Set<AnnotationMetaData> annotations)
{
this.annotations = annotations;
}
+ @XmlElement(name="binding", type=AbstractBindingMetaData.class)
public void setBindings(Set<BindingMetaData> bindings)
{
this.bindings = bindings;
@@ -124,5 +142,4 @@
buffer.append('/');
buffer.append(bindings);
}
-
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/policy/AbstractScopeMetaData.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/policy/AbstractScopeMetaData.java 2008-03-03 16:55:29 UTC (rev 70328)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/policy/AbstractScopeMetaData.java 2008-03-03 17:24:36 UTC (rev 70329)
@@ -25,6 +25,11 @@
import java.lang.annotation.Annotation;
import java.util.Iterator;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlTransient;
+import javax.xml.bind.annotation.XmlAttribute;
+
import org.jboss.annotation.factory.AnnotationCreator;
import org.jboss.beans.metadata.spi.MetaDataVisitor;
import org.jboss.beans.metadata.spi.MetaDataVisitorNode;
@@ -42,14 +47,17 @@
*
* @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
*/
+ at XmlRootElement(name="scope")
+ at XmlType(name="scopeType")
public class AbstractScopeMetaData extends JBossObject implements ScopeMetaData, Serializable
{
- private static final long serialVersionUID = 1;
+ private static final long serialVersionUID = 2;
private String scope;
private String level;
private String qualifier;
+ @XmlTransient
public Object getUnderlyingValue()
{
return scope;
@@ -102,11 +110,13 @@
vistor.describeVisit(this);
}
+ @XmlTransient
public Iterator<? extends MetaDataVisitorNode> getChildren()
{
return null;
}
+ @XmlTransient
public String getScope()
{
return scope;
@@ -127,11 +137,13 @@
this.scope = scope;
}
+ @XmlAttribute
public void setLevel(String level)
{
this.level = level;
}
+ @XmlAttribute
public void setQualifier(String qualifier)
{
this.qualifier = qualifier;
@@ -152,5 +164,4 @@
buffer.append('/');
buffer.append(qualifier);
}
-
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/policy/BindingMetaData.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/policy/BindingMetaData.java 2008-03-03 16:55:29 UTC (rev 70328)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/policy/BindingMetaData.java 2008-03-03 17:24:36 UTC (rev 70329)
@@ -38,6 +38,13 @@
String getName();
/**
+ * Get the type
+ *
+ * @return binding type
+ */
+ String getType();
+
+ /**
* Get the value
*
* @return binding value
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BindingHandler.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BindingHandler.java 2008-03-03 16:55:29 UTC (rev 70328)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BindingHandler.java 2008-03-03 17:24:36 UTC (rev 70329)
@@ -52,6 +52,8 @@
String localName = attrs.getLocalName(i);
if ("name".equals(localName))
binding.setName(attrs.getValue(i));
+ else if ("class".equals(localName))
+ binding.setType(attrs.getValue(i));
}
}
Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/BindingWithType.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/BindingWithType.xml (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/BindingWithType.xml 2008-03-03 17:24:36 UTC (rev 70329)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<policy xmlns="urn:jboss:policy:1.0">
+ <binding name="somename" class="java.lang.Integer">42</binding>
+</policy>
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/AbstractPolicyTest.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/AbstractPolicyTest.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/AbstractPolicyTest.java 2008-03-03 17:24:36 UTC (rev 70329)
@@ -0,0 +1,58 @@
+/*
+* 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.kernel.deployment.xml.test;
+
+import org.jboss.beans.metadata.plugins.policy.AbstractBindingMetaData;
+import org.jboss.beans.metadata.plugins.policy.AbstractPolicyMetaData;
+import org.jboss.beans.metadata.plugins.policy.AbstractScopeMetaData;
+import org.jboss.kernel.plugins.deployment.AbstractKernelDeployment;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class AbstractPolicyTest extends AbstractMCTest
+{
+ protected AbstractPolicyTest(String name)
+ {
+ super(name);
+ }
+
+ private <T> T unmarshal(Class<T> expected) throws Exception
+ {
+ return unmarshalObject(expected, AbstractPolicyMetaData.class, AbstractKernelDeployment.class);
+ }
+
+ protected AbstractPolicyMetaData unmarshalPolicy() throws Exception
+ {
+ return unmarshal(AbstractPolicyMetaData.class);
+ }
+
+ protected AbstractScopeMetaData unmarshalScope() throws Exception
+ {
+ return unmarshal(AbstractScopeMetaData.class);
+ }
+
+ protected AbstractBindingMetaData unmarshalBinding() throws Exception
+ {
+ return unmarshal(AbstractBindingMetaData.class);
+ }
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/BindingJaxbTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/BindingJaxbTestCase.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/BindingJaxbTestCase.java 2008-03-03 17:24:36 UTC (rev 70329)
@@ -0,0 +1,92 @@
+/*
+* 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.kernel.deployment.xml.test;
+
+import junit.framework.Test;
+import org.jboss.beans.metadata.plugins.StringValueMetaData;
+import org.jboss.beans.metadata.spi.policy.BindingMetaData;
+import org.jboss.beans.metadata.spi.policy.PolicyMetaData;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class BindingJaxbTestCase extends AbstractPolicyTest
+{
+ public BindingJaxbTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return suite(BindingJaxbTestCase.class);
+ }
+
+ public void testBindingWithNoName() throws Throwable
+ {
+ PolicyMetaData policy = unmarshalPolicy();
+ assertFalse(policy.getBindings().isEmpty());
+ assertEquals(1, policy.getBindings().size());
+ BindingMetaData binding = policy.getBindings().iterator().next();
+// assertEquals("", binding.getName()); // todo
+ assertNotNull(binding.getValue());
+ assertNull(binding.getType());
+ }
+
+ public void testBindingWithPlainValue() throws Throwable
+ {
+ PolicyMetaData policy = unmarshalPolicy();
+ assertFalse(policy.getBindings().isEmpty());
+ assertEquals(1, policy.getBindings().size());
+ BindingMetaData binding = policy.getBindings().iterator().next();
+ assertNotNull(binding.getName());
+ assertNotNull(binding.getValue());
+ assertNull(binding.getType());
+ assertInstanceOf(binding.getValue(), StringValueMetaData.class);
+ }
+
+ public void testBindingWithType() throws Throwable
+ {
+ PolicyMetaData policy = unmarshalPolicy();
+ assertFalse(policy.getBindings().isEmpty());
+ assertEquals(1, policy.getBindings().size());
+ BindingMetaData binding = policy.getBindings().iterator().next();
+ assertNotNull(binding.getName());
+ assertNotNull(binding.getValue());
+ assertInstanceOf(binding.getValue(), StringValueMetaData.class);
+ assertEquals(Integer.class.getName(), binding.getType());
+ }
+
+ public void testBindingWithComplexValue() throws Throwable
+ {
+ // FIXME
+/*
+ PolicyMetaData policy = unmarshalPolicy();
+ assertFalse(policy.getBindings().isEmpty());
+ assertEquals(1, policy.getBindings().size());
+ BindingMetaData binding = policy.getBindings().iterator().next();
+ assertNotNull(binding.getName());
+ assertNotNull(binding.getValue());
+ assertInstanceOf(binding.getValue(), StringValueMetaData.class);
+*/
+ }
+}
Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/BindingTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/BindingTestCase.java 2008-03-03 16:55:29 UTC (rev 70328)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/BindingTestCase.java 2008-03-03 17:24:36 UTC (rev 70329)
@@ -50,6 +50,7 @@
BindingMetaData binding = policy.getBindings().iterator().next();
// assertEquals("", binding.getName()); // todo
assertNotNull(binding.getValue());
+ assertNull(binding.getType());
}
public void testBindingWithPlainValue() throws Throwable
@@ -60,9 +61,22 @@
BindingMetaData binding = policy.getBindings().iterator().next();
assertNotNull(binding.getName());
assertNotNull(binding.getValue());
+ assertNull(binding.getType());
assertInstanceOf(binding.getValue(), StringValueMetaData.class);
}
+ public void testBindingWithType() throws Throwable
+ {
+ PolicyMetaData policy = unmarshal("BindingWithType.xml", AbstractPolicyMetaData.class);
+ assertFalse(policy.getBindings().isEmpty());
+ assertEquals(1, policy.getBindings().size());
+ BindingMetaData binding = policy.getBindings().iterator().next();
+ assertNotNull(binding.getName());
+ assertNotNull(binding.getValue());
+ assertInstanceOf(binding.getValue(), StringValueMetaData.class);
+ assertEquals(Integer.class.getName(), binding.getType());
+ }
+
public void testBindingWithComplexValue() throws Throwable
{
PolicyMetaData policy = unmarshal("BindingWithComplexValue.xml", AbstractPolicyMetaData.class);
@@ -73,5 +87,4 @@
assertNotNull(binding.getValue());
assertInstanceOf(binding.getValue(), StringValueMetaData.class);
}
-
}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/PolicyJaxbTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/PolicyJaxbTestCase.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/PolicyJaxbTestCase.java 2008-03-03 17:24:36 UTC (rev 70329)
@@ -0,0 +1,107 @@
+/*
+* 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.kernel.deployment.xml.test;
+
+import junit.framework.Test;
+import org.jboss.beans.metadata.spi.policy.PolicyMetaData;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class PolicyJaxbTestCase extends AbstractPolicyTest
+{
+ public PolicyJaxbTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return suite(PolicyJaxbTestCase.class);
+ }
+
+ public void testPolicy() throws Throwable
+ {
+ PolicyMetaData policy = unmarshalPolicy();
+ assertNull(policy.getName());
+ assertNull(policy.getExtends());
+ assertNull(policy.getScope());
+ assertNull(policy.getAnnotations());
+ assertNull(policy.getBindings());
+ }
+
+ public void testPolicyWithName() throws Throwable
+ {
+ PolicyMetaData policy = unmarshalPolicy();
+ assertEquals("NamedPolicy", policy.getName());
+ assertNull(policy.getExtends());
+ assertNull(policy.getScope());
+ assertNull(policy.getAnnotations());
+ assertNull(policy.getBindings());
+ }
+
+ public void testPolicyWithExtends() throws Throwable
+ {
+ PolicyMetaData policy = unmarshalPolicy();
+ assertNull(policy.getName());
+ assertEquals("ExtendablePolicy", policy.getExtends());
+ assertNull(policy.getScope());
+ assertNull(policy.getAnnotations());
+ assertNull(policy.getBindings());
+ }
+
+ public void testPolicyWithScope() throws Throwable
+ {
+ PolicyMetaData policy = unmarshalPolicy();
+ assertNull(policy.getName());
+ assertNull(policy.getExtends());
+ assertNotNull(policy.getScope());
+ assertEquals("DefaultLevel", policy.getScope().getLevel());
+ assertNull(policy.getAnnotations());
+ assertNull(policy.getBindings());
+ }
+
+ public void testPolicyWithAnnotations() throws Throwable
+ {
+/*
+ PolicyMetaData policy = unmarshal("PolicyWithAnnotations.xml", AbstractPolicyMetaData.class);
+ assertNull(policy.getName());
+ assertNull(policy.getExtends());
+ assertNull(policy.getScope());
+ assertNotNull(policy.getAnnotations());
+ assertTrue(policy.getAnnotations().size() > 0);
+ assertNull(policy.getBindings());
+*/
+ }
+
+ public void testPolicyWithBindings() throws Throwable
+ {
+ PolicyMetaData policy = unmarshalPolicy();
+ assertNull(policy.getName());
+ assertNull(policy.getExtends());
+ assertNull(policy.getScope());
+ assertNull(policy.getAnnotations());
+ assertNotNull(policy.getBindings());
+ assertTrue(policy.getBindings().size() > 0);
+ }
+
+}
Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/ScopeJaxbTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/ScopeJaxbTestCase.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/ScopeJaxbTestCase.java 2008-03-03 17:24:36 UTC (rev 70329)
@@ -0,0 +1,69 @@
+/*
+* 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.kernel.deployment.xml.test;
+
+import junit.framework.Test;
+import org.jboss.beans.metadata.spi.policy.PolicyMetaData;
+import org.jboss.beans.metadata.spi.policy.ScopeMetaData;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ScopeJaxbTestCase extends AbstractPolicyTest
+{
+ public ScopeJaxbTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return suite(ScopeJaxbTestCase.class);
+ }
+
+ public void testScope() throws Throwable
+ {
+ PolicyMetaData policy = unmarshalPolicy();
+ ScopeMetaData scope = policy.getScope();
+ assertNull(scope.getLevel());
+ assertNull(scope.getQualifier());
+ }
+
+ public void testScopeWithLevel() throws Throwable
+ {
+ PolicyMetaData policy = unmarshalPolicy();
+ ScopeMetaData scope = policy.getScope();
+ assertNotNull(scope.getLevel());
+ assertEquals("DefaultLevel", scope.getLevel());
+ assertNull(scope.getQualifier());
+ }
+
+ public void testScopeWithQualifier() throws Throwable
+ {
+ PolicyMetaData policy = unmarshalPolicy();
+ ScopeMetaData scope = policy.getScope();
+ assertNull(scope.getLevel());
+ assertNotNull(scope.getQualifier());
+ assertEquals("SimpleQualifier", scope.getQualifier());
+ }
+
+}
Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/XMLTestSuite.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/XMLTestSuite.java 2008-03-03 16:55:29 UTC (rev 70328)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/XMLTestSuite.java 2008-03-03 17:24:36 UTC (rev 70329)
@@ -63,12 +63,14 @@
suite.addTest(ArrayTestCase.suite());
suite.addTest(MapTestCase.suite());
suite.addTest(AnnotationTestCase.suite());
+ suite.addTest(AliasTestCase.suite());
+ suite.addTest(CallbackTestCase.suite());
+ suite.addTest(ValueFactoryTestCase.suite());
+ // policy
suite.addTest(ScopeTestCase.suite());
suite.addTest(BindingTestCase.suite());
suite.addTest(PolicyTestCase.suite());
- suite.addTest(AliasTestCase.suite());
- suite.addTest(CallbackTestCase.suite());
- suite.addTest(ValueFactoryTestCase.suite());
+
// jaxb
suite.addTest(DeploymentJaxbTestCase.suite());
suite.addTest(BeanJaxbTestCase.suite());
@@ -94,6 +96,10 @@
suite.addTest(AliasJaxbTestCase.suite());
suite.addTest(CallbackJaxbTestCase.suite());
suite.addTest(ValueFactoryJaxbTestCase.suite());
+ // policy
+ suite.addTest(ScopeJaxbTestCase.suite());
+ suite.addTest(BindingJaxbTestCase.suite());
+ suite.addTest(PolicyJaxbTestCase.suite());
return suite;
}
More information about the jboss-cvs-commits
mailing list