jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clomb...@apache.org
Subject svn commit: r735401 - in /jackrabbit/trunk/jackrabbit-ocm/src: main/java/org/apache/jackrabbit/ocm/mapper/impl/annotation/ test/java/org/apache/jackrabbit/ocm/ test/java/org/apache/jackrabbit/ocm/manager/interfaces/ test/java/org/apache/jackrabbit/ocm/...
Date Sun, 18 Jan 2009 08:54:09 GMT
Author: clombart
Date: Sun Jan 18 00:54:09 2009
New Revision: 735401

URL: http://svn.apache.org/viewvc?rev=735401&view=rev
Log:
Patch for JCR-1889 - Incorrect support for java interfaces in typed collection fields

Added:
    jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/interfaces/ListOfInterfaceTest.java
    jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/interfaces/EntityA.java
    jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/interfaces/EntityB.java
    jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/interfaces/MyInterface.java
Modified:
    jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/mapper/impl/annotation/AnnotationDescriptorReader.java
    jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/AnnotationTestBase.java

Modified: jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/mapper/impl/annotation/AnnotationDescriptorReader.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/mapper/impl/annotation/AnnotationDescriptorReader.java?rev=735401&r1=735400&r2=735401&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/mapper/impl/annotation/AnnotationDescriptorReader.java
(original)
+++ jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/mapper/impl/annotation/AnnotationDescriptorReader.java
Sun Jan 18 00:54:09 2009
@@ -291,13 +291,13 @@
 			// If only one type argument, the object is certainly a collection
 			if (paramType.length == 1)
 			{
-				collectionDescriptor.setElementClassName(paramType[0].toString().replace("class ", ""));
+				collectionDescriptor.setElementClassName(paramType[0].toString().replace("class ", "").replace("interface
", ""));
 
 			}
 			// either, it is certainly a map
 			else
 			{
-				collectionDescriptor.setElementClassName(paramType[1].toString().replace("class ", ""));
+				collectionDescriptor.setElementClassName(paramType[1].toString().replace("class ", "").replace("interface
", ""));
 			}
 
 		}

Modified: jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/AnnotationTestBase.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/AnnotationTestBase.java?rev=735401&r1=735400&r2=735401&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/AnnotationTestBase.java
(original)
+++ jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/AnnotationTestBase.java
Sun Jan 18 00:54:09 2009
@@ -68,8 +68,11 @@
 import org.apache.jackrabbit.ocm.testmodel.interfaces.CmsObject;
 import org.apache.jackrabbit.ocm.testmodel.interfaces.Content;
 import org.apache.jackrabbit.ocm.testmodel.interfaces.Document;
+import org.apache.jackrabbit.ocm.testmodel.interfaces.EntityA;
+import org.apache.jackrabbit.ocm.testmodel.interfaces.EntityB;
 import org.apache.jackrabbit.ocm.testmodel.interfaces.Folder;
 import org.apache.jackrabbit.ocm.testmodel.interfaces.Interface;
+import org.apache.jackrabbit.ocm.testmodel.interfaces.MyInterface;
 import org.apache.jackrabbit.ocm.testmodel.version.Author;
 import org.apache.jackrabbit.ocm.testmodel.version.PressRelease;
 
@@ -175,6 +178,10 @@
 		classes.add(Person.class);
 		classes.add(Odyssey.class);
 		
+		classes.add(EntityA.class); 
+		classes.add(EntityB.class); 
+		classes.add(MyInterface.class);
+		
 		Mapper mapper = new AnnotationMapperImpl(classes);
 		ocm = new ObjectContentManagerImpl(session, mapper);
 

Added: jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/interfaces/ListOfInterfaceTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/interfaces/ListOfInterfaceTest.java?rev=735401&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/interfaces/ListOfInterfaceTest.java
(added)
+++ jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/interfaces/ListOfInterfaceTest.java
Sun Jan 18 00:54:09 2009
@@ -0,0 +1,98 @@
+/*
+ * 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.manager.interfaces;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jackrabbit.ocm.AnnotationTestBase;
+import org.apache.jackrabbit.ocm.RepositoryLifecycleTestSetup;
+import org.apache.jackrabbit.ocm.manager.ObjectContentManager;
+import org.apache.jackrabbit.ocm.testmodel.interfaces.EntityA;
+import org.apache.jackrabbit.ocm.testmodel.interfaces.EntityB;
+import org.apache.jackrabbit.ocm.testmodel.interfaces.MyInterface;
+
+
+public class ListOfInterfaceTest extends AnnotationTestBase
+{
+	private final static Log log = LogFactory.getLog(ListOfInterfaceTest.class);
+
+	/**
+	 * <p>Defines the test case name for junit.</p>
+	 * @param testName The test case name.
+	 */
+	public ListOfInterfaceTest(String testName) throws Exception {
+		super(testName);
+
+	}
+
+	public static Test suite() {
+		// All methods starting with "test" will be executed in the test suite.
+		return new RepositoryLifecycleTestSetup(new TestSuite(
+				ListOfInterfaceTest.class));
+	}
+
+
+
+	public void testListOfInterface() {
+
+		try {
+			ObjectContentManager ocm = this.getObjectContentManager();
+
+			EntityA a = new EntityA();
+			a.setPath("/test");
+
+			List<MyInterface> bList = new ArrayList<MyInterface>();
+			EntityB b = new EntityB();
+			b.setId("ID_B");
+			b.setName("NAME_B");
+			bList.add(b);
+
+			a.setEntityB(bList);
+
+			ocm.insert(a);
+			ocm.save();
+			
+			
+			a = (EntityA) ocm.getObject("/test");
+			bList = a.getEntityB();
+			assertNotNull(bList);
+			assertEquals(1, bList.size());
+			
+			
+			ocm.remove("/test");
+			ocm.save();
+			
+
+
+			
+		} catch (Exception e) {
+			e.printStackTrace();
+			fail();
+		}
+
+	}
+	
+
+
+	
+}
\ No newline at end of file

Added: jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/interfaces/EntityA.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/interfaces/EntityA.java?rev=735401&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/interfaces/EntityA.java
(added)
+++ jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/interfaces/EntityA.java
Sun Jan 18 00:54:09 2009
@@ -0,0 +1,43 @@
+/*
+ * 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.interfaces;
+
+
+import java.util.List;
+
+import org.apache.jackrabbit.ocm.mapper.impl.annotation.Collection;
+import org.apache.jackrabbit.ocm.mapper.impl.annotation.Field;
+import org.apache.jackrabbit.ocm.mapper.impl.annotation.Node;
+
+@Node
+public class EntityA {
+       @Field(path=true) String path;
+       @Collection List<MyInterface> entityB;
+
+       public String getPath() {
+               return path;
+       }
+       public void setPath(String path) {
+               this.path = path;
+       }
+       public List<MyInterface> getEntityB() {
+               return entityB;
+       }
+       public void setEntityB(List<MyInterface> entityB) {
+               this.entityB = entityB;
+       }
+}
\ No newline at end of file

Added: jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/interfaces/EntityB.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/interfaces/EntityB.java?rev=735401&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/interfaces/EntityB.java
(added)
+++ jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/interfaces/EntityB.java
Sun Jan 18 00:54:09 2009
@@ -0,0 +1,42 @@
+/*
+ * 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.interfaces;
+
+import org.apache.jackrabbit.ocm.mapper.impl.annotation.Field;
+import org.apache.jackrabbit.ocm.mapper.impl.annotation.Node;
+
+@Node
+public class EntityB implements MyInterface {
+       @Field private String name;
+       @Field private String id;
+
+       public String getId() {
+               return id;
+       }
+
+       public void setId(String id) {
+               this.id = id;
+       }
+
+       public String getName() {
+               return name;
+       }
+
+       public void setName(String name) {
+               this.name = name;
+       }
+}

Added: jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/interfaces/MyInterface.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/interfaces/MyInterface.java?rev=735401&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/interfaces/MyInterface.java
(added)
+++ jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/interfaces/MyInterface.java
Sun Jan 18 00:54:09 2009
@@ -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.jackrabbit.ocm.testmodel.interfaces;
+
+import org.apache.jackrabbit.ocm.mapper.impl.annotation.Node;
+
+@Node
+public interface MyInterface {
+    public String getId();
+}



Mime
View raw message