You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2012/12/06 18:42:16 UTC

[13/52] [partial] ISIS-188: moving framework/ subdirs up to parent

http://git-wip-us.apache.org/repos/asf/isis/blob/255ef514/component/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/encryption/blowfish/DataEncryptionBlowfishUsingConfiguration.java
----------------------------------------------------------------------
diff --git a/component/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/encryption/blowfish/DataEncryptionBlowfishUsingConfiguration.java b/component/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/encryption/blowfish/DataEncryptionBlowfishUsingConfiguration.java
new file mode 100644
index 0000000..c3c5ee2
--- /dev/null
+++ b/component/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/encryption/blowfish/DataEncryptionBlowfishUsingConfiguration.java
@@ -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.
+ */
+package org.apache.isis.runtimes.dflt.objectstores.nosql.encryption.blowfish;
+
+import org.apache.isis.core.commons.config.ConfigurationConstants;
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.runtimes.dflt.objectstores.nosql.NoSqlStoreException;
+
+public class DataEncryptionBlowfishUsingConfiguration extends DataEncryptionBlowfishAbstract {
+
+    private static final String ENCRYPTION_KEY = ConfigurationConstants.ROOT + "nosql.encryption.blowfish-key";
+
+    @Override
+    public byte[] secretKey(final IsisConfiguration configuration) {
+        final String key = configuration.getString(ENCRYPTION_KEY);
+        if (key == null) {
+            throw new NoSqlStoreException("No blowfish encryption key specified in the configuration file (key: " + ENCRYPTION_KEY + ")");
+        }
+        return key.getBytes();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/255ef514/component/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/encryption/blowfish/DataEncryptionBlowfishUsingKeyFile.java
----------------------------------------------------------------------
diff --git a/component/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/encryption/blowfish/DataEncryptionBlowfishUsingKeyFile.java b/component/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/encryption/blowfish/DataEncryptionBlowfishUsingKeyFile.java
new file mode 100644
index 0000000..bc98393
--- /dev/null
+++ b/component/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/encryption/blowfish/DataEncryptionBlowfishUsingKeyFile.java
@@ -0,0 +1,54 @@
+/*
+ *  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.isis.runtimes.dflt.objectstores.nosql.encryption.blowfish;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.isis.core.commons.config.ConfigurationConstants;
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.runtimes.dflt.objectstores.nosql.NoSqlStoreException;
+
+public class DataEncryptionBlowfishUsingKeyFile extends DataEncryptionBlowfishAbstract {
+
+    private static final String ENCRYPTION_KEY_FILE = ConfigurationConstants.ROOT + "nosql.encryption.blowfish-key-file";
+
+    @Override
+    public byte[] secretKey(final IsisConfiguration configuration) {
+        final String fileName = configuration.getString(ENCRYPTION_KEY_FILE, "./blowfish.key");
+        final File file = new File(fileName);
+        if (file.exists()) {
+            try {
+                final InputStream fileInput = new FileInputStream(file);
+                final byte[] buffer = new byte[1024];
+                final int length = fileInput.read(buffer);
+                final byte[] key = new byte[length];
+                System.arraycopy(buffer, 0, key, 0, length);
+                return key;
+            } catch (final IOException e) {
+                throw new NoSqlStoreException("Failed to read in encryption file: " + file.getAbsolutePath(), e);
+            }
+        } else {
+            throw new NoSqlStoreException("Cannot find encryption file: " + file.getAbsolutePath());
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/255ef514/component/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/encryption/none/DataEncryptionNone.java
----------------------------------------------------------------------
diff --git a/component/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/encryption/none/DataEncryptionNone.java b/component/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/encryption/none/DataEncryptionNone.java
new file mode 100644
index 0000000..c7e8ecc
--- /dev/null
+++ b/component/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/encryption/none/DataEncryptionNone.java
@@ -0,0 +1,45 @@
+/*
+ *  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.isis.runtimes.dflt.objectstores.nosql.encryption.none;
+
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.runtimes.dflt.objectstores.nosql.encryption.DataEncryption;
+
+public class DataEncryptionNone implements DataEncryption {
+
+    @Override
+    public void init(final IsisConfiguration configuration) {
+    }
+    
+    @Override
+    public String getType() {
+        return "none";
+    }
+
+    @Override
+    public String encrypt(final String plainText) {
+        return plainText;
+    }
+
+    @Override
+    public String decrypt(final String encryptedText) {
+        return encryptedText;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/255ef514/component/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/encryption/rot13/Rot13Encryption.java
----------------------------------------------------------------------
diff --git a/component/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/encryption/rot13/Rot13Encryption.java b/component/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/encryption/rot13/Rot13Encryption.java
new file mode 100644
index 0000000..a6c0ece
--- /dev/null
+++ b/component/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/encryption/rot13/Rot13Encryption.java
@@ -0,0 +1,68 @@
+/*
+ *  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.isis.runtimes.dflt.objectstores.nosql.encryption.rot13;
+
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.runtimes.dflt.objectstores.nosql.encryption.DataEncryption;
+
+public class Rot13Encryption implements DataEncryption {
+
+    @Override
+    public String getType() {
+        return "rot13";
+    }
+
+    @Override
+    public void init(final IsisConfiguration configuration) {
+    }
+
+    @Override
+    public String encrypt(final String plainText) {
+        return encode(plainText);
+    }
+
+    @Override
+    public String decrypt(final String encryptedText) {
+        return encode(encryptedText);
+    }
+
+    private String encode(final String plainText) {
+        if (plainText == null) {
+            return plainText;
+        }
+
+        // encode plainText
+        String encodedMessage = "";
+        for (int i = 0; i < plainText.length(); i++) {
+            char c = plainText.charAt(i);
+            if (c >= 'a' && c <= 'm') {
+                c += 13;
+            } else if (c >= 'n' && c <= 'z') {
+                c -= 13;
+            } else if (c >= 'A' && c <= 'M') {
+                c += 13;
+            } else if (c >= 'N' && c <= 'Z') {
+                c -= 13;
+            }
+            encodedMessage += c;
+        }
+        return encodedMessage;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/255ef514/component/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/keys/KeyCreatorDefault.java
----------------------------------------------------------------------
diff --git a/component/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/keys/KeyCreatorDefault.java b/component/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/keys/KeyCreatorDefault.java
new file mode 100644
index 0000000..9b3ede9
--- /dev/null
+++ b/component/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/keys/KeyCreatorDefault.java
@@ -0,0 +1,99 @@
+/*
+ *  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.isis.runtimes.dflt.objectstores.nosql.keys;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.oid.Oid;
+import org.apache.isis.core.metamodel.adapter.oid.OidMarshaller;
+import org.apache.isis.core.metamodel.adapter.oid.RootOid;
+import org.apache.isis.core.metamodel.adapter.oid.RootOidDefault;
+import org.apache.isis.core.metamodel.adapter.oid.TypedOid;
+import org.apache.isis.core.metamodel.spec.ObjectSpecId;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.SpecificationLoaderSpi;
+import org.apache.isis.runtimes.dflt.objectstores.nosql.NoSqlStoreException;
+import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
+
+public class KeyCreatorDefault {
+
+    /**
+     * returns {@link RootOid#getIdentifier()} (oid must be {@link RootOid}, and must be persistent). 
+     */
+    public String getIdentifierForPersistentRoot(final Oid oid) {
+        if (!(oid instanceof RootOid)) {
+            throw new NoSqlStoreException("Oid is not a RootOid: " + oid);
+        } 
+        RootOid rootOid = (RootOid) oid;
+        if (rootOid.isTransient()) {
+            throw new NoSqlStoreException("Oid is not for a persistent object: " + oid);
+        }
+        return rootOid.getIdentifier();
+    }
+
+    /**
+     * Equivalent to the {@link Oid#enString(OidMarshaller)} for the adapter's Oid.
+     */
+    public String oidStrFor(final ObjectAdapter adapter) {
+        if(adapter == null) {
+            return null;
+        }
+        try {
+            //return adapter.getSpecification().getFullIdentifier() + "@" + key(adapter.getOid());
+            return adapter.getOid().enString(getOidMarshaller());
+        } catch (final NoSqlStoreException e) {
+            throw new NoSqlStoreException("Failed to create refence for " + adapter, e);
+        }
+    }
+
+    public RootOid createRootOid(ObjectSpecification objectSpecification, final String identifier) {
+        final ObjectSpecId objectSpecId = objectSpecification.getSpecId();
+        return RootOidDefault.create(objectSpecId, identifier);
+    }
+
+    public RootOid unmarshal(final String oidStr) {
+//        final ObjectSpecification objectSpecification = specificationFromReference(ref);
+//        final String id = ref.split("@")[1];
+//        return oid(objectSpecification, id);
+        return getOidMarshaller().unmarshal(oidStr, RootOid.class);
+    }
+
+    public ObjectSpecification specificationFromOidStr(final String oidStr) {
+//        final String name = ref.split("@")[0];
+//        return getSpecificationLoader().loadSpecification(name);
+        final TypedOid oid = getOidMarshaller().unmarshal(oidStr, TypedOid.class);
+        return getSpecificationLoader().lookupBySpecId(oid.getObjectSpecId());
+    }
+
+    
+    /////////////////////////////////////////////////
+    // dependencies (from context)
+    /////////////////////////////////////////////////
+    
+    
+    protected SpecificationLoaderSpi getSpecificationLoader() {
+        return IsisContext.getSpecificationLoader();
+    }
+
+    protected OidMarshaller getOidMarshaller() {
+        return IsisContext.getOidMarshaller();
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/255ef514/component/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/versions/VersionCreator.java
----------------------------------------------------------------------
diff --git a/component/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/versions/VersionCreator.java b/component/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/versions/VersionCreator.java
new file mode 100644
index 0000000..9e7babb
--- /dev/null
+++ b/component/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/versions/VersionCreator.java
@@ -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.isis.runtimes.dflt.objectstores.nosql.versions;
+
+import org.apache.isis.core.metamodel.adapter.version.Version;
+
+public interface VersionCreator {
+
+    Version version(String versionString, String user, String time);
+    String versionString(Version version);
+
+    String timeString(Version version);
+
+    Version newVersion(String user);
+
+    Version nextVersion(Version version, final String user);
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/255ef514/component/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/versions/VersionCreatorDefault.java
----------------------------------------------------------------------
diff --git a/component/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/versions/VersionCreatorDefault.java b/component/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/versions/VersionCreatorDefault.java
new file mode 100644
index 0000000..45a545c
--- /dev/null
+++ b/component/objectstore/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/versions/VersionCreatorDefault.java
@@ -0,0 +1,59 @@
+/*
+ *  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.isis.runtimes.dflt.objectstores.nosql.versions;
+
+import java.util.Date;
+
+import org.apache.isis.core.metamodel.adapter.version.SerialNumberVersion;
+import org.apache.isis.core.metamodel.adapter.version.Version;
+
+public class VersionCreatorDefault implements VersionCreator {
+
+    @Override
+    public String versionString(final Version version) {
+        final long sequence = version.getSequence();
+        return Long.toHexString(sequence);
+    }
+
+    @Override
+    public String timeString(final Version version) {
+        final Date time = version.getTime();
+        return Long.toHexString(time.getTime());
+    }
+
+    @Override
+    public Version version(final String versionString, final String user, final String timeString) {
+        final Long sequence = Long.valueOf(versionString, 16);
+        final Long time = Long.valueOf(timeString, 16);
+        final Date date = new Date(time);
+        return SerialNumberVersion.create(sequence, user, date);
+    }
+
+    @Override
+    public Version newVersion(final String user) {
+        return SerialNumberVersion.create(1, user, new Date());
+    }
+
+    @Override
+    public Version nextVersion(final Version version, final String user) {
+        final long sequence = version.getSequence() + 1;
+        return SerialNumberVersion.create(sequence, user, new Date());
+    }
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/255ef514/component/objectstore/nosql/src/site/apt/index.apt
----------------------------------------------------------------------
diff --git a/component/objectstore/nosql/src/site/apt/index.apt b/component/objectstore/nosql/src/site/apt/index.apt
new file mode 100644
index 0000000..9df5853
--- /dev/null
+++ b/component/objectstore/nosql/src/site/apt/index.apt
@@ -0,0 +1,37 @@
+~~  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.
+
+
+
+NoSQL Objectstore Implementation
+ 
+ The <nosql> objectstore module provides an implementation of the object store
+ API that persists domain objects using JSON.
+
+Alternatives
+
+  Alternatives include:
+  
+  * the {{{../dflt/index.html}dflt}} in-memory object store (for prototyping only)
+
+  * the {{{../sql/index.html}SQL}} object store
+
+  * the {{{../xml/index.html}XML}} object store
+
+  []
+ 
+ []
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/isis/blob/255ef514/component/objectstore/nosql/src/site/apt/jottings.apt
----------------------------------------------------------------------
diff --git a/component/objectstore/nosql/src/site/apt/jottings.apt b/component/objectstore/nosql/src/site/apt/jottings.apt
new file mode 100644
index 0000000..c5d1200
--- /dev/null
+++ b/component/objectstore/nosql/src/site/apt/jottings.apt
@@ -0,0 +1,24 @@
+~~  Licensed to the Apache Software Foundation (ASF) under one
+~~  or more contributor license agreements.  See the NOTICE file
+~~  distributed with this work for additional information
+~~  regarding copyright ownership.  The ASF licenses this file
+~~  to you under the Apache License, Version 2.0 (the
+~~  "License"); you may not use this file except in compliance
+~~  with the License.  You may obtain a copy of the License at
+~~
+~~        http://www.apache.org/licenses/LICENSE-2.0
+~~
+~~  Unless required by applicable law or agreed to in writing,
+~~  software distributed under the License is distributed on an
+~~  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+~~  KIND, either express or implied.  See the License for the
+~~  specific language governing permissions and limitations
+~~  under the License.
+
+
+
+Jottings
+ 
+  This page is to capture any random jottings relating to this module prior 
+  to being moved into formal documentation. 
+ 

http://git-wip-us.apache.org/repos/asf/isis/blob/255ef514/component/objectstore/nosql/src/site/site.xml
----------------------------------------------------------------------
diff --git a/component/objectstore/nosql/src/site/site.xml b/component/objectstore/nosql/src/site/site.xml
new file mode 100644
index 0000000..419f3ca
--- /dev/null
+++ b/component/objectstore/nosql/src/site/site.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<project>
+
+	<body>
+		<breadcrumbs>
+			<item name="NoSQL" href="index.html"/>
+		</breadcrumbs>
+
+		<menu name="NoSQL Objectstore">
+			<item name="About" href="index.html" />
+            <item name="Jottings" href="jottings.html" />
+		</menu>
+
+        <menu name="Objectstore Modules">
+            <item name="Default (in-mem)" href="../dflt/index.html" />
+            <item name="XML" href="../xml/index.html" />
+            <item name="SQL" href="../sql/index.html" />
+            <item name="NoSQL" href="../nosql/index.html" />
+        </menu>
+
+        <menu name="Documentation">
+            <item name="${docbkxGuideTitle} (PDF)" href="docbkx/pdf/${docbkxGuideName}.pdf" />
+            <item name="${docbkxGuideTitle} (HTML)" href="docbkx/html/guide/${docbkxGuideName}.html" />
+        </menu>
+
+        <menu name="Maven Reports" ref="reports" />
+	</body>
+</project>

http://git-wip-us.apache.org/repos/asf/isis/blob/255ef514/component/objectstore/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/DestroyObjectCommandImplementationTest.java
----------------------------------------------------------------------
diff --git a/component/objectstore/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/DestroyObjectCommandImplementationTest.java b/component/objectstore/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/DestroyObjectCommandImplementationTest.java
new file mode 100644
index 0000000..82cc3a6
--- /dev/null
+++ b/component/objectstore/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/DestroyObjectCommandImplementationTest.java
@@ -0,0 +1,106 @@
+/*
+ *  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.isis.runtimes.dflt.objectstores.nosql;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.oid.RootOid;
+import org.apache.isis.core.metamodel.adapter.oid.RootOidDefault;
+import org.apache.isis.core.metamodel.adapter.version.Version;
+import org.apache.isis.core.metamodel.spec.ObjectSpecId;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2;
+import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2.Mode;
+import org.apache.isis.runtimes.dflt.objectstores.nosql.versions.VersionCreatorDefault;
+import org.jmock.Expectations;
+import org.jmock.auto.Mock;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+public class DestroyObjectCommandImplementationTest {
+
+    @Rule
+    public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
+    
+    @Mock
+    private NoSqlCommandContext commandContext;
+    @Mock
+    private ObjectSpecification specification;
+    @Mock
+    private ObjectAdapter adapter;
+    
+    @Mock
+    private VersionCreatorDefault versionCreator;
+    @Mock
+    private Version version;
+
+    //private KeyCreatorDefault keyCreator;
+
+    private final ObjectSpecId specId = ObjectSpecId.of("com.foo.bar.SomeClass");
+
+    private long id = 123;
+    private String keyStr = Long.toString(id, 16);
+
+    private RootOid rootOid = RootOidDefault.create(specId, keyStr);
+
+    private NoSqlDestroyObjectCommand command;
+
+    @Before
+    public void setup() {
+        //keyCreator = new KeyCreatorDefault();
+        
+        context.checking(new Expectations(){{
+
+            allowing(specification).getFullIdentifier();
+            will(returnValue("com.foo.bar.SomeClass"));
+
+            allowing(specification).getSpecId();
+            will(returnValue(specId));
+
+            allowing(adapter).getSpecification();
+            will(returnValue(specification));
+            
+            allowing(adapter).getOid();
+            will(returnValue(rootOid));
+
+            allowing(adapter).getVersion();
+            will(returnValue(version));
+
+        }});
+    }
+
+    @Test
+    public void execute() throws Exception {
+        
+        final String versionStr = "3";
+
+        context.checking(new Expectations() {
+            {
+                one(versionCreator).versionString(version);
+                will(returnValue(versionStr));
+
+                one(commandContext).delete(specification.getSpecId(), keyStr, versionStr, rootOid);
+            }
+        });
+
+        command = new NoSqlDestroyObjectCommand(versionCreator, adapter);
+        command.execute(commandContext);
+    }
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/255ef514/component/objectstore/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlIdentifierGeneratorTest.java
----------------------------------------------------------------------
diff --git a/component/objectstore/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlIdentifierGeneratorTest.java b/component/objectstore/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlIdentifierGeneratorTest.java
new file mode 100644
index 0000000..5b4f322
--- /dev/null
+++ b/component/objectstore/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlIdentifierGeneratorTest.java
@@ -0,0 +1,144 @@
+/*
+ *  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.isis.runtimes.dflt.objectstores.nosql;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.jmock.Expectations;
+import org.jmock.auto.Mock;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.isis.core.metamodel.adapter.oid.RootOid;
+import org.apache.isis.core.metamodel.adapter.oid.RootOidDefault;
+import org.apache.isis.core.metamodel.spec.ObjectSpecId;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.SpecificationLoaderSpi;
+import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2;
+import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2.Mode;
+import org.apache.isis.runtimes.dflt.objectstores.nosql.db.NoSqlDataDatabase;
+import org.apache.isis.runtimes.dflt.runtime.system.persistence.IdentifierGenerator;
+
+public class NoSqlIdentifierGeneratorTest {
+
+    public static class ExamplePojo {
+    }
+
+    @Rule
+    public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_ONLY);
+
+    @Mock
+    private NoSqlDataDatabase db;
+    @Mock
+    private SpecificationLoaderSpi mockSpecificationLoader;
+    @Mock
+    private ObjectSpecification mockSpecification;
+
+    private final ObjectSpecId sequenceNumbersSpecId = ObjectSpecId.of("_id");
+    private IdentifierGenerator identifierGenerator;
+
+    @Before
+    public void setup() {
+        Logger.getRootLogger().setLevel(Level.OFF);
+
+        context.checking(new Expectations() {
+            {
+                allowing(mockSpecificationLoader).loadSpecification(with(ExamplePojo.class));
+                will(returnValue(mockSpecification));
+
+                allowing(mockSpecification).getCorrespondingClass();
+                will(returnValue(ExamplePojo.class));
+
+                allowing(mockSpecification).getCorrespondingClass();
+                will(returnValue(sequenceNumbersSpecId));
+            }
+        });
+
+        identifierGenerator = new NoSqlIdentifierGenerator(db, -999, 4);
+    }
+
+    @Test
+    public void transientIdentifier() throws Exception {
+        String identifier = identifierGenerator.createTransientIdentifierFor(sequenceNumbersSpecId, new ExamplePojo());
+        assertEquals("-999", identifier);
+        
+        identifier = identifierGenerator.createTransientIdentifierFor(sequenceNumbersSpecId, new ExamplePojo());
+        assertEquals("-998", identifier);
+    }
+
+    @Test
+    public void batchCreatedAndReused() throws Exception {
+        context.checking(new Expectations() {
+            {
+                one(db).nextSerialNumberBatch(sequenceNumbersSpecId, 4);
+                will(returnValue(1L));
+            }
+        });
+
+        RootOid transientRootOid = RootOidDefault.createTransient(sequenceNumbersSpecId, "-998");
+        String identifier = identifierGenerator.createPersistentIdentifierFor(sequenceNumbersSpecId, new ExamplePojo(), transientRootOid);
+        assertEquals("1", identifier);
+
+        transientRootOid = RootOidDefault.createTransient(sequenceNumbersSpecId, "-997");
+        identifier = identifierGenerator.createPersistentIdentifierFor(sequenceNumbersSpecId, new ExamplePojo(), transientRootOid);
+        assertEquals("2", identifier);
+    }
+
+    @Test
+    public void secondBatchCreated() throws Exception {
+        context.checking(new Expectations() {
+            {
+                one(db).nextSerialNumberBatch(sequenceNumbersSpecId, 4);
+                will(returnValue(1L));
+            }
+        });
+
+        RootOid transientRootOid = RootOidDefault.createTransient(sequenceNumbersSpecId, "-998");
+        String identifier = identifierGenerator.createPersistentIdentifierFor(sequenceNumbersSpecId, new ExamplePojo(), transientRootOid);
+        assertEquals("1", identifier);
+
+        transientRootOid = RootOidDefault.createTransient(sequenceNumbersSpecId, "-997");
+        identifier = identifierGenerator.createPersistentIdentifierFor(sequenceNumbersSpecId, new ExamplePojo(), transientRootOid);
+        assertEquals("2", identifier);
+
+        transientRootOid = RootOidDefault.createTransient(sequenceNumbersSpecId, "-996");
+        identifier = identifierGenerator.createPersistentIdentifierFor(sequenceNumbersSpecId, new ExamplePojo(), transientRootOid);
+        assertEquals("3", identifier);
+
+        transientRootOid = RootOidDefault.createTransient(sequenceNumbersSpecId, "-995");
+        identifier = identifierGenerator.createPersistentIdentifierFor(sequenceNumbersSpecId, new ExamplePojo(), transientRootOid);
+        assertEquals("4", identifier);
+
+        context.checking(new Expectations() {
+            {
+                one(db).nextSerialNumberBatch(sequenceNumbersSpecId, 4);
+                will(returnValue(5L));
+            }
+        });
+
+        transientRootOid = RootOidDefault.createTransient(sequenceNumbersSpecId, "-994");
+        identifier = identifierGenerator.createPersistentIdentifierFor(sequenceNumbersSpecId, new ExamplePojo(), transientRootOid);
+        assertEquals("5", identifier);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/255ef514/component/objectstore/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlKeyCreatorTest.java
----------------------------------------------------------------------
diff --git a/component/objectstore/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlKeyCreatorTest.java b/component/objectstore/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlKeyCreatorTest.java
new file mode 100644
index 0000000..9dbe1f6
--- /dev/null
+++ b/component/objectstore/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlKeyCreatorTest.java
@@ -0,0 +1,98 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.runtimes.dflt.objectstores.nosql;
+
+import static org.junit.Assert.assertEquals;
+
+import org.jmock.Expectations;
+import org.jmock.auto.Mock;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.isis.core.metamodel.adapter.oid.OidMarshaller;
+import org.apache.isis.core.metamodel.adapter.oid.RootOid;
+import org.apache.isis.core.metamodel.adapter.oid.RootOidDefault;
+import org.apache.isis.core.metamodel.adapter.oid.TypedOid;
+import org.apache.isis.core.metamodel.spec.ObjectSpecId;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.SpecificationLoaderSpi;
+import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2;
+import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2.Mode;
+import org.apache.isis.runtimes.dflt.objectstores.nosql.keys.KeyCreatorDefault;
+
+public class NoSqlKeyCreatorTest {
+
+    @Rule
+    public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
+
+    @Mock
+    private OidMarshaller mockOidMarshaller;
+    @Mock
+    private SpecificationLoaderSpi mockSpecificationLoader;
+    @Mock
+    private ObjectSpecification mockSpecification;
+
+    private final RootOidDefault oid = RootOidDefault.create(ObjectSpecId.of("ERP"), "3");
+    private final String oidStr = oid.enString(new OidMarshaller());
+
+    private KeyCreatorDefault keyCreatorDefault;
+
+    
+    @Before
+    public void setUp() throws Exception {
+        keyCreatorDefault = new KeyCreatorDefault() {
+            @Override
+            protected OidMarshaller getOidMarshaller() {
+                return mockOidMarshaller;
+            }
+            @Override
+            protected SpecificationLoaderSpi getSpecificationLoader() {
+                return mockSpecificationLoader;
+            }
+        };
+    }
+
+    @Test
+    public void unmarshal() throws Exception {
+        context.checking(new Expectations() {
+
+            {
+                one(mockOidMarshaller).unmarshal(oidStr, RootOid.class);
+                will(returnValue(oid));
+            }
+        });
+        assertEquals(oid, keyCreatorDefault.unmarshal(oidStr));
+    }
+
+    @Test
+    public void specification() throws Exception {
+        context.checking(new Expectations() {
+            {
+                one(mockOidMarshaller).unmarshal(oidStr, TypedOid.class);
+                will(returnValue(oid));
+                one(mockSpecificationLoader).lookupBySpecId(oid.getObjectSpecId());
+                will(returnValue(mockSpecification));
+            }
+        });
+        final ObjectSpecification spec = keyCreatorDefault.specificationFromOidStr(oidStr);
+        assertEquals(mockSpecification, spec);
+    }
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/255ef514/component/objectstore/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlKeyCreatorTest_reference.java
----------------------------------------------------------------------
diff --git a/component/objectstore/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlKeyCreatorTest_reference.java b/component/objectstore/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlKeyCreatorTest_reference.java
new file mode 100644
index 0000000..2c388bc
--- /dev/null
+++ b/component/objectstore/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlKeyCreatorTest_reference.java
@@ -0,0 +1,78 @@
+/*
+ *  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.isis.runtimes.dflt.objectstores.nosql;
+
+import static org.junit.Assert.assertEquals;
+
+import org.jmock.Expectations;
+import org.jmock.auto.Mock;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.oid.RootOidDefault;
+import org.apache.isis.core.metamodel.spec.ObjectSpecId;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2;
+import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2.Mode;
+import org.apache.isis.runtimes.dflt.objectstores.nosql.keys.KeyCreatorDefault;
+
+public class NoSqlKeyCreatorTest_reference {
+
+    @Rule
+    public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_ONLY);
+
+    @Mock
+    private ObjectSpecification specification;
+    @Mock
+    private ObjectAdapter adapter;
+    
+    private final String className = "com.foo.bar.SomeClass";
+    private final String objectType = "SCL";
+    
+    private final RootOidDefault rootOidDefault = RootOidDefault.create(ObjectSpecId.of(objectType), ""+123);
+    
+    private KeyCreatorDefault keyCreatorDefault;
+
+    @Before
+    public void setup() {
+        keyCreatorDefault = new KeyCreatorDefault();
+        
+        context.checking(new Expectations() {
+            {
+                allowing(adapter).getSpecification();
+                will(returnValue(specification));
+
+                allowing(adapter).getOid();
+                will(returnValue(rootOidDefault));
+
+                allowing(specification).getFullIdentifier();
+                will(returnValue(className));
+            }
+        });
+    }
+
+    @Test
+    public void reference() throws Exception {
+        final String expectedReference = objectType + ":" + rootOidDefault.getIdentifier();
+        assertEquals(expectedReference, keyCreatorDefault.oidStrFor(adapter));
+    }
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/255ef514/component/objectstore/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlObjectStoreTest_constructor.java
----------------------------------------------------------------------
diff --git a/component/objectstore/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlObjectStoreTest_constructor.java b/component/objectstore/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlObjectStoreTest_constructor.java
new file mode 100644
index 0000000..6e7b96f
--- /dev/null
+++ b/component/objectstore/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlObjectStoreTest_constructor.java
@@ -0,0 +1,105 @@
+/*
+ *  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.isis.runtimes.dflt.objectstores.nosql;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Map;
+
+import com.google.common.collect.Maps;
+
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.jmock.Expectations;
+import org.jmock.Sequence;
+import org.jmock.auto.Mock;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2;
+import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2.Mode;
+import org.apache.isis.runtimes.dflt.objectstores.nosql.db.NoSqlDataDatabase;
+import org.apache.isis.runtimes.dflt.objectstores.nosql.encryption.DataEncryption;
+import org.apache.isis.runtimes.dflt.objectstores.nosql.versions.VersionCreator;
+import org.apache.isis.runtimes.dflt.runtime.system.persistence.OidGenerator;
+
+public class NoSqlObjectStoreTest_constructor {
+
+    @Rule
+    public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
+    
+    @Mock
+    private NoSqlDataDatabase db;
+    
+    @Mock
+    private VersionCreator versionCreator;
+
+    private Map<String, DataEncryption> dataEncrypter = Maps.newHashMap();
+
+    private NoSqlObjectStore store;
+
+    @Before
+    public void setup() {
+        Logger.getRootLogger().setLevel(Level.OFF);
+    }
+
+    @Test
+    public void withFixturesNotInstalled() throws Exception {
+        final Sequence constructor = context.sequence("<init>");
+        context.checking(new Expectations() {
+            {
+                one(db).open();
+                inSequence(constructor);
+                
+                one(db).containsData();
+                will(returnValue(false));
+                inSequence(constructor);
+                
+                one(db).close();
+                inSequence(constructor);
+            }
+        });
+        store = new NoSqlObjectStore(db, new OidGenerator(new NoSqlIdentifierGenerator(db)), versionCreator, null, dataEncrypter);
+        assertFalse(store.isFixturesInstalled());
+    }
+
+    @Test
+    public void withFixturesInstalled() throws Exception {
+        final Sequence constructor = context.sequence("<init>");
+        context.checking(new Expectations() {
+            {
+                one(db).open();
+                inSequence(constructor);
+                
+                one(db).containsData();
+                will(returnValue(true));
+                inSequence(constructor);
+                
+                one(db).close();
+                inSequence(constructor);
+            }
+        });
+        store = new NoSqlObjectStore(db, new OidGenerator(new NoSqlIdentifierGenerator(db)), versionCreator, null, dataEncrypter);
+        assertTrue(store.isFixturesInstalled());
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/255ef514/component/objectstore/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlObjectStoreTest_interactWith_db.java
----------------------------------------------------------------------
diff --git a/component/objectstore/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlObjectStoreTest_interactWith_db.java b/component/objectstore/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlObjectStoreTest_interactWith_db.java
new file mode 100644
index 0000000..b2f0d68
--- /dev/null
+++ b/component/objectstore/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlObjectStoreTest_interactWith_db.java
@@ -0,0 +1,226 @@
+/*
+ *  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.isis.runtimes.dflt.objectstores.nosql;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import com.google.common.collect.Maps;
+
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.jmock.Expectations;
+import org.jmock.Sequence;
+import org.jmock.auto.Mock;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.ResolveState;
+import org.apache.isis.core.metamodel.adapter.oid.RootOid;
+import org.apache.isis.core.metamodel.adapter.oid.RootOidDefault;
+import org.apache.isis.core.metamodel.spec.ObjectSpecId;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2;
+import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2.Mode;
+import org.apache.isis.runtimes.dflt.objectstores.nosql.db.NoSqlDataDatabase;
+import org.apache.isis.runtimes.dflt.objectstores.nosql.encryption.DataEncryption;
+import org.apache.isis.runtimes.dflt.objectstores.nosql.versions.VersionCreator;
+import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.PersistenceCommand;
+import org.apache.isis.runtimes.dflt.runtime.system.persistence.OidGenerator;
+import org.apache.isis.runtimes.dflt.runtime.system.persistence.PersistenceQuery;
+
+public class NoSqlObjectStoreTest_interactWith_db {
+
+    @Rule
+    public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
+    
+    @Mock
+    private NoSqlDataDatabase db;
+    
+    @Mock
+    private VersionCreator versionCreator;
+
+    @Mock
+    private PersistenceCommand command;
+
+    @Mock
+    private ObjectSpecification cusSpecification;
+
+    @Mock
+    private ObjectSpecification serviceSpecification;
+
+    @Mock
+    private ObjectAdapter cusAdapter;
+
+    private final ObjectSpecId cusSpecId = ObjectSpecId.of("CUS");
+    private RootOid cusRootOid = RootOidDefault.create(cusSpecId, "3");
+
+    final ObjectSpecId serviceSpecId = ObjectSpecId.of("service");
+
+    private Map<String, DataEncryption> dataEncrypter = Maps.newHashMap();
+
+    private NoSqlObjectStore store;
+
+
+
+
+
+    @Before
+    public void setup() {
+        Logger.getRootLogger().setLevel(Level.OFF);
+
+        context.checking(new Expectations() {
+            {
+                // in the constructor of the object store
+                one(db).open();
+                one(db).containsData();
+                will(returnValue(false));
+                one(db).close();
+
+                allowing(cusAdapter).getOid();
+                will(returnValue(cusRootOid));
+
+                allowing(cusAdapter).getSpecification();
+                will(returnValue(cusSpecification));
+
+                allowing(cusSpecification).getSpecId();
+                will(returnValue(cusSpecId));
+
+                allowing(serviceSpecification).getSpecId();
+                will(returnValue(serviceSpecId));
+            }
+        });
+
+        store = new NoSqlObjectStore(db, new OidGenerator(new NoSqlIdentifierGenerator(db)), versionCreator, null, dataEncrypter);
+    }
+
+    @Test
+    public void open() throws Exception {
+        context.checking(new Expectations() {
+            {
+                one(db).open();
+            }
+        });
+        store.open();
+    }
+
+    @Test
+    public void close() throws Exception {
+        context.checking(new Expectations() {
+            {
+                one(db).close();
+            }
+        });
+        store.close();
+    }
+
+    @Test
+    public void registerService() throws Exception {
+        context.checking(new Expectations() {
+            {
+                one(db).addService(serviceSpecId, "4");
+            }
+        });
+        store.registerService(RootOidDefault.create(serviceSpecId, "4"));
+    }
+
+    @Test
+    public void oidForService() throws Exception {
+        context.checking(new Expectations() {
+            {
+                one(db).getService(serviceSpecId);
+                will(returnValue("4"));
+            }
+        });
+        store.getOidForService(serviceSpecification);
+    }
+
+    @Test
+    public void hasInstances() throws Exception {
+        context.checking(new Expectations() {
+            {
+                one(db).hasInstances(cusSpecification.getSpecId());
+                will(returnValue(true));
+            }
+        });
+        store.hasInstances(cusSpecification);
+    }
+
+    @Test
+    public void execute() throws Exception {
+        final List<PersistenceCommand> commands = new ArrayList<PersistenceCommand>();
+        commands.add(command);
+
+        context.checking(new Expectations() {
+            {
+                // Hone(command).execute(null); // REVIEW: DKH ... how was this expectation ever met?
+                one(db).write(commands);
+            }
+        });
+
+        store.execute(commands);
+    }
+
+    @Test
+    public void instances() throws Exception {
+        final PersistenceQuery persistenceQuery = context.mock(PersistenceQuery.class);
+        context.checking(new Expectations() {
+            {
+                one(persistenceQuery).getSpecification();
+                will(returnValue(cusSpecification));
+
+                one(db).instancesOf(cusSpecification.getSpecId());
+                will(returnIterator());
+                
+                allowing(cusSpecification).subclasses();
+            }
+        });
+
+        store.loadInstancesAndAdapt(persistenceQuery);
+    }
+
+    @Test
+    public void resolve() throws Exception {
+        final Sequence changingState = context.sequence("changingState");
+        context.checking(new Expectations() {
+            {
+                one(db).getInstance("3", cusSpecId);
+
+                allowing(cusAdapter).getResolveState();
+                inSequence(changingState);
+                will(returnValue(ResolveState.GHOST));
+
+                ignoring(cusSpecification);
+                
+                one(cusAdapter).changeState(ResolveState.RESOLVING);
+                inSequence(changingState);
+                one(cusAdapter).changeState(ResolveState.RESOLVED);
+                inSequence(changingState);
+                
+                one(cusAdapter).setVersion(null);
+            }
+        });
+        store.resolveImmediately(cusAdapter);
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/255ef514/component/objectstore/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/WriteObjectCommandTest.java
----------------------------------------------------------------------
diff --git a/component/objectstore/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/WriteObjectCommandTest.java b/component/objectstore/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/WriteObjectCommandTest.java
new file mode 100644
index 0000000..3de31df
--- /dev/null
+++ b/component/objectstore/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/WriteObjectCommandTest.java
@@ -0,0 +1,220 @@
+/*
+ *  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.isis.runtimes.dflt.objectstores.nosql;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+
+import java.util.ArrayList;
+
+import org.jmock.Expectations;
+import org.jmock.auto.Mock;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.commons.exceptions.UnexpectedCallException;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.oid.OidMarshaller;
+import org.apache.isis.core.metamodel.adapter.oid.RootOidDefault;
+import org.apache.isis.core.metamodel.adapter.version.SerialNumberVersion;
+import org.apache.isis.core.metamodel.adapter.version.Version;
+import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2;
+import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2.Mode;
+import org.apache.isis.runtimes.dflt.objectstores.nosql.db.StateWriter;
+import org.apache.isis.runtimes.dflt.objectstores.nosql.encryption.DataEncryption;
+import org.apache.isis.runtimes.dflt.objectstores.nosql.versions.VersionCreator;
+import org.apache.isis.runtimes.dflt.testsupport.IsisSystemWithFixtures;
+import org.apache.isis.tck.dom.refs.ParentEntity;
+import org.apache.isis.tck.dom.refs.ReferencingEntity;
+import org.apache.isis.tck.dom.refs.SimpleEntity;
+
+public class WriteObjectCommandTest {
+    
+    @Rule
+    public IsisSystemWithFixtures iswf = IsisSystemWithFixtures.builder().build();
+
+    @Rule
+    public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
+
+    @Mock
+    private StateWriter writer;
+    @Mock
+    private VersionCreator versionCreator;
+    
+    @Mock
+    private NoSqlCommandContext commandContext;
+
+    private DataEncryption dataEncrypter;
+
+    private ObjectAdapter smpl1Adapter;
+    private ObjectAdapter rfcg1Adapter;
+    private ObjectAdapter prnt1Adapter;
+
+    private SimpleEntity smpl1;
+    private SimpleEntity smpl2;
+
+    private ReferencingEntity rfcg1;
+
+    private ParentEntity prnt1;
+
+    @Before
+    public void setup() {
+
+        smpl1 = iswf.fixtures.smpl1;
+        smpl1.setName("Fred Smith");
+        smpl1.setSize(108);
+        smpl1Adapter = iswf.remapAsPersistent(smpl1, RootOidDefault.deString("SMPL:1", new OidMarshaller()));
+
+        smpl2 = iswf.fixtures.smpl2;
+        smpl2.setName("John Brown");
+        iswf.remapAsPersistent(smpl2, RootOidDefault.deString("SMPL:2", new OidMarshaller()));
+
+        rfcg1 = iswf.fixtures.rfcg1;
+        rfcg1.setReference(smpl1);
+        rfcg1Adapter = iswf.remapAsPersistent(rfcg1, RootOidDefault.deString("RFCG:1", new OidMarshaller()));
+
+        prnt1 = iswf.fixtures.prnt1;
+        prnt1.getHomogeneousCollection().add(smpl1);
+        prnt1.getHomogeneousCollection().add(smpl2);
+        
+        prnt1Adapter = iswf.remapAsPersistent(prnt1, RootOidDefault.deString("PRNT:1", new OidMarshaller()));
+
+        final Version version = SerialNumberVersion.create(2, "username", null);
+
+        context.checking(new Expectations() {
+            {
+                one(versionCreator).newVersion("tester");
+                will(returnValue(version));
+                one(versionCreator).versionString(version);
+                will(returnValue("2"));
+                one(versionCreator).timeString(version);
+                will(returnValue("1057"));
+            }
+        });
+
+        dataEncrypter = new DataEncryption() {
+            @Override
+            public String getType() {
+                return "etc1";
+            }
+
+            @Override
+            public void init(final IsisConfiguration configuration) {
+            }
+
+            @Override
+            public String encrypt(final String plainText) {
+                return "ENC" + plainText;
+            }
+
+            @Override
+            public String decrypt(final String encryptedText) {
+                throw new UnexpectedCallException();
+            }
+        };
+    }
+
+
+    @Test
+    public void objectWithValues() throws Exception {
+
+        context.checking(new Expectations() {
+
+            {
+                one(commandContext).createStateWriter(smpl1Adapter.getSpecification().getSpecId());
+                will(returnValue(writer));
+
+                final RootOidDefault oid = RootOidDefault.create(smpl1Adapter.getSpecification().getSpecId(), "1");
+                exactly(2).of(writer).writeOid(oid); // once for the id, once for the type
+
+                one(writer).writeField("name", "ENCFred Smith");
+                one(writer).writeField("size", "ENC108");
+                one(writer).writeField("date", null);
+                one(writer).writeField("nullable", null);
+                one(writer).writeVersion(null, "2");
+                one(writer).writeUser("username");
+                one(writer).writeTime("1057");
+                one(writer).writeEncryptionType("etc1");
+
+                one(commandContext).insert(writer);
+
+            }
+        });
+
+        final WriteObjectCommand command = new WriteObjectCommand(WriteObjectCommand.Mode.NON_UPDATE, versionCreator, dataEncrypter, smpl1Adapter);
+        command.execute(commandContext);
+    }
+
+    @Test
+    public void objectWithReferences() throws Exception {
+
+        context.checking(new Expectations() {
+            {
+                one(commandContext).createStateWriter(rfcg1Adapter.getSpecification().getSpecId());
+                will(returnValue(writer));
+
+                final RootOidDefault oid = RootOidDefault.create(rfcg1Adapter.getSpecification().getSpecId(), "1");
+                exactly(2).of(writer).writeOid(oid); // once for the id, once for the type
+                
+                one(writer).writeField("reference", "SMPL:1");
+                one(writer).writeField("aggregatedReference", null);
+                one(writer).writeCollection(with(equalTo("aggregatedEntities")), with(equalTo(new ArrayList<StateWriter>())));
+                
+                one(writer).writeVersion(null, "2");
+                one(writer).writeUser("username");
+                one(writer).writeTime("1057");
+                one(writer).writeEncryptionType("etc1");
+
+                one(commandContext).insert(writer);
+            }
+        });
+
+        final WriteObjectCommand command = new WriteObjectCommand(WriteObjectCommand.Mode.NON_UPDATE, versionCreator, dataEncrypter, rfcg1Adapter);
+        command.execute(commandContext);
+    }
+
+    @Test
+    public void objectWithCollections() throws Exception {
+
+        context.checking(new Expectations() {
+            {
+                one(commandContext).createStateWriter(prnt1Adapter.getSpecification().getSpecId());
+                will(returnValue(writer));
+
+                final RootOidDefault oid = RootOidDefault.create(prnt1Adapter.getSpecification().getSpecId(), "1");
+                exactly(2).of(writer).writeOid(oid); // once for the id, once for the type
+
+                one(writer).writeField("name", null);
+                one(writer).writeField("homogeneousCollection", "SMPL:1|SMPL:2|");
+
+                one(writer).writeVersion(null, "2");
+                one(writer).writeUser("username");
+                one(writer).writeTime("1057");
+                one(writer).writeEncryptionType("etc1");
+
+                one(commandContext).insert(writer);
+            }
+        });
+
+        final WriteObjectCommand command = new WriteObjectCommand(WriteObjectCommand.Mode.NON_UPDATE, versionCreator, dataEncrypter, prnt1Adapter);
+        command.execute(commandContext);
+    }
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/255ef514/component/objectstore/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/db/file/ChecksummingPerfomance.java
----------------------------------------------------------------------
diff --git a/component/objectstore/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/db/file/ChecksummingPerfomance.java b/component/objectstore/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/db/file/ChecksummingPerfomance.java
new file mode 100644
index 0000000..8f3e1e5
--- /dev/null
+++ b/component/objectstore/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/db/file/ChecksummingPerfomance.java
@@ -0,0 +1,140 @@
+/*
+ *  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.isis.runtimes.dflt.objectstores.nosql.db.file;
+
+import java.io.BufferedReader;
+import java.io.FileInputStream;
+import java.io.InputStreamReader;
+import java.util.zip.CRC32;
+import java.util.zip.CheckedInputStream;
+
+import org.apache.isis.runtimes.dflt.objectstores.nosql.db.file.server.Util;
+
+public class ChecksummingPerfomance {
+
+    public static void main(final String[] args) throws Exception {
+
+        //final CRC32 inputChecksum = new CRC32();
+        //final CheckedInputStream in = new CheckedInputStream(new FileInputStream("test.data"), inputChecksum);
+        //final BufferedReader reader = new BufferedReader(new InputStreamReader(in, Util.ENCODING));
+
+        for (int i = 0; i < 30; i++) {
+            long time = System.currentTimeMillis();
+            StringBuffer buf = null;
+            for (int j = 0; j < 1000; j++) {
+                buf = readFile(i);
+            }
+            time = System.currentTimeMillis() - time;
+            System.out.print(time);
+            System.out.print("   ");
+
+            time = System.currentTimeMillis();
+            for (int j = 0; j < 1000; j++) {
+                readChecksummedFile(i);
+            }
+            time = System.currentTimeMillis() - time;
+            System.out.print(time);
+            System.out.print("   ");
+
+            time = System.currentTimeMillis();
+            for (int j = 0; j < 1000; j++) {
+                testArray(buf);
+            }
+            time = System.currentTimeMillis() - time;
+            System.out.print(time);
+            System.out.print("   ");
+
+            byte[] data = null;
+            time = System.currentTimeMillis();
+            for (int j = 0; j < 1000; j++) {
+                data = extractArray(buf);
+            }
+            time = System.currentTimeMillis() - time;
+            System.out.print(time);
+            System.out.print("   ");
+
+            time = System.currentTimeMillis();
+            for (int j = 0; j < 1000; j++) {
+                checksumArray(data);
+            }
+            time = System.currentTimeMillis() - time;
+            System.out.println(time);
+        }
+
+    }
+
+    private static void testArray(final StringBuffer buf) {
+        final byte[] data = buf.toString().getBytes();
+
+        final CRC32 inputChecksum = new CRC32();
+        inputChecksum.reset();
+        inputChecksum.update(data);
+
+        // System.out.println(inputChecksum.getValue());
+    }
+
+    private static byte[] extractArray(final StringBuffer buf) {
+        final byte[] data = buf.toString().getBytes();
+        return data;
+    }
+
+    private static void checksumArray(final byte[] data) {
+        final CRC32 inputChecksum = new CRC32();
+        inputChecksum.reset();
+        inputChecksum.update(data);
+
+        // System.out.println(inputChecksum.getValue());
+    }
+
+    private static StringBuffer readChecksummedFile(final int i) throws Exception {
+        final CRC32 inputChecksum = new CRC32();
+        final CheckedInputStream in = new CheckedInputStream(new FileInputStream("test" + i % 3 + ".data"), inputChecksum);
+        final BufferedReader reader = new BufferedReader(new InputStreamReader(in, Util.ENCODING));
+
+        final StringBuffer buf = new StringBuffer();
+        String line;
+        while ((line = reader.readLine()) != null) {
+            buf.append(line);
+            buf.append('\n');
+        }
+
+        // System.out.println(inputChecksum.getValue());
+
+        reader.close();
+
+        return buf;
+    }
+
+    private static StringBuffer readFile(final int i) throws Exception {
+        final BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream("test" + i % 3 + ".data"), Util.ENCODING));
+
+        final StringBuffer buf = new StringBuffer();
+        String line;
+        while ((line = reader.readLine()) != null) {
+            buf.append(line);
+            buf.append('\n');
+        }
+
+        // System.out.println(inputChecksum.getValue());
+
+        reader.close();
+
+        return buf;
+    }
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/255ef514/component/objectstore/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/db/file/ClientConnectionTest.java
----------------------------------------------------------------------
diff --git a/component/objectstore/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/db/file/ClientConnectionTest.java b/component/objectstore/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/db/file/ClientConnectionTest.java
new file mode 100644
index 0000000..2a57d28
--- /dev/null
+++ b/component/objectstore/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/db/file/ClientConnectionTest.java
@@ -0,0 +1,127 @@
+/*
+ *  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.isis.runtimes.dflt.objectstores.nosql.db.file;
+
+import static org.hamcrest.Matchers.containsString;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
+
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.apache.isis.core.commons.exceptions.IsisException;
+import org.apache.isis.core.commons.lang.IoUtils;
+import org.apache.isis.core.metamodel.adapter.version.ConcurrencyException;
+import org.apache.isis.runtimes.dflt.runtime.persistence.ObjectNotFoundException;
+
+public class ClientConnectionTest {
+
+    private InputStream input;
+    private ByteArrayOutputStream output;
+    private ClientConnection connection;
+
+    @Before
+    public void setup() throws Exception {
+        Logger.getRootLogger().setLevel(Level.OFF);
+
+        input = IoUtils.asUtf8ByteStream("org.domain.Class false true 1025\n{data...}\n\n102334");
+        output = new ByteArrayOutputStream();
+        connection = new ClientConnection(input, output);
+    }
+
+    @Test
+    public void testRequest() throws Exception {
+        connection.request('D', "xxx yyy");
+        connection.close();
+        assertEquals("Dxxx yyy\n", output.toString());
+    }
+
+    @Test
+    public void testRequestData() throws Exception {
+        connection.requestData("{data...}");
+        connection.close();
+        // assertEquals("{data...}\n\n5de98274", output.toString());
+    }
+
+    @Test
+    public void testResponseHeaders() throws Exception {
+        connection.getReponseHeader();
+        assertEquals("org.domain.Class", connection.getResponse());
+        assertEquals(false, connection.getResponseAsBoolean());
+        assertEquals(true, connection.getResponseAsBoolean());
+        assertEquals(1025L, connection.getResponseAsLong());
+    }
+
+    @Test
+    public void tooManyResponseHeadersExpected() throws Exception {
+        connection.getReponseHeader();
+        connection.getResponse();
+        connection.getResponse();
+        connection.getResponse();
+        connection.getResponse();
+        try {
+            connection.getResponse();
+            fail();
+        } catch (final RemotingException e) {
+            assertThat(e.getMessage(), containsString("are only 4"));
+        }
+    }
+
+    @Test
+    public void testResponseData() throws Exception {
+        connection.getReponseHeader();
+        final String data = connection.getResponseData();
+        assertEquals("{data...}\n", data);
+    }
+
+    @Test
+    public void validateResponseOk() throws Exception {
+        input = IoUtils.asUtf8ByteStream("ok xx xx\n{data...}");
+        connection = new ClientConnection(input, output);
+        connection.validateRequest();
+    }
+
+    @Test(expected = RemotingException.class)
+    public void validateResponseError() throws Exception {
+        input = IoUtils.asUtf8ByteStream("error message about it\n");
+        connection = new ClientConnection(input, output);
+        connection.validateRequest();
+    }
+
+    @Test(expected = ObjectNotFoundException.class)
+    public void validateObjectNotFound() throws Exception {
+        input = IoUtils.asUtf8ByteStream("not-found message about it\n");
+        connection = new ClientConnection(input, output);
+        connection.validateRequest();
+    }
+
+    @Test(expected = ConcurrencyException.class)
+    public void validateConcurrencyException() throws Exception {
+        input = IoUtils.asUtf8ByteStream("concurrency message about it\n");
+        connection = new ClientConnection(input, output);
+        connection.validateRequest();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/255ef514/component/objectstore/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/db/file/JsonStateReaderTest.java
----------------------------------------------------------------------
diff --git a/component/objectstore/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/db/file/JsonStateReaderTest.java b/component/objectstore/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/db/file/JsonStateReaderTest.java
new file mode 100644
index 0000000..89b6db8
--- /dev/null
+++ b/component/objectstore/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/db/file/JsonStateReaderTest.java
@@ -0,0 +1,127 @@
+/*
+ *  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.isis.runtimes.dflt.objectstores.nosql.db.file;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import org.apache.isis.runtimes.dflt.objectstores.nosql.db.StateReader;
+import org.apache.isis.runtimes.dflt.objectstores.nosql.db.file.JsonStateReader;
+
+public class JsonStateReaderTest {
+
+    private JsonStateReader reader;
+
+    @Before
+    public void setup() {
+        reader = new JsonStateReader(
+                "{" + 
+                    "\"_encrypt\": \"etc1\"," + 
+                    "\"_oid\": \"com.package.ClassName:#2\"," + 
+                    "\"_time\": \"ddmmyy\"," + 
+                    "\"_user\": \"fred\"," + 
+                    "\"_version\": \"2\"," + 
+                    "\"field-1\": \"1234\"," + 
+                    "\"field-2\": \"data\"," + 
+                    "\"field-3\": null,"
+                    + "\"list\": [{}, {}]," + 
+                    "\"aggregate\": {" +
+                        "\"_oid\": \"com.package.ClassName:#2~com.package.AggregatedClassName:#3\""  +
+                        "}," + 
+                    "}");
+    }
+
+    @Test
+    public void readEncryptionType() throws Exception {
+        assertEquals("etc1", reader.readEncrytionType());
+    }
+
+//    @Test
+//    public void readId() throws Exception {
+//        assertEquals("#2", reader.readId());
+//    }
+//
+//    @Test
+//    public void readObjectType() throws Exception {
+//        assertEquals("com.package.ClassName", reader.readObjectType());
+//    }
+
+    @Test
+    public void readOid() throws Exception {
+        assertEquals("com.package.ClassName:#2", reader.readOid());
+    }
+
+    @Test
+    public void readTime() throws Exception {
+        assertEquals("ddmmyy", reader.readTime());
+    }
+
+    @Test
+    public void readUser() throws Exception {
+        assertEquals("fred", reader.readUser());
+    }
+
+    @Test
+    public void readVersion() throws Exception {
+        assertEquals("2", reader.readVersion());
+    }
+
+    @Test
+    public void readNumberField() throws Exception {
+        assertEquals(1234L, reader.readLongField("field-1"));
+    }
+
+    @Test
+    public void readNumberFieldAsNull() throws Exception {
+        assertEquals(0L, reader.readLongField("field-4"));
+    }
+
+    @Test
+    public void readStringField() throws Exception {
+        assertEquals("data", reader.readField("field-2"));
+    }
+
+    @Test
+    public void readStringFieldAsNull() throws Exception {
+        assertEquals(null, reader.readField("field-4"));
+    }
+
+    @Test
+    public void readUnsavedCollection() throws Exception {
+        assertEquals(new ArrayList<StateReader>(), reader.readCollection("unknown-list"));
+    }
+
+    @Test
+    public void readList() throws Exception {
+        final List<StateReader> collection = reader.readCollection("list");
+        assertEquals(2, collection.size());
+        // assertEquals(null, reader.readField("field-4"));
+    }
+
+    @Test
+    public void readAggregate() throws Exception {
+        final StateReader aggregate = reader.readAggregate("aggregate");
+        assertEquals("com.package.ClassName:#2~com.package.AggregatedClassName:#3", aggregate.readOid());
+    }
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/255ef514/component/objectstore/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/db/file/JsonStateWriterTest.java
----------------------------------------------------------------------
diff --git a/component/objectstore/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/db/file/JsonStateWriterTest.java b/component/objectstore/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/db/file/JsonStateWriterTest.java
new file mode 100644
index 0000000..163ce1b
--- /dev/null
+++ b/component/objectstore/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/db/file/JsonStateWriterTest.java
@@ -0,0 +1,123 @@
+/*
+ *  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.isis.runtimes.dflt.objectstores.nosql.db.file;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.isis.core.metamodel.adapter.oid.OidMarshaller;
+import org.apache.isis.core.metamodel.adapter.oid.RootOidDefault;
+import org.apache.isis.runtimes.dflt.objectstores.nosql.db.StateWriter;
+import org.apache.isis.runtimes.dflt.testsupport.IsisSystemWithFixtures;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+public class JsonStateWriterTest {
+
+    @Rule
+    public IsisSystemWithFixtures iswf = IsisSystemWithFixtures.builder().build();
+    
+    private JsonStateWriter writer;
+
+    @Before
+    public void setup() {
+        writer = new JsonStateWriter();
+    }
+
+    @Test
+    public void noData() throws Exception {
+        assertEquals("{}", writer.getData());
+    }
+
+    @Test
+    public void basicData() throws Exception {
+//        writer.writeObjectType("com.planchase.ClassName");
+//        writer.writeId("#1");
+        writer.writeOid(RootOidDefault.deString("com.planchase.ClassName:1", new OidMarshaller()));
+        writer.writeTime("ddmmyy");
+        writer.writeVersion("1", "2");
+        writer.writeUser("fred");
+        assertEquals("{\n" +
+        		"    \"_oid\": \"com.planchase.ClassName:1\",\n" +
+        		"    \"_time\": \"ddmmyy\",\n" +
+        		"    \"_user\": \"fred\",\n" +
+        		"    \"_version\": \"2\"\n" +
+        		"}", 
+        		writer.getData());
+    }
+
+    @Test
+    public void encrytionVersion() throws Exception {
+        writer.writeEncryptionType("etc1");
+        assertEquals("{\"_encrypt\": \"etc1\"}", writer.getData());
+    }
+
+    @Test
+    public void numberData() throws Exception {
+        writer.writeField("number", 1239912);
+        assertEquals("{\"number\": \"1239912\"}", writer.getData());
+    }
+
+    @Test
+    public void stringData() throws Exception {
+        writer.writeField("number", "string-data");
+        assertEquals("{\"number\": \"string-data\"}", writer.getData());
+    }
+
+    @Test
+    public void nullData() throws Exception {
+        writer.writeField("number", null);
+        assertEquals("{\"number\": null}", writer.getData());
+    }
+
+    @Test
+    public void addAggregate() throws Exception {
+        final StateWriter aggregate = writer.addAggregate("#4");
+        aggregate.writeField("number", "string-data");
+        assertEquals("{\"#4\": {\"number\": \"string-data\"}}", writer.getData());
+    }
+
+    @Test
+    public void elementData() throws Exception {
+        final List<StateWriter> elements = new ArrayList<StateWriter>();
+        final StateWriter elementWriter1 = writer.createElementWriter();
+        elementWriter1.writeField("number", "1");
+        elements.add(elementWriter1);
+        final StateWriter elementWriter2 = writer.createElementWriter();
+        elementWriter2.writeField("number", "4");
+        elements.add(elementWriter2);
+
+        writer.writeCollection("coll", elements);
+
+        assertEquals("{\"coll\": [\n    {\"number\": \"1\"},\n    {\"number\": \"4\"}\n]}", writer.getData());
+    }
+
+    @Test
+    public void requestData() throws Exception {
+//        writer.writeObjectType("com.planchase.ClassName");
+//        writer.writeId("#8");
+        writer.writeOid(RootOidDefault.deString("com.planchase.ClassName:8", new OidMarshaller()));
+        writer.writeVersion("1", "2");
+        assertEquals("com.planchase.ClassName:8 1 2", writer.getRequest());
+    }
+
+}