jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clomb...@apache.org
Subject svn commit: r697994 - in /jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm: mapper/ testmodel/inheritance/withmixin/
Date Mon, 22 Sep 2008 21:10:18 GMT
Author: clombart
Date: Mon Sep 22 14:10:18 2008
New Revision: 697994

URL: http://svn.apache.org/viewvc?rev=697994&view=rev
Log:
Add unit tests for JCR-1505 (Improve handling of inherited mixins). With the current head,
the mixin types are correctly inherited in the descendant classes. This is not necessary to
defined them in all descendant classes. You can aslo review the classes defined in org.apache.ocm.tesmmodel.inheritance.withmixins.

Added:
    jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/inheritance/withmixin/
    jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/inheritance/withmixin/Ancestor.java
    jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/inheritance/withmixin/AnotherDescendant.java
    jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/inheritance/withmixin/Descendant.java
    jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/inheritance/withmixin/SubDescendant.java
Modified:
    jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/mapper/AnnotationMapperImplTest.java

Modified: jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/mapper/AnnotationMapperImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/mapper/AnnotationMapperImplTest.java?rev=697994&r1=697993&r2=697994&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/mapper/AnnotationMapperImplTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/mapper/AnnotationMapperImplTest.java
Mon Sep 22 14:10:18 2008
@@ -462,6 +462,34 @@
 			fail("Impossible to retrieve the converter " + e);
 		}
 	}
