You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by nt...@apache.org on 2019/03/01 08:24:17 UTC
[cayenne] branch master updated: CAY-2544 Possible name clash of
ivar and property name in generated class add and fix tests
This is an automated email from the ASF dual-hosted git repository.
ntimofeev pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cayenne.git
The following commit(s) were added to refs/heads/master by this push:
new a40a080 CAY-2544 Possible name clash of ivar and property name in generated class add and fix tests
a40a080 is described below
commit a40a080c05418bcd6b73299e79b0078b712775d7
Author: Nikita Timofeev <st...@gmail.com>
AuthorDate: Fri Mar 1 11:24:15 2019 +0300
CAY-2544 Possible name clash of ivar and property name in generated class
add and fix tests
---
.../org/apache/cayenne/gen/PropertyUtilsTest.java | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/cayenne-cgen/src/test/java/org/apache/cayenne/gen/PropertyUtilsTest.java b/cayenne-cgen/src/test/java/org/apache/cayenne/gen/PropertyUtilsTest.java
index f38965a..6c025eb 100644
--- a/cayenne-cgen/src/test/java/org/apache/cayenne/gen/PropertyUtilsTest.java
+++ b/cayenne-cgen/src/test/java/org/apache/cayenne/gen/PropertyUtilsTest.java
@@ -118,9 +118,11 @@ public class PropertyUtilsTest {
public void simpleNumericDefinition() throws Exception {
importUtils.addType(NumericProperty.class.getName());
+ ObjEntity entity = new ObjEntity("test");
ObjAttribute attribute = new ObjAttribute();
attribute.setName("test");
attribute.setType("int");
+ entity.addAttribute(attribute);
String definition = propertyUtils.propertyDefinition(attribute);
assertEquals("public static final NumericProperty<Integer> TEST = PropertyFactory.createNumeric(\"test\", Integer.class);",
@@ -131,9 +133,11 @@ public class PropertyUtilsTest {
public void simpleStringDefinition() throws Exception {
importUtils.addType(StringProperty.class.getName());
+ ObjEntity entity = new ObjEntity("test");
ObjAttribute attribute = new ObjAttribute();
attribute.setName("test");
attribute.setType("java.lang.String");
+ entity.addAttribute(attribute);
String definition = propertyUtils.propertyDefinition(attribute);
assertEquals("public static final StringProperty<String> TEST = PropertyFactory.createString(\"test\", String.class);",
@@ -141,13 +145,30 @@ public class PropertyUtilsTest {
}
@Test
+ public void uppercaseNameDefinition() throws Exception {
+ importUtils.addType(StringProperty.class.getName());
+
+ ObjEntity entity = new ObjEntity("test");
+ ObjAttribute attribute = new ObjAttribute();
+ attribute.setName("URL");
+ attribute.setType("java.lang.String");
+ entity.addAttribute(attribute);
+
+ String definition = propertyUtils.propertyDefinition(attribute);
+ assertEquals("public static final StringProperty<String> URL_ = PropertyFactory.createString(\"URL\", String.class);",
+ definition);
+ }
+
+ @Test
public void customPropertyDefinition() throws ClassNotFoundException {
importUtils.addType(CustomProperty.class.getName());
importUtils.addType(TimestampType.class.getName());
+ ObjEntity entity = new ObjEntity("test");
ObjAttribute attribute = new ObjAttribute();
attribute.setName("test");
attribute.setType("org.apache.cayenne.access.types.TimestampType");
+ entity.addAttribute(attribute);
String definition = propertyUtils.propertyDefinition(attribute);
assertEquals("public static final CustomProperty<TimestampType> TEST = new CustomProperty(\"test\", TimestampType.class);",