[Practicalxml-commits] SF.net SVN: practicalxml:[95] branches/dev-1.1/src/test/java/net/sf/ practic
Brought to you by:
kdgregory
|
From: Auto-Generated S. C. M. <pra...@li...> - 2009-07-23 22:23:55
|
Revision: 95
http://practicalxml.svn.sourceforge.net/practicalxml/?rev=95&view=rev
Author: kdgregory
Date: 2009-07-23 22:23:42 +0000 (Thu, 23 Jul 2009)
Log Message:
-----------
refactor common code from bean converter testcases into abstract super
Modified Paths:
--------------
branches/dev-1.1/src/test/java/net/sf/practicalxml/AbstractTestCase.java
branches/dev-1.1/src/test/java/net/sf/practicalxml/converter/TestBean2XmlHandler.java
branches/dev-1.1/src/test/java/net/sf/practicalxml/converter/TestBeanConverter.java
Added Paths:
-----------
branches/dev-1.1/src/test/java/net/sf/practicalxml/converter/AbstractBeanConverterTestCase.java
Modified: branches/dev-1.1/src/test/java/net/sf/practicalxml/AbstractTestCase.java
===================================================================
--- branches/dev-1.1/src/test/java/net/sf/practicalxml/AbstractTestCase.java 2009-07-23 22:06:24 UTC (rev 94)
+++ branches/dev-1.1/src/test/java/net/sf/practicalxml/AbstractTestCase.java 2009-07-23 22:23:42 UTC (rev 95)
@@ -14,6 +14,10 @@
package net.sf.practicalxml;
+import java.util.List;
+
+import org.w3c.dom.Element;
+
import junit.framework.TestCase;
/**
@@ -41,6 +45,10 @@
}
+//----------------------------------------------------------------------------
+// Assertions
+//----------------------------------------------------------------------------
+
/**
* Asserts a multi-line string, after stripping out any '\r' characters.
* Needed for a cross-platform build.
@@ -55,4 +63,16 @@
}
assertEquals(expected, buf.toString());
}
+
+
+ /**
+ * Asserts that an element has the expected number of element children
+ * (verifies that we didn't append to the wrong element).
+ */
+ protected void assertChildCount(String message, Element parent, int expected)
+ {
+ List<Element> children = DomUtil.getChildren(parent);
+ assertEquals(message + " child count:", expected, children.size());
+ }
+
}
Added: branches/dev-1.1/src/test/java/net/sf/practicalxml/converter/AbstractBeanConverterTestCase.java
===================================================================
--- branches/dev-1.1/src/test/java/net/sf/practicalxml/converter/AbstractBeanConverterTestCase.java (rev 0)
+++ branches/dev-1.1/src/test/java/net/sf/practicalxml/converter/AbstractBeanConverterTestCase.java 2009-07-23 22:23:42 UTC (rev 95)
@@ -0,0 +1,108 @@
+// Copyright 2008-2009 severally by the contributors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package net.sf.practicalxml.converter;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+import net.sf.practicalxml.AbstractTestCase;
+
+
+/**
+ * Provides common support code (primary test bean classes) for the converter
+ * testcases. Note that the bean classes are public, so that they can be
+ * instrospected.
+ */
+public abstract class AbstractBeanConverterTestCase
+extends AbstractTestCase
+{
+ protected AbstractBeanConverterTestCase(String name)
+ {
+ super(name);
+ }
+
+
+//----------------------------------------------------------------------------
+// Test Bean Classes
+//----------------------------------------------------------------------------
+
+ public static class SimpleBean
+ {
+ private String _sval;
+ private int _ival;
+ private BigDecimal _dval;
+ private boolean _bval;
+
+ public SimpleBean()
+ {
+ // nothign to see here
+ }
+
+ public SimpleBean(String sval, int ival, BigDecimal dval, boolean bval)
+ {
+ _sval = sval;
+ _ival = ival;
+ _dval = dval;
+ _bval = bval;
+ }
+
+ public String getSval() { return _sval; }
+ public void setSval(String sval) { _sval = sval; }
+
+ public int getIval() { return _ival; }
+ public void setIval(int ival) { _ival = ival; }
+
+ public BigDecimal getDval() { return _dval; }
+ public void setDval(BigDecimal dval) { _dval = dval; }
+
+ public boolean isBval() { return _bval; }
+ public void setBval(boolean bval) { _bval = bval; }
+ }
+
+
+ public static class CompoundBean
+ {
+ private SimpleBean _simple;
+ private int[] _primArray;
+ private List<String> _stringList;
+
+ public CompoundBean()
+ {
+ // nothing here
+ }
+
+ public CompoundBean(SimpleBean simple, int[] primArray, List<String> stringList)
+ {
+ super();
+ _simple = simple;
+ _primArray = primArray;
+ _stringList = stringList;
+ }
+
+ public SimpleBean getSimple() { return _simple; }
+ public void setSimple(SimpleBean simple) { _simple = simple; }
+
+ public int[] getPrimArray() { return _primArray; }
+ public void setPrimArray(int[] primArray) { _primArray = primArray; }
+
+ public List<String> getStringList() { return _stringList; }
+ public void setStringList(List<String> list) { _stringList = list; }
+ }
+
+
+//----------------------------------------------------------------------------
+// Common Assertions
+//----------------------------------------------------------------------------
+}
Property changes on: branches/dev-1.1/src/test/java/net/sf/practicalxml/converter/AbstractBeanConverterTestCase.java
___________________________________________________________________
Added: svn:executable
+ *
Modified: branches/dev-1.1/src/test/java/net/sf/practicalxml/converter/TestBean2XmlHandler.java
===================================================================
--- branches/dev-1.1/src/test/java/net/sf/practicalxml/converter/TestBean2XmlHandler.java 2009-07-23 22:06:24 UTC (rev 94)
+++ branches/dev-1.1/src/test/java/net/sf/practicalxml/converter/TestBean2XmlHandler.java 2009-07-23 22:23:42 UTC (rev 95)
@@ -28,8 +28,6 @@
import org.w3c.dom.Element;
-import junit.framework.TestCase;
-
import net.sf.practicalxml.DomUtil;
import net.sf.practicalxml.OutputUtil;
import net.sf.practicalxml.junit.DomAsserts;
@@ -37,8 +35,14 @@
public class TestBean2XmlHandler
-extends TestCase
+extends AbstractBeanConverterTestCase
{
+ public TestBean2XmlHandler(String name)
+ {
+ super(name);
+ }
+
+
//----------------------------------------------------------------------------
// Test Data / Classes
//----------------------------------------------------------------------------
@@ -65,87 +69,7 @@
};
- // has to be public so that we can introspect it
- public static class SimpleBean
- {
- private String _sval;
- private int _ival;
- private BigDecimal _dval;
- private boolean _bval;
-
- public SimpleBean()
- {
- // nothign to see here
- }
-
- public SimpleBean(String sval, int ival, BigDecimal dval, boolean bval)
- {
- _sval = sval;
- _ival = ival;
- _dval = dval;
- _bval = bval;
- }
-
- public String getSval() { return _sval; }
- public void setSval(String sval) { _sval = sval; }
-
- public int getIval() { return _ival; }
- public void setIval(int ival) { _ival = ival; }
-
- public BigDecimal getDval() { return _dval; }
- public void setDval(BigDecimal dval) { _dval = dval; }
-
- public boolean isBval() { return _bval; }
- public void setBval(boolean bval) { _bval = bval; }
- }
-
-
- public static class CompoundBean
- {
- private SimpleBean _simple;
- private int[] _primArray;
- private List<String> _stringList;
-
- public CompoundBean()
- {
- // nothing here
- }
-
- public CompoundBean(SimpleBean simple, int[] primArray, List<String> stringList)
- {
- super();
- _simple = simple;
- _primArray = primArray;
- _stringList = stringList;
- }
-
- public SimpleBean getSimple() { return _simple; }
- public void setSimple(SimpleBean simple) { _simple = simple; }
-
- public int[] getPrimArray() { return _primArray; }
- public void setPrimArray(int[] primArray) { _primArray = primArray; }
-
- public List<String> getStringList() { return _stringList; }
- public void setStringList(List<String> list) { _stringList = list; }
- }
-
-
-//----------------------------------------------------------------------------
-// Support Code
-//----------------------------------------------------------------------------
-
/**
- * Asserts that an element has the expected number of children (verifies
- * that we didn't append to the wrong element).
- */
- private void assertChildCount(String message, Element parent, int expected)
- {
- List<Element> children = DomUtil.getChildren(parent);
- assertEquals(message + " child count:", expected, children.size());
- }
-
-
- /**
* Asserts the name, type, and value of an element. If any of the expected
* values are null, the associated test isn't performed.
*/
Modified: branches/dev-1.1/src/test/java/net/sf/practicalxml/converter/TestBeanConverter.java
===================================================================
--- branches/dev-1.1/src/test/java/net/sf/practicalxml/converter/TestBeanConverter.java 2009-07-23 22:06:24 UTC (rev 94)
+++ branches/dev-1.1/src/test/java/net/sf/practicalxml/converter/TestBeanConverter.java 2009-07-23 22:23:42 UTC (rev 95)
@@ -21,7 +21,6 @@
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import junit.framework.TestCase;
/**
* Tests for the top-level <code>BeanConverter</code> methods. These tend to
@@ -29,12 +28,19 @@
* and {@link TestBeanInputHandler}.
*/
public class TestBeanConverter
-extends TestCase
+extends AbstractBeanConverterTestCase
{
+ public TestBeanConverter(String name)
+ {
+ super(name);
+ }
+
+
//----------------------------------------------------------------------------
// Support Code
//----------------------------------------------------------------------------
+
//----------------------------------------------------------------------------
// Test Cases
//----------------------------------------------------------------------------
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|