cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r887667 [2/2] - in /cayenne/main/trunk/framework: cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/ cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/ cayenne-jdk1.5-unpublished/src/main/java/org/apac...
Date Sun, 06 Dec 2009 11:22:21 GMT
Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/DefaultDataSourceFactoryLoaderTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/DefaultDataSourceFactoryLoaderTest.java?rev=887667&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/DefaultDataSourceFactoryLoaderTest.java
(added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/DefaultDataSourceFactoryLoaderTest.java
Sun Dec  6 11:22:19 2009
@@ -0,0 +1,96 @@
+/*****************************************************************
+ *   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.cayenne.configuration;
+
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.apache.cayenne.configuration.mock.MockDataSourceFactory1;
+import org.apache.cayenne.di.Binder;
+import org.apache.cayenne.di.DIBootstrap;
+import org.apache.cayenne.di.Injector;
+import org.apache.cayenne.di.Module;
+import org.apache.cayenne.resource.ResourceLocator;
+import org.apache.cayenne.resource.URLResource;
+import org.apache.cayenne.resource.mock.MockResourceLocator;
+
+public class DefaultDataSourceFactoryLoaderTest extends TestCase {
+
+    public void testGetDataSourceFactory_Implicit() throws Exception {
+        String baseUrl = getClass().getPackage().getName().replace('.', '/');
+        URL url = getClass().getClassLoader().getResource(
+                baseUrl + "/testNode1.driver.xml");
+        assertNotNull(url);
+
+        DataNodeDescriptor nodeDescriptor = new DataNodeDescriptor();
+        nodeDescriptor.setName("node1");
+        nodeDescriptor.setConfigurationResource(new URLResource(url));
+
+        Module testModule = new Module() {
+
+            public void configure(Binder binder) {
+                binder.bind(AdhocObjectFactory.class).to(DefaultAdhocObjectFactory.class);
+                binder.bind(ResourceLocator.class).to(MockResourceLocator.class);
+            }
+        };
+
+        Injector injector = DIBootstrap.createInjector(testModule);
+
+        DefaultDataSourceFactoryLoader factoryLoader = new DefaultDataSourceFactoryLoader();
+        injector.injectMembers(factoryLoader);
+
+        DataSourceFactory factory = factoryLoader.getDataSourceFactory(nodeDescriptor);
+        assertNotNull(factory);
+        assertTrue(factory instanceof XMLPoolingDataSourceFactory);
+    }
+
+    public void testGetDataSourceFactory_Explicit() throws Exception {
+        String baseUrl = getClass().getPackage().getName().replace('.', '/');
+        URL url = getClass().getClassLoader().getResource(
+                baseUrl + "/testNode1.driver.xml");
+        assertNotNull(url);
+
+        DataNodeDescriptor nodeDescriptor = new DataNodeDescriptor();
+        nodeDescriptor.setName("node1");
+        nodeDescriptor.setConfigurationResource(new URLResource(url));
+        nodeDescriptor.setDataSourceFactoryType(MockDataSourceFactory1.class.getName());
+
+        Module testModule = new Module() {
+
+            public void configure(Binder binder) {
+                binder.bind(AdhocObjectFactory.class).to(DefaultAdhocObjectFactory.class);
+                binder.bind(ResourceLocator.class).to(MockResourceLocator.class);
+            }
+        };
+
+        Injector injector = DIBootstrap.createInjector(testModule);
+
+        DefaultDataSourceFactoryLoader factoryLoader = new DefaultDataSourceFactoryLoader();
+        injector.injectMembers(factoryLoader);
+
+        DataSourceFactory factory = factoryLoader.getDataSourceFactory(nodeDescriptor);
+        assertNotNull(factory);
+        assertTrue(factory instanceof MockDataSourceFactory1);
+        assertSame(
+                "Injection on the factory hasn't been performed",
+                injector,
+                ((MockDataSourceFactory1) factory).getInjector());
+    }
+}

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/DefaultDbAdapterFactoryTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/DefaultDbAdapterFactoryTest.java?rev=887667&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/DefaultDbAdapterFactoryTest.java
(added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/DefaultDbAdapterFactoryTest.java
Sun Dec  6 11:22:19 2009
@@ -0,0 +1,138 @@
+/*****************************************************************
+ *   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.cayenne.configuration;
+
+import java.sql.DatabaseMetaData;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.apache.cayenne.dba.AutoAdapter;
+import org.apache.cayenne.dba.DbAdapter;
+import org.apache.cayenne.dba.MockDbAdapter;
+import org.apache.cayenne.di.Binder;
+import org.apache.cayenne.di.DIBootstrap;
+import org.apache.cayenne.di.Injector;
+import org.apache.cayenne.di.Module;
+import org.apache.cayenne.map.DbEntity;
+
+import com.mockrunner.mock.jdbc.MockConnection;
+import com.mockrunner.mock.jdbc.MockDataSource;
+
+public class DefaultDbAdapterFactoryTest extends TestCase {
+
+    public void testCreatedAdapter_Auto() throws Exception {
+
+        final DbAdapter adapter = new MockDbAdapter() {
+
+            @Override
+            public String createTable(DbEntity ent) {
+                return "XXXXX";
+            }
+        };
+
+        List<DbAdapterDetector> detectors = new ArrayList<DbAdapterDetector>();
+        detectors.add(new DbAdapterDetector() {
+
+            public DbAdapter createAdapter(DatabaseMetaData md) throws SQLException {
+                return adapter;
+            }
+        });
+
+        MockConnection connection = new MockConnection();
+
+        MockDataSource dataSource = new MockDataSource();
+        dataSource.setupConnection(connection);
+
+        Module testModule = new Module() {
+
+            public void configure(Binder binder) {
+                binder.bind(AdhocObjectFactory.class).to(DefaultAdhocObjectFactory.class);
+            }
+        };
+
+        Injector injector = DIBootstrap.createInjector(testModule);
+
+        DefaultDbAdapterFactory factory = new DefaultDbAdapterFactory(detectors);
+        injector.injectMembers(factory);
+
+        DbAdapter createdAdapter = factory.createAdapter(
+                new DataNodeDescriptor(),
+                dataSource);
+        assertTrue(createdAdapter instanceof AutoAdapter);
+        assertEquals("XXXXX", createdAdapter.createTable(new DbEntity("Test")));
+    }
+
+    public void testCreatedAdapter_Generic() throws Exception {
+
+        List<DbAdapterDetector> detectors = new ArrayList<DbAdapterDetector>();
+
+        Module testModule = new Module() {
+
+            public void configure(Binder binder) {
+                binder.bind(AdhocObjectFactory.class).to(DefaultAdhocObjectFactory.class);
+            }
+        };
+
+        Injector injector = DIBootstrap.createInjector(testModule);
+
+        DefaultDbAdapterFactory factory = new DefaultDbAdapterFactory(detectors);
+        injector.injectMembers(factory);
+
+        DbAdapter createdAdapter = factory.createAdapter(
+                new DataNodeDescriptor(),
+                new MockDataSource());
+        assertNotNull(createdAdapter);
+        assertTrue(
+                "Unexpected class: " + createdAdapter.getClass().getName(),
+                createdAdapter instanceof AutoAdapter);
+        assertEquals("CREATE TABLE Test ()", createdAdapter.createTable(new DbEntity(
+                "Test")));
+    }
+
+    public void testCreatedAdapter_Custom() throws Exception {
+
+        DataNodeDescriptor nodeDescriptor = new DataNodeDescriptor();
+        nodeDescriptor.setAdapterType(MockDbAdapter.class.getName());
+
+        List<DbAdapterDetector> detectors = new ArrayList<DbAdapterDetector>();
+
+        Module testModule = new Module() {
+
+            public void configure(Binder binder) {
+                binder.bind(AdhocObjectFactory.class).to(DefaultAdhocObjectFactory.class);
+            }
+        };
+
+        Injector injector = DIBootstrap.createInjector(testModule);
+
+        DefaultDbAdapterFactory factory = new DefaultDbAdapterFactory(detectors);
+        injector.injectMembers(factory);
+
+        DbAdapter createdAdapter = factory.createAdapter(
+                nodeDescriptor,
+                new MockDataSource());
+        assertNotNull(createdAdapter);
+        assertTrue(
+                "Unexpected class: " + createdAdapter.getClass().getName(),
+                createdAdapter instanceof MockDbAdapter);
+    }
+}

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/XMLPoolingDataSourceFactoryTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/XMLPoolingDataSourceFactoryTest.java?rev=887667&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/XMLPoolingDataSourceFactoryTest.java
(added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/XMLPoolingDataSourceFactoryTest.java
Sun Dec  6 11:22:19 2009
@@ -0,0 +1,66 @@
+/*****************************************************************
+ *   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.cayenne.configuration;
+
+import java.net.URL;
+
+import javax.sql.DataSource;
+
+import junit.framework.TestCase;
+
+import org.apache.cayenne.conn.DataSourceInfo;
+import org.apache.cayenne.resource.URLResource;
+
+import com.mockrunner.mock.jdbc.MockDataSource;
+
+public class XMLPoolingDataSourceFactoryTest extends TestCase {
+
+    public void testGetDataSource() throws Exception {
+
+        String baseUrl = getClass().getPackage().getName().replace('.', '/');
+        URL url = getClass().getClassLoader().getResource(
+                baseUrl + "/testNode1.driver.xml");
+        assertNotNull(url);
+
+        DataNodeDescriptor nodeDescriptor = new DataNodeDescriptor();
+        nodeDescriptor.setConfigurationResource(new URLResource(url));
+
+        final DataSource dataSource = new MockDataSource();
+
+        XMLPoolingDataSourceFactory factory = new XMLPoolingDataSourceFactory() {
+
+            // override super to make test assertions and to prevent DB connection
+            @Override
+            protected DataSource createDataSource(DataSourceInfo dataSourceDescriptor)
+                    throws Exception {
+
+                assertEquals("jdbcDriver", dataSourceDescriptor.getJdbcDriver());
+                assertEquals("jdbcUrl", dataSourceDescriptor.getDataSourceUrl());
+                assertEquals(2, dataSourceDescriptor.getMinConnections());
+                assertEquals(3, dataSourceDescriptor.getMaxConnections());
+                assertEquals("jdbcUserName", dataSourceDescriptor.getUserName());
+                assertEquals("jdbcPassword", dataSourceDescriptor.getPassword());
+                return dataSource;
+            }
+        };
+
+        DataSource newDataSource = factory.getDataSource(nodeDescriptor);
+        assertSame(dataSource, newDataSource);
+    }
+}

Copied: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/mock/MockDataSourceFactory.java
(from r887666, cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/runtime/MockDataSourceFactory1.java)
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/mock/MockDataSourceFactory.java?p2=cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/mock/MockDataSourceFactory.java&p1=cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/runtime/MockDataSourceFactory1.java&r1=887666&r2=887667&rev=887667&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/runtime/MockDataSourceFactory1.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/mock/MockDataSourceFactory.java
Sun Dec  6 11:22:19 2009
@@ -16,15 +16,16 @@
  *  specific language governing permissions and limitations
  *  under the License.
  ****************************************************************/
-package org.apache.cayenne.runtime;
+package org.apache.cayenne.configuration.mock;
 
 import javax.sql.DataSource;
 
 import org.apache.cayenne.configuration.DataNodeDescriptor;
+import org.apache.cayenne.configuration.DataSourceFactory;
 
 import com.mockrunner.mock.jdbc.MockDataSource;
 
-public class MockDataSourceFactory1 implements DataSourceFactory {
+public class MockDataSourceFactory implements DataSourceFactory {
 
     public DataSource getDataSource(DataNodeDescriptor nodeDescriptor) {
         return new MockDataSource();

Copied: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/mock/MockDataSourceFactory1.java
(from r887666, cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/runtime/MockDataSourceFactory2.java)
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/mock/MockDataSourceFactory1.java?p2=cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/mock/MockDataSourceFactory1.java&p1=cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/runtime/MockDataSourceFactory2.java&r1=887666&r2=887667&rev=887667&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/runtime/MockDataSourceFactory2.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/mock/MockDataSourceFactory1.java
Sun Dec  6 11:22:19 2009
@@ -16,18 +16,25 @@
  *  specific language governing permissions and limitations
  *  under the License.
  ****************************************************************/
-package org.apache.cayenne.runtime;
+package org.apache.cayenne.configuration.mock;
 
 import javax.sql.DataSource;
 
 import org.apache.cayenne.configuration.DataNodeDescriptor;
+import org.apache.cayenne.configuration.DataSourceFactory;
+import org.apache.cayenne.di.Inject;
+import org.apache.cayenne.di.Injector;
 
-import com.mockrunner.mock.jdbc.MockDataSource;
+public class MockDataSourceFactory1 implements DataSourceFactory {
 
-public class MockDataSourceFactory2 implements DataSourceFactory {
+    @Inject
+    protected Injector injector;
 
-    public DataSource getDataSource(DataNodeDescriptor nodeDescriptor) {
-        return new MockDataSource();
+    public DataSource getDataSource(DataNodeDescriptor nodeDescriptor) throws Exception {
+        return null;
     }
 
+    public Injector getInjector() {
+        return injector;
+    }
 }

Copied: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/mock/MockDataSourceFactoryLoader.java
(from r887666, cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/runtime/MockDataSourceFactory2.java)
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/mock/MockDataSourceFactoryLoader.java?p2=cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/mock/MockDataSourceFactoryLoader.java&p1=cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/runtime/MockDataSourceFactory2.java&r1=887666&r2=887667&rev=887667&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/runtime/MockDataSourceFactory2.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/configuration/mock/MockDataSourceFactoryLoader.java
Sun Dec  6 11:22:19 2009
@@ -16,18 +16,16 @@
  *  specific language governing permissions and limitations
  *  under the License.
  ****************************************************************/
-package org.apache.cayenne.runtime;
-
-import javax.sql.DataSource;
+package org.apache.cayenne.configuration.mock;
 
 import org.apache.cayenne.configuration.DataNodeDescriptor;
+import org.apache.cayenne.configuration.DataSourceFactory;
+import org.apache.cayenne.configuration.DataSourceFactoryLoader;
 
-import com.mockrunner.mock.jdbc.MockDataSource;
-
-public class MockDataSourceFactory2 implements DataSourceFactory {
+public class MockDataSourceFactoryLoader implements DataSourceFactoryLoader {
 
-    public DataSource getDataSource(DataNodeDescriptor nodeDescriptor) {
-        return new MockDataSource();
+    public DataSourceFactory getDataSourceFactory(DataNodeDescriptor nodeDescriptor) {
+        return new MockDataSourceFactory();
     }
 
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/MockDbAdapter.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/MockDbAdapter.java?rev=887667&r1=887666&r2=887667&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/MockDbAdapter.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/MockDbAdapter.java
Sun Dec  6 11:22:19 2009
@@ -19,13 +19,11 @@
 
 package org.apache.cayenne.dba;
 
-import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.SQLException;
 import java.util.Collection;
 
 import org.apache.cayenne.access.DataNode;
-import org.apache.cayenne.access.OperationObserver;
 import org.apache.cayenne.access.trans.QualifierTranslator;
 import org.apache.cayenne.access.trans.QueryAssembler;
 import org.apache.cayenne.access.types.ExtendedTypeMap;
@@ -33,7 +31,6 @@
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.DbRelationship;
 import org.apache.cayenne.merge.MergerFactory;
-import org.apache.cayenne.query.BatchQuery;
 import org.apache.cayenne.query.Query;
 import org.apache.cayenne.query.SQLAction;
 
@@ -69,10 +66,6 @@
         return false;
     }
 
-    public String dropTable(DbEntity ent) {
-        return null;
-    }
-
     public Collection<String> dropTableStatements(DbEntity table) {
         return null;
     }
@@ -127,28 +120,13 @@
         return null;
     }
 
-    public boolean shouldRunBatchQuery(
-            DataNode node,
-            Connection con,
-            BatchQuery query,
-            OperationObserver delegate) throws SQLException, Exception {
-        return false;
-    }
-
     public MergerFactory mergerFactory() {
         return null;
     }
 
     public void createTableAppendColumn(StringBuffer sqlBuffer, DbAttribute column) {
     }
-    
-    public String getIdentifiersStartQuote(){
-        return "\"";
-    }
-    public String getIdentifiersEndQuote(){
-        return "\"";
-    }
-    
+
     public QuotingStrategy getQuotingStrategy(boolean isQuoteStrategy) {
         return null;
     }

Copied: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/resource/mock/MockResourceLocator.java
(from r887666, cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/runtime/DriverDataSourceFactory.java)
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/resource/mock/MockResourceLocator.java?p2=cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/resource/mock/MockResourceLocator.java&p1=cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/runtime/DriverDataSourceFactory.java&r1=887666&r2=887667&rev=887667&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/runtime/DriverDataSourceFactory.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/resource/mock/MockResourceLocator.java
Sun Dec  6 11:22:19 2009
@@ -16,19 +16,17 @@
  *  specific language governing permissions and limitations
  *  under the License.
  ****************************************************************/
-package org.apache.cayenne.runtime;
+package org.apache.cayenne.resource.mock;
 
-import javax.sql.DataSource;
+import java.util.Collection;
 
-import org.apache.cayenne.configuration.DataNodeDescriptor;
+import org.apache.cayenne.resource.Resource;
+import org.apache.cayenne.resource.ResourceLocator;
 
-/**
- * @since 3.1
- */
-public class DriverDataSourceFactory implements DataSourceFactory {
+public class MockResourceLocator implements ResourceLocator {
 
-    public DataSource getDataSource(DataNodeDescriptor nodeDescriptor) {
-        throw new UnsupportedOperationException("TODO");
+    public Collection<Resource> findResources(String name) {
+        return null;
     }
 
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/runtime/DataDomainProviderTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/runtime/DataDomainProviderTest.java?rev=887667&r1=887666&r2=887667&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/runtime/DataDomainProviderTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/runtime/DataDomainProviderTest.java
Sun Dec  6 11:22:19 2009
@@ -33,11 +33,16 @@
 import org.apache.cayenne.access.dbsync.SchemaUpdateStrategy;
 import org.apache.cayenne.access.dbsync.SkipSchemaUpdateStrategy;
 import org.apache.cayenne.access.dbsync.ThrowOnPartialOrCreateSchemaStrategy;
+import org.apache.cayenne.configuration.AdhocObjectFactory;
 import org.apache.cayenne.configuration.DataChannelDescriptor;
 import org.apache.cayenne.configuration.DataChannelDescriptorLoader;
 import org.apache.cayenne.configuration.DataNodeDescriptor;
+import org.apache.cayenne.configuration.DataSourceFactoryLoader;
+import org.apache.cayenne.configuration.DefaultAdhocObjectFactory;
 import org.apache.cayenne.configuration.DefaultRuntimeProperties;
 import org.apache.cayenne.configuration.RuntimeProperties;
+import org.apache.cayenne.configuration.mock.MockDataSourceFactory;
+import org.apache.cayenne.configuration.mock.MockDataSourceFactoryLoader;
 import org.apache.cayenne.dba.AutoAdapter;
 import org.apache.cayenne.dba.DbAdapter;
 import org.apache.cayenne.dba.DbAdapterFactory;
@@ -68,7 +73,7 @@
         nodeDescriptor1.setName("node1");
         nodeDescriptor1.getDataMapNames().add("map1");
         nodeDescriptor1.setAdapterType(OracleAdapter.class.getName());
-        nodeDescriptor1.setDataSourceFactoryType(MockDataSourceFactory1.class.getName());
+        nodeDescriptor1.setDataSourceFactoryType(MockDataSourceFactory.class.getName());
         nodeDescriptor1.setLocation("jdbc/testDataNode1");
         nodeDescriptor1
                 .setSchemaUpdateStrategyType(ThrowOnPartialOrCreateSchemaStrategy.class
@@ -112,8 +117,9 @@
 
                 binder.bind(DataSource.class).toInstance(new MockDataSource());
                 binder.bind(DbAdapter.class).to(AutoAdapter.class);
-                binder.bind(DataSourceFactory.class).toInstance(
-                        new MockDataSourceFactory2());
+                binder.bind(DataSourceFactoryLoader.class).toInstance(
+                        new MockDataSourceFactoryLoader());
+                binder.bind(AdhocObjectFactory.class).to(DefaultAdhocObjectFactory.class);
             }
         };
 
@@ -165,8 +171,7 @@
         assertEquals(1, node2.getDataMaps().size());
         assertSame(map2, node2.getDataMaps().iterator().next());
         assertSame(node2, domain.lookupDataNode(map2));
-        assertEquals(MockDataSourceFactory2.class.getName(), node2
-                .getDataSourceFactory());
+        assertNull(node2.getDataSourceFactory());
         assertNotNull(node2.getDataSource());
         assertEquals(nodeDescriptor2.getLocation(), node2.getDataSourceLocation());
         assertEquals(SkipSchemaUpdateStrategy.class.getName(), node2

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/org/apache/cayenne/configuration/testNode1.driver.xml
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/org/apache/cayenne/configuration/testNode1.driver.xml?rev=887667&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/org/apache/cayenne/configuration/testNode1.driver.xml
(added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/org/apache/cayenne/configuration/testNode1.driver.xml
Sun Dec  6 11:22:19 2009
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<driver project-version="6" class="jdbcDriver">
+	<url value="jdbcUrl"/>
+	<connectionPool min="2" max="3"/>
+	<login userName="jdbcUserName" password="jdbcPassword"/>
+</driver>

Added: cayenne/main/trunk/framework/cayenne-server/pom.properties
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-server/pom.properties?rev=887667&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-server/pom.properties (added)
+++ cayenne/main/trunk/framework/cayenne-server/pom.properties Sun Dec  6 11:22:19 2009
@@ -0,0 +1,5 @@
+#Generated by Maven
+#Sat Dec 05 14:56:16 CET 2009
+version=3.1-SNAPSHOT
+groupId=org.apache.cayenne
+artifactId=cayenne-server



Mime
View raw message