From: Mathieu Baudier Date: Sun, 9 Jan 2011 16:15:34 +0000 (+0000) Subject: Improve JCR and Jackrabbit X-Git-Tag: argeo-commons-2.1.30~1548 X-Git-Url: http://git.argeo.org/?a=commitdiff_plain;h=a5edbf6176d62305155b4be10601aa4156d72709;p=lgpl%2Fargeo-commons.git Improve JCR and Jackrabbit git-svn-id: https://svn.argeo.org/commons/trunk@3998 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- diff --git a/pom.xml b/pom.xml index 8f6ae885f..de428292f 100644 --- a/pom.xml +++ b/pom.xml @@ -142,9 +142,10 @@ limitations under the License. org.codehaus.mojo buildnumber-maven-plugin + 1.0-beta-4 - validate + generate-resources create @@ -153,7 +154,14 @@ limitations under the License. false false - true + {0,date,yyyyMMdd_HHmmss} + + timestamp + + git + + svn + diff --git a/security/dep/pom.xml b/security/dep/pom.xml index dd5bbfee6..fe6851e51 100644 --- a/security/dep/pom.xml +++ b/security/dep/pom.xml @@ -4,7 +4,7 @@ org.argeo.commons 0.2.2-SNAPSHOT - server + security .. org.argeo.commons.security diff --git a/server/dep/org.argeo.server.dep.jackrabbit.server/pom.xml b/server/dep/org.argeo.server.dep.jackrabbit.server/pom.xml index 16b7df005..11e658918 100644 --- a/server/dep/org.argeo.server.dep.jackrabbit.server/pom.xml +++ b/server/dep/org.argeo.server.dep.jackrabbit.server/pom.xml @@ -100,10 +100,6 @@ edu.oswego.cs.concurrent com.springsource.edu.oswego.cs.dl.util.concurrent - - org.apache.derby - com.springsource.org.apache.derby - diff --git a/server/runtime/org.argeo.server.jackrabbit/pom.xml b/server/runtime/org.argeo.server.jackrabbit/pom.xml index 79d9ee198..808bae686 100644 --- a/server/runtime/org.argeo.server.jackrabbit/pom.xml +++ b/server/runtime/org.argeo.server.jackrabbit/pom.xml @@ -57,7 +57,7 @@ 0.2.2-SNAPSHOT - + org.argeo.commons.server org.argeo.server.dep.jackrabbit.server @@ -112,12 +112,6 @@ com.springsource.org.apache.commons.fileupload - - org.junit - com.springsource.junit - true - - org.argeo.commons.basic diff --git a/server/runtime/org.argeo.server.jackrabbit/src/main/java/org/argeo/server/jackrabbit/unit/AbstractJcrTestCase.java b/server/runtime/org.argeo.server.jackrabbit/src/main/java/org/argeo/server/jackrabbit/unit/AbstractJcrTestCase.java deleted file mode 100644 index db6203656..000000000 --- a/server/runtime/org.argeo.server.jackrabbit/src/main/java/org/argeo/server/jackrabbit/unit/AbstractJcrTestCase.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2010 Mathieu Baudier - * - * Licensed 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.argeo.server.jackrabbit.unit; - -import java.io.File; - -import javax.jcr.Repository; -import javax.jcr.Session; -import javax.jcr.SimpleCredentials; - -import junit.framework.TestCase; - -import org.apache.commons.io.FileUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.jackrabbit.core.TransientRepository; -import org.argeo.ArgeoException; - -public abstract class AbstractJcrTestCase extends TestCase { - private final static Log log = LogFactory.getLog(AbstractJcrTestCase.class); - - private TransientRepository repository; - private Session session = null; - - protected abstract File getRepositoryFile() throws Exception; - - @Override - protected void setUp() throws Exception { - File homeDir = new File(System.getProperty("java.io.tmpdir"), - AbstractJcrTestCase.class.getSimpleName() + "-" - + System.getProperty("user.name")); - FileUtils.deleteDirectory(homeDir); - repository = new TransientRepository(getRepositoryFile(), homeDir); - } - - @Override - protected void tearDown() throws Exception { - if (session != null) { - session.logout(); - if (log.isDebugEnabled()) - log.debug("Logout session"); - } - } - - protected Session session() { - if (session == null) { - try { - if (log.isDebugEnabled()) - log.debug("Login session"); - session = getRepository().login( - new SimpleCredentials("demo", "demo".toCharArray())); - } catch (Exception e) { - throw new ArgeoException("Cannot login to repository", e); - } - } - return session; - } - - protected Repository getRepository() { - return repository; - } -} diff --git a/server/runtime/org.argeo.server.jcr/build.properties b/server/runtime/org.argeo.server.jcr/build.properties index d657ce9d2..2f77ca900 100644 --- a/server/runtime/org.argeo.server.jcr/build.properties +++ b/server/runtime/org.argeo.server.jcr/build.properties @@ -16,4 +16,5 @@ additional.bundles = org.argeo.server.jackrabbit,\ com.springsource.org.apache.xml.serializer,\ com.springsource.org.apache.commons.dbcp,\ com.springsource.org.apache.commons.pool,\ + org.argeo.dep.osgi.jackrabbit diff --git a/server/runtime/org.argeo.server.jcr/pom.xml b/server/runtime/org.argeo.server.jcr/pom.xml index c9bd5d402..823b050f2 100644 --- a/server/runtime/org.argeo.server.jcr/pom.xml +++ b/server/runtime/org.argeo.server.jcr/pom.xml @@ -123,6 +123,10 @@ 0.2.2-SNAPSHOT test + + org.apache.derby + com.springsource.org.apache.derby + org.argeo.commons.basic org.argeo.support.junit diff --git a/server/runtime/org.argeo.server.jcr/src/main/java/org/argeo/jcr/unit/AbstractJcrTestCase.java b/server/runtime/org.argeo.server.jcr/src/main/java/org/argeo/jcr/unit/AbstractJcrTestCase.java new file mode 100644 index 000000000..e1433604a --- /dev/null +++ b/server/runtime/org.argeo.server.jcr/src/main/java/org/argeo/jcr/unit/AbstractJcrTestCase.java @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2010 Mathieu Baudier + * + * Licensed 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.argeo.jcr.unit; + +import java.io.File; + +import javax.jcr.Repository; +import javax.jcr.Session; +import javax.jcr.SimpleCredentials; + +import junit.framework.TestCase; + +import org.apache.commons.io.FileUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.argeo.ArgeoException; + +public abstract class AbstractJcrTestCase extends TestCase { + private final static Log log = LogFactory.getLog(AbstractJcrTestCase.class); + + private Repository repository; + private Session session = null; + + protected abstract File getRepositoryFile() throws Exception; + + protected abstract Repository createRepository() throws Exception; + + @Override + protected void setUp() throws Exception { + File homeDir = getHomeDir(); + FileUtils.deleteDirectory(homeDir); + repository = createRepository(); + } + + protected File getHomeDir() { + File homeDir = new File(System.getProperty("java.io.tmpdir"), + AbstractJcrTestCase.class.getSimpleName() + "-" + + System.getProperty("user.name")); + return homeDir; + } + + @Override + protected void tearDown() throws Exception { + if (session != null) { + session.logout(); + if (log.isDebugEnabled()) + log.debug("Logout session"); + } + } + + protected Session session() { + if (session == null) { + try { + if (log.isDebugEnabled()) + log.debug("Login session"); + session = getRepository().login( + new SimpleCredentials("demo", "demo".toCharArray())); + } catch (Exception e) { + throw new ArgeoException("Cannot login to repository", e); + } + } + return session; + } + + protected Repository getRepository() { + return repository; + } +} diff --git a/server/runtime/org.argeo.server.jcr/src/test/java/org/argeo/jcr/MapperTest.java b/server/runtime/org.argeo.server.jcr/src/test/java/org/argeo/jcr/MapperTest.java index 87be7e2f2..121d72298 100644 --- a/server/runtime/org.argeo.server.jcr/src/test/java/org/argeo/jcr/MapperTest.java +++ b/server/runtime/org.argeo.server.jcr/src/test/java/org/argeo/jcr/MapperTest.java @@ -19,8 +19,10 @@ package org.argeo.jcr; import java.io.File; import javax.jcr.Node; +import javax.jcr.Repository; -import org.argeo.server.jackrabbit.unit.AbstractJcrTestCase; +import org.apache.jackrabbit.core.TransientRepository; +import org.argeo.jcr.unit.AbstractJcrTestCase; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; @@ -53,4 +55,10 @@ public class MapperTest extends AbstractJcrTestCase { return res.getFile(); } + protected Repository createRepository() throws Exception{ + Repository repository = new TransientRepository(getRepositoryFile(), getHomeDir()); + return repository; + } + + } diff --git a/server/runtime/org.argeo.server.jcr/src/test/java/org/argeo/server/jcr/JcrResourceAdapterTest.java b/server/runtime/org.argeo.server.jcr/src/test/java/org/argeo/server/jcr/JcrResourceAdapterTest.java index 525208c43..51e3af2d8 100644 --- a/server/runtime/org.argeo.server.jcr/src/test/java/org/argeo/server/jcr/JcrResourceAdapterTest.java +++ b/server/runtime/org.argeo.server.jcr/src/test/java/org/argeo/server/jcr/JcrResourceAdapterTest.java @@ -22,11 +22,14 @@ import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.List; +import javax.jcr.Repository; + import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.jackrabbit.core.TransientRepository; import org.argeo.jcr.JcrResourceAdapter; -import org.argeo.server.jackrabbit.unit.AbstractJcrTestCase; +import org.argeo.jcr.unit.AbstractJcrTestCase; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; @@ -107,4 +110,10 @@ public class JcrResourceAdapterTest extends AbstractJcrTestCase { return res.getFile(); } + protected Repository createRepository() throws Exception { + Repository repository = new TransientRepository(getRepositoryFile(), + getHomeDir()); + return repository; + } + }