cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntimof...@apache.org
Subject cayenne git commit: CAY-2265 ServerRuntime.builder() fails to set default runtime name when a the project file doesn't follow recognized pattern.
Date Tue, 14 Mar 2017 15:08:16 GMT
Repository: cayenne
Updated Branches:
  refs/heads/master ba3c7eadf -> daaa20381


CAY-2265 ServerRuntime.builder() fails to set default runtime name when a the project file
doesn't follow recognized pattern.


Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/daaa2038
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/daaa2038
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/daaa2038

Branch: refs/heads/master
Commit: daaa20381c937d17a4b4f84b6320bc1c28a066bb
Parents: ba3c7ea
Author: Nikita Timofeev <stariy95@gmail.com>
Authored: Tue Mar 14 18:02:35 2017 +0300
Committer: Nikita Timofeev <stariy95@gmail.com>
Committed: Tue Mar 14 18:02:35 2017 +0300

----------------------------------------------------------------------
 .../configuration/DefaultConfigurationNameMapper.java  |  4 +++-
 .../configuration/server/ServerRuntimeBuilderIT.java   | 13 +++++++++++++
 .../apache/cayenne/unit/di/server/CayenneProjects.java |  1 +
 cayenne-server/src/test/resources/custom-name-file.xml |  4 ++++
 docs/doc/src/main/resources/RELEASE-NOTES.txt          |  1 +
 5 files changed, 22 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/daaa2038/cayenne-server/src/main/java/org/apache/cayenne/configuration/DefaultConfigurationNameMapper.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/configuration/DefaultConfigurationNameMapper.java
b/cayenne-server/src/main/java/org/apache/cayenne/configuration/DefaultConfigurationNameMapper.java
index ffe2868..5e6a53d 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/configuration/DefaultConfigurationNameMapper.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/configuration/DefaultConfigurationNameMapper.java
@@ -26,6 +26,7 @@ import org.apache.cayenne.resource.Resource;
  */
 public class DefaultConfigurationNameMapper implements ConfigurationNameMapper {
 
+	private static final String DEFAULT_NAME = "cayenne";
 	private static final String CAYENNE_PREFIX = "cayenne-";
 	private static final String CAYENNE_SUFFIX = ".xml";
 
@@ -74,7 +75,8 @@ public class DefaultConfigurationNameMapper implements ConfigurationNameMapper
{
 
 		if (DataChannelDescriptor.class.isAssignableFrom(type)) {
 			if (!path.startsWith(CAYENNE_PREFIX) || !path.endsWith(CAYENNE_SUFFIX)) {
-				return null;
+				// DataChannelDescriptor should always have name
+				return DEFAULT_NAME;
 			}
 
 			return path.substring(CAYENNE_PREFIX.length(), path.length() - CAYENNE_SUFFIX.length());

http://git-wip-us.apache.org/repos/asf/cayenne/blob/daaa2038/cayenne-server/src/test/java/org/apache/cayenne/configuration/server/ServerRuntimeBuilderIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/configuration/server/ServerRuntimeBuilderIT.java
b/cayenne-server/src/test/java/org/apache/cayenne/configuration/server/ServerRuntimeBuilderIT.java
index 60a38d4..dc9fe1e 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/configuration/server/ServerRuntimeBuilderIT.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/configuration/server/ServerRuntimeBuilderIT.java
@@ -27,6 +27,7 @@ import java.util.List;
 import javax.sql.DataSource;
 
 import org.apache.cayenne.DataRow;
+import org.apache.cayenne.ObjectContext;
 import org.apache.cayenne.access.DataNode;
 import org.apache.cayenne.conn.DataSourceInfo;
 import org.apache.cayenne.di.Inject;
@@ -144,4 +145,16 @@ public class ServerRuntimeBuilderIT extends ServerCase {
 				CayenneProjects.EMBEDDABLE_PROJECT).build();
 		assertEquals("myd", localRuntime.getDataDomain().getName());
 	}
+
+	/**
+	 * Test case for CAY-2265
+	 */
+	@Test
+	public void test_UnnamedDomain_CustomNameProjectFile() {
+		localRuntime = new ServerRuntimeBuilder().addConfigs(CayenneProjects.CUSTOM_NAME_PROJECT).build();
+		assertEquals("cayenne", localRuntime.getDataDomain().getName());
+
+		ObjectContext context = localRuntime.newContext();
+		assertNotNull(context);
+	}
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/daaa2038/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/CayenneProjects.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/CayenneProjects.java
b/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/CayenneProjects.java
index d7eb2f2..5710bcd 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/CayenneProjects.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/unit/di/server/CayenneProjects.java
@@ -78,5 +78,6 @@ public class CayenneProjects {
     public static final String TOONE_PROJECT = "cayenne-toone.xml";
     public static final String UNSUPPORTED_DISTINCT_TYPES_PROJECT = "cayenne-unsupported-distinct-types.xml";
     public static final String UUID_PROJECT = "cayenne-uuid.xml";
+    public static final String CUSTOM_NAME_PROJECT = "custom-name-file.xml";
 
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/daaa2038/cayenne-server/src/test/resources/custom-name-file.xml
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/resources/custom-name-file.xml b/cayenne-server/src/test/resources/custom-name-file.xml
new file mode 100644
index 0000000..3c44022
--- /dev/null
+++ b/cayenne-server/src/test/resources/custom-name-file.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<domain project-version="9">
+	<map name="testmap"/>
+</domain>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/daaa2038/docs/doc/src/main/resources/RELEASE-NOTES.txt
----------------------------------------------------------------------
diff --git a/docs/doc/src/main/resources/RELEASE-NOTES.txt b/docs/doc/src/main/resources/RELEASE-NOTES.txt
index 5c8be17..9dc1c80 100644
--- a/docs/doc/src/main/resources/RELEASE-NOTES.txt
+++ b/docs/doc/src/main/resources/RELEASE-NOTES.txt
@@ -20,6 +20,7 @@ Bug Fixes:
 
 CAY-2240 Modeler: issue with cursor rendering for EJBQL query
 CAY-2256 Cannot Save/Insert an Object With null Flattened (complex) toOne Relationship (see
also CAY-2146)
+CAY-2265 ServerRuntime.builder() fails to set default runtime name when a the project file
doesn't follow recognized pattern
 
 ----------------------------------
 Release: 4.0.M5


Mime
View raw message