jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1521876 [2/2] - in /jackrabbit/trunk/jackrabbit-aws-ext: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/jackrabbit/ src/main/java/org/apache/jackrabbit/aws/ src/main/java/org/apache/j...
Date Wed, 11 Sep 2013 14:35:03 GMT
Added: jackrabbit/trunk/jackrabbit-aws-ext/src/test/java/org/apache/jackrabbit/aws/ext/TestLocalCache.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-aws-ext/src/test/java/org/apache/jackrabbit/aws/ext/TestLocalCache.java?rev=1521876&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-aws-ext/src/test/java/org/apache/jackrabbit/aws/ext/TestLocalCache.java (added)
+++ jackrabbit/trunk/jackrabbit-aws-ext/src/test/java/org/apache/jackrabbit/aws/ext/TestLocalCache.java Wed Sep 11 14:35:02 2013
@@ -0,0 +1,191 @@
+/*
+ * 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.aws.ext;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Random;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.io.FileUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Testcase to test local cache.
+ */
+public class TestLocalCache extends TestCase {
+
+    private static final String CACHE_DIR = "target/cache";
+
+    private static final String TEMP_DIR = "target/temp";
+
+    private static final Logger LOG = LoggerFactory.getLogger(TestLocalCache.class);
+
+    @Override
+    protected void setUp() {
+        try {
+            File cachedir = new File(CACHE_DIR);
+            if (cachedir.exists()) {
+                FileUtils.deleteQuietly(cachedir);
+            }
+            cachedir.mkdirs();
+
+            File tempdir = new File(TEMP_DIR);
+            if (tempdir.exists()) {
+                FileUtils.deleteQuietly(tempdir);
+            }
+            tempdir.mkdirs();
+        } catch (Exception e) {
+            LOG.error("error:", e);
+            fail();
+        }
+    }
+
+    @Override
+    protected void tearDown() throws IOException {
+        File cachedir = new File(CACHE_DIR);
+        if (cachedir.exists()) {
+            FileUtils.deleteQuietly(cachedir);
+        }
+
+        File tempdir = new File(TEMP_DIR);
+        if (tempdir.exists()) {
+            FileUtils.deleteQuietly(tempdir);
+        }
+    }
+
+    /**
+     * Test to validate store retrieve in cache.
+     */
+    public void testStoreRetrieve() {
+        try {
+            LocalCache cache = new LocalCache(CACHE_DIR, TEMP_DIR, 400, 0.95,
+                0.70);
+            Random random = new Random(12345);
+            byte[] data = new byte[100];
+            Map<String, byte[]> byteMap = new HashMap<String, byte[]>();
+            random.nextBytes(data);
+            byteMap.put("a1", data);
+
+            data = new byte[100];
+            random.nextBytes(data);
+            byteMap.put("a2", data);
+
+            data = new byte[100];
+            random.nextBytes(data);
+            byteMap.put("a3", data);
+
+            cache.store("a1", new ByteArrayInputStream(byteMap.get("a1")));
+            cache.store("a2", new ByteArrayInputStream(byteMap.get("a2")));
+            cache.store("a3", new ByteArrayInputStream(byteMap.get("a3")));
+            assertEquals(new ByteArrayInputStream(byteMap.get("a1")),
+                cache.getIfStored("a1"));
+            assertEquals(new ByteArrayInputStream(byteMap.get("a2")),
+                cache.getIfStored("a2"));
+            assertEquals(new ByteArrayInputStream(byteMap.get("a3")),
+                cache.getIfStored("a3"));
+        } catch (Exception e) {
+            LOG.error("error:", e);
+            fail();
+        }
+
+    }
+
+    /**
+     * Test to verify cache's purging if cache current size exceeds
+     * cachePurgeTrigFactor * size.
+     */
+    public void testAutoPurge() {
+        try {
+
+            LocalCache cache = new LocalCache(CACHE_DIR, TEMP_DIR, 400, 0.95,
+                0.70);
+            Random random = new Random(12345);
+            byte[] data = new byte[100];
+            Map<String, byte[]> byteMap = new HashMap<String, byte[]>();
+            random.nextBytes(data);
+            byteMap.put("a1", data);
+
+            data = new byte[100];
+            random.nextBytes(data);
+            byteMap.put("a2", data);
+
+            data = new byte[100];
+            random.nextBytes(data);
+            byteMap.put("a3", data);
+
+            data = new byte[100];
+            random.nextBytes(data);
+            byteMap.put("a4", data);
+
+            cache.store("a1", new ByteArrayInputStream(byteMap.get("a1")));
+            cache.store("a2", new ByteArrayInputStream(byteMap.get("a2")));
+            cache.store("a3", new ByteArrayInputStream(byteMap.get("a3")));
+            assertEquals(new ByteArrayInputStream(byteMap.get("a1")),
+                cache.getIfStored("a1"));
+            assertEquals(new ByteArrayInputStream(byteMap.get("a2")),
+                cache.getIfStored("a2"));
+            assertEquals(new ByteArrayInputStream(byteMap.get("a3")),
+                cache.getIfStored("a3"));
+
+            data = new byte[90];
+            random.nextBytes(data);
+            byteMap.put("a4", data);
+            // storing a4 should purge cache
+            cache.store("a4", new ByteArrayInputStream(byteMap.get("a4")));
+            Thread.sleep(1000);
+
+            assertNull("a1 should be null", cache.getIfStored("a1"));
+            assertNull("a2 should be null", cache.getIfStored("a2"));
+            assertEquals(new ByteArrayInputStream(byteMap.get("a3")),
+                cache.getIfStored("a3"));
+            assertEquals(new ByteArrayInputStream(byteMap.get("a4")),
+                cache.getIfStored("a4"));
+            data = new byte[100];
+            random.nextBytes(data);
+            byteMap.put("a5", data);
+            cache.store("a5", new ByteArrayInputStream(byteMap.get("a5")));
+            assertEquals(new ByteArrayInputStream(byteMap.get("a3")),
+                cache.getIfStored("a3"));
+        } catch (Exception e) {
+            LOG.error("error:", e);
+            fail();
+        }
+    }
+    
+    /**
+     * Assert two inputstream
+     */
+    protected void assertEquals(InputStream a, InputStream b)
+            throws IOException {
+        while (true) {
+            int ai = a.read();
+            int bi = b.read();
+            assertEquals(ai, bi);
+            if (ai < 0) {
+                break;
+            }
+        }
+    }
+
+}

