commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1300873 - in /commons/proper/digester/trunk/core/src/test: java/org/apache/commons/digester3/binder/ resources/org/apache/commons/digester3/binder/
Date Thu, 15 Mar 2012 09:57:48 GMT
Author: simonetripodi
Date: Thu Mar 15 09:57:47 2012
New Revision: 1300873

URL: http://svn.apache.org/viewvc?rev=1300873&view=rev
Log:
imported testcase for [DIGESTER-163]

Added:
    commons/proper/digester/trunk/core/src/test/java/org/apache/commons/digester3/binder/Digester163TestCase.java
  (with props)
    commons/proper/digester/trunk/core/src/test/java/org/apache/commons/digester3/binder/Entity.java
  (with props)
    commons/proper/digester/trunk/core/src/test/resources/org/apache/commons/digester3/binder/
    commons/proper/digester/trunk/core/src/test/resources/org/apache/commons/digester3/binder/rules.xml
  (with props)
    commons/proper/digester/trunk/core/src/test/resources/org/apache/commons/digester3/binder/test.xml
  (with props)

Added: commons/proper/digester/trunk/core/src/test/java/org/apache/commons/digester3/binder/Digester163TestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/core/src/test/java/org/apache/commons/digester3/binder/Digester163TestCase.java?rev=1300873&view=auto
==============================================================================
--- commons/proper/digester/trunk/core/src/test/java/org/apache/commons/digester3/binder/Digester163TestCase.java
(added)
+++ commons/proper/digester/trunk/core/src/test/java/org/apache/commons/digester3/binder/Digester163TestCase.java
Thu Mar 15 09:57:47 2012
@@ -0,0 +1,121 @@
+package org.apache.commons.digester3.binder;
+
+/*
+ * 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.
+ */
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.fail;
+import static org.apache.commons.digester3.binder.DigesterLoader.newLoader;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.commons.digester3.Digester;
+import org.apache.commons.digester3.xmlrules.FromXmlRulesModule;
+import org.junit.Before;
+import org.junit.Test;
+
+
+/**
+ * Test.
+ */
+public class Digester163TestCase
+{
+
+    public static final int MAX_THREADS = 4;
+
+    private DigesterLoader loader;
+
+    @Before
+    public void setUp()
+    {
+        loader = newLoader( new FromXmlRulesModule()
+        {
+
+            @Override
+            protected void loadRules()
+            {
+                loadXMLRules( getClass().getResourceAsStream( "rules.xml" ) );
+            }
+
+        } );
+    }
+
+    @Test
+    public void test()
+        throws InterruptedException
+    {
+        ThreadPoolExecutor executor = new ThreadPoolExecutor( MAX_THREADS, MAX_THREADS,
+                                                              Long.MAX_VALUE,
+                                                              TimeUnit.NANOSECONDS,
+                                                              new LinkedBlockingQueue<Runnable>()
);
+        for ( int i = 0; i < MAX_THREADS * 2; i++ )
+        {
+            executor.submit( new Runnable()
+            {
+
+                public void run()
+                {
+                    Digester dig = loader.newDigester();
+                    InputStream in = null;
+                    try
+                    {
+                        in = this.getClass().getClassLoader().getResourceAsStream( "test.xml"
);
+                        Entity et = dig.parse( in );
+                        assertEquals( "Author 1", et.getAuthor() );
+                    }
+                    catch ( Exception e )
+                    {
+                        fail( e.getMessage() );
+                    }
+                    finally
+                    {
+                        if ( in != null )
+                        {
+                            try
+                            {
+                                in.close();
+                            }
+                            catch ( IOException e )
+                            {
+                                // close quietly
+                            }
+                        }
+                    }
+                }
+            } );
+        }
+
+        while ( !executor.awaitTermination( 10, TimeUnit.MILLISECONDS ) )
+        {
+            if ( executor.getQueue().isEmpty() )
+            {
+                executor.shutdown();
+            }
+            if ( executor.isTerminated() )
+            {
+                break;
+            }
+        }
+    }
+
+}

