You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by sk...@apache.org on 2005/02/08 13:04:30 UTC
svn commit: r152668 -
jakarta/commons/proper/digester/branches/digester2/src/test/org/apache/commons/digester2/actions/CreateObjectActionTestCase.java
Author: skitching
Date: Tue Feb 8 04:04:25 2005
New Revision: 152668
URL: http://svn.apache.org/viewcvs?view=rev&rev=152668
Log:
Add test cases for CreateObjectAction
Added:
jakarta/commons/proper/digester/branches/digester2/src/test/org/apache/commons/digester2/actions/CreateObjectActionTestCase.java (with props)
Added: jakarta/commons/proper/digester/branches/digester2/src/test/org/apache/commons/digester2/actions/CreateObjectActionTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/digester/branches/digester2/src/test/org/apache/commons/digester2/actions/CreateObjectActionTestCase.java?view=auto&rev=152668
==============================================================================
--- jakarta/commons/proper/digester/branches/digester2/src/test/org/apache/commons/digester2/actions/CreateObjectActionTestCase.java (added)
+++ jakarta/commons/proper/digester/branches/digester2/src/test/org/apache/commons/digester2/actions/CreateObjectActionTestCase.java Tue Feb 8 04:04:25 2005
@@ -0,0 +1,111 @@
+/* $Id$
+ *
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * 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 org.apache.commons.digester2.actions;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import java.io.StringReader;
+
+import org.xml.sax.InputSource;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.digester2.Digester;
+
+/**
+ * <p>Test Cases for the CreateObjectAction class.</p>
+ */
+
+public class CreateObjectActionTestCase extends TestCase {
+
+ public static class Item {
+ }
+
+ public static class TestObject {
+ private Item item;
+
+ public void addItem(Item item) { this.item = item; }
+ public Item getItem() { return item; }
+ }
+
+ // -----------------------------------------------------------
+ // Constructors
+ // -----------------------------------------------------------
+
+ /**
+ * Construct a new instance of this test case.
+ *
+ * @param name Name of the test case
+ */
+ public CreateObjectActionTestCase(String name) {
+ super(name);
+ }
+
+ // --------------------------------------------------
+ // Overall Test Methods
+ // --------------------------------------------------
+
+ /**
+ * Set up instance variables required by this test case.
+ */
+ public void setUp() {
+ }
+
+ /**
+ * Return the tests included in this test suite.
+ */
+ public static Test suite() {
+ return (new TestSuite(CreateObjectActionTestCase.class));
+ }
+
+ /**
+ * Tear down instance variables required by this test case.
+ */
+ public void tearDown() {
+ }
+
+ // ------------------------------------------------
+ // Individual Test Methods
+ // ------------------------------------------------
+
+ /**
+ * Test basic operations.
+ */
+ public void testBasicOperations() throws Exception {
+ String inputText =
+ "<root>" +
+ " <item/>" +
+ "</root>";
+
+ InputSource source = new InputSource(new StringReader(inputText));
+
+ Digester d = new Digester();
+ d.addRule("/root/item", new CreateObjectAction(Item.class));
+ d.addRule("/root/item", new SetNextAction("addItem"));
+
+ TestObject testObject = new TestObject();
+ d.setInitialObject(testObject);
+ d.parse(source);
+
+ // string was passed ok
+ Item item = testObject.getItem();
+ assertNotNull("CreateObjectAction works", item);
+ }
+}
Propchange: jakarta/commons/proper/digester/branches/digester2/src/test/org/apache/commons/digester2/actions/CreateObjectActionTestCase.java
------------------------------------------------------------------------------
svn:keywords = Id
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org