+	
+	public void testInheritanceWithMixin()
+	{
+		try {
+			Mapper mapper = getMapper();
+			assertNotNull("Mapper is null", mapper);
+			ClassDescriptor classDescriptor = mapper.getClassDescriptorByClass(org.apache.jackrabbit.ocm.testmodel.inheritance.withmixin.Ancestor.class);
+			assertNotNull("Classdescriptor is null", classDescriptor);
+			assertEquals("No mixin defined for Ancestor", 1, classDescriptor.getJcrMixinTypes().length);
+			String[] mixinTypes = classDescriptor.getJcrMixinTypes();
+			assertEquals("Invalid mixin defined for Ancestor", "mix:referenceable", mixinTypes[0]);
+			
+			classDescriptor = mapper.getClassDescriptorByClass(org.apache.jackrabbit.ocm.testmodel.inheritance.withmixin.Descendant.class);
+			assertEquals("No mixin defined for Descendant", 1, classDescriptor.getJcrMixinTypes().length);
+			mixinTypes = classDescriptor.getJcrMixinTypes();
+			assertEquals("Invalid mixin defined for Ancestor", "mix:referenceable", mixinTypes[0]);
+			
+			classDescriptor = mapper.getClassDescriptorByClass(org.apache.jackrabbit.ocm.testmodel.inheritance.withmixin.SubDescendant.class);
+			assertEquals("No mixin defined for SubDescendant", 1, classDescriptor.getJcrMixinTypes().length);
+			mixinTypes = classDescriptor.getJcrMixinTypes();
+			assertEquals("Invalid mixin defined for Ancestor", "mix:referenceable", mixinTypes[0]);
+
+			
+		} catch (JcrMappingException e) {
+			e.printStackTrace();
+			fail("Impossible to retrieve the converter " + e);
+		}
+	}
 
 	/**
 	 *
@@ -495,6 +523,10 @@
 		classes.add(org.apache.jackrabbit.ocm.testmodel.inheritance.AnotherDescendant.class);
 		classes.add( org.apache.jackrabbit.ocm.testmodel.inheritance.Descendant.class);
 		classes.add(org.apache.jackrabbit.ocm.testmodel.inheritance.SubDescendant.class);
+		classes.add(org.apache.jackrabbit.ocm.testmodel.inheritance.withmixin.Ancestor.class);
+		classes.add(org.apache.jackrabbit.ocm.testmodel.inheritance.withmixin.AnotherDescendant.class);
+		classes.add( org.apache.jackrabbit.ocm.testmodel.inheritance.withmixin.Descendant.class);
+		classes.add(org.apache.jackrabbit.ocm.testmodel.inheritance.withmixin.SubDescendant.class);
 		classes.add(org.apache.jackrabbit.ocm.testmodel.inheritance.impl.CmsObjectImpl.class);
 		classes.add(org.apache.jackrabbit.ocm.testmodel.inheritance.impl.DocumentImpl.class);
 		classes.add(org.apache.jackrabbit.ocm.testmodel.interfaces.CmsObject.class);

Added: jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/inheritance/withmixin/Ancestor.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/inheritance/withmixin/Ancestor.java?rev=697994&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/inheritance/withmixin/Ancestor.java
(added)
+++ jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/inheritance/withmixin/Ancestor.java
Mon Sep 22 14:10:18 2008
@@ -0,0 +1,52 @@
+/*
+ * 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.jackrabbit.ocm.testmodel.inheritance.withmixin;
+
+import org.apache.jackrabbit.ocm.mapper.impl.annotation.Field;
+import org.apache.jackrabbit.ocm.mapper.impl.annotation.Node;
+
+@Node(isAbstract=true,jcrMixinTypes="mix:referenceable")
+public class Ancestor
+{
+	@Field(path=true)protected String path;
+	@Field protected String ancestorField;
+	protected String discriminator;
+	
+	public String getPath() {
+		return path;
+	}
+
+	public void setPath(String path) {
+		this.path = path;
+	}
+
+	public String getAncestorField() {
+		return ancestorField;
+	}
+
+	public void setAncestorField(String ancestorField) {
+		this.ancestorField = ancestorField;
+	}
+
+	public String getDiscriminator() {
+		return discriminator;
+	}
+
+	public void setDiscriminator(String discriminator) {
+		this.discriminator = discriminator;
+	}
+}

Added: jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/inheritance/withmixin/AnotherDescendant.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/inheritance/withmixin/AnotherDescendant.java?rev=697994&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/inheritance/withmixin/AnotherDescendant.java
(added)
+++ jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/inheritance/withmixin/AnotherDescendant.java
Mon Sep 22 14:10:18 2008
@@ -0,0 +1,40 @@
+/*
+ * 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.jackrabbit.ocm.testmodel.inheritance.withmixin;
+
+import org.apache.jackrabbit.ocm.mapper.impl.annotation.Field;
+import org.apache.jackrabbit.ocm.mapper.impl.annotation.Implement;
+import org.apache.jackrabbit.ocm.mapper.impl.annotation.Node;
+import org.apache.jackrabbit.ocm.testmodel.interfaces.Interface;
+
+@Node(extend=Ancestor.class)
+@Implement(interfaceName=Interface.class)
+public class AnotherDescendant extends Ancestor implements Interface
+{
+
+	@Field protected String anotherDescendantField;
+
+	public String getAnotherDescendantField() {
+		return anotherDescendantField;
+	}
+
+	public void setAnotherDescendantField(String anotherDescendantField) {
+		this.anotherDescendantField = anotherDescendantField;
+	}
+	
+
+}

Added: jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/inheritance/withmixin/Descendant.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/inheritance/withmixin/Descendant.java?rev=697994&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/inheritance/withmixin/Descendant.java
(added)
+++ jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/inheritance/withmixin/Descendant.java
Mon Sep 22 14:10:18 2008
@@ -0,0 +1,52 @@
+/*
+ * 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.jackrabbit.ocm.testmodel.inheritance.withmixin;
+
+import org.apache.jackrabbit.ocm.mapper.impl.annotation.Field;
+import org.apache.jackrabbit.ocm.mapper.impl.annotation.Implement;
+import org.apache.jackrabbit.ocm.mapper.impl.annotation.Node;
+import org.apache.jackrabbit.ocm.testmodel.interfaces.AnotherInterface;
+
+@Node(extend=Ancestor.class)
+@Implement(interfaceName=AnotherInterface.class)
+public class Descendant extends Ancestor implements AnotherInterface {
+
+	@Field protected String descendantField;
+	@Field protected int intField;
+	
+
+	public String getDescendantField() {
+		return descendantField;
+	}
+
+	public void setDescendantField(String descendantField) {
+		this.descendantField = descendantField;
+	}
+
+	public int getIntField() {
+		return intField;
+	}
+
+	public void setIntField(int intField) {
+		this.intField = intField;
+	}
+
+
+	
+	
+
+}

Added: jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/inheritance/withmixin/SubDescendant.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/inheritance/withmixin/SubDescendant.java?rev=697994&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/inheritance/withmixin/SubDescendant.java
(added)
+++ jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/inheritance/withmixin/SubDescendant.java
Mon Sep 22 14:10:18 2008
@@ -0,0 +1,38 @@
+/*
+ * 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.jackrabbit.ocm.testmodel.inheritance.withmixin;
+
+import org.apache.jackrabbit.ocm.mapper.impl.annotation.Field;
+import org.apache.jackrabbit.ocm.mapper.impl.annotation.Node;
+
+
+@Node(extend=Descendant.class)
+
+public class SubDescendant extends Descendant {
+
+	@Field protected String subDescendantField;
+
+	public String getSubDescendantField() {
+		return subDescendantField;
+	}
+
+	public void setSubDescendantField(String subDescendantField) {
+		this.subDescendantField = subDescendantField;
+	}
+
+	
+}



Mime
View raw message