Property changes on: . ___________________________________________________________________ Modified: svn:ignore - derby.log target *.iws *.ipr *.iml .* jcoverage* junit*.properties + derby.log target *.iws *.ipr *.iml .* jcoverage* junit*.properties target-eclipse Index: pom.xml =================================================================== --- pom.xml (revision 699938) +++ pom.xml (working copy) @@ -1,5 +1,4 @@ - - + - - + --> 4.0.0 @@ -138,6 +132,12 @@ slf4j-log4j12 test + + org.springframework + spring + 2.5.5 + test + @@ -152,4 +152,4 @@ - + \ No newline at end of file Index: src/test/java/org/apache/jackrabbit/ocm/AnnotationSpringTestBase.java =================================================================== --- src/test/java/org/apache/jackrabbit/ocm/AnnotationSpringTestBase.java (revision 0) +++ src/test/java/org/apache/jackrabbit/ocm/AnnotationSpringTestBase.java (revision 0) @@ -0,0 +1,39 @@ +/* + * 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; + + +/** + * Base class for spring testcases (Digester). Provides priviledged access to the jcr test + * repository. + * + * @author Boni Gopalan + * + * + */ +public abstract class AnnotationSpringTestBase extends SpringTestBase +{ + public AnnotationSpringTestBase(String testName) + { + super(testName); + } + + protected String getBeanConfigLocation(){ + return "classpath:repository-bean-annotation-config.xml"; + } + +} \ No newline at end of file Index: src/test/java/org/apache/jackrabbit/ocm/AnnotationTestBaseHelper.java =================================================================== --- src/test/java/org/apache/jackrabbit/ocm/AnnotationTestBaseHelper.java (revision 0) +++ src/test/java/org/apache/jackrabbit/ocm/AnnotationTestBaseHelper.java (revision 0) @@ -0,0 +1,124 @@ +package org.apache.jackrabbit.ocm; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.jackrabbit.ocm.testmodel.A; +import org.apache.jackrabbit.ocm.testmodel.Atomic; +import org.apache.jackrabbit.ocm.testmodel.B; +import org.apache.jackrabbit.ocm.testmodel.C; +import org.apache.jackrabbit.ocm.testmodel.D; +import org.apache.jackrabbit.ocm.testmodel.DFull; +import org.apache.jackrabbit.ocm.testmodel.Default; +import org.apache.jackrabbit.ocm.testmodel.Discriminator; +import org.apache.jackrabbit.ocm.testmodel.E; +import org.apache.jackrabbit.ocm.testmodel.File; +import org.apache.jackrabbit.ocm.testmodel.HierarchyNode; +import org.apache.jackrabbit.ocm.testmodel.Lockable; +import org.apache.jackrabbit.ocm.testmodel.MultiValue; +import org.apache.jackrabbit.ocm.testmodel.MultiValueWithObjectCollection; +import org.apache.jackrabbit.ocm.testmodel.Page; +import org.apache.jackrabbit.ocm.testmodel.Paragraph; +import org.apache.jackrabbit.ocm.testmodel.PropertyTest; +import org.apache.jackrabbit.ocm.testmodel.Residual; +import org.apache.jackrabbit.ocm.testmodel.Resource; +import org.apache.jackrabbit.ocm.testmodel.SimpleAnnotedAbstractClass; +import org.apache.jackrabbit.ocm.testmodel.SimpleAnnotedClass; +import org.apache.jackrabbit.ocm.testmodel.SimpleInterface; +import org.apache.jackrabbit.ocm.testmodel.Residual.ResidualNodes; +import org.apache.jackrabbit.ocm.testmodel.Residual.ResidualProperties; +import org.apache.jackrabbit.ocm.testmodel.collection.Element; +import org.apache.jackrabbit.ocm.testmodel.collection.Main; +import org.apache.jackrabbit.ocm.testmodel.inheritance.Ancestor; +import org.apache.jackrabbit.ocm.testmodel.inheritance.AnotherDescendant; +import org.apache.jackrabbit.ocm.testmodel.inheritance.Descendant; +import org.apache.jackrabbit.ocm.testmodel.inheritance.SubDescendant; +import org.apache.jackrabbit.ocm.testmodel.inheritance.impl.CmsObjectImpl; +import org.apache.jackrabbit.ocm.testmodel.inheritance.impl.ContentImpl; +import org.apache.jackrabbit.ocm.testmodel.inheritance.impl.DocumentExtImpl; +import org.apache.jackrabbit.ocm.testmodel.inheritance.impl.DocumentImpl; +import org.apache.jackrabbit.ocm.testmodel.inheritance.impl.DocumentStream; +import org.apache.jackrabbit.ocm.testmodel.inheritance.impl.FolderImpl; +import org.apache.jackrabbit.ocm.testmodel.interfaces.AnotherInterface; +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.Folder; +import org.apache.jackrabbit.ocm.testmodel.interfaces.Interface; +import org.apache.jackrabbit.ocm.testmodel.version.Author; +import org.apache.jackrabbit.ocm.testmodel.version.PressRelease; + +public class AnnotationTestBaseHelper { + public static List getAnnotatedClassList(){ + List classes = new ArrayList(); + + // Register content classes used by the unit tests + classes.add(Atomic.class); + classes.add(Default.class); + classes.add(A.class); + classes.add(B.class); + classes.add(C.class); + classes.add(D.class); + classes.add(DFull.class); + classes.add(E.class); + classes.add(Page.class); + classes.add(Paragraph.class); + classes.add(Main.class); + classes.add(Element.class); + classes.add(MultiValue.class); + classes.add(MultiValueWithObjectCollection.class); + classes.add(Discriminator.class); + + classes.add(Residual.class); + classes.add(ResidualProperties.class); + classes.add(ResidualNodes.class); + + classes.add(CmsObject.class); + classes.add(Content.class); + classes.add(Document.class); + classes.add(Folder.class); + classes.add(CmsObjectImpl.class); + classes.add(ContentImpl.class); + classes.add(DocumentImpl.class); + classes.add(DocumentExtImpl.class); + classes.add(DocumentStream.class); + classes.add(FolderImpl.class); + + classes.add(Ancestor.class); + classes.add(Descendant.class); + classes.add(AnotherDescendant.class); + classes.add(SubDescendant.class); + classes.add(Interface.class); + classes.add(AnotherInterface.class); + + classes.add(HierarchyNode.class); + classes.add(File.class); + classes.add(org.apache.jackrabbit.ocm.testmodel.Folder.class); + classes.add(Resource.class); + classes.add(PropertyTest.class); + + classes.add(Lockable.class); + + classes.add(org.apache.jackrabbit.ocm.testmodel.proxy.Main.class); + classes.add(org.apache.jackrabbit.ocm.testmodel.proxy.Detail.class); + + classes.add(org.apache.jackrabbit.ocm.testmodel.proxy.NTMain.class); + classes.add(org.apache.jackrabbit.ocm.testmodel.proxy.NTDetail.class); + + classes.add(org.apache.jackrabbit.ocm.testmodel.uuid.A.class); + classes.add(org.apache.jackrabbit.ocm.testmodel.uuid.B.class); + classes.add(org.apache.jackrabbit.ocm.testmodel.uuid.B2.class); + classes.add(org.apache.jackrabbit.ocm.testmodel.uuid.Ancestor.class); + classes.add(org.apache.jackrabbit.ocm.testmodel.uuid.Descendant.class); + classes.add(org.apache.jackrabbit.ocm.testmodel.unstructured.UnstructuredParagraph.class); + classes.add(org.apache.jackrabbit.ocm.testmodel.unstructured.UnstructuredPage.class); + + classes.add(PressRelease.class); + classes.add(Author.class); + + classes.add(SimpleAnnotedAbstractClass.class); + classes.add(SimpleAnnotedClass.class); + classes.add(SimpleInterface.class); + return classes; + } +} Index: src/test/java/org/apache/jackrabbit/ocm/DigesterSpringTestBase.java =================================================================== --- src/test/java/org/apache/jackrabbit/ocm/DigesterSpringTestBase.java (revision 0) +++ src/test/java/org/apache/jackrabbit/ocm/DigesterSpringTestBase.java (revision 0) @@ -0,0 +1,39 @@ +/* + * 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; + + +/** + * Base class for spring testcases (Digester). Provides priviledged access to the jcr test + * repository. + * + * @author Boni Gopalan + * + * + */ +public abstract class DigesterSpringTestBase extends SpringTestBase +{ + public DigesterSpringTestBase(String testName) + { + super(testName); + } + + protected String getBeanConfigLocation(){ + return "classpath:repository-bean-digester-config.xml"; + } + +} \ No newline at end of file Index: src/test/java/org/apache/jackrabbit/ocm/manager/spring/AnnotationAtomicSpringTest.java =================================================================== --- src/test/java/org/apache/jackrabbit/ocm/manager/spring/AnnotationAtomicSpringTest.java (revision 0) +++ src/test/java/org/apache/jackrabbit/ocm/manager/spring/AnnotationAtomicSpringTest.java (revision 0) @@ -0,0 +1,192 @@ +/* + * 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.spring; + +import java.io.ByteArrayInputStream; +import java.sql.Timestamp; +import java.util.Calendar; +import java.util.Date; + +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.AnnotationSpringTestBase; +import org.apache.jackrabbit.ocm.RepositoryLifecycleTestSetup; +import org.apache.jackrabbit.ocm.manager.ObjectContentManager; +import org.apache.jackrabbit.ocm.testmodel.Atomic; +import org.springframework.context.ApplicationContext; + +/** + * Test atomic persistence fields + * + * @author Boni Gopalan + */ +public class AnnotationAtomicSpringTest extends AnnotationSpringTestBase +{ + private final static Log log = LogFactory.getLog(AnnotationAtomicSpringTest.class); + protected ApplicationContext aContext; + /** + *

Defines the test case name for junit.

+ * @param testName The test case name. + */ + public AnnotationAtomicSpringTest(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(AnnotationAtomicSpringTest.class)); + } + public void testAtomicFields() + { + try + { + ObjectContentManager ocm = getObjectContentManager(); + Date date = new Date(); + Calendar calendar = Calendar.getInstance(); + // -------------------------------------------------------------------------------- + // Create and store an object graph in the repository + // -------------------------------------------------------------------------------- + Atomic a = new Atomic(); + a.setPath("/test"); + a.setBooleanObject(new Boolean(true)); + a.setBooleanPrimitive(true); + a.setIntegerObject(new Integer(100)); + a.setIntPrimitive(200); + a.setString("Test String"); + a.setDate(date); + a.setInt2boolean(true); + + byte[] content = "Test Byte".getBytes(); + a.setByteArray(content); + a.setCalendar(calendar); + a.setDoubleObject(new Double(2.12)); + a.setDoublePrimitive(1.23); + long now = System.currentTimeMillis(); + a.setTimestamp(new Timestamp(now)); + + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream("Test Stream".getBytes()); + a.setInputStream(byteArrayInputStream); + a.setNamedProperty("ocm:test"); + a.setPathProperty("/node1/node2"); + a.setUndefinedProperty("aStringData"); + + ocm.insert(a); + ocm.save(); + + + // -------------------------------------------------------------------------------- + // Get the object + // -------------------------------------------------------------------------------- + a = null; + a = (Atomic) ocm.getObject( "/test"); + assertNotNull("a is null", a); + assertNotNull("Boolean object is null", a.getBooleanObject()); + assertTrue("Incorrect boolean object", a.getBooleanObject().booleanValue()); + assertTrue("Incorrect boolean primitive", a.isBooleanPrimitive()); + assertNotNull("Integer Object is null", a.getIntegerObject()); + assertTrue("Incorrect Integer object", a.getIntegerObject().intValue() == 100); + assertTrue("Incorrect int primitive", a.getIntPrimitive() == 200); + assertNotNull("String object is null", a.getString()); + assertTrue("Incorrect boolean object", a.getString().equals("Test String")); + assertNotNull("Byte array object is null", a.getByteArray()); + assertTrue("Incorrect byte object", new String(a.getByteArray()).equals("Test Byte")); + + assertNotNull("date object is null", a.getDate()); + assertTrue("Invalid date", a.getDate().equals(date)); + assertNotNull("calendar object is null", a.getCalendar()); + + log.debug("Calendar : " + a.getCalendar().get(Calendar.YEAR) + "-" + a.getCalendar().get(Calendar.MONTH) + "-" + a.getCalendar().get(Calendar.DAY_OF_MONTH)); + assertTrue("Invalid calendar object", a.getCalendar().equals(calendar)); + + assertNotNull("Double object is null", a.getDoubleObject()); + assertTrue("Incorrect double object", a.getDoubleObject().doubleValue() == 2.12); + assertTrue("Incorrect double primitive", a.getDoublePrimitive() == 1.23); + + assertNotNull("Incorrect input stream primitive", a.getInputStream()); + assertNotNull("Incorrect timestamp", a.getTimestamp()); + assertTrue("Invalid timestamp value ", a.getTimestamp().getTime() == now); + assertTrue("Invalid int2boolean value ", a.isInt2boolean()); + + assertTrue("Invalid namedProperty value ", a.getNamedProperty().equals("ocm:test")); + assertTrue("Invalid pathProperty value ", a.getPathProperty().equals("/node1/node2")); + assertTrue("Invalid undefinedProperty value ", ((String) a.getUndefinedProperty()).equals("aStringData")); + // -------------------------------------------------------------------------------- + // Update the property "namedProperty" with an invalid value + // -------------------------------------------------------------------------------- + try + { + // update with an incorrect namespace - Should throws an exception + a.setNamedProperty("unknown:test"); + ocm.update(a); + fail("Exception was not triggered with an invalid namespace"); + ocm.save(); + } + catch (Exception e) + { + + + } + + // -------------------------------------------------------------------------------- + // Update the property "pathProperty" with an invalid value + // -------------------------------------------------------------------------------- + try + { + // update with an incorrect namespace - Should throws an exception + a.setPathProperty("//node1"); + ocm.update(a); + fail("Exception was not triggered with an invalid path"); + ocm.save(); + } + catch (Exception e) + { + + + } + + // -------------------------------------------------------------------------------- + // Update the property "undefinedProperty" with an invalid value + // -------------------------------------------------------------------------------- + a = null; + a = (Atomic) ocm.getObject( "/test"); + + a.setUndefinedProperty(new Double(1.2)); + ocm.update(a); + ocm.save(); + + // -------------------------------------------------------------------------------- + // Get the object + // -------------------------------------------------------------------------------- + a = null; + a = (Atomic) ocm.getObject( "/test"); + assertNotNull("a is null", a); + assertTrue("Invalid undefinedProperty value ", ((Double) a.getUndefinedProperty()).doubleValue() == 1.2); + + } + catch (Exception e) + { + e.printStackTrace(); + fail("Exception occurs during the unit test : " + e); + } + + } +} \ No newline at end of file Index: src/test/java/org/apache/jackrabbit/ocm/manager/spring/DigesterAtomicSpringTest.java =================================================================== --- src/test/java/org/apache/jackrabbit/ocm/manager/spring/DigesterAtomicSpringTest.java (revision 0) +++ src/test/java/org/apache/jackrabbit/ocm/manager/spring/DigesterAtomicSpringTest.java (revision 0) @@ -0,0 +1,192 @@ +/* + * 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.spring; + +import java.io.ByteArrayInputStream; +import java.sql.Timestamp; +import java.util.Calendar; +import java.util.Date; + +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.DigesterSpringTestBase; +import org.apache.jackrabbit.ocm.RepositoryLifecycleTestSetup; +import org.apache.jackrabbit.ocm.manager.ObjectContentManager; +import org.apache.jackrabbit.ocm.testmodel.Atomic; +import org.springframework.context.ApplicationContext; + +/** + * Test atomic persistence fields + * + * @author Boni Gopalan + */ +public class DigesterAtomicSpringTest extends DigesterSpringTestBase +{ + private final static Log log = LogFactory.getLog(DigesterAtomicSpringTest.class); + protected ApplicationContext aContext; + /** + *

Defines the test case name for junit.

+ * @param testName The test case name. + */ + public DigesterAtomicSpringTest(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(DigesterAtomicSpringTest.class)); + } + public void testAtomicFields() + { + try + { + ObjectContentManager ocm = getObjectContentManager(); + Date date = new Date(); + Calendar calendar = Calendar.getInstance(); + // -------------------------------------------------------------------------------- + // Create and store an object graph in the repository + // -------------------------------------------------------------------------------- + Atomic a = new Atomic(); + a.setPath("/test"); + a.setBooleanObject(new Boolean(true)); + a.setBooleanPrimitive(true); + a.setIntegerObject(new Integer(100)); + a.setIntPrimitive(200); + a.setString("Test String"); + a.setDate(date); + a.setInt2boolean(true); + + byte[] content = "Test Byte".getBytes(); + a.setByteArray(content); + a.setCalendar(calendar); + a.setDoubleObject(new Double(2.12)); + a.setDoublePrimitive(1.23); + long now = System.currentTimeMillis(); + a.setTimestamp(new Timestamp(now)); + + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream("Test Stream".getBytes()); + a.setInputStream(byteArrayInputStream); + a.setNamedProperty("ocm:test"); + a.setPathProperty("/node1/node2"); + a.setUndefinedProperty("aStringData"); + + ocm.insert(a); + ocm.save(); + + + // -------------------------------------------------------------------------------- + // Get the object + // -------------------------------------------------------------------------------- + a = null; + a = (Atomic) ocm.getObject( "/test"); + assertNotNull("a is null", a); + assertNotNull("Boolean object is null", a.getBooleanObject()); + assertTrue("Incorrect boolean object", a.getBooleanObject().booleanValue()); + assertTrue("Incorrect boolean primitive", a.isBooleanPrimitive()); + assertNotNull("Integer Object is null", a.getIntegerObject()); + assertTrue("Incorrect Integer object", a.getIntegerObject().intValue() == 100); + assertTrue("Incorrect int primitive", a.getIntPrimitive() == 200); + assertNotNull("String object is null", a.getString()); + assertTrue("Incorrect boolean object", a.getString().equals("Test String")); + assertNotNull("Byte array object is null", a.getByteArray()); + assertTrue("Incorrect byte object", new String(a.getByteArray()).equals("Test Byte")); + + assertNotNull("date object is null", a.getDate()); + assertTrue("Invalid date", a.getDate().equals(date)); + assertNotNull("calendar object is null", a.getCalendar()); + + log.debug("Calendar : " + a.getCalendar().get(Calendar.YEAR) + "-" + a.getCalendar().get(Calendar.MONTH) + "-" + a.getCalendar().get(Calendar.DAY_OF_MONTH)); + assertTrue("Invalid calendar object", a.getCalendar().equals(calendar)); + + assertNotNull("Double object is null", a.getDoubleObject()); + assertTrue("Incorrect double object", a.getDoubleObject().doubleValue() == 2.12); + assertTrue("Incorrect double primitive", a.getDoublePrimitive() == 1.23); + + assertNotNull("Incorrect input stream primitive", a.getInputStream()); + assertNotNull("Incorrect timestamp", a.getTimestamp()); + assertTrue("Invalid timestamp value ", a.getTimestamp().getTime() == now); + assertTrue("Invalid int2boolean value ", a.isInt2boolean()); + + assertTrue("Invalid namedProperty value ", a.getNamedProperty().equals("ocm:test")); + assertTrue("Invalid pathProperty value ", a.getPathProperty().equals("/node1/node2")); + assertTrue("Invalid undefinedProperty value ", ((String) a.getUndefinedProperty()).equals("aStringData")); + // -------------------------------------------------------------------------------- + // Update the property "namedProperty" with an invalid value + // -------------------------------------------------------------------------------- + try + { + // update with an incorrect namespace - Should throws an exception + a.setNamedProperty("unknown:test"); + ocm.update(a); + fail("Exception was not triggered with an invalid namespace"); + ocm.save(); + } + catch (Exception e) + { + + + } + + // -------------------------------------------------------------------------------- + // Update the property "pathProperty" with an invalid value + // -------------------------------------------------------------------------------- + try + { + // update with an incorrect namespace - Should throws an exception + a.setPathProperty("//node1"); + ocm.update(a); + fail("Exception was not triggered with an invalid path"); + ocm.save(); + } + catch (Exception e) + { + + + } + + // -------------------------------------------------------------------------------- + // Update the property "undefinedProperty" with an invalid value + // -------------------------------------------------------------------------------- + a = null; + a = (Atomic) ocm.getObject( "/test"); + + a.setUndefinedProperty(new Double(1.2)); + ocm.update(a); + ocm.save(); + + // -------------------------------------------------------------------------------- + // Get the object + // -------------------------------------------------------------------------------- + a = null; + a = (Atomic) ocm.getObject( "/test"); + assertNotNull("a is null", a); + assertTrue("Invalid undefinedProperty value ", ((Double) a.getUndefinedProperty()).doubleValue() == 1.2); + + } + catch (Exception e) + { + e.printStackTrace(); + fail("Exception occurs during the unit test : " + e); + } + + } +} \ No newline at end of file Index: src/test/java/org/apache/jackrabbit/ocm/SpringTestBase.java =================================================================== --- src/test/java/org/apache/jackrabbit/ocm/SpringTestBase.java (revision 0) +++ src/test/java/org/apache/jackrabbit/ocm/SpringTestBase.java (revision 0) @@ -0,0 +1,75 @@ +/* + * 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; + +import javax.jcr.Repository; +import javax.jcr.Session; +import javax.jcr.UnsupportedRepositoryOperationException; + +import org.apache.jackrabbit.ocm.manager.ObjectContentManager; +import org.apache.jackrabbit.ocm.manager.impl.ObjectContentManagerImpl; +import org.apache.jackrabbit.ocm.repository.RepositoryUtil; +import org.springframework.context.ApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +/** + * Base class for spring testcases (Digester). Provides priviledged access to the jcr test + * repository. + * + * @author Boni Gopalan + * + * + */ +public abstract class SpringTestBase extends AbstractTestBase +{ + protected ApplicationContext aContext; + /** + *

+ * Defines the test case name for junit. + *

+ * + * @param testName + * The test case name. + */ + public SpringTestBase(String testName) + { + super(testName); + } + + @Override + protected void setUp() throws Exception + { + aContext = new ClassPathXmlApplicationContext(getBeanConfigLocation()); + super.setUp(); + } + + protected String getBeanConfigLocation(){ + return "classpath:repository-bean-digester-config.xml"; + } + + @Override + protected void initObjectContentManager() throws UnsupportedRepositoryOperationException, javax.jcr.RepositoryException + { + ocm = (ObjectContentManager)aContext.getBean("ocm"); + } + + @Override + protected Session getSession() { + return (Session)aContext.getBean("session"); + } + +} \ No newline at end of file Index: src/test/resources/repository-bean-annotation-config.xml =================================================================== --- src/test/resources/repository-bean-annotation-config.xml (revision 0) +++ src/test/resources/repository-bean-annotation-config.xml (revision 0) @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + Index: src/test/resources/repository-bean-digester-config.xml =================================================================== --- src/test/resources/repository-bean-digester-config.xml (revision 0) +++ src/test/resources/repository-bean-digester-config.xml (revision 0) @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + ./src/test/test-config/jcrmapping.xml + ./src/test/test-config/jcrmapping-proxy.xml + ./src/test/test-config/jcrmapping-atomic.xml + ./src/test/test-config/jcrmapping-default.xml + ./src/test/test-config/jcrmapping-beandescriptor.xml + ./src/test/test-config/jcrmapping-inheritance.xml + ./src/test/test-config/jcrmapping-jcrnodetypes.xml + ./src/test/test-config/jcrmapping-uuid.xml + + + +