Added: jackrabbit/trunk/jackrabbit-aws-ext/src/test/java/org/apache/jackrabbit/aws/ext/ds/InMemoryBackend.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-aws-ext/src/test/java/org/apache/jackrabbit/aws/ext/ds/InMemoryBackend.java?rev=1521876&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-aws-ext/src/test/java/org/apache/jackrabbit/aws/ext/ds/InMemoryBackend.java (added)
+++ jackrabbit/trunk/jackrabbit-aws-ext/src/test/java/org/apache/jackrabbit/aws/ext/ds/InMemoryBackend.java Wed Sep 11 14:35:02 2013
@@ -0,0 +1,150 @@
+/*
+ * 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.aws.ext.ds;
+
+import java.io.ByteArrayInputStream;
+import java.io.DataInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.jackrabbit.core.data.DataIdentifier;
+import org.apache.jackrabbit.core.data.DataStoreException;
+
+/**
+ * An in-memory backend implementation used to speed up testing.
+ */
+public class InMemoryBackend implements Backend {
+
+    private HashMap<DataIdentifier, byte[]> data = new HashMap<DataIdentifier, byte[]>();
+
+    private HashMap<DataIdentifier, Long> timeMap = new HashMap<DataIdentifier, Long>();
+
+    @Override
+    public void init(CachingDataStore store, String homeDir, String config)
+            throws DataStoreException {
+        // ignore
+        log("init");
+    }
+
+    @Override
+    public void close() {
+        // ignore
+        log("close");
+    }
+
+    @Override
+    public boolean exists(final DataIdentifier identifier) {
+        log("exists " + identifier);
+        return data.containsKey(identifier);
+    }
+
+    @Override
+    public Iterator<DataIdentifier> getAllIdentifiers()
+            throws DataStoreException {
+        log("getAllIdentifiers");
+        return data.keySet().iterator();
+    }
+
+    @Override
+    public InputStream read(final DataIdentifier identifier)
+            throws DataStoreException {
+        log("read " + identifier);
+        return new ByteArrayInputStream(data.get(identifier));
+    }
+
+    @Override
+    public void write(final DataIdentifier identifier, final File file)
+            throws DataStoreException {
+        log("write " + identifier + " " + file.length());
+        byte[] buffer = new byte[(int) file.length()];
+        try {
+            DataInputStream din = new DataInputStream(new FileInputStream(file));
+            din.readFully(buffer);
+            din.close();
+            data.put(identifier, buffer);
+            timeMap.put(identifier, System.currentTimeMillis());
+        } catch (IOException e) {
+            throw new DataStoreException(e);
+        }
+    }
+
+    /**
+     * Log a message if logging is enabled.
+     * 
+     * @param message the message
+     */
+    private void log(final String message) {
+        // System.out.println(message);
+    }
+
+    @Override
+    public long getLastModified(final DataIdentifier identifier)
+            throws DataStoreException {
+        log("getLastModified " + identifier);
+        return timeMap.get(identifier);
+    }
+
+    @Override
+    public void deleteRecord(final DataIdentifier identifier)
+            throws DataStoreException {
+        timeMap.remove(identifier);
+        data.remove(identifier);
+    }
+
+    @Override
+    public List<DataIdentifier> deleteAllOlderThan(final long min) {
+        log("deleteAllOlderThan " + min);
+        List<DataIdentifier> tobeDeleted = new ArrayList<DataIdentifier>();
+        for (Map.Entry<DataIdentifier, Long> entry : timeMap.entrySet()) {
+            DataIdentifier identifier = entry.getKey();
+            long timestamp = entry.getValue();
+            if (timestamp < min) {
+                tobeDeleted.add(identifier);
+            }
+        }
+        for (DataIdentifier identifier : tobeDeleted) {
+            timeMap.remove(identifier);
+            data.remove(identifier);
+        }
+        return tobeDeleted;
+    }
+
+    @Override
+    public long getLength(final DataIdentifier identifier) throws DataStoreException {
+        try {
+            return data.get(identifier).length;
+        } catch (Exception e) {
+            throw new DataStoreException(e);
+        }
+    }
+
+    @Override
+    public void touch(final DataIdentifier identifier, final long minModifiedDate)
+            throws DataStoreException {
+        if (minModifiedDate > 0 && data.containsKey(identifier)) {
+            timeMap.put(identifier, System.currentTimeMillis());
+        }
+    }
+}

