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/21 03:22:40 UTC
svn commit: r154610 - in
jakarta/commons/proper/digester/branches/digester2/src/test/org/apache/commons/digester2/plugins/strategies:
./ LoaderSetPropertiesTestCase.java
Author: skitching
Date: Sun Feb 20 18:22:40 2005
New Revision: 154610
URL: http://svn.apache.org/viewcvs?view=rev&rev=154610
Log:
Test case for LoaderSetProperties.
Added:
jakarta/commons/proper/digester/branches/digester2/src/test/org/apache/commons/digester2/plugins/strategies/
jakarta/commons/proper/digester/branches/digester2/src/test/org/apache/commons/digester2/plugins/strategies/LoaderSetPropertiesTestCase.java (with props)
Added: jakarta/commons/proper/digester/branches/digester2/src/test/org/apache/commons/digester2/plugins/strategies/LoaderSetPropertiesTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/digester/branches/digester2/src/test/org/apache/commons/digester2/plugins/strategies/LoaderSetPropertiesTestCase.java?view=auto&rev=154610
==============================================================================
--- jakarta/commons/proper/digester/branches/digester2/src/test/org/apache/commons/digester2/plugins/strategies/LoaderSetPropertiesTestCase.java (added)
+++ jakarta/commons/proper/digester/branches/digester2/src/test/org/apache/commons/digester2/plugins/strategies/LoaderSetPropertiesTestCase.java Sun Feb 20 18:22:40 2005
@@ -0,0 +1,102 @@
+/* $Id$
+ *
+ * Copyright 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.plugins.strategies;
+
+import java.util.List;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.commons.digester2.*;
+import org.apache.commons.digester2.actions.*;
+import org.apache.commons.digester2.plugins.*;
+
+/**
+ * Test cases for LoaderSetProperties behaviour.
+ */
+
+public class LoaderSetPropertiesTestCase extends TestCase {
+ // -----------------------------------------------------------
+ // Constructors
+ // -----------------------------------------------------------
+
+ /**
+ * Construct a new instance of this test case.
+ *
+ * @param name Name of the test case
+ */
+ public LoaderSetPropertiesTestCase(String name) {
+ super(name);
+ }
+
+ // --------------------------------------------------
+ // Overall Test Methods
+ // --------------------------------------------------
+
+ /**
+ * Return the tests included in this test suite.
+ */
+ public static Test suite() {
+ return (new TestSuite(LoaderSetPropertiesTestCase.class));
+ }
+
+ // ------------------------------------------------
+ // Individual Test Methods
+ // ------------------------------------------------
+
+
+ /**
+ * Test the basic functionality of this class.
+ */
+ public void testBasicOperation() throws Exception {
+ SAXHandler saxHandler = new SAXHandler();
+ RuleManager ruleManager = saxHandler.getRuleManager();
+ Context context = new Context(
+ saxHandler, saxHandler.getLogger(),
+ null, ruleManager);
+
+ LoaderSetProperties loader = new LoaderSetProperties();
+
+ context.pushMatchPath("", "foo");
+ context.pushMatchPath("", "bar");
+ String path = context.getMatchPath();
+
+ // paranoia test...
+ assertEquals("Unexpected path", "/foo/bar", path);
+
+ assertEquals("RuleManager not empty", 0, ruleManager.getActions().size());
+ loader.addRules(context);
+
+ // assert ruleManager has one rule
+ assertEquals("RuleManager has unexpected number of actions",
+ 1,
+ ruleManager.getActions().size());
+ assertEquals("Action is not of expected type",
+ SetPropertiesAction.class, ruleManager.getActions().get(0).getClass());
+
+ // assert that match(context.getMatchPath()) returns a SetPropertiesAction
+ List matchingActions = ruleManager.getMatchingActions("/foo");
+ assertEquals("Unexpected actions", 0, matchingActions.size());
+ matchingActions = ruleManager.getMatchingActions("/foo/bar");
+ assertEquals("Unexpected actions", 1, matchingActions.size());
+ assertEquals("Unexpected action type",
+ SetPropertiesAction.class, matchingActions.get(0).getClass());
+ }
+}
Propchange: jakarta/commons/proper/digester/branches/digester2/src/test/org/apache/commons/digester2/plugins/strategies/LoaderSetPropertiesTestCase.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