Return-Path: Delivered-To: apmail-jackrabbit-commits-archive@www.apache.org Received: (qmail 25139 invoked from network); 18 Jan 2009 08:54:31 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 18 Jan 2009 08:54:31 -0000 Received: (qmail 81246 invoked by uid 500); 18 Jan 2009 08:54:31 -0000 Delivered-To: apmail-jackrabbit-commits-archive@jackrabbit.apache.org Received: (qmail 81207 invoked by uid 500); 18 Jan 2009 08:54:31 -0000 Mailing-List: contact commits-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jackrabbit.apache.org Delivered-To: mailing list commits@jackrabbit.apache.org Received: (qmail 81197 invoked by uid 99); 18 Jan 2009 08:54:31 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 18 Jan 2009 00:54:31 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 18 Jan 2009 08:54:30 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 2DB75238889C; Sun, 18 Jan 2009 00:54:10 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@jackrabbit.apache.org From: clombart@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090118085410.2DB75238889C@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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); + + /** + *

Defines the test case name for junit.

+ * @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 bList = new ArrayList(); + 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 entityB; + + public String getPath() { + return path; + } + public void setPath(String path) { + this.path = path; + } + public List getEntityB() { + return entityB; + } + public void setEntityB(List 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(); +}