Added: jackrabbit/trunk/jackrabbit-aws-ext/src/test/java/org/apache/jackrabbit/aws/ext/ds/InMemoryDataStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-aws-ext/src/test/java/org/apache/jackrabbit/aws/ext/ds/InMemoryDataStore.java?rev=1521876&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-aws-ext/src/test/java/org/apache/jackrabbit/aws/ext/ds/InMemoryDataStore.java (added)
+++ jackrabbit/trunk/jackrabbit-aws-ext/src/test/java/org/apache/jackrabbit/aws/ext/ds/InMemoryDataStore.java Wed Sep 11 14:35:02 2013
@@ -0,0 +1,34 @@
+/*
+ * 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.aws.ext.ds;
+
+/**
+ * A caching data store that uses the in-memory backend.
+ */
+public class InMemoryDataStore extends CachingDataStore {
+
+    @Override
+    Backend createBackend() {
+        return new InMemoryBackend();
+    }
+
+    @Override
+    String getMarkerFile() {
+        return "mem.init.done";
+    }
+
+}

Added: jackrabbit/trunk/jackrabbit-aws-ext/src/test/java/org/apache/jackrabbit/aws/ext/ds/TestCaseBase.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-aws-ext/src/test/java/org/apache/jackrabbit/aws/ext/ds/TestCaseBase.java?rev=1521876&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-aws-ext/src/test/java/org/apache/jackrabbit/aws/ext/ds/TestCaseBase.java (added)
+++ jackrabbit/trunk/jackrabbit-aws-ext/src/test/java/org/apache/jackrabbit/aws/ext/ds/TestCaseBase.java Wed Sep 11 14:35:02 2013
@@ -0,0 +1,584 @@
+/*
+ * 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.aws.ext.ds;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Random;
+
+import javax.jcr.RepositoryException;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.jackrabbit.core.data.DataIdentifier;
+import org.apache.jackrabbit.core.data.DataRecord;
+import org.apache.jackrabbit.core.data.DataStore;
+import org.apache.jackrabbit.core.data.DataStoreException;
+import org.apache.jackrabbit.core.data.RandomInputStream;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Test base class which covers all scenarios.
+ */
+public abstract class TestCaseBase extends TestCase {
+    
+    /**
+     * Constant describing aws properties file path.
+     */
+    public static final String CONFIG = "config";
+    
+    /**
+     * Logger
+     */
+    protected static final Logger LOG = LoggerFactory.getLogger(TestCaseBase.class);
+
+    /**
+     * temp directory
+     */
+    private static final String TEST_DIR = "target/temp";
+
+    /**
+     * File path of aws properties.
+     */
+    protected String config;
+
+    /**
+     * Parameter to use in-memory backend. If false {@link S3Backend}
+     */
+    protected boolean memoryBackend = true;
+
+    /**
+     * Parameter to use local cache. If true local cache {@link LocalCache} is
+     * not used.
+     */
+    protected boolean noCache;
+
+    /**
+     * Delete temporary directory.
+     */
+    @Override
+    protected void setUp() {
+        FileUtils.deleteQuietly(new File(TEST_DIR));
+    }
+
+    /**
+     * Delete temporary directory.
+     */
+    @Override
+    protected void tearDown() throws IOException {
+        FileUtils.deleteQuietly(new File(TEST_DIR));
+    }
+
+    /**
+     * Testcase to validate {@link DataStore#addRecord(InputStream)} API.
+     */
+    public void testAddRecord() {
+        try {
+            doAddRecordTest();
+        } catch (Exception e) {
+            LOG.error("error:", e);
+            fail(e.getMessage());
+        }
+    }
+
+    /**
+     * Testcase to validate {@link DataStore#getRecord(DataIdentifier)} API.
+     */
+    public void testGetRecord() {
+        try {
+            doGetRecordTest();
+        } catch (Exception e) {
+            LOG.error("error:", e);
+        }
+    }
+
+    /**
+     * Testcase to validate {@link DataStore#getAllIdentifiers()} API.
+     */
+    public void testGetAllIdentifiers() {
+        try {
+            doGetAllIdentifiersTest();
+        } catch (Exception e) {
+            LOG.error("error:", e);
+            fail(e.getMessage());
+        }
+    }
+
+    /**
+     * Testcase to validate {@link DataStore#updateModifiedDateOnAccess(long)}
+     * API.
+     */
+    public void testUpdateLastModifiedOnAccess() {
+        try {
+            doUpdateLastModifiedOnAccessTest();
+        } catch (Exception e) {
+            LOG.error("error:", e);
+        }
+    }
+
+    /**
+     * Testcase to validate
+     * {@link MultiDataStoreAware#deleteRecord(DataIdentifier)}.API.
+     */
+    public void testDeleteRecord() {
+        try {
+            doDeleteRecordTest();
+        } catch (Exception e) {
+            LOG.error("error:", e);
+            fail(e.getMessage());
+        }
+    }
+
+    /**
+     * Testcase to validate {@link DataStore#deleteAllOlderThan(long)} API.
+     */
+    public void testDeleteAllOlderThan() {
+        try {
+            doDeleteAllOlderThan();
+        } catch (Exception e) {
+            LOG.error("error:", e);
+            fail(e.getMessage());
+        }
+    }
+
+    /**
+     * Testcase to validate {@link DataStore#getRecordFromReference(String)}
+     */
+    public void testReference() {
+        try {
+            doReferenceTest();
+        } catch (Exception e) {
+            LOG.error("error:", e);
+            fail(e.getMessage());
+        }
+    }
+
+    /**
+     * Testcase to validate mixed scenario use of {@link DataStore}.
+     */
+    public void testSingleThread() {
+        try {
+            doTestSingleThread();
+        } catch (Exception e) {
+            LOG.error("error:", e);
+            fail(e.getMessage());
+        }
+    }
+
+    /**
+     * Testcase to validate mixed scenario use of {@link DataStore} in
+     * multi-threaded concurrent environment.
+     */
+    public void testMultiThreaded() {
+        try {
+            doTestMultiThreaded();
+        } catch (Exception e) {
+            LOG.error("error:", e);
+            fail(e.getMessage());
+        }
+
+    }
+    
+    private CachingDataStore createDataStore() throws RepositoryException {
+        CachingDataStore ds = memoryBackend
+                ? new InMemoryDataStore()
+                : new S3DataStore();
+        ds.setConfig(config);
+        if (noCache) {
+            ds.setCacheSize(0);
+        }
+        ds.init(TEST_DIR);
+        return ds;
+    }
+    
+    /**
+     * Test {@link DataStore#addRecord(InputStream)} and assert length of added
+     * record.
+     */
+    protected void doAddRecordTest() throws Exception {
+        CachingDataStore ds = createDataStore();
+        byte[] data = new byte[12345];
+        new Random(12345).nextBytes(data);
+        DataRecord rec = ds.addRecord(new ByteArrayInputStream(data));
+        assertEquals(data.length, rec.getLength());
+        assertRecord(data, rec);
+        ds.close();
+    }
+
+    /**
+     * Test {@link DataStore#getRecord(DataIdentifier)} and assert length and
+     * inputstream.
+     */
+    protected void doGetRecordTest() throws Exception {
+        CachingDataStore ds = createDataStore();
+        byte[] data = new byte[12345];
+        new Random(12345).nextBytes(data);
+        DataRecord rec = ds.addRecord(new ByteArrayInputStream(data));
+        rec = ds.getRecord(rec.getIdentifier());
+        assertEquals(data.length, rec.getLength());
+        assertRecord(data, rec);
+        ds.close();
+    }
+
+    /**
+     * Test {@link MultiDataStoreAware#deleteRecord(DataIdentifier)}.
+     */
+    protected void doDeleteRecordTest() throws Exception {
+        CachingDataStore ds = createDataStore();
+        Random random = new Random(12345);
+        byte[] data1 = new byte[12345];
+        random.nextBytes(data1);
+        DataRecord rec1 = ds.addRecord(new ByteArrayInputStream(data1));
+
+        byte[] data2 = new byte[12345];
+        random.nextBytes(data2);
+        DataRecord rec2 = ds.addRecord(new ByteArrayInputStream(data2));
+
+        byte[] data3 = new byte[12345];
+        random.nextBytes(data3);
+        DataRecord rec3 = ds.addRecord(new ByteArrayInputStream(data3));
+
+        ds.deleteRecord(rec2.getIdentifier());
+
+        assertNull("rec2 should be null",
+            ds.getRecordIfStored(rec2.getIdentifier()));
+        assertEquals(new ByteArrayInputStream(data1),
+            ds.getRecord(rec1.getIdentifier()).getStream());
+        assertEquals(new ByteArrayInputStream(data3),
+            ds.getRecord(rec3.getIdentifier()).getStream());
+        ds.close();
+    }
+
+    /**
+     * Test {@link DataStore#getAllIdentifiers()} and asserts all identifiers
+     * are returned.
+     */
+    protected void doGetAllIdentifiersTest() throws Exception {
+        CachingDataStore ds = createDataStore();
+        List<DataIdentifier> list = new ArrayList<DataIdentifier>();
+        Random random = new Random(12345);
+        byte[] data = new byte[12345];
+        random.nextBytes(data);
+        DataRecord rec = ds.addRecord(new ByteArrayInputStream(data));
+        list.add(rec.getIdentifier());
+
+        data = new byte[12345];
+        random.nextBytes(data);
+        rec = ds.addRecord(new ByteArrayInputStream(data));
+        list.add(rec.getIdentifier());
+
+        data = new byte[12345];
+        random.nextBytes(data);
+        rec = ds.addRecord(new ByteArrayInputStream(data));
+        list.add(rec.getIdentifier());
+
+        Iterator<DataIdentifier> itr = ds.getAllIdentifiers();
+        while (itr.hasNext()) {
+            assertTrue("record found on list", list.remove(itr.next()));
+        }
+        assertEquals(0, list.size());
+        ds.close();
+    }
+
+    /**
+     * Asserts that timestamp of all records accessed after
+     * {@link DataStore#updateModifiedDateOnAccess(long)} invocation.
+     */
+    protected void doUpdateLastModifiedOnAccessTest() throws Exception {
+        CachingDataStore ds = createDataStore();
+        Random random = new Random(12345);
+        byte[] data = new byte[12345];
+        random.nextBytes(data);
+        DataRecord rec1 = ds.addRecord(new ByteArrayInputStream(data));
+
+        data = new byte[12345];
+        random.nextBytes(data);
+        DataRecord rec2 = ds.addRecord(new ByteArrayInputStream(data));
+
+        Thread.sleep(1000);
+        long updateTime = System.currentTimeMillis();
+        ds.updateModifiedDateOnAccess(updateTime);
+        Thread.sleep(1000);
+        data = new byte[12345];
+        random.nextBytes(data);
+        DataRecord rec3 = ds.addRecord(new ByteArrayInputStream(data));
+
+        data = new byte[12345];
+        random.nextBytes(data);
+        DataRecord rec4 = ds.addRecord(new ByteArrayInputStream(data));
+
+        rec1 = ds.getRecord(rec1.getIdentifier());
+
+        assertEquals("rec1 touched", true,
+            ds.getLastModified(rec1.getIdentifier()) > updateTime);
+        assertEquals("rec2 not touched", true,
+            ds.getLastModified(rec2.getIdentifier()) < updateTime);
+        assertEquals("rec3 touched", true,
+            ds.getLastModified(rec3.getIdentifier()) > updateTime);
+        assertEquals("rec4 touched", true,
+            ds.getLastModified(rec4.getIdentifier()) > updateTime);
+        ds.close();
+
+    }
+
+    /**
+     * Asserts that {@link DataStore#deleteAllOlderThan(long)} only deleted
+     * records older than argument passed.
+     */
+    protected void doDeleteAllOlderThan() throws Exception {
+        CachingDataStore ds = createDataStore();
+        Random random = new Random(12345);
+        byte[] data = new byte[12345];
+        random.nextBytes(data);
+        DataRecord rec1 = ds.addRecord(new ByteArrayInputStream(data));
+
+        data = new byte[12345];
+        random.nextBytes(data);
+        DataRecord rec2 = ds.addRecord(new ByteArrayInputStream(data));
+        
+        Thread.sleep(2000);
+        long updateTime = System.currentTimeMillis();
+        ds.updateModifiedDateOnAccess(updateTime);
+
+        data = new byte[12345];
+        random.nextBytes(data);
+        DataRecord rec3 = ds.addRecord(new ByteArrayInputStream(data));
+
+        data = new byte[12345];
+        random.nextBytes(data);
+        DataRecord rec4 = ds.addRecord(new ByteArrayInputStream(data));
+
+        rec1 = ds.getRecord(rec1.getIdentifier());
+        ds.clearInUse();
+        assertEquals("only rec2 should be deleted", 1,
+            ds.deleteAllOlderThan(updateTime));
+        assertNull("rec2 should be null",
+            ds.getRecordIfStored(rec2.getIdentifier()));
+
+        Iterator<DataIdentifier> itr = ds.getAllIdentifiers();
+        List<DataIdentifier> list = new ArrayList<DataIdentifier>();
+        list.add(rec1.getIdentifier());
+        list.add(rec3.getIdentifier());
+        list.add(rec4.getIdentifier());
+        while (itr.hasNext()) {
+            assertTrue("record found on list", list.remove(itr.next()));
+        }
+
+        assertEquals("touched records found", 0, list.size());
+        assertEquals("rec1 touched", true,
+            ds.getLastModified(rec1.getIdentifier()) > updateTime);
+        assertEquals("rec3 touched", true,
+            ds.getLastModified(rec3.getIdentifier()) > updateTime);
+        assertEquals("rec4 touched", true,
+            ds.getLastModified(rec4.getIdentifier()) > updateTime);
+        ds.close();
+
+    }
+
+    /**
+     * Test if record can be accessed via
+     * {@link DataStore#getRecordFromReference(String)}
+     */
+    public void doReferenceTest() throws Exception {
+        CachingDataStore ds = createDataStore();
+        ds.setSecret("12345");
+        byte[] data = new byte[12345];
+        new Random(12345).nextBytes(data);
+        String reference;
+        DataRecord record = ds.addRecord(new ByteArrayInputStream(data));
+        reference = record.getReference();
+        assertReference(data, reference, ds);
+        ds.close();
+    }
+
+    /**
+     * Method to validate mixed scenario use of {@link DataStore}.
+     */
+    protected void doTestSingleThread() throws Exception {
+        CachingDataStore ds = createDataStore();
+        doTestMultiThreaded(ds, 1);
+        ds.close();
+    }
+
+    /**
+     * Method to validate mixed scenario use of {@link DataStore} in
+     * multi-threaded concurrent environment.
+     */
+    protected void doTestMultiThreaded() throws Exception {
+        CachingDataStore ds = createDataStore();
+        doTestMultiThreaded(ds, 4);
+        ds.close();
+    }
+
+    /**
+     * Method to assert record with byte array.
+     */
+    protected void assertRecord(byte[] expected, DataRecord record)
+            throws DataStoreException, IOException {
+        InputStream stream = record.getStream();
+        try {
+            for (int i = 0; i < expected.length; i++) {
+                assertEquals(expected[i] & 0xff, stream.read());
+            }
+            assertEquals(-1, stream.read());
+        } finally {
+            stream.close();
+        }
+    }
+
+    /**
+     * Method to run {@link TestCaseBase#doTest(DataStore, int)} in multiple
+     * concurrent threads.
+     */
+    protected void doTestMultiThreaded(final DataStore ds, int threadCount)
+            throws Exception {
+        final Exception[] exception = new Exception[1];
+        Thread[] threads = new Thread[threadCount];
+        for (int i = 0; i < threadCount; i++) {
+            final int x = i;
+            Thread t = new Thread() {
+                @Override
+                public void run() {
+                    try {
+                        doTest(ds, x);
+                    } catch (Exception e) {
+                        exception[0] = e;
+                    }
+                }
+            };
+            threads[i] = t;
+            t.start();
+        }
+        for (int i = 0; i < threadCount; i++) {
+            threads[i].join();
+        }
+        if (exception[0] != null) {
+            throw exception[0];
+        }
+    }
+
+    /**
+     * Assert randomly read stream from record.
+     */
+    void doTest(DataStore ds, int offset) throws Exception {
+        LOG.info(Thread.currentThread().getName() + " started.");
+        ArrayList<DataRecord> list = new ArrayList<DataRecord>();
+        HashMap<DataRecord, Integer> map = new HashMap<DataRecord, Integer>();
+        for (int i = 0; i < 100; i++) {
+            int size = 100 + i * 10;
+            RandomInputStream in = new RandomInputStream(size + offset, size);
+            DataRecord rec = ds.addRecord(in);
+            list.add(rec);
+            map.put(rec, new Integer(size));
+        }
+        Random random = new Random(1);
+        for (int i = 0; i < list.size(); i++) {
+            int pos = random.nextInt(list.size());
+            DataRecord rec = list.get(pos);
+            int size = map.get(rec);
+            rec = ds.getRecord(rec.getIdentifier());
+            assertEquals(size, rec.getLength());
+            InputStream in = rec.getStream();
+            RandomInputStream expected = new RandomInputStream(size + offset,
+                size);
+            if (random.nextBoolean()) {
+                in = readInputStreamRandomly(in, random);
+            }
+            assertEquals(expected, in);
+            in.close();
+        }
+        LOG.info(Thread.currentThread().getName() + " finished.");
+    }
+
+    InputStream readInputStreamRandomly(InputStream in, Random random)
+            throws IOException {
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        byte[] buffer = new byte[8000];
+        while (true) {
+            if (random.nextBoolean()) {
+                int x = in.read();
+                if (x < 0) {
+                    break;
+                }
+                out.write(x);
+            } else {
+                if (random.nextBoolean()) {
+                    int l = in.read(buffer);
+                    if (l < 0) {
+                        break;
+                    }
+                    out.write(buffer, 0, l);
+                } else {
+                    int offset = random.nextInt(buffer.length / 2);
+                    int len = random.nextInt(buffer.length / 2);
+                    int l = in.read(buffer, offset, len);
+                    if (l < 0) {
+                        break;
+                    }
+                    out.write(buffer, offset, l);
+                }
+            }
+        }
+        in.close();
+        return new ByteArrayInputStream(out.toByteArray());
+    }
+
+    /**
+     * Assert two inputstream
+     */
+    protected void assertEquals(InputStream a, InputStream b)
+            throws IOException {
+        while (true) {
+            int ai = a.read();
+            int bi = b.read();
+            assertEquals(ai, bi);
+            if (ai < 0) {
+                break;
+            }
+        }
+    }
+
+    /**
+     * Assert inputstream read from reference.
+     */
+    protected void assertReference(byte[] expected, String reference,
+            DataStore store) throws Exception {
+        DataRecord record = store.getRecordFromReference(reference);
+        assertNotNull(record);
+        assertEquals(expected.length, record.getLength());
+
+        InputStream stream = record.getStream();
+        try {
+            for (int i = 0; i < expected.length; i++) {
+                assertEquals(expected[i] & 0xff, stream.read());
+            }
+            assertEquals(-1, stream.read());
+        } finally {
+            stream.close();
+        }
+    }
+
+}