Propchange: commons/proper/digester/trunk/core/src/test/java/org/apache/commons/digester3/binder/Digester163TestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/digester/trunk/core/src/test/java/org/apache/commons/digester3/binder/Digester163TestCase.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/proper/digester/trunk/core/src/test/java/org/apache/commons/digester3/binder/Digester163TestCase.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/proper/digester/trunk/core/src/test/java/org/apache/commons/digester3/binder/Entity.java
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/core/src/test/java/org/apache/commons/digester3/binder/Entity.java?rev=1300873&view=auto
==============================================================================
--- commons/proper/digester/trunk/core/src/test/java/org/apache/commons/digester3/binder/Entity.java
(added)
+++ commons/proper/digester/trunk/core/src/test/java/org/apache/commons/digester3/binder/Entity.java
Thu Mar 15 09:57:47 2012
@@ -0,0 +1,46 @@
+package org.apache.commons.digester3.binder;
+
+/*
+ * 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.
+ */
+
+/**
+ * Entity.
+ */
+public class Entity
+{
+
+    private String author = null;
+
+    /**
+     * @return Returns the author.
+     */
+    public String getAuthor()
+    {
+        return author;
+    }
+
+    /**
+     * @param author The author to set.
+     */
+    public void setAuthor( String author )
+    {
+        this.author = author;
+    }
+
+}

Propchange: commons/proper/digester/trunk/core/src/test/java/org/apache/commons/digester3/binder/Entity.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/digester/trunk/core/src/test/java/org/apache/commons/digester3/binder/Entity.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/proper/digester/trunk/core/src/test/java/org/apache/commons/digester3/binder/Entity.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/proper/digester/trunk/core/src/test/resources/org/apache/commons/digester3/binder/rules.xml
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/core/src/test/resources/org/apache/commons/digester3/binder/rules.xml?rev=1300873&view=auto
==============================================================================
--- commons/proper/digester/trunk/core/src/test/resources/org/apache/commons/digester3/binder/rules.xml
(added)
+++ commons/proper/digester/trunk/core/src/test/resources/org/apache/commons/digester3/binder/rules.xml
Thu Mar 15 09:57:47 2012
@@ -0,0 +1,23 @@
+<?xml version="1.0"?>
+<!DOCTYPE digester-rules PUBLIC "-//Apache Commons //DTD digester-rules XML V1.0//EN"
"http://commons.apache.org/digester/dtds/digester-rules-3.0.dtd">
+<!--
+   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.
+-->
+<digester-rules>
+  <object-create-rule classname="org.apache.commons.digester3.binder.Entity" pattern="container"/>
+  <!-- author -->
+  <call-method-rule methodname="setAuthor" paramcount="1" pattern="container/header/authors/author"/>
+</digester-rules>

Propchange: commons/proper/digester/trunk/core/src/test/resources/org/apache/commons/digester3/binder/rules.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/digester/trunk/core/src/test/resources/org/apache/commons/digester3/binder/rules.xml
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: commons/proper/digester/trunk/core/src/test/resources/org/apache/commons/digester3/binder/rules.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: commons/proper/digester/trunk/core/src/test/resources/org/apache/commons/digester3/binder/test.xml
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/core/src/test/resources/org/apache/commons/digester3/binder/test.xml?rev=1300873&view=auto
==============================================================================
--- commons/proper/digester/trunk/core/src/test/resources/org/apache/commons/digester3/binder/test.xml
(added)
+++ commons/proper/digester/trunk/core/src/test/resources/org/apache/commons/digester3/binder/test.xml
Thu Mar 15 09:57:47 2012
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+   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.
+-->
+<root>
+  <container>
+    <header>
+      <authors>
+        <author>Author 1</author>
+      </authors>
+    </header>
+  </container>
+</root>

Propchange: commons/proper/digester/trunk/core/src/test/resources/org/apache/commons/digester3/binder/test.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/digester/trunk/core/src/test/resources/org/apache/commons/digester3/binder/test.xml
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: commons/proper/digester/trunk/core/src/test/resources/org/apache/commons/digester3/binder/test.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml



Mime
View raw message