You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by aa...@apache.org on 2008/05/25 16:14:11 UTC
svn commit: r659987 - in /cayenne/main/trunk/framework:
cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/
cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/
cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/co...
Author: aadamchik
Date: Sun May 25 07:14:10 2008
New Revision: 659987
URL: http://svn.apache.org/viewvc?rev=659987&view=rev
Log:
CAY-943 Support multiple cayenne.xml files in the project
(preliminary refactoring)
Modified:
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/Configuration.java
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextStaticsTest.java
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/conf/ConfigurationTest.java
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/conf/MockConfiguration.java
cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/Provider.java
cayenne/main/trunk/framework/cayenne-modeler/src/test/java/org/apache/cayenne/modeler/action/MockConfiguration.java
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/Configuration.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/Configuration.java?rev=659987&r1=659986&r2=659987&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/Configuration.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/conf/Configuration.java Sun May 25 07:14:10 2008
@@ -216,10 +216,13 @@
/**
* Returns a DataDomain as a stream or <code>null</code> if it cannot be found.
+ *
+ * @deprecated since 3.0 This method is specific to subclass, so it should not be in the
+ * superclass.
*/
- // TODO: this method is only used in sublcass (DefaultConfiguration),
- // should we remove it from here?
- protected abstract InputStream getDomainConfiguration();
+ protected InputStream getDomainConfiguration() {
+ throw new UnsupportedOperationException();
+ }
/**
* Returns a DataMap with the given name or <code>null</code> if it cannot be found.
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextStaticsTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextStaticsTest.java?rev=659987&r1=659986&r2=659987&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextStaticsTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextStaticsTest.java Sun May 25 07:14:10 2008
@@ -29,6 +29,7 @@
* @author Andrus Adamchik
*/
public class DataContextStaticsTest extends CayenneCase {
+
protected Configuration savedConfig;
public void testCreateDataContext1() throws Exception {
@@ -38,7 +39,8 @@
assertNotNull(c1);
assertSame(c1.getParentDataDomain(), getDomain());
assertTrue(c1 != DataContext.createDataContext());
- } finally {
+ }
+ finally {
conf.restoreConfig();
}
}
@@ -51,12 +53,14 @@
assertNotNull(c1);
assertSame(c1.getParentDataDomain(), getDomain());
assertTrue(c1 != DataContext.createDataContext(name));
- } finally {
+ }
+ finally {
conf.restoreConfig();
}
}
class TestConfig extends Configuration {
+
protected Configuration savedConfig;
public TestConfig(DataDomain domain) {
@@ -69,26 +73,21 @@
Configuration.sharedConfiguration = savedConfig;
}
- @Override
+ @Override
public boolean canInitialize() {
- return true;
- }
+ return true;
+ }
- @Override
+ @Override
public void initialize() throws Exception {
- }
+ }
- @Override
+ @Override
public void didInitialize() {
- }
-
- @Override
- public ResourceLocator getResourceLocator() {
- return null;
- }
+ }
@Override
- protected InputStream getDomainConfiguration() {
+ public ResourceLocator getResourceLocator() {
return null;
}
@@ -96,7 +95,7 @@
protected InputStream getMapConfiguration(String location) {
return null;
}
-
+
@Override
protected InputStream getViewConfiguration(String location) {
return null;
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/conf/ConfigurationTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/conf/ConfigurationTest.java?rev=659987&r1=659986&r2=659987&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/conf/ConfigurationTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/conf/ConfigurationTest.java Sun May 25 07:14:10 2008
@@ -20,18 +20,16 @@
package org.apache.cayenne.conf;
import java.io.File;
-import java.io.InputStream;
import org.apache.cayenne.ConfigurationException;
import org.apache.cayenne.access.DataDomain;
import org.apache.cayenne.project.ProjectDataSourceFactory;
import org.apache.cayenne.unit.CayenneCase;
-import org.apache.cayenne.util.ResourceLocator;
public class ConfigurationTest extends CayenneCase {
- public void testDomain() throws java.lang.Exception {
- Configuration cfg = new Config();
+ public void testDomain() throws Exception {
+ Configuration cfg = new MockConfiguration();
DataDomain d1 = new DataDomain("d1");
cfg.addDomain(d1);
@@ -40,83 +38,47 @@
cfg.removeDomain(d1.getName());
assertNull(cfg.getDomain(d1.getName()));
}
-
+
/**
* @deprecated since 3.0
*/
- public void testOverrideFactory() throws java.lang.Exception {
- Configuration cfg = new Config();
+ public void testOverrideFactory() throws java.lang.Exception {
+ Configuration cfg = new MockConfiguration();
assertNull(cfg.getDataSourceFactory());
- ProjectDataSourceFactory factory = new ProjectDataSourceFactory(null);
+ ProjectDataSourceFactory factory = new ProjectDataSourceFactory(null);
cfg.setDataSourceFactory(factory);
assertSame(factory, cfg.getDataSourceFactory());
- }
+ }
+
+ public void testDefaultConfigurationConstructorWithNullName() {
+ try {
+ new DefaultConfiguration(null);
+ fail("expected ConfigurationException!");
+ }
+ catch (ConfigurationException ex) {
+ // OK
+ }
+ }
- public void testDefaultConfigurationConstructorWithNullName() {
- try {
- new DefaultConfiguration(null);
- fail("expected ConfigurationException!");
- }
- catch (ConfigurationException ex) {
- // OK
- }
- }
-
- public void testFileConfigurationConstructorWithNullFile() {
- try {
- new FileConfiguration((File)null);
- fail("expected ConfigurationException!");
- }
- catch (ConfigurationException ex) {
- // OK
- }
- }
-
- public void testFileConfigurationConstructorWithNullName() {
- try {
- new FileConfiguration((String)null);
- fail("expected ConfigurationException!");
- }
- catch (ConfigurationException ex) {
- // OK
- }
- }
-
- /** Concrete Configuration subclass used for tests. */
- public static class Config extends Configuration {
-
- @Override
- public boolean canInitialize() {
- return true;
- }
-
- @Override
- public void initialize() throws Exception {
- }
-
- @Override
- public void didInitialize() {
- }
-
- @Override
- public ResourceLocator getResourceLocator() {
- return null;
- }
-
- @Override
- protected InputStream getDomainConfiguration() {
- return null;
- }
-
- @Override
- protected InputStream getMapConfiguration(String location) {
- return null;
- }
-
- @Override
- protected InputStream getViewConfiguration(String location) {
- return null;
+ public void testFileConfigurationConstructorWithNullFile() {
+ try {
+ new FileConfiguration((File) null);
+ fail("expected ConfigurationException!");
+ }
+ catch (ConfigurationException ex) {
+ // OK
+ }
+ }
+
+ public void testFileConfigurationConstructorWithNullName() {
+ try {
+ new FileConfiguration((String) null);
+ fail("expected ConfigurationException!");
+ }
+ catch (ConfigurationException ex) {
+ // OK
}
}
+
}
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/conf/MockConfiguration.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/conf/MockConfiguration.java?rev=659987&r1=659986&r2=659987&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/conf/MockConfiguration.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/conf/MockConfiguration.java Sun May 25 07:14:10 2008
@@ -42,12 +42,6 @@
}
@Override
- protected InputStream getDomainConfiguration() {
- throw new UnsupportedOperationException(
- "this is an in-memory mockup...'getDomainConfiguration' is not implemented.");
- }
-
- @Override
protected InputStream getMapConfiguration(String name) {
return null;
}
Modified: cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/Provider.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/Provider.java?rev=659987&r1=659986&r2=659987&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/Provider.java (original)
+++ cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/Provider.java Sun May 25 07:14:10 2008
@@ -576,11 +576,6 @@
}
@Override
- protected InputStream getDomainConfiguration() {
- throw new UnsupportedOperationException();
- }
-
- @Override
protected InputStream getMapConfiguration(String name) {
throw new UnsupportedOperationException();
}
Modified: cayenne/main/trunk/framework/cayenne-modeler/src/test/java/org/apache/cayenne/modeler/action/MockConfiguration.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/test/java/org/apache/cayenne/modeler/action/MockConfiguration.java?rev=659987&r1=659986&r2=659987&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/test/java/org/apache/cayenne/modeler/action/MockConfiguration.java (original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/test/java/org/apache/cayenne/modeler/action/MockConfiguration.java Sun May 25 07:14:10 2008
@@ -36,11 +36,6 @@
public void didInitialize() {
}
- protected InputStream getDomainConfiguration() {
- throw new UnsupportedOperationException(
- "this is an in-memory mockup...'getDomainConfiguration' is not implemented.");
- }
-
protected InputStream getMapConfiguration(String name) {
return null;
}