Author: simonetripodi
Date: Mon Jan 11 20:03:24 2010
New Revision: 898037

URL: http://svn.apache.org/viewvc?rev=898037&view=rev
Log:
first checkin of AbstractAnnotatedPojoTestCase class

Added:
    
commons/sandbox/at-digester/trunk/src/test/org/apache/commons/digester/annotations/
    
commons/sandbox/at-digester/trunk/src/test/org/apache/commons/digester/annotations/AbstractAnnotatedPojoTestCase.java
   (with props)

Added: 
commons/sandbox/at-digester/trunk/src/test/org/apache/commons/digester/annotations/AbstractAnnotatedPojoTestCase.java
URL: 
http://svn.apache.org/viewvc/commons/sandbox/at-digester/trunk/src/test/org/apache/commons/digester/annotations/AbstractAnnotatedPojoTestCase.java?rev=898037&view=auto
==============================================================================
--- 
commons/sandbox/at-digester/trunk/src/test/org/apache/commons/digester/annotations/AbstractAnnotatedPojoTestCase.java
 (added)
+++ 
commons/sandbox/at-digester/trunk/src/test/org/apache/commons/digester/annotations/AbstractAnnotatedPojoTestCase.java
 Mon Jan 11 20:03:24 2010
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.digester.annotations;
+
+import java.io.InputStream;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.digester.Digester;
+
+/**
+ * Abstract implementation of Class->Digester Rules->parse & confronting.
+ *
+ * @version $Id$
+ * @since 2.1
+ */
+public abstract class AbstractAnnotatedPojoTestCase extends TestCase {
+
+    /**
+     * Loads the digester rules parsing the expected object class, parses the
+     * XML and verify the digester produces the same result.
+     *
+     * @param expected the expected object
+     * @throws Exception if any error occurs
+     */
+    public final void verifyExpectedEqualsToParsed(Object expected) throws 
Exception {
+        Class<?> clazz = expected.getClass();
+
+        String resource = clazz.getSimpleName() + ".xml";
+        InputStream input = clazz.getResourceAsStream(resource);
+
+        Digester digester = DigesterLoader.createDigester(clazz);
+
+        Object actual = digester.parse(input);
+
+        if (input != null) {
+            input.close();
+        }
+
+        assertEquals(expected, actual);
+    } 
+
+}

Propchange: 
commons/sandbox/at-digester/trunk/src/test/org/apache/commons/digester/annotations/AbstractAnnotatedPojoTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
commons/sandbox/at-digester/trunk/src/test/org/apache/commons/digester/annotations/AbstractAnnotatedPojoTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: 
commons/sandbox/at-digester/trunk/src/test/org/apache/commons/digester/annotations/AbstractAnnotatedPojoTestCase.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain


Reply via email to