Added: jackrabbit/trunk/jackrabbit-aws-ext/src/test/java/org/apache/jackrabbit/aws/ext/ds/TestInMemDs.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-aws-ext/src/test/java/org/apache/jackrabbit/aws/ext/ds/TestInMemDs.java?rev=1521876&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-aws-ext/src/test/java/org/apache/jackrabbit/aws/ext/ds/TestInMemDs.java (added)
+++ jackrabbit/trunk/jackrabbit-aws-ext/src/test/java/org/apache/jackrabbit/aws/ext/ds/TestInMemDs.java Wed Sep 11 14:35:02 2013
@@ -0,0 +1,30 @@
+/*
+ * 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.aws.ext.ds;
+
+/**
+ * Test {@link CachingDataStore} with InMemoryBackend and local cache on.
+ */
+public class TestInMemDs extends TestCaseBase {
+
+    public TestInMemDs() {
+        config = null;
+        memoryBackend = true;
+        noCache = false;
+    }
+
+}

Added: jackrabbit/trunk/jackrabbit-aws-ext/src/test/java/org/apache/jackrabbit/aws/ext/ds/TestInMemDsCacheOff.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-aws-ext/src/test/java/org/apache/jackrabbit/aws/ext/ds/TestInMemDsCacheOff.java?rev=1521876&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-aws-ext/src/test/java/org/apache/jackrabbit/aws/ext/ds/TestInMemDsCacheOff.java (added)
+++ jackrabbit/trunk/jackrabbit-aws-ext/src/test/java/org/apache/jackrabbit/aws/ext/ds/TestInMemDsCacheOff.java Wed Sep 11 14:35:02 2013
@@ -0,0 +1,29 @@
+/*
+ * 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.aws.ext.ds;
+
+/**
+ * Test {@link CachingDataStore} with InMemoryBackend and local cache off.
+ */
+public class TestInMemDsCacheOff extends TestCaseBase {
+
+    public TestInMemDsCacheOff() {
+        config = null;
+        memoryBackend = true;
+        noCache = true;
+    }
+}

