You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by si...@apache.org on 2010/09/01 20:15:24 UTC
svn commit: r991633 [2/2] - in /commons/proper/digester/trunk: ./
src/test/org/apache/commons/digester/
src/test/org/apache/commons/digester/annotations/
src/test/org/apache/commons/digester/annotations/addressbook/
src/test/org/apache/commons/digester...
Modified: commons/proper/digester/trunk/src/test/org/apache/commons/digester/XMLSchemaTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/test/org/apache/commons/digester/XMLSchemaTestCase.java?rev=991633&r1=991632&r2=991633&view=diff
==============================================================================
--- commons/proper/digester/trunk/src/test/org/apache/commons/digester/XMLSchemaTestCase.java (original)
+++ commons/proper/digester/trunk/src/test/org/apache/commons/digester/XMLSchemaTestCase.java Wed Sep 1 18:15:22 2010
@@ -20,6 +20,11 @@
package org.apache.commons.digester;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
import java.io.IOException;
import java.io.InputStream;
@@ -27,10 +32,9 @@ import javax.xml.XMLConstants;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
@@ -40,7 +44,7 @@ import org.xml.sax.SAXParseException;
* <p>Tests for XInclude aware parsing.</p>
*
*/
-public class XMLSchemaTestCase extends TestCase {
+public class XMLSchemaTestCase {
// ----------------------------------------------------- Instance Variables
@@ -52,28 +56,13 @@ public class XMLSchemaTestCase extends T
protected Digester digester = null;
- // ----------------------------------------------------------- Constructors
-
-
- /**
- * Construct a new instance of this test case.
- *
- * @param name Name of the test case
- */
- public XMLSchemaTestCase(String name) {
-
- super(name);
-
- }
-
-
// --------------------------------------------------- Overall Test Methods
/**
* Set up instance variables required by this test case.
*/
- @Override
+ @Before
public void setUp() throws SAXException {
digester = new Digester();
@@ -101,19 +90,9 @@ public class XMLSchemaTestCase extends T
/**
- * Return the tests included in this test suite.
- */
- public static Test suite() {
-
- return (new TestSuite(XMLSchemaTestCase.class));
-
- }
-
-
- /**
* Tear down instance variables required by this test case.
*/
- @Override
+ @After
public void tearDown() {
digester = null;
@@ -128,6 +107,7 @@ public class XMLSchemaTestCase extends T
/**
* Test XML Schema validation.
*/
+ @Test
public void testGoodDocument() throws SAXException, IOException {
// Listen to validation errors
@@ -147,6 +127,7 @@ public class XMLSchemaTestCase extends T
}
+ @Test
public void testBadDocument() throws SAXException, IOException {
// Listen to validation errors
Modified: commons/proper/digester/trunk/src/test/org/apache/commons/digester/annotations/AbstractAnnotatedPojoTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/test/org/apache/commons/digester/annotations/AbstractAnnotatedPojoTestCase.java?rev=991633&r1=991632&r2=991633&view=diff
==============================================================================
--- commons/proper/digester/trunk/src/test/org/apache/commons/digester/annotations/AbstractAnnotatedPojoTestCase.java (original)
+++ commons/proper/digester/trunk/src/test/org/apache/commons/digester/annotations/AbstractAnnotatedPojoTestCase.java Wed Sep 1 18:15:22 2010
@@ -16,11 +16,13 @@
*/
package org.apache.commons.digester.annotations;
-import java.io.InputStream;
+import static org.junit.Assert.assertEquals;
-import junit.framework.TestCase;
+import java.io.InputStream;
import org.apache.commons.digester.Digester;
+import org.junit.After;
+import org.junit.Before;
/**
* Abstract implementation of Class->Digester Rules->parse & confronting.
@@ -28,23 +30,17 @@ import org.apache.commons.digester.Diges
* @version $Id$
* @since 2.1
*/
-public abstract class AbstractAnnotatedPojoTestCase extends TestCase {
+public abstract class AbstractAnnotatedPojoTestCase {
private DigesterLoader digesterLoader;
- /**
- * {@inheritDoc}
- */
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
this.digesterLoader = DigesterLoaderBuilder.byDefaultFactories();
}
- /**
- * {@inheritDoc}
- */
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
this.digesterLoader = null;
}
Modified: commons/proper/digester/trunk/src/test/org/apache/commons/digester/annotations/addressbook/AddressBookTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/test/org/apache/commons/digester/annotations/addressbook/AddressBookTestCase.java?rev=991633&r1=991632&r2=991633&view=diff
==============================================================================
--- commons/proper/digester/trunk/src/test/org/apache/commons/digester/annotations/addressbook/AddressBookTestCase.java (original)
+++ commons/proper/digester/trunk/src/test/org/apache/commons/digester/annotations/addressbook/AddressBookTestCase.java Wed Sep 1 18:15:22 2010
@@ -17,6 +17,7 @@
package org.apache.commons.digester.annotations.addressbook;
import org.apache.commons.digester.annotations.AbstractAnnotatedPojoTestCase;
+import org.junit.Test;
/**
*
@@ -26,6 +27,7 @@ import org.apache.commons.digester.annot
*/
public final class AddressBookTestCase extends AbstractAnnotatedPojoTestCase {
+ @Test
public void testAddressBook() throws Exception {
AddressBook addressBook = new AddressBook();
Modified: commons/proper/digester/trunk/src/test/org/apache/commons/digester/annotations/catalog/CatalogTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/test/org/apache/commons/digester/annotations/catalog/CatalogTestCase.java?rev=991633&r1=991632&r2=991633&view=diff
==============================================================================
--- commons/proper/digester/trunk/src/test/org/apache/commons/digester/annotations/catalog/CatalogTestCase.java (original)
+++ commons/proper/digester/trunk/src/test/org/apache/commons/digester/annotations/catalog/CatalogTestCase.java Wed Sep 1 18:15:22 2010
@@ -18,6 +18,7 @@ package org.apache.commons.digester.anno
import org.apache.commons.digester.Digester;
import org.apache.commons.digester.annotations.AbstractAnnotatedPojoTestCase;
+import org.junit.Test;
/**
*
@@ -27,6 +28,7 @@ import org.apache.commons.digester.annot
*/
public final class CatalogTestCase extends AbstractAnnotatedPojoTestCase {
+ @Test
public void testCatalog() throws Exception {
Catalog catalog = new Catalog();
Modified: commons/proper/digester/trunk/src/test/org/apache/commons/digester/annotations/employee/EmployeeTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/test/org/apache/commons/digester/annotations/employee/EmployeeTestCase.java?rev=991633&r1=991632&r2=991633&view=diff
==============================================================================
--- commons/proper/digester/trunk/src/test/org/apache/commons/digester/annotations/employee/EmployeeTestCase.java (original)
+++ commons/proper/digester/trunk/src/test/org/apache/commons/digester/annotations/employee/EmployeeTestCase.java Wed Sep 1 18:15:22 2010
@@ -18,6 +18,7 @@ package org.apache.commons.digester.anno
import org.apache.commons.digester.Digester;
import org.apache.commons.digester.annotations.AbstractAnnotatedPojoTestCase;
+import org.junit.Test;
/**
*
@@ -26,6 +27,7 @@ import org.apache.commons.digester.annot
*/
public final class EmployeeTestCase extends AbstractAnnotatedPojoTestCase {
+ @Test
public void testEmployee() throws Exception {
Employee employee = new Employee();
employee.setFirstName("First Name");
Modified: commons/proper/digester/trunk/src/test/org/apache/commons/digester/annotations/person/PersonTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/test/org/apache/commons/digester/annotations/person/PersonTestCase.java?rev=991633&r1=991632&r2=991633&view=diff
==============================================================================
--- commons/proper/digester/trunk/src/test/org/apache/commons/digester/annotations/person/PersonTestCase.java (original)
+++ commons/proper/digester/trunk/src/test/org/apache/commons/digester/annotations/person/PersonTestCase.java Wed Sep 1 18:15:22 2010
@@ -17,6 +17,7 @@
package org.apache.commons.digester.annotations.person;
import org.apache.commons.digester.annotations.AbstractAnnotatedPojoTestCase;
+import org.junit.Test;
/**
*
@@ -25,6 +26,7 @@ import org.apache.commons.digester.annot
*/
public final class PersonTestCase extends AbstractAnnotatedPojoTestCase {
+ @Test
public void testPerson() throws Exception {
Person person = new Person();
person.setId(1);
Modified: commons/proper/digester/trunk/src/test/org/apache/commons/digester/annotations/rss/RssTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/test/org/apache/commons/digester/annotations/rss/RssTestCase.java?rev=991633&r1=991632&r2=991633&view=diff
==============================================================================
--- commons/proper/digester/trunk/src/test/org/apache/commons/digester/annotations/rss/RssTestCase.java (original)
+++ commons/proper/digester/trunk/src/test/org/apache/commons/digester/annotations/rss/RssTestCase.java Wed Sep 1 18:15:22 2010
@@ -17,6 +17,7 @@
package org.apache.commons.digester.annotations.rss;
import org.apache.commons.digester.annotations.AbstractAnnotatedPojoTestCase;
+import org.junit.Test;
/**
*
@@ -26,6 +27,7 @@ import org.apache.commons.digester.annot
*/
public final class RssTestCase extends AbstractAnnotatedPojoTestCase {
+ @Test
public void testRss() throws Exception {
Channel channel = new Channel();
channel.setTitle("Apache");
Modified: commons/proper/digester/trunk/src/test/org/apache/commons/digester/annotations/servletbean/ServletBeanTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/test/org/apache/commons/digester/annotations/servletbean/ServletBeanTestCase.java?rev=991633&r1=991632&r2=991633&view=diff
==============================================================================
--- commons/proper/digester/trunk/src/test/org/apache/commons/digester/annotations/servletbean/ServletBeanTestCase.java (original)
+++ commons/proper/digester/trunk/src/test/org/apache/commons/digester/annotations/servletbean/ServletBeanTestCase.java Wed Sep 1 18:15:22 2010
@@ -17,6 +17,7 @@
package org.apache.commons.digester.annotations.servletbean;
import org.apache.commons.digester.annotations.AbstractAnnotatedPojoTestCase;
+import org.junit.Test;
/**
*
@@ -25,6 +26,7 @@ import org.apache.commons.digester.annot
*/
public final class ServletBeanTestCase extends AbstractAnnotatedPojoTestCase {
+ @Test
public void testServletBean() throws Exception {
ServletBean servletBean = new ServletBean();
servletBean.setServletName("action");
Copied: commons/proper/digester/trunk/src/test/org/apache/commons/digester/plugins/ObjectTestImpl.java (from r990027, commons/proper/digester/trunk/src/test/org/apache/commons/digester/plugins/TestObject.java)
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/test/org/apache/commons/digester/plugins/ObjectTestImpl.java?p2=commons/proper/digester/trunk/src/test/org/apache/commons/digester/plugins/ObjectTestImpl.java&p1=commons/proper/digester/trunk/src/test/org/apache/commons/digester/plugins/TestObject.java&r1=990027&r2=991633&rev=991633&view=diff
==============================================================================
--- commons/proper/digester/trunk/src/test/org/apache/commons/digester/plugins/TestObject.java (original)
+++ commons/proper/digester/trunk/src/test/org/apache/commons/digester/plugins/ObjectTestImpl.java Wed Sep 1 18:15:22 2010
@@ -21,11 +21,11 @@ package org.apache.commons.digester.plug
* Test harness object for holding results of digestion.
*/
-public class TestObject {
+public class ObjectTestImpl {
private String value;
- public TestObject() {
+ public ObjectTestImpl() {
}
public void setValue(String val) {
Modified: commons/proper/digester/trunk/src/test/org/apache/commons/digester/plugins/TestConfigurablePluginAttributes.java
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/test/org/apache/commons/digester/plugins/TestConfigurablePluginAttributes.java?rev=991633&r1=991632&r2=991633&view=diff
==============================================================================
--- commons/proper/digester/trunk/src/test/org/apache/commons/digester/plugins/TestConfigurablePluginAttributes.java (original)
+++ commons/proper/digester/trunk/src/test/org/apache/commons/digester/plugins/TestConfigurablePluginAttributes.java Wed Sep 1 18:15:22 2010
@@ -19,43 +19,23 @@
package org.apache.commons.digester.plugins;
-import java.util.List;
-import java.util.LinkedList;
+import static org.junit.Assert.*;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import java.util.LinkedList;
+import java.util.List;
import org.apache.commons.digester.Digester;
+import org.junit.Test;
/**
* Test cases for functionality which sets what xml attributes specify
* the plugin class or plugin declaration id.
*/
-public class TestConfigurablePluginAttributes extends TestCase {
- /** Standard constructor */
- public TestConfigurablePluginAttributes(String name) {
- super(name);
- }
-
- /** Set up instance variables required by this test case. */
- @Override
- public void setUp() {}
-
- /** Return the tests included in this test suite. */
- public static Test suite() {
-
- return (new TestSuite(TestConfigurablePluginAttributes.class));
+public class TestConfigurablePluginAttributes {
- }
-
- /** Tear down instance variables required by this test case.*/
- @Override
- public void tearDown() {}
-
// --------------------------------------------------------------- Test cases
-
+ @Test
public void testDefaultBehaviour() throws Exception {
// tests that by default the attributes used are
// named "plugin-class" and "plugin-id"
@@ -81,7 +61,7 @@ public class TestConfigurablePluginAttri
try {
digester.parse(
- TestAll.getInputStream(this, "test7.xml"));
+ Utils.getInputStream(this, "test7.xml"));
} catch(Exception e) {
throw e;
@@ -105,7 +85,8 @@ public class TestConfigurablePluginAttri
assertEquals(TextLabel.class, gadgets.get(2).getClass());
assertEquals(TextLabel.class, gadgets.get(3).getClass());
}
-
+
+ @Test
public void testGlobalOverride() throws Exception {
// Tests that using setDefaultPluginXXXX overrides behaviour for all
// PluginCreateRule instances. Also tests specifying attributes
@@ -138,7 +119,7 @@ public class TestConfigurablePluginAttri
try {
digester.parse(
- TestAll.getInputStream(this, "test7.xml"));
+ Utils.getInputStream(this, "test7.xml"));
} catch(Exception e) {
throw e;
@@ -162,7 +143,8 @@ public class TestConfigurablePluginAttri
assertEquals(Slider.class, gadgets.get(2).getClass());
assertEquals(Slider.class, gadgets.get(3).getClass());
}
-
+
+ @Test
public void testInstanceOverride() throws Exception {
// Tests that using setPluginXXXX overrides behaviour for only
// that particular PluginCreateRule instance. Also tests that
@@ -197,7 +179,7 @@ public class TestConfigurablePluginAttri
try {
digester.parse(
- TestAll.getInputStream(this, "test7.xml"));
+ Utils.getInputStream(this, "test7.xml"));
} catch(Exception e) {
throw e;
}
Modified: commons/proper/digester/trunk/src/test/org/apache/commons/digester/plugins/TestDeclaration.java
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/test/org/apache/commons/digester/plugins/TestDeclaration.java?rev=991633&r1=991632&r2=991633&view=diff
==============================================================================
--- commons/proper/digester/trunk/src/test/org/apache/commons/digester/plugins/TestDeclaration.java (original)
+++ commons/proper/digester/trunk/src/test/org/apache/commons/digester/plugins/TestDeclaration.java Wed Sep 1 18:15:22 2010
@@ -19,41 +19,21 @@
package org.apache.commons.digester.plugins;
-import java.util.List;
+import static org.junit.Assert.*;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import java.util.List;
import org.apache.commons.digester.Digester;
+import org.junit.Test;
/**
* Test cases for basic PluginDeclarationRule behaviour.
*/
-public class TestDeclaration extends TestCase {
- /** Standard constructor */
- public TestDeclaration(String name) {
- super(name);
- }
-
- /** Set up instance variables required by this test case. */
- @Override
- public void setUp() {}
-
- /** Return the tests included in this test suite. */
- public static Test suite() {
+public class TestDeclaration {
- return (new TestSuite(TestDeclaration.class));
-
- }
-
- /** Tear down instance variables required by this test case.*/
- @Override
- public void tearDown() {}
-
// --------------------------------------------------------------- Test cases
-
+ @Test
public void testPredeclaration() throws Exception {
// * tests that rules can be declared via a PluginDeclarationRule
@@ -73,7 +53,7 @@ public class TestDeclaration extends Tes
try {
digester.parse(
- TestAll.getInputStream(this, "test3.xml"));
+ Utils.getInputStream(this, "test3.xml"));
}
catch(Exception e) {
throw e;
Modified: commons/proper/digester/trunk/src/test/org/apache/commons/digester/plugins/TestDefaultPlugin.java
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/test/org/apache/commons/digester/plugins/TestDefaultPlugin.java?rev=991633&r1=991632&r2=991633&view=diff
==============================================================================
--- commons/proper/digester/trunk/src/test/org/apache/commons/digester/plugins/TestDefaultPlugin.java (original)
+++ commons/proper/digester/trunk/src/test/org/apache/commons/digester/plugins/TestDefaultPlugin.java Wed Sep 1 18:15:22 2010
@@ -19,46 +19,20 @@
package org.apache.commons.digester.plugins;
-import java.util.List;
+import static org.junit.Assert.*;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import java.util.List;
import org.apache.commons.digester.Digester;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.impl.NoOpLog;
-
-/**
- * Test cases for the use of default plugin classes.
- */
-
+import org.junit.Test;
import org.xml.sax.SAXParseException;
-public class TestDefaultPlugin extends TestCase {
- /** Standard constructor */
- public TestDefaultPlugin(String name) {
- super(name);
- }
-
- /** Set up instance variables required by this test case. */
- @Override
- public void setUp() {}
-
- /** Return the tests included in this test suite. */
- public static Test suite() {
-
- return (new TestSuite(TestDefaultPlugin.class));
+public class TestDefaultPlugin {
- }
-
- /** Tear down instance variables required by this test case.*/
- @Override
- public void tearDown() {}
-
// --------------------------------------------------------------- Test cases
-
+ @Test
public void testDefaultPlugins1() throws Exception {
// * tests that when a PluginCreateRule is defined with a default
// class, that the default class is instantiated when no class
@@ -76,7 +50,7 @@ public class TestDefaultPlugin extends T
try {
digester.parse(
- TestAll.getInputStream(this, "test2.xml"));
+ Utils.getInputStream(this, "test2.xml"));
}
catch(Exception e) {
throw e;
@@ -125,7 +99,7 @@ public class TestDefaultPlugin extends T
try {
digester.setLogger(new NoOpLog());
digester.parse(
- TestAll.getInputStream(this, "test2.xml"));
+ Utils.getInputStream(this, "test2.xml"));
}
catch(Exception e) {
exception = e;
@@ -160,7 +134,7 @@ public class TestDefaultPlugin extends T
try {
digester.setLogger(new NoOpLog());
digester.parse(
- TestAll.getInputStream(this, "test2.xml"));
+ Utils.getInputStream(this, "test2.xml"));
}
catch(Exception e) {
exception = e;
Modified: commons/proper/digester/trunk/src/test/org/apache/commons/digester/plugins/TestDelegate.java
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/test/org/apache/commons/digester/plugins/TestDelegate.java?rev=991633&r1=991632&r2=991633&view=diff
==============================================================================
--- commons/proper/digester/trunk/src/test/org/apache/commons/digester/plugins/TestDelegate.java (original)
+++ commons/proper/digester/trunk/src/test/org/apache/commons/digester/plugins/TestDelegate.java Wed Sep 1 18:15:22 2010
@@ -19,37 +19,16 @@
package org.apache.commons.digester.plugins;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
import org.apache.commons.digester.Digester;
+import org.junit.Test;
/**
* Test cases for Delegate behaviour.
*/
-public class TestDelegate extends TestCase {
- /** Standard constructor */
- public TestDelegate(String name) {
- super(name);
- }
-
- /** Set up instance variables required by this test case. */
- @Override
- public void setUp() {}
-
- /** Return the tests included in this test suite. */
- public static Test suite() {
- return (new TestSuite(TestDelegate.class));
- }
-
- /** Tear down instance variables required by this test case.*/
- @Override
- public void tearDown() {}
-
+public class TestDelegate {
// --------------------------------------------------------------- Test cases
-
+ @Test
public void testDummy() {
// it is an error if a TestSuite doesn't have at least one test,
// so here is one...
@@ -69,7 +48,7 @@ public class TestDelegate extends TestCa
try {
digester.parse(
- TestAll.getInputStream(this, "test1.xml"));
+ Utils.getInputStream(this, "test1.xml"));
}
catch(Exception e) {
throw e;
Modified: commons/proper/digester/trunk/src/test/org/apache/commons/digester/plugins/TestInline.java
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/test/org/apache/commons/digester/plugins/TestInline.java?rev=991633&r1=991632&r2=991633&view=diff
==============================================================================
--- commons/proper/digester/trunk/src/test/org/apache/commons/digester/plugins/TestInline.java (original)
+++ commons/proper/digester/trunk/src/test/org/apache/commons/digester/plugins/TestInline.java Wed Sep 1 18:15:22 2010
@@ -19,42 +19,22 @@
package org.apache.commons.digester.plugins;
-import java.util.List;
+import static org.junit.Assert.*;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import java.util.List;
import org.apache.commons.digester.Digester;
+import org.junit.Test;
/**
* Test cases for declaration of plugin classes "inline" (ie by specifying
* plugin-class).
*/
-public class TestInline extends TestCase {
- /** Standard constructor */
- public TestInline(String name) {
- super(name);
- }
-
- /** Set up instance variables required by this test case. */
- @Override
- public void setUp() {}
-
- /** Return the tests included in this test suite. */
- public static Test suite() {
-
- return (new TestSuite(TestInline.class));
+public class TestInline {
- }
-
- /** Tear down instance variables required by this test case.*/
- @Override
- public void tearDown() {}
-
// --------------------------------------------------------------- Test cases
-
+ @Test
public void testInlineDeclaration() throws Exception {
// * tests that plugins can be specified by class, and that the
// correct class gets loaded.
@@ -74,7 +54,7 @@ public class TestInline extends TestCase
try {
digester.parse(
- TestAll.getInputStream(this, "test1.xml"));
+ Utils.getInputStream(this, "test1.xml"));
}
catch(Exception e) {
throw e;
@@ -99,7 +79,8 @@ public class TestInline extends TestCase
assertEquals("L1", label2.getId());
assertEquals("2", label2.getLabel());
}
-
+
+ @Test
public void testLeadingSlash() throws Exception {
// Tests that PluginRules handles patterns with a leading slash.
//
@@ -120,7 +101,7 @@ public class TestInline extends TestCase
try {
digester.parse(
- TestAll.getInputStream(this, "test1.xml"));
+ Utils.getInputStream(this, "test1.xml"));
}
catch(Exception e) {
throw e;
Modified: commons/proper/digester/trunk/src/test/org/apache/commons/digester/plugins/TestLocalRules.java
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/test/org/apache/commons/digester/plugins/TestLocalRules.java?rev=991633&r1=991632&r2=991633&view=diff
==============================================================================
--- commons/proper/digester/trunk/src/test/org/apache/commons/digester/plugins/TestLocalRules.java (original)
+++ commons/proper/digester/trunk/src/test/org/apache/commons/digester/plugins/TestLocalRules.java Wed Sep 1 18:15:22 2010
@@ -19,41 +19,21 @@
package org.apache.commons.digester.plugins;
-import java.util.List;
+import static org.junit.Assert.*;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import java.util.List;
import org.apache.commons.digester.Digester;
+import org.junit.Test;
/**
* Test cases for defining custom rules on the plugin class itself.
*/
-public class TestLocalRules extends TestCase {
- /** Standard constructor */
- public TestLocalRules(String name) {
- super(name);
- }
-
- /** Set up instance variables required by this test case. */
- @Override
- public void setUp() {}
-
- /** Return the tests included in this test suite. */
- public static Test suite() {
+public class TestLocalRules {
- return (new TestSuite(TestLocalRules.class));
-
- }
-
- /** Tear down instance variables required by this test case.*/
- @Override
- public void tearDown() {}
-
// --------------------------------------------------------------- Test cases
-
+ @Test
public void testLocalRules() throws Exception {
// * tests that the plugin class can define an addRules method,
// which gets detected and executed.
@@ -73,7 +53,7 @@ public class TestLocalRules extends Test
try {
digester.parse(
- TestAll.getInputStream(this, "test4a.xml"));
+ Utils.getInputStream(this, "test4a.xml"));
}
catch(Exception e) {
throw e;
@@ -110,7 +90,8 @@ public class TestLocalRules extends Test
assertEquals(TextLabel.class, child.getClass());
assertEquals("text1", ((TextLabel)child).getLabel());
}
-
+
+ @Test
public void testNonStandardLocalRules() throws Exception {
// * tests that using PluginDeclarationRule to declare an alternate
// rule method name invokes that alternate method instead (the
@@ -136,7 +117,7 @@ public class TestLocalRules extends Test
try {
digester.parse(
- TestAll.getInputStream(this, "test4b.xml"));
+ Utils.getInputStream(this, "test4b.xml"));
}
catch(Exception e) {
throw e;
Modified: commons/proper/digester/trunk/src/test/org/apache/commons/digester/plugins/TestRecursion.java
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/test/org/apache/commons/digester/plugins/TestRecursion.java?rev=991633&r1=991632&r2=991633&view=diff
==============================================================================
--- commons/proper/digester/trunk/src/test/org/apache/commons/digester/plugins/TestRecursion.java (original)
+++ commons/proper/digester/trunk/src/test/org/apache/commons/digester/plugins/TestRecursion.java Wed Sep 1 18:15:22 2010
@@ -19,42 +19,22 @@
package org.apache.commons.digester.plugins;
-import java.util.List;
+import static org.junit.Assert.*;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import java.util.List;
import org.apache.commons.digester.Digester;
+import org.junit.Test;
/**
* Test cases for plugins with custom rules which include PluginCreateRule
* instances, allowing recursive datastructures to be processed.
*/
-public class TestRecursion extends TestCase {
- /** Standard constructor */
- public TestRecursion(String name) {
- super(name);
- }
-
- /** Set up instance variables required by this test case. */
- @Override
- public void setUp() {}
-
- /** Return the tests included in this test suite. */
- public static Test suite() {
+public class TestRecursion {
- return (new TestSuite(TestRecursion.class));
-
- }
-
- /** Tear down instance variables required by this test case.*/
- @Override
- public void tearDown() {}
-
// --------------------------------------------------------------- Test cases
-
+ @Test
public void testRecursiveRules() throws Exception {
// * tests that a rule can declare custom PluginCreateRules
// that allow it to plug in instances of itself below
@@ -76,7 +56,7 @@ public class TestRecursion extends TestC
try {
digester.parse(
- TestAll.getInputStream(this, "test6.xml"));
+ Utils.getInputStream(this, "test6.xml"));
}
catch(Exception e) {
throw e;
Modified: commons/proper/digester/trunk/src/test/org/apache/commons/digester/plugins/TestRuleInfo.java
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/test/org/apache/commons/digester/plugins/TestRuleInfo.java?rev=991633&r1=991632&r2=991633&view=diff
==============================================================================
--- commons/proper/digester/trunk/src/test/org/apache/commons/digester/plugins/TestRuleInfo.java (original)
+++ commons/proper/digester/trunk/src/test/org/apache/commons/digester/plugins/TestRuleInfo.java Wed Sep 1 18:15:22 2010
@@ -19,42 +19,22 @@
package org.apache.commons.digester.plugins;
-import java.util.List;
+import static org.junit.Assert.*;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import java.util.List;
import org.apache.commons.digester.Digester;
+import org.junit.Test;
/**
* Test cases for the declaration of custom rules for a plugin using
* a separate class to define the rules.
*/
-public class TestRuleInfo extends TestCase {
- /** Standard constructor */
- public TestRuleInfo(String name) {
- super(name);
- }
-
- /** Set up instance variables required by this test case. */
- @Override
- public void setUp() {}
-
- /** Return the tests included in this test suite. */
- public static Test suite() {
-
- return (new TestSuite(TestRuleInfo.class));
+public class TestRuleInfo {
- }
-
- /** Tear down instance variables required by this test case.*/
- @Override
- public void tearDown() {}
-
// --------------------------------------------------------------- Test cases
-
+ @Test
public void testRuleInfoExplicitClass() throws Exception {
// * tests that custom rules can be declared on a
// separate class by explicitly declaring the rule class.
@@ -75,7 +55,7 @@ public class TestRuleInfo extends TestCa
try {
digester.parse(
- TestAll.getInputStream(this, "test5a.xml"));
+ Utils.getInputStream(this, "test5a.xml"));
}
catch(Exception e) {
throw e;
@@ -95,7 +75,8 @@ public class TestRuleInfo extends TestCa
assertEquals("anonymous", label.getId());
assertEquals("std label", label.getLabel());
}
-
+
+ @Test
public void testRuleInfoExplicitMethod() throws Exception {
// * tests that custom rules can be declared on a
// separate class by explicitly declaring the rule class.
@@ -117,7 +98,7 @@ public class TestRuleInfo extends TestCa
try {
digester.parse(
- TestAll.getInputStream(this, "test5b.xml"));
+ Utils.getInputStream(this, "test5b.xml"));
}
catch(Exception e) {
throw e;
@@ -137,7 +118,8 @@ public class TestRuleInfo extends TestCa
assertEquals("anonymous", label.getId());
assertEquals("alt label", label.getLabel());
}
-
+
+ @Test
public void testRuleInfoAutoDetect() throws Exception {
// * tests that custom rules can be declared on a
// separate class with name {plugin-class}RuleInfo,
@@ -159,7 +141,7 @@ public class TestRuleInfo extends TestCa
try {
digester.parse(
- TestAll.getInputStream(this, "test5c.xml"));
+ Utils.getInputStream(this, "test5c.xml"));
}
catch(Exception e) {
throw e;
Modified: commons/proper/digester/trunk/src/test/org/apache/commons/digester/plugins/TestXmlRuleInfo.java
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/test/org/apache/commons/digester/plugins/TestXmlRuleInfo.java?rev=991633&r1=991632&r2=991633&view=diff
==============================================================================
--- commons/proper/digester/trunk/src/test/org/apache/commons/digester/plugins/TestXmlRuleInfo.java (original)
+++ commons/proper/digester/trunk/src/test/org/apache/commons/digester/plugins/TestXmlRuleInfo.java Wed Sep 1 18:15:22 2010
@@ -18,42 +18,22 @@
package org.apache.commons.digester.plugins;
-import java.io.StringReader;
+import static org.junit.Assert.*;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import java.io.StringReader;
import org.apache.commons.digester.Digester;
+import org.junit.Test;
/**
* Test cases for the declaration of custom rules for a plugin using
* xmlrules format files.
*/
-public class TestXmlRuleInfo extends TestCase {
- /** Standard constructor */
- public TestXmlRuleInfo(String name) {
- super(name);
- }
-
- /** Set up instance variables required by this test case. */
- @Override
- public void setUp() {}
-
- /** Return the tests included in this test suite. */
- public static Test suite() {
-
- return (new TestSuite(TestXmlRuleInfo.class));
+public class TestXmlRuleInfo {
- }
-
- /** Tear down instance variables required by this test case.*/
- @Override
- public void tearDown() {}
-
// --------------------------------------------------------------- Test cases
-
+ @Test
public void testXmlRuleInfoExplicitFile() throws Exception {
// * tests that custom rules can be declared on a
// separate class by explicitly declaring a file containing
@@ -63,7 +43,7 @@ public class TestXmlRuleInfo extends Tes
input.append("<root>");
input.append(" <plugin");
input.append(" id='testobject'");
- input.append(" class='org.apache.commons.digester.plugins.TestObject'");
+ input.append(" class='org.apache.commons.digester.plugins.ObjectTestImpl'");
input.append(" file='src/test/org/apache/commons/digester/plugins/xmlrules1.xml'");
input.append(" />");
input.append(" <object plugin-id='testobject'/>");
@@ -76,7 +56,7 @@ public class TestXmlRuleInfo extends Tes
PluginDeclarationRule pdr = new PluginDeclarationRule();
digester.addRule("root/plugin", pdr);
- PluginCreateRule pcr = new PluginCreateRule(TestObject.class);
+ PluginCreateRule pcr = new PluginCreateRule(ObjectTestImpl.class);
digester.addRule("root/object", pcr);
try {
@@ -87,11 +67,12 @@ public class TestXmlRuleInfo extends Tes
}
Object root = digester.getRoot();
- assertEquals(TestObject.class, root.getClass());
- TestObject testObject = (TestObject) root;
+ assertEquals(ObjectTestImpl.class, root.getClass());
+ ObjectTestImpl testObject = (ObjectTestImpl) root;
assertEquals("xmlrules1", testObject.getValue());
}
+ @Test
public void testXmlRuleInfoExplicitResource() throws Exception {
// * tests that custom rules can be declared on a
// separate class by explicitly declaring the rule class.
@@ -102,7 +83,7 @@ public class TestXmlRuleInfo extends Tes
input.append("<root>");
input.append(" <plugin");
input.append(" id='testobject'");
- input.append(" class='org.apache.commons.digester.plugins.TestObject'");
+ input.append(" class='org.apache.commons.digester.plugins.ObjectTestImpl'");
input.append(" resource='org/apache/commons/digester/plugins/xmlrules2.xml'");
input.append(" />");
input.append(" <object plugin-id='testobject'/>");
@@ -115,7 +96,7 @@ public class TestXmlRuleInfo extends Tes
PluginDeclarationRule pdr = new PluginDeclarationRule();
digester.addRule("root/plugin", pdr);
- PluginCreateRule pcr = new PluginCreateRule(TestObject.class);
+ PluginCreateRule pcr = new PluginCreateRule(ObjectTestImpl.class);
digester.addRule("root/object", pcr);
try {
@@ -126,11 +107,12 @@ public class TestXmlRuleInfo extends Tes
}
Object root = digester.getRoot();
- assertEquals(TestObject.class, root.getClass());
- TestObject testObject = (TestObject) root;
+ assertEquals(ObjectTestImpl.class, root.getClass());
+ ObjectTestImpl testObject = (ObjectTestImpl) root;
assertEquals("xmlrules2", testObject.getValue());
}
-
+
+ @Test
public void testXmlRuleImplicitResource() throws Exception {
// * tests that custom rules can be declared on a
// separate class by explicitly declaring the rule class.
@@ -141,7 +123,7 @@ public class TestXmlRuleInfo extends Tes
input.append("<root>");
input.append(" <plugin");
input.append(" id='testobject'");
- input.append(" class='org.apache.commons.digester.plugins.TestObject'");
+ input.append(" class='org.apache.commons.digester.plugins.ObjectTestImpl'");
input.append(" />");
input.append(" <object plugin-id='testobject'/>");
input.append("</root>");
@@ -153,7 +135,7 @@ public class TestXmlRuleInfo extends Tes
PluginDeclarationRule pdr = new PluginDeclarationRule();
digester.addRule("root/plugin", pdr);
- PluginCreateRule pcr = new PluginCreateRule(TestObject.class);
+ PluginCreateRule pcr = new PluginCreateRule(ObjectTestImpl.class);
digester.addRule("root/object", pcr);
try {
@@ -164,8 +146,8 @@ public class TestXmlRuleInfo extends Tes
}
Object root = digester.getRoot();
- assertEquals(TestObject.class, root.getClass());
- TestObject testObject = (TestObject) root;
+ assertEquals(ObjectTestImpl.class, root.getClass());
+ ObjectTestImpl testObject = (ObjectTestImpl) root;
assertEquals("xmlrules-ruleinfo", testObject.getValue());
}
}
Copied: commons/proper/digester/trunk/src/test/org/apache/commons/digester/plugins/Utils.java (from r990027, commons/proper/digester/trunk/src/test/org/apache/commons/digester/plugins/TestAll.java)
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/test/org/apache/commons/digester/plugins/Utils.java?p2=commons/proper/digester/trunk/src/test/org/apache/commons/digester/plugins/Utils.java&p1=commons/proper/digester/trunk/src/test/org/apache/commons/digester/plugins/TestAll.java&r1=990027&r2=991633&rev=991633&view=diff
==============================================================================
--- commons/proper/digester/trunk/src/test/org/apache/commons/digester/plugins/TestAll.java (original)
+++ commons/proper/digester/trunk/src/test/org/apache/commons/digester/plugins/Utils.java Wed Sep 1 18:15:22 2010
@@ -17,56 +17,15 @@
*/
package org.apache.commons.digester.plugins;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import java.io.InputStream;
import java.io.IOException;
+import java.io.InputStream;
/**
* Entry point for all plugins package tests.
*
* @author Simon Kitching
*/
-public class TestAll extends TestCase {
- public TestAll(String testName) {
- super(testName);
- }
-
- // MORE TESTS REQUIRED::
- // test that problem is detected if rules object not PluginRules
- // test that problem is detected if wildcard pattern used
- // test that problem is detected if rule mounted with multiple patterns
- // test that problem is detected if specified class doesn't descend
- // from required base class.
- // test scenario where bodytext of actual plugin element is accessed
-
- // test rules in resource
- // test rules in explicit file
- // test autosetdefaults on/off
-
-
- public static Test suite() {
- TestSuite suite = new TestSuite();
- suite.addTest(TestXmlRuleInfo.suite());
- suite.addTest(TestInline.suite());
- suite.addTest(TestDelegate.suite());
- suite.addTest(TestDeclaration.suite());
- suite.addTest(TestDefaultPlugin.suite());
- suite.addTest(TestLocalRules.suite());
- suite.addTest(TestRuleInfo.suite());
- suite.addTest(TestRecursion.suite());
- suite.addTest(TestConfigurablePluginAttributes.suite());
- return suite;
- }
-
- public static void main(String args[]) {
- String[] testCaseName = { TestAll.class.getName() };
- junit.textui.TestRunner.main(testCaseName);
- }
-
- // ------------------------------------------------ Utility Support Methods
+public class Utils {
/**
* Return an appropriate InputStream for the specified test file (which
Modified: commons/proper/digester/trunk/src/test/org/apache/commons/digester/substitution/VariableExpansionTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/test/org/apache/commons/digester/substitution/VariableExpansionTestCase.java?rev=991633&r1=991632&r2=991633&view=diff
==============================================================================
--- commons/proper/digester/trunk/src/test/org/apache/commons/digester/substitution/VariableExpansionTestCase.java (original)
+++ commons/proper/digester/trunk/src/test/org/apache/commons/digester/substitution/VariableExpansionTestCase.java Wed Sep 1 18:15:22 2010
@@ -19,19 +19,17 @@
package org.apache.commons.digester.substitution;
-import org.apache.commons.digester.CallMethodRule;
-import org.apache.commons.digester.Digester;
-import org.apache.commons.digester.SimpleTestBean;
+import static org.junit.Assert.*;
import java.io.IOException;
import java.io.StringReader;
import java.util.HashMap;
import java.util.LinkedList;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
+import org.apache.commons.digester.CallMethodRule;
+import org.apache.commons.digester.Digester;
+import org.apache.commons.digester.SimpleTestBean;
+import org.junit.Test;
import org.xml.sax.SAXException;
/**
@@ -41,46 +39,10 @@ import org.xml.sax.SAXException;
* @version $Revision$ $Date$
*/
-public class VariableExpansionTestCase extends TestCase {
-
- // ----------------------------------------------------------- Constructors
-
- /**
- * Construct a new instance of this test case.
- *
- * @param name Name of the test case
- */
- public VariableExpansionTestCase(String name) {
-
- super(name);
-
- }
+public class VariableExpansionTestCase {
// --------------------------------------------------- Overall Test Methods
- /**
- * Set up instance variables required by this test case.
- */
- @Override
- public void setUp() {
- }
-
-
- /**
- * Return the tests included in this test suite.
- */
- public static Test suite() {
- return (new TestSuite(VariableExpansionTestCase.class));
- }
-
-
- /**
- * Tear down instance variables required by this test case.
- */
- @Override
- public void tearDown() {
- }
-
// method used in tests4
private LinkedList<SimpleTestBean> simpleTestBeans = new LinkedList<SimpleTestBean>();
public void addSimpleTestBean(SimpleTestBean bean) {
@@ -131,6 +93,7 @@ public class VariableExpansionTestCase e
/**
* Test that by default no expansion occurs.
*/
+ @Test
public void testNoExpansion() throws SAXException, IOException {
String xml = "<root alpha='${attr1}' beta='var{attr2}'/>";
@@ -154,6 +117,7 @@ public class VariableExpansionTestCase e
/**
* Test that a MultiVariableExpander with no sources does no expansion.
*/
+ @Test
public void testExpansionWithNoSource() throws SAXException, IOException {
String xml = "<root alpha='${attr1}' beta='var{attr2}'/>";
@@ -181,6 +145,7 @@ public class VariableExpansionTestCase e
* It also tests that expansion works ok where multiple elements
* exist.
*/
+ @Test
public void testExpansionWithMultipleSources() throws SAXException, IOException {
String xml =
@@ -234,6 +199,7 @@ public class VariableExpansionTestCase e
/**
* Test expansion of text in element bodies.
*/
+ @Test
public void testBodyExpansion() throws SAXException, IOException {
String xml =
@@ -278,6 +244,7 @@ public class VariableExpansionTestCase e
/**
* Test that an unknown variable causes a RuntimeException.
*/
+ @Test
public void testExpansionException() throws IOException {
String xml = "<root alpha='${attr1}'/>";
@@ -317,6 +284,7 @@ public class VariableExpansionTestCase e
* @throws IOException
* @throws SAXException
*/
+ @Test
public void testExpansionWithMutableSource() throws SAXException, IOException {
String xml =
"<root>" +
@@ -349,6 +317,7 @@ public class VariableExpansionTestCase e
* @throws IOException
* @throws SAXException
*/
+ @Test
public void testExpansionOfPropertyInProperty() throws SAXException, IOException {
String xml =
"<root>" +
Modified: commons/proper/digester/trunk/src/test/org/apache/commons/digester/xmlrules/DigesterLoaderRulesTest.java
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/test/org/apache/commons/digester/xmlrules/DigesterLoaderRulesTest.java?rev=991633&r1=991632&r2=991633&view=diff
==============================================================================
--- commons/proper/digester/trunk/src/test/org/apache/commons/digester/xmlrules/DigesterLoaderRulesTest.java (original)
+++ commons/proper/digester/trunk/src/test/org/apache/commons/digester/xmlrules/DigesterLoaderRulesTest.java Wed Sep 1 18:15:22 2010
@@ -17,13 +17,13 @@
*/
package org.apache.commons.digester.xmlrules;
-import java.io.StringReader;
-
-import junit.framework.TestCase;
+import static org.junit.Assert.*;
-import org.xml.sax.InputSource;
+import java.io.StringReader;
import org.apache.commons.digester.Digester;
+import org.junit.Test;
+import org.xml.sax.InputSource;
/**
* Tests for digester loader rule implementations,
@@ -31,12 +31,9 @@ import org.apache.commons.digester.Diges
* @author Robert Burrell Donkin
*/
-public class DigesterLoaderRulesTest extends TestCase {
+public class DigesterLoaderRulesTest {
- public DigesterLoaderRulesTest(java.lang.String testName) {
- super(testName);
- }
-
+ @Test
/** Basic test for object param rule */
public void testObjectParamRule() throws Exception {
String xmlRules =
@@ -76,6 +73,7 @@ public class DigesterLoaderRulesTest ext
}
/** Test for call method rule with target offset */
+ @Test
public void testCallMethodRuleTargetOffset() throws Exception {
String xmlRules =
"<?xml version='1.0'?>" +
Modified: commons/proper/digester/trunk/src/test/org/apache/commons/digester/xmlrules/DigesterLoaderTest.java
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/test/org/apache/commons/digester/xmlrules/DigesterLoaderTest.java?rev=991633&r1=991632&r2=991633&view=diff
==============================================================================
--- commons/proper/digester/trunk/src/test/org/apache/commons/digester/xmlrules/DigesterLoaderTest.java (original)
+++ commons/proper/digester/trunk/src/test/org/apache/commons/digester/xmlrules/DigesterLoaderTest.java Wed Sep 1 18:15:22 2010
@@ -20,19 +20,21 @@
package org.apache.commons.digester.xmlrules;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.io.InputStream;
import java.io.StringReader;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
import org.apache.commons.digester.Address;
import org.apache.commons.digester.Digester;
-import org.apache.commons.digester.TestObjectCreationFactory;
-
+import org.apache.commons.digester.ObjectCreationFactoryTestImpl;
+import org.junit.Test;
import org.w3c.dom.Node;
import org.xml.sax.InputSource;
@@ -43,27 +45,14 @@ import org.xml.sax.InputSource;
* @author Scott Sanders - Added ASL, removed external dependencies
*/
-public class DigesterLoaderTest extends TestCase {
-
- public DigesterLoaderTest(java.lang.String testName) {
- super(testName);
- }
-
- public static void main(java.lang.String[] args) {
- junit.textui.TestRunner.run(suite());
- }
-
- public static junit.framework.Test suite() {
- TestSuite suite = new TestSuite(DigesterLoaderTest.class);
-
- return suite;
- }
+public class DigesterLoaderTest {
/**
* Tests the DigesterLoader.createDigester(), with multiple
* included rule sources: testrules.xml includes another rules xml
* file, and also includes programmatically created rules.
*/
+ @Test
public void testCreateDigester() throws Exception {
URL rules = getClass().getClassLoader().getResource("org/apache/commons/digester/xmlrules/testrules.xml");
URL input = getClass().getClassLoader().getResource("org/apache/commons/digester/xmlrules/test.xml");
@@ -80,6 +69,7 @@ public class DigesterLoaderTest extends
* sources: testrules.xml includes another rules xml file, and
* also includes programmatically created rules.
*/
+ @Test
public void testLoad1() throws Exception {
ClassLoader classLoader = getClass().getClassLoader();
URL rules = classLoader.getResource("org/apache/commons/digester/xmlrules/testrules.xml");
@@ -95,10 +85,10 @@ public class DigesterLoaderTest extends
@SuppressWarnings("unchecked") // root is an ArrayList
ArrayList<Object> al = (ArrayList<Object>)root;
Object obj = al.get(0);
- if (! (obj instanceof TestObject)) {
+ if (! (obj instanceof ObjectTestImpl)) {
fail("Unexpected object returned from DigesterLoader. Expected TestObject; got " + obj.getClass().getName());
}
- TestObject to = (TestObject)obj;
+ ObjectTestImpl to = (ObjectTestImpl)obj;
assertEquals(new Long(555),to.getLongValue());
assertEquals( "foo", to.getMapValue( "test1" ) );
assertEquals( "bar", to.getMapValue( "test2" ) );
@@ -108,6 +98,7 @@ public class DigesterLoaderTest extends
* The same as testLoad1, exception the input file is passed to
* DigesterLoader as an InputStream instead of a URL.
*/
+ @Test
public void testLoad2() throws Exception {
URL rules = getClass().getClassLoader().getResource("org/apache/commons/digester/xmlrules/testrules.xml");
InputStream input = getClass().getClassLoader().getResource("org/apache/commons/digester/xmlrules/test.xml").openStream();
@@ -119,15 +110,16 @@ public class DigesterLoaderTest extends
ArrayList<Object> list = (ArrayList<Object>) root;
assertEquals(root.toString(), "[foo1 baz1 foo2, foo3 foo4]");
assertEquals("Wrong number of classes created", 2 , list.size());
- assertEquals("Pushed first", true , ((TestObject)list.get(0)).isPushed());
- assertEquals("Didn't push second", false , ((TestObject)list.get(1)).isPushed());
- assertTrue("Property was set properly", ((TestObject)list.get(0)).getProperty().equals("I am a property!") );
+ assertEquals("Pushed first", true , ((ObjectTestImpl)list.get(0)).isPushed());
+ assertEquals("Didn't push second", false , ((ObjectTestImpl)list.get(1)).isPushed());
+ assertTrue("Property was set properly", ((ObjectTestImpl)list.get(0)).getProperty().equals("I am a property!") );
}
/**
* Validates that circular includes are detected and result in an exception
*/
+ @Test
public void testCircularInclude1() {
URL rules = ClassLoader.getSystemResource("org/apache/commons/digester/xmlrules/testCircularRules.xml");
try {
@@ -142,6 +134,7 @@ public class DigesterLoaderTest extends
/**
*/
+ @Test
public void testSetCustomProperties() throws Exception {
URL rules = getClass().getClassLoader().getResource
("org/apache/commons/digester/xmlrules/testPropertyAliasRules.xml");
@@ -192,7 +185,8 @@ public class DigesterLoaderTest extends
assertEquals("(4) State attribute", "Ohio", addressFour.getState());
}
-
+
+ @Test
public void testFactoryCreateRule() throws Exception {
URL rules = getClass().getClassLoader().getResource
("org/apache/commons/digester/xmlrules/testfactory.xml");
@@ -202,7 +196,7 @@ public class DigesterLoaderTest extends
rules,
getClass().getClassLoader(),
new StringReader(xml),
- new ArrayList<TestObjectCreationFactory>());
+ new ArrayList<ObjectCreationFactoryTestImpl>());
if (!(obj instanceof ArrayList<?>)) {
fail(
@@ -211,10 +205,10 @@ public class DigesterLoaderTest extends
}
@SuppressWarnings("unchecked") // root is an ArrayList of TestObjectCreationFactory
- ArrayList<TestObjectCreationFactory> list = (ArrayList<TestObjectCreationFactory>) obj;
+ ArrayList<ObjectCreationFactoryTestImpl> list = (ArrayList<ObjectCreationFactoryTestImpl>) obj;
assertEquals("List should contain only the factory object", list.size() , 1);
- TestObjectCreationFactory factory = list.get(0);
+ ObjectCreationFactoryTestImpl factory = list.get(0);
assertEquals("Object create not called(1)", factory.called , true);
assertEquals(
"Attribute not passed (1)",
@@ -259,6 +253,7 @@ public class DigesterLoaderTest extends
}
}
+ @Test
public void testCallParamRule() throws Exception {
URL rules = getClass().getClassLoader().getResource
@@ -279,7 +274,8 @@ public class DigesterLoaderTest extends
assertEquals("Incorrect middle value", "short", testObject.getMiddle());
assertEquals("Incorrect right value", "", testObject.getRight());
}
-
+
+ @Test
public void testInputSourceLoader() throws Exception {
String rulesXml = "<?xml version='1.0'?>"
+ "<digester-rules>"
@@ -315,6 +311,7 @@ public class DigesterLoaderTest extends
assertEquals("Incorrect right value", "", testObject.getRight());
}
+ @Test
public void testNodeCreateRule() throws Exception {
URL rules = getClass().getClassLoader().getResource("org/apache/commons/digester/xmlrules/test-node-create-rules.xml");
Modified: commons/proper/digester/trunk/src/test/org/apache/commons/digester/xmlrules/DigesterPatternStackTest.java
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/test/org/apache/commons/digester/xmlrules/DigesterPatternStackTest.java?rev=991633&r1=991632&r2=991633&view=diff
==============================================================================
--- commons/proper/digester/trunk/src/test/org/apache/commons/digester/xmlrules/DigesterPatternStackTest.java (original)
+++ commons/proper/digester/trunk/src/test/org/apache/commons/digester/xmlrules/DigesterPatternStackTest.java Wed Sep 1 18:15:22 2010
@@ -19,8 +19,10 @@
package org.apache.commons.digester.xmlrules;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import static org.junit.Assert.*;
+
+import org.junit.Before;
+import org.junit.Test;
/**
@@ -31,33 +33,21 @@ import junit.framework.TestSuite;
* DigesterRuleParser.PatternStack.toString() returns the properly
* formatted string.
*/
-public class DigesterPatternStackTest extends TestCase {
-
- public DigesterPatternStackTest(String testName) {
- super(testName);
- }
-
- public static void main(java.lang.String[] args) {
- junit.textui.TestRunner.run(suite());
- }
-
- public static junit.framework.Test suite() {
- TestSuite suite = new TestSuite(DigesterPatternStackTest.class);
-
- return suite;
- }
+public class DigesterPatternStackTest {
private DigesterRuleParser parser;
- @Override
+ @Before
public void setUp() {
parser = new DigesterRuleParser();
}
+ @Test
public void test1() throws Exception {
assertEquals("", parser.patternStack.toString());
}
+ @Test
public void test2() throws Exception {
parser.patternStack.push("A");
assertEquals("A", parser.patternStack.toString());
@@ -65,6 +55,7 @@ public class DigesterPatternStackTest ex
assertEquals("", parser.patternStack.toString());
}
+ @Test
public void test3() throws Exception {
parser.patternStack.push("A");
parser.patternStack.push("B");
@@ -74,6 +65,7 @@ public class DigesterPatternStackTest ex
assertEquals("A", parser.patternStack.toString());
}
+ @Test
public void test4() throws Exception {
parser.patternStack.push("");
assertEquals("", parser.patternStack.toString());
@@ -82,6 +74,7 @@ public class DigesterPatternStackTest ex
assertEquals("", parser.patternStack.toString());
}
+ @Test
public void test5() throws Exception {
parser.patternStack.push("A");
assertEquals("A", parser.patternStack.toString());
@@ -92,6 +85,7 @@ public class DigesterPatternStackTest ex
}
+ @Test
public void test6() throws Exception {
parser.patternStack.push("A");
parser.patternStack.push("B");
@@ -99,6 +93,7 @@ public class DigesterPatternStackTest ex
assertEquals("", parser.patternStack.toString());
}
+ @Test
public void test7() throws Exception {
parser.patternStack.push("///");
assertEquals("///", parser.patternStack.toString());
Copied: commons/proper/digester/trunk/src/test/org/apache/commons/digester/xmlrules/DigesterRulesSourceTestImpl.java (from r990027, commons/proper/digester/trunk/src/test/org/apache/commons/digester/xmlrules/TestDigesterRulesSource.java)
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/test/org/apache/commons/digester/xmlrules/DigesterRulesSourceTestImpl.java?p2=commons/proper/digester/trunk/src/test/org/apache/commons/digester/xmlrules/DigesterRulesSourceTestImpl.java&p1=commons/proper/digester/trunk/src/test/org/apache/commons/digester/xmlrules/TestDigesterRulesSource.java&r1=990027&r2=991633&rev=991633&view=diff
==============================================================================
--- commons/proper/digester/trunk/src/test/org/apache/commons/digester/xmlrules/TestDigesterRulesSource.java (original)
+++ commons/proper/digester/trunk/src/test/org/apache/commons/digester/xmlrules/DigesterRulesSourceTestImpl.java Wed Sep 1 18:15:22 2010
@@ -30,14 +30,14 @@ import org.apache.commons.digester.Diges
* @author David H. Martin - Initial Contribution
* @author Scott Sanders - Added ASL, removed external dependencies
*/
-public class TestDigesterRulesSource implements DigesterRulesSource {
+public class DigesterRulesSourceTestImpl implements DigesterRulesSource {
/**
* Creates and adds Digester Rules to a given Rules object
* @param digester the Digester to add the new Rule objects to
*/
public void getRules(Digester digester) {
- digester.addObjectCreate("/baz", TestObject.class.getName());
+ digester.addObjectCreate("/baz", ObjectTestImpl.class.getName());
digester.addSetNext("/baz", "add", "java.lang.Object");
digester.addSetProperties("/baz");
}
Modified: commons/proper/digester/trunk/src/test/org/apache/commons/digester/xmlrules/FromXmlRuleSetTest.java
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/test/org/apache/commons/digester/xmlrules/FromXmlRuleSetTest.java?rev=991633&r1=991632&r2=991633&view=diff
==============================================================================
--- commons/proper/digester/trunk/src/test/org/apache/commons/digester/xmlrules/FromXmlRuleSetTest.java (original)
+++ commons/proper/digester/trunk/src/test/org/apache/commons/digester/xmlrules/FromXmlRuleSetTest.java Wed Sep 1 18:15:22 2010
@@ -19,40 +19,25 @@
package org.apache.commons.digester.xmlrules;
-import java.io.StringReader;
+import static org.junit.Assert.*;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import java.io.StringReader;
import org.apache.commons.digester.Digester;
-
+import org.junit.Test;
import org.xml.sax.InputSource;
/**
* Tests loading Digester rules from an XML file.
*/
-public class FromXmlRuleSetTest extends TestCase {
-
- public FromXmlRuleSetTest(java.lang.String testName) {
- super(testName);
- }
-
- public static void main(java.lang.String[] args) {
- junit.textui.TestRunner.run(suite());
- }
-
- public static junit.framework.Test suite() {
- TestSuite suite = new TestSuite(FromXmlRuleSetTest.class);
-
- return suite;
- }
+public class FromXmlRuleSetTest {
/**
* Test the FromXmlRules.addRuleInstances(digester, path) method, ie
* test loading rules at a base position other than the root.
*/
-
+ @Test
public void testBasePath() throws Exception {
String xmlRules =
"<?xml version='1.0'?>" +
@@ -73,7 +58,7 @@ public class FromXmlRuleSetTest extends
// First try with no base path. The rule shouldn't match, because
// foo is not the root element.
{
- TestObject testObject = new TestObject();
+ ObjectTestImpl testObject = new ObjectTestImpl();
FromXmlRuleSet ruleset =
new FromXmlRuleSet(
new InputSource(new StringReader(xmlRules)));
@@ -88,7 +73,7 @@ public class FromXmlRuleSetTest extends
// Now try with a base path. The rule should now match.
{
- TestObject testObject = new TestObject();
+ ObjectTestImpl testObject = new ObjectTestImpl();
FromXmlRuleSet ruleset =
new FromXmlRuleSet(
new InputSource(new StringReader(xmlRules)));
Modified: commons/proper/digester/trunk/src/test/org/apache/commons/digester/xmlrules/IncludeTest.java
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/test/org/apache/commons/digester/xmlrules/IncludeTest.java?rev=991633&r1=991632&r2=991633&view=diff
==============================================================================
--- commons/proper/digester/trunk/src/test/org/apache/commons/digester/xmlrules/IncludeTest.java (original)
+++ commons/proper/digester/trunk/src/test/org/apache/commons/digester/xmlrules/IncludeTest.java Wed Sep 1 18:15:22 2010
@@ -18,19 +18,20 @@
package org.apache.commons.digester.xmlrules;
-import java.util.ArrayList;
-import java.io.StringReader;
-import org.xml.sax.InputSource;
+import static org.junit.Assert.assertEquals;
-import junit.framework.TestCase;
+import java.io.StringReader;
+import java.util.ArrayList;
import org.apache.commons.digester.Digester;
import org.apache.commons.digester.Rule;
+import org.junit.Test;
+import org.xml.sax.InputSource;
/**
* Test for the include class functionality
*/
-public class IncludeTest extends TestCase {
+public class IncludeTest {
public static class TestDigesterRuleSource implements DigesterRulesSource {
public void getRules(Digester digester) {
@@ -44,10 +45,7 @@ public class IncludeTest extends TestCas
}
}
- public IncludeTest(String testName) {
- super(testName);
- }
-
+ @Test
public void testBasicInclude() throws Exception {
String rulesXml = "<?xml version='1.0'?>"
+ "<digester-rules>"
Copied: commons/proper/digester/trunk/src/test/org/apache/commons/digester/xmlrules/ObjectTestImpl.java (from r990027, commons/proper/digester/trunk/src/test/org/apache/commons/digester/xmlrules/TestObject.java)
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/test/org/apache/commons/digester/xmlrules/ObjectTestImpl.java?p2=commons/proper/digester/trunk/src/test/org/apache/commons/digester/xmlrules/ObjectTestImpl.java&p1=commons/proper/digester/trunk/src/test/org/apache/commons/digester/xmlrules/TestObject.java&r1=990027&r2=991633&rev=991633&view=diff
==============================================================================
--- commons/proper/digester/trunk/src/test/org/apache/commons/digester/xmlrules/TestObject.java (original)
+++ commons/proper/digester/trunk/src/test/org/apache/commons/digester/xmlrules/ObjectTestImpl.java Wed Sep 1 18:15:22 2010
@@ -30,7 +30,7 @@ import java.util.HashMap;
* @author Scott Sanders - Added ASL, removed external dependencies
* @author Tim O'Brien - Added bean property to test bean property setter rule
*/
-public class TestObject {
+public class ObjectTestImpl {
private ArrayList<Object> children = new ArrayList<Object>();
private String value = "";
@@ -42,7 +42,7 @@ public class TestObject {
private boolean pushed = false;
- public TestObject() {
+ public ObjectTestImpl() {
}
@Override
Modified: commons/proper/digester/trunk/src/test/org/apache/commons/digester/xmlrules/testCircularRules.xml
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/test/org/apache/commons/digester/xmlrules/testCircularRules.xml?rev=991633&r1=991632&r2=991633&view=diff
==============================================================================
--- commons/proper/digester/trunk/src/test/org/apache/commons/digester/xmlrules/testCircularRules.xml (original)
+++ commons/proper/digester/trunk/src/test/org/apache/commons/digester/xmlrules/testCircularRules.xml Wed Sep 1 18:15:22 2010
@@ -23,7 +23,7 @@
<digester-rules>
<pattern value="root/foo">
- <object-create-rule classname="org.apache.commons.digester.xmlrules.TestObject"/>
+ <object-create-rule classname="org.apache.commons.digester.xmlrules.ObjectTestImpl"/>
<set-next-rule methodname="add" paramtype="java.lang.Object"/>
<set-properties-rule/>
<include path="org/apache/commons/digester/xmlrules/testCircularRules.xml"/>
Modified: commons/proper/digester/trunk/src/test/org/apache/commons/digester/xmlrules/testfactory.xml
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/test/org/apache/commons/digester/xmlrules/testfactory.xml?rev=991633&r1=991632&r2=991633&view=diff
==============================================================================
--- commons/proper/digester/trunk/src/test/org/apache/commons/digester/xmlrules/testfactory.xml (original)
+++ commons/proper/digester/trunk/src/test/org/apache/commons/digester/xmlrules/testfactory.xml Wed Sep 1 18:15:22 2010
@@ -20,7 +20,7 @@
<digester-rules>
<pattern value="root">
<factory-create-rule
- classname="org.apache.commons.digester.TestObjectCreationFactory"
+ classname="org.apache.commons.digester.ObjectCreationFactoryTestImpl"
ignore-exceptions='true'/>
<set-next-rule methodname="add"/>
</pattern>
Modified: commons/proper/digester/trunk/src/test/org/apache/commons/digester/xmlrules/testrules.xml
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/test/org/apache/commons/digester/xmlrules/testrules.xml?rev=991633&r1=991632&r2=991633&view=diff
==============================================================================
--- commons/proper/digester/trunk/src/test/org/apache/commons/digester/xmlrules/testrules.xml (original)
+++ commons/proper/digester/trunk/src/test/org/apache/commons/digester/xmlrules/testrules.xml Wed Sep 1 18:15:22 2010
@@ -20,11 +20,11 @@
<!DOCTYPE digester-rules PUBLIC "-//Jakarta Apache //DTD digester-rules XML V1.0//EN" "http://jakarta.apache.org/commons/digester/dtds/digester-rules.dtd">
<digester-rules>
<pattern value="root/foo">
- <object-create-rule classname="org.apache.commons.digester.xmlrules.TestObject"/>
+ <object-create-rule classname="org.apache.commons.digester.xmlrules.ObjectTestImpl"/>
<set-next-rule methodname="add" paramtype="java.lang.Object"/>
<set-properties-rule/>
<include path="org/apache/commons/digester/xmlrules/testrulesinclude.xml"/>
- <include class="org.apache.commons.digester.xmlrules.TestDigesterRulesSource"/>
+ <include class="org.apache.commons.digester.xmlrules.DigesterRulesSourceTestImpl"/>
<pattern value="call-method-rule-tests">
<call-method-rule pattern="longValue" methodname="setLongValue" paramcount="0" paramtypes="java.lang.Long"/>
<call-method-rule pattern="defaultParamType" methodname="setStringValue" paramcount="0"/>
Modified: commons/proper/digester/trunk/src/test/org/apache/commons/digester/xmlrules/testrulesinclude.xml
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/src/test/org/apache/commons/digester/xmlrules/testrulesinclude.xml?rev=991633&r1=991632&r2=991633&view=diff
==============================================================================
--- commons/proper/digester/trunk/src/test/org/apache/commons/digester/xmlrules/testrulesinclude.xml (original)
+++ commons/proper/digester/trunk/src/test/org/apache/commons/digester/xmlrules/testrulesinclude.xml Wed Sep 1 18:15:22 2010
@@ -19,7 +19,7 @@
<digester-rules>
<pattern value = "bar">
<pattern value="foo">
- <object-create-rule classname="org.apache.commons.digester.xmlrules.TestObject"/>
+ <object-create-rule classname="org.apache.commons.digester.xmlrules.ObjectTestImpl"/>
<set-next-rule methodname="add" paramtype="java.lang.Object"/>
<set-properties-rule/>
</pattern>