[jboss-cvs] JBossAS SVN: r106819 - in projects/jboss-jca/trunk/common/src: test/java/org/jboss/jca/common/metadata/ra and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Jul 19 11:01:50 EDT 2010
Author: maeste
Date: 2010-07-19 11:01:49 -0400 (Mon, 19 Jul 2010)
New Revision: 106819
Added:
projects/jboss-jca/trunk/common/src/test/java/org/jboss/jca/common/metadata/ra/JbossRaParserTestCase.java
projects/jboss-jca/trunk/common/src/test/java/org/jboss/jca/common/metadata/ra/package.html
Removed:
projects/jboss-jca/trunk/common/src/test/java/org/jboss/jca/common/metadata/ra/RaParserTestCase.java
Modified:
projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/jbossra/JbossRaParser.java
Log:
JBJCA-385: jboss-ra_1_0 test suitei completed
Modified: projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/jbossra/JbossRaParser.java
===================================================================
--- projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/jbossra/JbossRaParser.java 2010-07-19 14:40:52 UTC (rev 106818)
+++ projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/jbossra/JbossRaParser.java 2010-07-19 15:01:49 UTC (rev 106819)
@@ -63,70 +63,71 @@
{
InputStream input = null;
XMLStreamReader reader = null;
+ JbossRa jbossRa = null;
try
{
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
input = new FileInputStream(xmlFile);
reader = inputFactory.createXMLStreamReader(input);
- JbossRa jbossRa = null;
- while (reader.hasNext())
+ //iterate over tags
+ switch (reader.nextTag())
{
- switch (reader.nextTag())
- {
- case END_ELEMENT : {
- // should mean we're done, so ignore it.
- break;
- }
- case START_ELEMENT : {
- if (JbossRa10.NAMESPACE.equals(reader.getNamespaceURI()))
+ case END_ELEMENT : {
+ // should mean we're done, so ignore it.
+ break;
+ }
+ case START_ELEMENT : {
+ if (JbossRa10.NAMESPACE.equals(reader.getNamespaceURI()))
+ {
+ switch (Tag.forName(reader.getLocalName()))
{
- switch (Tag.forName(reader.getLocalName()))
- {
- case JBOSSRA : {
- jbossRa = parseJbossRa10(reader);
- break;
- }
- default :
- throw new ParserException("Unexpected element:" + reader.getLocalName());
+ case JBOSSRA : {
+ jbossRa = parseJbossRa10(reader);
+ break;
}
+ default :
+ throw new ParserException("Unexpected element:" + reader.getLocalName());
+ }
- }
- else if (JbossRa20.NAMESPACE.equals(reader.getNamespaceURI()))
+ }
+ else if (JbossRa20.NAMESPACE.equals(reader.getNamespaceURI()))
+ {
+ switch (Tag.forName(reader.getLocalName()))
{
- switch (Tag.forName(reader.getLocalName()))
- {
- case JBOSSRA : {
- jbossRa = parseJbossRa20(reader, jbossRa);
- break;
- }
- default :
- throw new ParserException("Unexpected element:" + reader.getLocalName());
+ case JBOSSRA : {
+ jbossRa = parseJbossRa20(reader, jbossRa);
+ break;
}
+ default :
+ throw new ParserException("Unexpected element:" + reader.getLocalName());
}
- else
- {
- throw new ParserException(String.format("Namespace %s is not supported by %s parser",
- reader.getNamespaceURI(), this.getClass().getName()));
- }
+ }
+ else
+ {
+ throw new ParserException(String.format("Namespace %s is not supported by %s parser",
+ reader.getNamespaceURI(), this.getClass().getName()));
+ }
- break;
- }
- default :
- throw new IllegalStateException();
+ break;
}
+ default :
+ throw new IllegalStateException();
}
- return jbossRa;
}
+ catch (XMLStreamException e)
+ {
+ //ignore it. It is just saying that it isn't a tag
+ }
finally
{
if (reader != null)
reader.close();
if (input != null)
input.close();
-
}
+ return jbossRa;
}
Added: projects/jboss-jca/trunk/common/src/test/java/org/jboss/jca/common/metadata/ra/JbossRaParserTestCase.java
===================================================================
--- projects/jboss-jca/trunk/common/src/test/java/org/jboss/jca/common/metadata/ra/JbossRaParserTestCase.java (rev 0)
+++ projects/jboss-jca/trunk/common/src/test/java/org/jboss/jca/common/metadata/ra/JbossRaParserTestCase.java 2010-07-19 15:01:49 UTC (rev 106819)
@@ -0,0 +1,157 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jca.common.metadata.ra;
+
+import org.jboss.jca.common.metadata.jbossra.JbossRa;
+import org.jboss.jca.common.metadata.jbossra.JbossRaParser;
+import org.jboss.jca.common.metadata.jbossra.jbossra10.JbossRa10;
+import org.jboss.jca.common.metadata.jbossra.jbossra20.RaConfigProperty;
+
+import java.io.File;
+
+import org.junit.Test;
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsInstanceOf.instanceOf;
+import static org.junit.Assert.assertThat;
+
+/**
+ *
+ * A RaParserTestCase.
+ *
+ * @author <a href="stefano.maestri at jboss.com">Stefano Maestri</a>
+ *
+ */
+public class JbossRaParserTestCase
+{
+ /**
+ * shouldParseJbossRa10WithSingleProperty
+ * @throws Exception in case of error
+ */
+ @Test
+ public void shouldParseJbossRa10WithSingleProperty() throws Exception
+ {
+ //given
+ File xmlFile = new File(Thread.currentThread().getContextClassLoader()
+ .getResource("jboss-ra-1.0-single-attribute.xml").toURI());
+ JbossRaParser parser = new JbossRaParser();
+ //when
+ JbossRa jbossRa = parser.parse(xmlFile);
+ //then
+ assertThat(jbossRa, instanceOf(JbossRa10.class));
+ assertThat(jbossRa.getRaConfigProperties().size(), is(1));
+ assertThat(
+ jbossRa
+ .getRaConfigProperties()
+ .get(0)
+ .equals(
+ RaConfigProperty.buildRaConfigProperty("ra-config-property-name0", "ra-config-property-value0",
+ "ra-config-property-type0", null)), is(true));
+
+ }
+
+ /**
+ *
+ * shouldParseJbossRa10WithOutProperties
+ *
+ * @throws Exception in case of error
+ */
+ @Test
+ public void shouldParseJbossRa10WithOutProperties() throws Exception
+ {
+ //given
+ File xmlFile = new File(Thread.currentThread().getContextClassLoader()
+ .getResource("jboss-ra-1.0-no-attributes.xml").toURI());
+ JbossRaParser parser = new JbossRaParser();
+ //when
+ JbossRa jbossRa = parser.parse(xmlFile);
+ //then
+ assertThat(jbossRa, instanceOf(JbossRa10.class));
+ assertThat(jbossRa.getRaConfigProperties().size(), is(0));
+
+ }
+
+ /**
+ *
+ * shouldParseJbossRa10WithMultipleProperties
+ *
+ * @throws Exception in case of error
+ */
+ @Test
+ public void shouldParseJbossRa10WithMultipleProperties() throws Exception
+ {
+ //given
+ File xmlFile = new File(Thread.currentThread().getContextClassLoader()
+ .getResource("jboss-ra-1.0-multiple-attributes.xml").toURI());
+ JbossRaParser parser = new JbossRaParser();
+ //when
+ JbossRa jbossRa = parser.parse(xmlFile);
+ //then
+ assertThat(jbossRa, instanceOf(JbossRa10.class));
+ assertThat(jbossRa.getRaConfigProperties().size(), is(2));
+ assertThat(
+ jbossRa
+ .getRaConfigProperties()
+ .get(0)
+ .equals(
+ RaConfigProperty.buildRaConfigProperty("ra-config-property-name0", "ra-config-property-value0",
+ "ra-config-property-type0", null)), is(true));
+ assertThat(
+ jbossRa
+ .getRaConfigProperties()
+ .get(1)
+ .equals(
+ RaConfigProperty.buildRaConfigProperty("ra-config-property-name1", "ra-config-property-value1",
+ "ra-config-property-type1", null)), is(true));
+ }
+
+ // @Test
+ // public void shouldParseJbossRa10WithTonsOfProperties() throws Exception
+ // {
+ // //given
+ // File xmlFile = new File(Thread.currentThread().getContextClassLoader()
+ // .getResource("jboss-ra-1.0-tons-attributes.xml").toURI());
+ // JbossRaParser parser = new JbossRaParser();
+ // //when
+ // JbossRa jbossRa = parser.parse(xmlFile);
+ // //then
+ // assertThat(jbossRa, instanceOf(JbossRa10.class));
+ // assertThat(jbossRa.getRaConfigProperties().size(), is(200000));
+ // assertThat(
+ // jbossRa
+ // .getRaConfigProperties()
+ // .get(0)
+ // .equals(
+ // RaConfigProperty.buildRaConfigProperty("ra-config-property-name0",
+ // "ra-config-property-value0",
+ // "ra-config-property-type0", null)), is(true));
+ // assertThat(
+ // jbossRa
+ // .getRaConfigProperties()
+ // .get(1)
+ // .equals(
+ // RaConfigProperty.buildRaConfigProperty("ra-config-property-name1",
+ //"ra-config-property-value1",
+ // "ra-config-property-type1", null)), is(true));
+ // }
+
+}
Deleted: projects/jboss-jca/trunk/common/src/test/java/org/jboss/jca/common/metadata/ra/RaParserTestCase.java
===================================================================
--- projects/jboss-jca/trunk/common/src/test/java/org/jboss/jca/common/metadata/ra/RaParserTestCase.java 2010-07-19 14:40:52 UTC (rev 106818)
+++ projects/jboss-jca/trunk/common/src/test/java/org/jboss/jca/common/metadata/ra/RaParserTestCase.java 2010-07-19 15:01:49 UTC (rev 106819)
@@ -1,72 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.jca.common.metadata.ra;
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertTrue;
-
-public class RaParserTestCase
-{
- /**
- * shouldParseJbossRa10WithSingleProperty
- * @throws Exception in case of error
- */
- @Test
- public void shouldParseJbossRa10WithSingleProperty() throws Exception
- {
- //given
- // File xmlFile = new File(Thread.currentThread().getContextClassLoader()
- // .getResource("jboss-ra-1.0-single-attribute.xml").toURI());
- // JbossRaParser parser = new JbossRaParser();
- // //when
- // JbossRa jbossRa = parser.parse(xmlFile);
- // //then
- // assertThat(jbossRa, instanceOf(JbossRa10.class));
- assertTrue(true);
- }
-
- /**
- *
- * shouldParseJbossRa10WithOutProperties
- *
- * @throws Exception in case of error
- */
- @Test
- public void shouldParseJbossRa10WithOutProperties() throws Exception
- {
- assertTrue(true);
- }
-
- /**
- *
- * shouldParseJbossRa10WithMultipleProperties
- *
- * @throws Exception in case of error
- */
- @Test
- public void shouldParseJbossRa10WithMultipleProperties() throws Exception
- {
- assertTrue(true);
- }
-
-}
Added: projects/jboss-jca/trunk/common/src/test/java/org/jboss/jca/common/metadata/ra/package.html
===================================================================
--- projects/jboss-jca/trunk/common/src/test/java/org/jboss/jca/common/metadata/ra/package.html (rev 0)
+++ projects/jboss-jca/trunk/common/src/test/java/org/jboss/jca/common/metadata/ra/package.html 2010-07-19 15:01:49 UTC (rev 106819)
@@ -0,0 +1,3 @@
+<body>
+This package contains Ra parser tet cases
+</body>
More information about the jboss-cvs-commits
mailing list