Added: jackrabbit/trunk/jackrabbit-aws-ext/src/test/java/org/apache/jackrabbit/aws/ext/ds/TestS3Ds.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-aws-ext/src/test/java/org/apache/jackrabbit/aws/ext/ds/TestS3Ds.java?rev=1521876&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-aws-ext/src/test/java/org/apache/jackrabbit/aws/ext/ds/TestS3Ds.java (added)
+++ jackrabbit/trunk/jackrabbit-aws-ext/src/test/java/org/apache/jackrabbit/aws/ext/ds/TestS3Ds.java Wed Sep 11 14:35:02 2013
@@ -0,0 +1,46 @@
+/*
+ * 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.aws.ext.ds;
+
+import java.io.IOException;
+import java.util.Properties;
+
+import org.apache.jackrabbit.aws.ext.Utils;
+
+/**
+ * Test {@link CachingDataStore} with S3Backend and local cache on. It requires
+ * to pass aws config file via system property. For e.g.
+ * -Dconfig=/opt/cq/aws.properties. Sample aws properties located at
+ * src/test/resources/aws.properties
+ */
+public class TestS3Ds extends TestCaseBase {
+
+    public TestS3Ds() {
+        config = System.getProperty(CONFIG);
+        memoryBackend = false;
+        noCache = false;
+    }
+
+
+    @Override
+    protected void tearDown() throws IOException {
+        super.tearDown();
+        Properties props = Utils.readConfig(config);
+        Utils.deleteBucket(props);
+    }
+
+}

