Repository: cayenne Updated Branches: refs/heads/master fdfeb3ac4 -> f0782d260
Add failing unit test for BeanAccessors for classes with complex inheritance Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/bb0c8c77 Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/bb0c8c77 Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/bb0c8c77 Branch: refs/heads/master Commit: bb0c8c777404bd177c9601a5fae2341ff4ffbde6 Parents: 2f10481 Author: David Feshbach <[email protected]> Authored: Thu Feb 25 16:26:24 2016 -0600 Committer: David Feshbach <[email protected]> Committed: Thu Feb 25 16:38:50 2016 -0600 ---------------------------------------------------------------------- .../cayenne/reflect/BeanAccessorTest.java | 16 +++++++++++++ .../apache/cayenne/reflect/TstHasRelated.java | 24 ++++++++++++++++++++ .../cayenne/reflect/TstJavaBeanChild.java | 24 ++++++++++++++++++++ 3 files changed, 64 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cayenne/blob/bb0c8c77/cayenne-server/src/test/java/org/apache/cayenne/reflect/BeanAccessorTest.java ---------------------------------------------------------------------- diff --git a/cayenne-server/src/test/java/org/apache/cayenne/reflect/BeanAccessorTest.java b/cayenne-server/src/test/java/org/apache/cayenne/reflect/BeanAccessorTest.java index 9f62fb5..9129aaf 100644 --- a/cayenne-server/src/test/java/org/apache/cayenne/reflect/BeanAccessorTest.java +++ b/cayenne-server/src/test/java/org/apache/cayenne/reflect/BeanAccessorTest.java @@ -81,4 +81,20 @@ public class BeanAccessorTest { assertEquals("Incorrectly set null default", 0, o1.getIntField()); } + @Test + public void testInheritedCovariantProperty() { + + BeanAccessor accessor = new BeanAccessor( + TstJavaBeanChild.class, + "related", + null); + + TstJavaBeanChild o1 = new TstJavaBeanChild(); + + assertNull(o1.getRelated()); + accessor.setValue(o1, o1); + assertSame(o1, o1.getRelated()); + assertSame(o1, accessor.getValue(o1)); + } + } http://git-wip-us.apache.org/repos/asf/cayenne/blob/bb0c8c77/cayenne-server/src/test/java/org/apache/cayenne/reflect/TstHasRelated.java ---------------------------------------------------------------------- diff --git a/cayenne-server/src/test/java/org/apache/cayenne/reflect/TstHasRelated.java b/cayenne-server/src/test/java/org/apache/cayenne/reflect/TstHasRelated.java new file mode 100644 index 0000000..8ce9302 --- /dev/null +++ b/cayenne-server/src/test/java/org/apache/cayenne/reflect/TstHasRelated.java @@ -0,0 +1,24 @@ +/***************************************************************** + * 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.reflect; + +public interface TstHasRelated { + Object getRelated(); +} http://git-wip-us.apache.org/repos/asf/cayenne/blob/bb0c8c77/cayenne-server/src/test/java/org/apache/cayenne/reflect/TstJavaBeanChild.java ---------------------------------------------------------------------- diff --git a/cayenne-server/src/test/java/org/apache/cayenne/reflect/TstJavaBeanChild.java b/cayenne-server/src/test/java/org/apache/cayenne/reflect/TstJavaBeanChild.java new file mode 100644 index 0000000..4a0060e --- /dev/null +++ b/cayenne-server/src/test/java/org/apache/cayenne/reflect/TstJavaBeanChild.java @@ -0,0 +1,24 @@ +/***************************************************************** + * 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.reflect; + +public class TstJavaBeanChild extends TstJavaBean implements TstHasRelated { + +}
