You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-dev@db.apache.org by tv...@apache.org on 2007/03/06 22:12:12 UTC

svn commit: r515305 - in /db/torque: runtime/trunk/src/java/org/apache/torque/avalon/ test/trunk/test-project/src/java/org/apache/torque/avalon/ test/trunk/test-project/src/test/

Author: tv
Date: Tue Mar  6 13:12:12 2007
New Revision: 515305

URL: http://svn.apache.org/viewvc?view=rev&rev=515305
Log:
Next attempt to fix TORQUE-68 together with a TestCase to prove it.

Added:
    db/torque/test/trunk/test-project/src/java/org/apache/torque/avalon/
    db/torque/test/trunk/test-project/src/java/org/apache/torque/avalon/AvalonMapBuildersTest.java
    db/torque/test/trunk/test-project/src/test/
    db/torque/test/trunk/test-project/src/test/TestComponentConfig.xml
    db/torque/test/trunk/test-project/src/test/TestRoleConfig.xml
    db/torque/test/trunk/test-project/src/test/TurbineResources.properties
Modified:
    db/torque/runtime/trunk/src/java/org/apache/torque/avalon/TorqueComponent.java

Modified: db/torque/runtime/trunk/src/java/org/apache/torque/avalon/TorqueComponent.java
URL: http://svn.apache.org/viewvc/db/torque/runtime/trunk/src/java/org/apache/torque/avalon/TorqueComponent.java?view=diff&rev=515305&r1=515304&r2=515305
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/avalon/TorqueComponent.java (original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/avalon/TorqueComponent.java Tue Mar  6 13:12:12 2007
@@ -164,11 +164,10 @@
         
         TorqueInstance instance = org.apache.torque.Torque.getInstance();
         
-        // Check if another singleton is already running 
-        if (instance.isInit())
-        {
-            Map mapBuilders = instance.getMapBuilders();
-            
+        Map mapBuilders = instance.getMapBuilders();
+        
+        if (mapBuilders != null)
+        {    
             // Copy the registered MapBuilders and take care that they will be built again
             for (Iterator  i = mapBuilders.keySet().iterator(); i.hasNext();)
             {

Added: db/torque/test/trunk/test-project/src/java/org/apache/torque/avalon/AvalonMapBuildersTest.java
URL: http://svn.apache.org/viewvc/db/torque/test/trunk/test-project/src/java/org/apache/torque/avalon/AvalonMapBuildersTest.java?view=auto&rev=515305
==============================================================================
--- db/torque/test/trunk/test-project/src/java/org/apache/torque/avalon/AvalonMapBuildersTest.java (added)
+++ db/torque/test/trunk/test-project/src/java/org/apache/torque/avalon/AvalonMapBuildersTest.java Tue Mar  6 13:12:12 2007
@@ -0,0 +1,88 @@
+package org.apache.torque.avalon;
+/*
+ * 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 org.apache.avalon.framework.component.ComponentException;
+import org.apache.fulcrum.testcontainer.BaseUnitTest;
+import org.apache.torque.BaseRuntimeTestCase;
+import org.apache.torque.TorqueException;
+import org.apache.torque.map.DatabaseMap;
+import org.apache.torque.test.AuthorPeer;
+
+/**
+ * Testing of the correct MapBuilder handling of the Torque Avalon Component
+ *
+ * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
+ * @version $Id:$
+ */
+public class AvalonMapBuildersTest extends BaseUnitTest
+{
+    private Torque torque = null;
+    private org.apache.torque.TorqueInstance instance = null;
+    
+    /**
+     * Constructor for test.
+     *
+     * @param testName name of the test being executed
+     */
+    public AvalonMapBuildersTest(String name)
+    {
+        super( name );
+        
+        // trigger ststic constructor before Torque initialization
+        String testDB = AuthorPeer.DATABASE_NAME;
+        
+        // store old instance for comparison
+        instance = org.apache.torque.Torque.getInstance();
+    }
+
+    public void setUp() throws Exception
+    {
+        super.setUp();
+        try
+        {
+            torque = (Torque) this.resolve(Torque.ROLE);
+        }
+        catch (ComponentException e)
+        {
+            e.printStackTrace();
+            fail(e.getMessage());
+        }
+    }
+
+    /**
+     * Verifies that the MapBuilder is available in the DatabaseMap.
+     */
+    public void testMapBuilder()
+    {
+    	DatabaseMap dbMap = null;
+    	
+    	try 
+    	{
+			dbMap = torque.getDatabaseMap(AuthorPeer.DATABASE_NAME);
+		} 
+    	catch (TorqueException e) 
+    	{
+    		fail(e.getMessage());
+		}
+    	
+        assertTrue("Table author should be in the DatabaseMap", dbMap.containsTable(AuthorPeer.TABLE_NAME));
+        assertFalse("Torque instsnces should be different", torque == instance);
+    }
+}

Added: db/torque/test/trunk/test-project/src/test/TestComponentConfig.xml
URL: http://svn.apache.org/viewvc/db/torque/test/trunk/test-project/src/test/TestComponentConfig.xml?view=auto&rev=515305
==============================================================================
--- db/torque/test/trunk/test-project/src/test/TestComponentConfig.xml (added)
+++ db/torque/test/trunk/test-project/src/test/TestComponentConfig.xml Tue Mar  6 13:12:12 2007
@@ -0,0 +1,23 @@
+<!--
+ 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.
+-->
+<componentConfig>
+    <TorqueComponent>
+        <configfile>/src/test/TurbineResources.properties</configfile>
+    </TorqueComponent>
+</componentConfig>

Added: db/torque/test/trunk/test-project/src/test/TestRoleConfig.xml
URL: http://svn.apache.org/viewvc/db/torque/test/trunk/test-project/src/test/TestRoleConfig.xml?view=auto&rev=515305
==============================================================================
--- db/torque/test/trunk/test-project/src/test/TestRoleConfig.xml (added)
+++ db/torque/test/trunk/test-project/src/test/TestRoleConfig.xml Tue Mar  6 13:12:12 2007
@@ -0,0 +1,25 @@
+<!--
+ 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.
+-->
+<!-- This configuration file for Avalon components is used for testing the TorqueComponent -->
+<role-list>
+    <role
+        name="org.apache.torque.avalon.Torque"
+        shorthand="TorqueComponent"
+        default-class="org.apache.torque.avalon.TorqueComponent"/>
+</role-list>

Added: db/torque/test/trunk/test-project/src/test/TurbineResources.properties
URL: http://svn.apache.org/viewvc/db/torque/test/trunk/test-project/src/test/TurbineResources.properties?view=auto&rev=515305
==============================================================================
--- db/torque/test/trunk/test-project/src/test/TurbineResources.properties (added)
+++ db/torque/test/trunk/test-project/src/test/TurbineResources.properties Tue Mar  6 13:12:12 2007
@@ -0,0 +1,74 @@
+# 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.
+
+
+# -------------------------------------------------------------------
+#
+#  L O G G I N G
+#
+# -------------------------------------------------------------------
+# We use Log4J for all Turbine logging and we embed the log4j
+# properties within our application configuration.
+#
+# NOTE:
+# The presence of ${webapp} in the logging configuration
+# is not a mistake. Internally the value of ${webapp}
+# is set so that you can use it with standard log4j
+# properties to get logs to appear in your
+# webapp space.
+# -------------------------------------------------------------------
+
+# This first category is required and the category
+# must be named 'default'. This is used for all logging
+# where an explicit category is not specified.
+
+log4j.category.default = ALL, default
+log4j.appender.default = org.apache.log4j.FileAppender
+log4j.appender.default.file = ./turbine.log
+log4j.appender.default.layout = org.apache.log4j.PatternLayout
+log4j.appender.default.layout.conversionPattern = %d [%t] %-5p %c - %m%n
+log4j.appender.default.append = false
+
+# This category is used in the BasePeer class. All
+# SQL generated will be logged if the category
+# priority is set to DEBUG
+
+log4j.category.sql = DEBUG, sql
+log4j.appender.sql = org.apache.log4j.FileAppender
+log4j.appender.sql.file = ./sql.log
+log4j.appender.sql.layout = org.apache.log4j.PatternLayout
+log4j.appender.sql.layout.conversionPattern = %d [%t] %-5p %c - %m%n
+log4j.appender.sql.append = false
+
+log4j.category.org.apache.torque = ALL, default
+
+
+# -------------------------------------------------------------------
+#
+#  T O R Q U E
+#
+# -------------------------------------------------------------------
+
+torque.database.default = turbine
+torque.database.turbine.adapter=mymysql
+torque.database.turbine.adapter.mymysql.className=org.apache.torque.adapter.DBMM
+torque.dsfactory.turbine.factory= org.apache.torque.dsfactory.SharedPoolDataSourceFactory
+torque.idbroker.prefetch=false
+
+
+
+



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org