Added: jackrabbit/trunk/jackrabbit-aws-ext/src/test/java/org/apache/jackrabbit/aws/ext/ds/TestS3DsCacheOff.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-aws-ext/src/test/java/org/apache/jackrabbit/aws/ext/ds/TestS3DsCacheOff.java?rev=1521876&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-aws-ext/src/test/java/org/apache/jackrabbit/aws/ext/ds/TestS3DsCacheOff.java (added)
+++ jackrabbit/trunk/jackrabbit-aws-ext/src/test/java/org/apache/jackrabbit/aws/ext/ds/TestS3DsCacheOff.java Wed Sep 11 14:35:02 2013
@@ -0,0 +1,32 @@
+/*
+ * 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.aws.ext.ds;
+
+/**
+ * Test {@link CachingDataStore} with S3Backend and local cache Off. It requires
+ * to pass aws config file via system property. For e.g.
+ * -Dconfig=/opt/cq/aws.properties. Sample aws properties located at
+ * src/test/resources/aws.properties
+ */
+public class TestS3DsCacheOff extends TestS3Ds {
+
+    public TestS3DsCacheOff() {
+        config = System.getProperty(CONFIG);
+        memoryBackend = false;
+        noCache = true;
+    }
+}

Added: jackrabbit/trunk/jackrabbit-aws-ext/src/test/resources/aws.properties
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-aws-ext/src/test/resources/aws.properties?rev=1521876&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-aws-ext/src/test/resources/aws.properties (added)
+++ jackrabbit/trunk/jackrabbit-aws-ext/src/test/resources/aws.properties Wed Sep 11 14:35:02 2013
@@ -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.
+#
+
+# AWS account ID
+accessKey=
+# AWS secret key
+secretKey=
+# AWS bucket name
+s3Bucket=
+# AWS bucket region
+# Mapping of S3 regions to their constants
+# US Standard us-standard
+# US West us-west-2
+# US West (Northern California) us-west-1
+# EU (Ireland) EU
+# Asia Pacific (Singapore) ap-southeast-1
+# Asia Pacific (Sydney) ap-southeast-2
+# Asia Pacific (Tokyo) ap-northeast-1
+# South America (Sao Paulo) sa-east-1
+s3Region=
+connectionTimeout=120000
+socketTimeout=120000
+maxConnections=10
+maxErrorRetry=10

Added: jackrabbit/trunk/jackrabbit-aws-ext/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-aws-ext/src/test/resources/log4j.properties?rev=1521876&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-aws-ext/src/test/resources/log4j.properties (added)
+++ jackrabbit/trunk/jackrabbit-aws-ext/src/test/resources/log4j.properties Wed Sep 11 14:35:02 2013
@@ -0,0 +1,29 @@
+#
+# 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.
+#
+
+# this is the log4j configuration for the JCR API tests
+log4j.rootLogger=INFO, file
+
+#log4j.logger.org.apache.jackrabbit.test=DEBUG
+
+# 'file' is set to be a FileAppender.
+log4j.appender.file=org.apache.log4j.FileAppender
+log4j.appender.file.File=target/debug.log
+
+# 'file' uses PatternLayout.
+log4j.appender.file.layout=org.apache.log4j.PatternLayout
+log4j.appender.file.layout.ConversionPattern=%d{dd.MM.yyyy HH:mm:ss} *%-5p* [%t] %c{1}: %m (%F, line %L)\n

Added: jackrabbit/trunk/jackrabbit-aws-ext/src/test/resources/repository_sample.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-aws-ext/src/test/resources/repository_sample.xml?rev=1521876&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-aws-ext/src/test/resources/repository_sample.xml (added)
+++ jackrabbit/trunk/jackrabbit-aws-ext/src/test/resources/repository_sample.xml Wed Sep 11 14:35:02 2013
@@ -0,0 +1,166 @@
+<?xml version="1.0"?>
+<!--
+   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.
+  -->
+<!DOCTYPE Repository PUBLIC "-//The Apache Software Foundation//DTD Jackrabbit 1.6//EN"
+                            "http://jackrabbit.apache.org/dtd/repository-1.6.dtd">
+<!-- Example Repository Configuration File -->
+<Repository>
+    <!--
+        virtual file system where the repository stores global state
+        (e.g. registered namespaces, custom node types, etc.)
+    -->
+    <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+        <param name="path" value="${rep.home}/repository"/>
+    </FileSystem>
+
+    <!--
+        data store configuration
+    -->
+	<!--
+    <DataStore class="org.apache.jackrabbit.core.data.FileDataStore"/>
+	-->
+	<DataStore class="org.apache.jackrabbit.aws.ext.ds.S3DataStore">
+		<param name="config" value="${rep.home}/aws.properties"/>
+        <param name="secret" value="123456789"/>
+        <param name="minRecordLength " value="16384"/> 
+        <param name="cacheSize" value="68719476736"/>
+        <param name="cachePurgeTrigFactor" value="0.95d"/>
+        <param name="cachePurgeResizeFactor" value="0.85d"/>
+	</DataStore>
+    <!--
+        sample database data store configuration
+        <DataStore class="org.apache.jackrabbit.core.data.db.DbDataStore">
+            <param name="url" value="jdbc:h2:~/test"/>
+            <param name="user" value="sa"/>
+            <param name="password" value="sa"/>
+        </DataStore>
+    -->
+    
+    <!--
+        repository lock mechanism configuration
+    <RepositoryLockMechanism class="org.apache.jackrabbit.core.util.CooperativeFileLock"/>
+    -->
+
+    <!--
+        security configuration
+    -->
+    <Security appName="Jackrabbit">
+        <!--
+            security manager:
+            class: FQN of class implementing the JackrabbitSecurityManager interface
+        -->
+        <SecurityManager class="org.apache.jackrabbit.core.DefaultSecurityManager" workspaceName="security">
+            <!-- <param name="config" value="${rep.home}/security.xml"/> -->
+        </SecurityManager>
+
+        <!--
+            access manager:
+            class: FQN of class implementing the AccessManager interface
+        -->
+        <AccessManager class="org.apache.jackrabbit.core.security.DefaultAccessManager">
+            <!-- <param name="config" value="${rep.home}/access.xml"/> -->
+        </AccessManager>
+
+        <LoginModule class="org.apache.jackrabbit.core.security.authentication.DefaultLoginModule">
+           <!-- 
+              anonymous user name ('anonymous' is the default value)
+            -->
+           <param name="anonymousId" value="anonymous"/>
+           <!--
+              administrator user id (default value if param is missing is 'admin')
+            -->
+           <param name="adminId" value="admin"/>
+           <!--
+              optional parameter 'principalProvider'.
+              the value refers to the class name of the PrincipalProvider implementation.
+           -->
+           <!-- <param name="principalProvider" value="..."/> -->
+        </LoginModule>
+    </Security>
+
+    <!--
+        location of workspaces root directory and name of default workspace
+    -->
+    <Workspaces rootPath="${rep.home}/workspaces" defaultWorkspace="default" maxIdleTime="2"/>
+    <!--
+        workspace configuration template:
+        used to create the initial workspace if there's no workspace yet
+    -->
+    <Workspace name="${wsp.name}">
+        <!--
+            virtual file system of the workspace:
+            class: FQN of class implementing the FileSystem interface
+        -->
+        <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+            <param name="path" value="${wsp.home}"/>
+        </FileSystem>
+        <!--
+            persistence manager of the workspace:
+            class: FQN of class implementing the PersistenceManager interface
+        -->
+        <PersistenceManager class="org.apache.jackrabbit.core.persistence.pool.DerbyPersistenceManager">
+          <param name="url" value="jdbc:derby:${wsp.home}/db;create=true"/>
+          <param name="schemaObjectPrefix" value="${wsp.name}_"/>
+        </PersistenceManager>
+        <!--
+            Search index and the file system it uses.
+            class: FQN of class implementing the QueryHandler interface
+        -->
+        <SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
+            <param name="path" value="${wsp.home}/index"/>
+        </SearchIndex>
+    </Workspace>
+
+    <!--
+        Configures the versioning
+    -->
+    <Versioning rootPath="${rep.home}/version">
+        <!--
+            Configures the filesystem to use for versioning for the respective
+            persistence manager
+        -->
+        <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+            <param name="path" value="${rep.home}/version" />
+        </FileSystem>
+
+        <!--
+            Configures the persistence manager to be used for persisting version state.
+            Please note that the current versioning implementation is based on
+            a 'normal' persistence manager, but this could change in future
+            implementations.
+        -->
+        <PersistenceManager class="org.apache.jackrabbit.core.persistence.pool.DerbyPersistenceManager">
+          <param name="url" value="jdbc:derby:${rep.home}/version/db;create=true"/>
+          <param name="schemaObjectPrefix" value="version_"/>
+        </PersistenceManager>
+    </Versioning>
+
+    <!--
+        Search index for content that is shared repository wide
+        (/jcr:system tree, contains mainly versions)
+    -->
+    <SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
+        <param name="path" value="${rep.home}/repository/index"/>
+    </SearchIndex>
+    
+    <!--
+        Run with a cluster journal
+    -->
+    <Cluster id="node1">
+        <Journal class="org.apache.jackrabbit.core.journal.MemoryJournal"/>
+    </Cluster>
+</Repository>



Mime
View raw message