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 11:10:37 UTC

[49/51] [partial] ISIS-188: moving modules into core

http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/transaction/ObjectStoreTransactionManager_InstantiationTest.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/transaction/ObjectStoreTransactionManager_InstantiationTest.java b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/transaction/ObjectStoreTransactionManager_InstantiationTest.java
new file mode 100644
index 0000000..e7aac20
--- /dev/null
+++ b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/transaction/ObjectStoreTransactionManager_InstantiationTest.java
@@ -0,0 +1,33 @@
+/*
+ *  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.runtime.persistence.objectstore.transaction;
+
+import org.junit.Test;
+
+import org.apache.isis.runtimes.dflt.runtime.system.transaction.IsisTransactionManager;
+
+public class ObjectStoreTransactionManager_InstantiationTest extends ObjectStoreTransactionManagerAbstractTestCase {
+
+    @Test
+    public void canInstantiate() throws Exception {
+        transactionManager = new IsisTransactionManager(mockPersistenceSession, mockObjectStore);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/transaction/ObjectStoreTransactionManager_StartTransactionTest.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/transaction/ObjectStoreTransactionManager_StartTransactionTest.java b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/transaction/ObjectStoreTransactionManager_StartTransactionTest.java
new file mode 100644
index 0000000..7db2df1
--- /dev/null
+++ b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/transaction/ObjectStoreTransactionManager_StartTransactionTest.java
@@ -0,0 +1,89 @@
+/*
+ *  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.runtime.persistence.objectstore.transaction;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.CoreMatchers.sameInstance;
+import static org.junit.Assert.assertThat;
+
+import org.jmock.Expectations;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.apache.isis.runtimes.dflt.runtime.system.transaction.IsisTransaction;
+import org.apache.isis.runtimes.dflt.runtime.system.transaction.IsisTransactionManager;
+
+public class ObjectStoreTransactionManager_StartTransactionTest extends ObjectStoreTransactionManagerAbstractTestCase {
+
+    @Before
+    public void setUpTransactionManager() throws Exception {
+        transactionManager = new IsisTransactionManager(mockPersistenceSession, mockObjectStore);
+    }
+
+    @Before
+    public void setUpExpectations() throws Exception {
+        ignoreCallsToPersistenceSession();
+    }
+
+    @Test
+    public void startTransactionCreateTransactionIfNone() throws Exception {
+        ignoreCallsToObjectStore();
+
+        assertThat(transactionManager.getTransaction(), is(nullValue()));
+        transactionManager.startTransaction();
+        assertThat(transactionManager.getTransaction(), is(not(nullValue())));
+    }
+
+    @Test
+    public void startTransactionDoesNotOverwriteTransactionIfHasOne() throws Exception {
+        ignoreCallsToObjectStore();
+
+        // cause a transaction to be created
+        transactionManager.startTransaction();
+        final IsisTransaction transactionAfterFirstStart = transactionManager.getTransaction();
+
+        transactionManager.startTransaction();
+
+        assertThat(transactionManager.getTransaction(), is(sameInstance(transactionAfterFirstStart)));
+    }
+
+    @Test
+    public void startTransactionIncrementsTransactionLevel() throws Exception {
+        ignoreCallsToObjectStore();
+
+        assertThat(transactionManager.getTransactionLevel(), is(0));
+        transactionManager.startTransaction();
+        assertThat(transactionManager.getTransactionLevel(), is(1));
+    }
+
+    @Test
+    public void startTransactionCallsStartTransactionOnObjectStore() throws Exception {
+        context.checking(new Expectations() {
+            {
+                one(mockObjectStore).startTransaction();
+            }
+        });
+
+        transactionManager.startTransaction();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/transaction/PojoAdapterBuilder.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/transaction/PojoAdapterBuilder.java b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/transaction/PojoAdapterBuilder.java
new file mode 100644
index 0000000..769c9be
--- /dev/null
+++ b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/transaction/PojoAdapterBuilder.java
@@ -0,0 +1,251 @@
+/*
+ *  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.runtime.persistence.objectstore.transaction;
+
+import java.util.Iterator;
+
+import com.google.common.base.Splitter;
+
+import org.apache.isis.applib.profiles.Localization;
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.metamodel.adapter.ResolveState;
+import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
+import org.apache.isis.core.metamodel.adapter.oid.AggregatedOid;
+import org.apache.isis.core.metamodel.adapter.oid.CollectionOid;
+import org.apache.isis.core.metamodel.adapter.oid.Oid;
+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.metamodel.spec.SpecificationLoader;
+import org.apache.isis.core.metamodel.spec.SpecificationLoaderSpi;
+import org.apache.isis.runtimes.dflt.runtime.persistence.adapter.PojoAdapter;
+
+public class PojoAdapterBuilder {
+
+    private PojoAdapterBuilder(){
+    }
+    
+    private Object pojo = new Object();
+
+    // override; else will delegate to SpecificationLoader
+    private ObjectSpecification objectSpec;
+    
+    private SpecificationLoader specificationLoader;
+    
+    private AdapterManager objectAdapterLookup;
+    
+    private ObjectSpecId objectSpecId = ObjectSpecId.of("CUS");
+    private String identifier = "1";
+    // only used if type is AGGREGATED
+    private String aggregatedId = "firstName";
+    
+    private Type type = Type.ROOT;
+    private Persistence persistence = Persistence.PERSISTENT;
+
+    private String titleString;
+
+    private Version version;
+
+    private Localization localization;
+
+    private AuthenticationSession authenticationSession;
+
+    
+    public static enum Persistence {
+        TRANSIENT {
+            @Override
+            RootOid createOid(ObjectSpecId objectSpecId, String identifier) {
+                return RootOidDefault.createTransient(objectSpecId, identifier);
+            }
+
+            @Override
+            void changeStateOn(PojoAdapter pojoAdapter) {
+                pojoAdapter.changeState(ResolveState.TRANSIENT);
+            }
+        },
+        PERSISTENT {
+            @Override
+            RootOid createOid(ObjectSpecId objectSpecId, String identifier) {
+                return RootOidDefault.create(objectSpecId, identifier);
+            }
+
+            @Override
+            void changeStateOn(PojoAdapter pojoAdapter) {
+                pojoAdapter.changeState(ResolveState.TRANSIENT);
+                pojoAdapter.changeState(ResolveState.RESOLVED);
+            }
+        }, 
+        VALUE {
+            @Override
+            RootOid createOid(ObjectSpecId objectSpecId, String identifier) {
+                return null;
+            }
+
+            @Override
+            void changeStateOn(PojoAdapter pojoAdapter) {
+                pojoAdapter.changeState(ResolveState.VALUE);
+            }
+        };
+        abstract RootOid createOid(ObjectSpecId objectSpecId, String identifier);
+
+        abstract void changeStateOn(PojoAdapter pojoAdapter);
+    }
+
+    public static enum Type {
+        ROOT {
+            @Override
+            Oid oidFor(RootOid rootOid, ObjectSpecId objectSpecId, String unused) {
+                return rootOid;
+            }
+        }, AGGREGATED {
+            @Override
+            Oid oidFor(RootOid rootOid, ObjectSpecId objectSpecId, String aggregateLocalId) {
+                return new AggregatedOid(objectSpecId, rootOid, aggregateLocalId);
+            }
+        }, COLLECTION {
+            @Override
+            Oid oidFor(RootOid rootOid, ObjectSpecId objectSpecId, String collectionId) {
+                return new CollectionOid(rootOid, collectionId);
+            }
+        }, VALUE {
+            @Override
+            Oid oidFor(RootOid rootOid, ObjectSpecId objectSpecId, String unused) {
+                return null;
+            }
+        };
+
+        abstract Oid oidFor(RootOid rootOid, ObjectSpecId objectSpecId, String supplementalId);
+    }
+
+    public static PojoAdapterBuilder create() {
+        return new PojoAdapterBuilder();
+    }
+
+    public PojoAdapterBuilder withAggregatedId(String aggregatedId) {
+        this.aggregatedId = aggregatedId;
+        return this;
+    }
+    
+    public PojoAdapterBuilder withIdentifier(String identifier) {
+        this.identifier = identifier;
+        return this;
+    }
+    
+    public PojoAdapterBuilder withObjectType(String objectType) {
+        this.objectSpecId = ObjectSpecId.of(objectType);
+        return this;
+    }
+    
+    public PojoAdapterBuilder withPojo(Object pojo) {
+        this.pojo = pojo;
+        return this;
+    }
+
+    public PojoAdapterBuilder withOid(String oidAndTitle) {
+        final Iterator<String> iterator = Splitter.on("|").split(oidAndTitle).iterator();
+        if(!iterator.hasNext()) { return this; }
+        withObjectType(iterator.next());
+        if(!iterator.hasNext()) { return this; }
+        withIdentifier(iterator.next());
+        if(!iterator.hasNext()) { return this; }
+        withTitleString(iterator.next());
+        return this;
+    }
+    
+    /**
+     * A Persistence of VALUE implies a Type of VALUE also
+     */
+    public PojoAdapterBuilder with(Persistence persistence) {
+        this.persistence = persistence;
+        if(persistence == Persistence.VALUE) {
+            this.type = Type.VALUE;
+        }
+        return this;
+    }
+    
+    /**
+     * A Type of VALUE implies a Persistence of VALUE also.
+     */
+    public PojoAdapterBuilder with(Type type) {
+        this.type = type;
+        if(type == Type.VALUE) {
+            this.persistence = Persistence.VALUE;
+        }
+        return this;
+    }
+    
+    public PojoAdapterBuilder with(ObjectSpecification objectSpec) {
+        this.objectSpec = objectSpec;
+        return this;
+    }
+
+    public PojoAdapterBuilder with(AdapterManager objectAdapterLookup) {
+        this.objectAdapterLookup = objectAdapterLookup;
+        return this;
+    }
+    
+    public PojoAdapterBuilder with(SpecificationLoader specificationLoader) {
+        this.specificationLoader = specificationLoader;
+        return this;
+    }
+    
+    public PojoAdapterBuilder with(AuthenticationSession authenticationSession) {
+        this.authenticationSession = authenticationSession;
+        return this;
+    }
+    
+    public PojoAdapterBuilder with(Localization localization) {
+        this.localization = localization;
+        return this;
+    }
+
+    public PojoAdapterBuilder with(Version version) {
+        this.version = version;
+        return this;
+    }
+
+    public PojoAdapterBuilder withTitleString(String titleString) {
+        this.titleString = titleString;
+        return this;
+    }
+
+    public PojoAdapter build() {
+        final RootOid rootOid = persistence.createOid(objectSpecId, identifier);
+        final Oid oid = type.oidFor(rootOid, objectSpecId, aggregatedId);
+        final PojoAdapter pojoAdapter = new PojoAdapter(pojo, oid, specificationLoader, objectAdapterLookup, localization, authenticationSession) {
+            @Override
+            public ObjectSpecification getSpecification() { return objectSpec != null? objectSpec: super.getSpecification(); }
+            @Override
+            public String titleString() {
+                return titleString != null? titleString: super.titleString();
+            }
+        };
+        persistence.changeStateOn(pojoAdapter);
+        if(persistence == Persistence.PERSISTENT && version != null) {
+            pojoAdapter.setVersion(version);
+        }
+        return pojoAdapter;
+    }
+
+
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/transaction/TransactionTest.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/transaction/TransactionTest.java b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/transaction/TransactionTest.java
new file mode 100644
index 0000000..7e58387
--- /dev/null
+++ b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/transaction/TransactionTest.java
@@ -0,0 +1,318 @@
+/*
+ *  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.runtime.persistence.objectstore.transaction;
+
+import java.util.Collections;
+
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.hamcrest.CoreMatchers;
+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.matchers.IsisMatchers;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2;
+import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2.Mode;
+import org.apache.isis.runtimes.dflt.runtime.persistence.ObjectPersistenceException;
+import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.ObjectStoreSpi;
+import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.PojoAdapterBuilder.Persistence;
+import org.apache.isis.runtimes.dflt.runtime.system.transaction.IsisTransaction;
+import org.apache.isis.runtimes.dflt.runtime.system.transaction.IsisTransactionManager;
+import org.apache.isis.runtimes.dflt.runtime.system.transaction.MessageBroker;
+import org.apache.isis.runtimes.dflt.runtime.system.transaction.UpdateNotifier;
+
+public class TransactionTest {
+
+    @Rule
+    public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
+    
+    private IsisTransaction transaction;
+
+    private ObjectAdapter transientAdapter1;
+    private ObjectAdapter transientAdapter2;
+
+    private ObjectAdapter persistentAdapter1;
+    private ObjectAdapter persistentAdapter2;
+
+    @Mock
+    private ObjectStoreSpi mockObjectStore;
+
+    @Mock
+    private IsisTransactionManager mockTransactionManager;
+    @Mock
+    private MessageBroker mockMessageBroker;
+    @Mock
+    private UpdateNotifier mockUpdateNotifier;
+
+    private PersistenceCommand command;
+    private PersistenceCommand command2;
+    private PersistenceCommand command3;
+
+    private CreateObjectCommand createCreateCommand(final ObjectAdapter object, final String name) {
+        return new CreateObjectCommand() {
+
+            @Override
+            public void execute(final PersistenceCommandContext context) throws ObjectPersistenceException {
+            }
+
+            @Override
+            public ObjectAdapter onAdapter() {
+                return object;
+            }
+
+            @Override
+            public String toString() {
+                return name;
+            }
+        };
+    }
+
+    private DestroyObjectCommand createDestroyCommand(final ObjectAdapter object, final String name) {
+        return new DestroyObjectCommand() {
+
+            @Override
+            public void execute(final PersistenceCommandContext context) throws ObjectPersistenceException {
+            }
+
+            @Override
+            public ObjectAdapter onAdapter() {
+                return object;
+            }
+
+            @Override
+            public String toString() {
+                return name;
+            }
+        };
+    }
+
+    private SaveObjectCommand createSaveCommand(final ObjectAdapter object, final String name) {
+        return new SaveObjectCommand() {
+            @Override
+            public void execute(final PersistenceCommandContext context) throws ObjectPersistenceException {
+            }
+
+            @Override
+            public ObjectAdapter onAdapter() {
+                return object;
+            }
+
+            @Override
+            public String toString() {
+                return name;
+            }
+        };
+    }
+
+    private SaveObjectCommand createSaveCommandThatAborts(final ObjectAdapter object, final String name) {
+        return new SaveObjectCommand() {
+            @Override
+            public void execute(final PersistenceCommandContext context) throws ObjectPersistenceException {
+                throw new ObjectPersistenceException();
+            }
+
+            @Override
+            public ObjectAdapter onAdapter() {
+                return object;
+            }
+
+            @Override
+            public String toString() {
+                return name;
+            }
+        };
+    }
+
+    @Before
+    public void setUp() throws Exception {
+        Logger.getRootLogger().setLevel(Level.OFF);
+
+        transaction = new IsisTransaction(mockTransactionManager, mockMessageBroker, mockUpdateNotifier, mockObjectStore);
+        
+        transientAdapter1 = PojoAdapterBuilder.create().with(Persistence.TRANSIENT).withIdentifier("1").build();
+        transientAdapter2 = PojoAdapterBuilder.create().with(Persistence.TRANSIENT).withIdentifier("2").build();
+        persistentAdapter1 = PojoAdapterBuilder.create().with(Persistence.PERSISTENT).withIdentifier("3").build();
+        persistentAdapter2 = PojoAdapterBuilder.create().with(Persistence.PERSISTENT).withIdentifier("4").build();
+    }
+    
+    @Test
+    public void abort_neverDelegatesToObjectStore() throws Exception {
+
+        command = createSaveCommand(transientAdapter1, "command 1");
+        command2 = createSaveCommand(transientAdapter2, "command 2");
+
+        context.checking(new Expectations() {
+            {
+                never(mockObjectStore);
+            }
+        });
+
+        transaction.addCommand(command);
+        transaction.addCommand(command2);
+        transaction.abort();
+    }
+
+
+    @Test
+    public void commit_delegatesToObjectStoreToExecutesAllCommands() throws Exception {
+
+        command = createSaveCommand(transientAdapter1, "command 1");
+        command2 = createSaveCommandThatAborts(transientAdapter2, "command 2");
+
+        context.checking(new Expectations() {
+            {
+                one(mockObjectStore).execute(with(IsisMatchers.listContainingAll(command, command2)));
+            }
+        });
+        
+        transaction.addCommand(command);
+        transaction.addCommand(command2);
+        transaction.commit();
+    }
+
+    @Test
+    public void commit_disregardsSecondSaveCommandOnSameAdapter() throws Exception {
+
+        command = createSaveCommand(persistentAdapter1, "command 1");
+        command2 = createSaveCommand(persistentAdapter1, "command 2");
+
+        context.checking(new Expectations() {
+            {
+                one(mockObjectStore).execute(with(IsisMatchers.listContainingAll(command)));
+            }
+        });
+        
+        transaction.addCommand(command);
+        transaction.addCommand(command2);
+        transaction.commit();
+    }
+
+
+    @Test
+    public void commit_disregardsSaveCommandsForObjectBeingCreated() throws Exception {
+
+        command = createCreateCommand(transientAdapter1, "command 1");
+        command2 = createSaveCommandThatAborts(transientAdapter1, "command 2");
+
+        context.checking(new Expectations() {
+            {
+                one(mockObjectStore).execute(with(IsisMatchers.listContainingAll(command)));
+            }
+        });
+        
+        transaction.addCommand(command);
+        transaction.addCommand(command2);
+        transaction.commit();
+    }
+
+    @Test
+    public void commit_destroyCausesPrecedingSaveCommandsToBeDisregarded() throws Exception {
+
+        command = createSaveCommand(persistentAdapter1, "command 1");
+        command2 = createSaveCommand(persistentAdapter2, "command 2");
+        command3 = createDestroyCommand(persistentAdapter1, "command 3");
+
+        context.checking(new Expectations() {
+            {
+                one(mockObjectStore).execute(with(IsisMatchers.listContainingAll(command2, command3)));
+            }
+        });
+        
+        transaction.addCommand(command);
+        transaction.addCommand(command2);
+        transaction.addCommand(command3);
+        transaction.commit();
+    }
+
+    @Test
+    public void commit_ignoresBothCreateAndDestroyCommandsWhenForSameObject() throws Exception {
+
+        command = createSaveCommand(persistentAdapter1, "command 1");
+        command2 = createSaveCommand(persistentAdapter2, "command 2");
+        command3 = createDestroyCommand(persistentAdapter1, "command 3");
+
+        context.checking(new Expectations() {
+            {
+                one(mockObjectStore).execute(with(IsisMatchers.listContainingAll(command2)));
+            }
+        });
+        
+        transaction.addCommand(command);
+        transaction.addCommand(command2);
+        transaction.addCommand(command3);
+        transaction.commit();
+    }
+
+
+    @Test
+    public void commit_testNoCommands() throws Exception {
+        context.checking(new Expectations() {
+            {
+                one(mockObjectStore).execute(with(Collections.<PersistenceCommand>emptyList()));
+            }
+        });
+
+        transaction.commit();
+    }
+
+
+    @Test(expected = IllegalStateException.class)
+    public void shouldThrowExceptionIfAttemptToAbortAnAlreadyAbortedTransaction() throws Exception {
+        transaction.abort();
+
+        transaction.abort();
+    }
+
+    @Test(expected = IllegalStateException.class)
+    public void shouldThrowExceptionIfAttemptToCommitAnAlreadyAbortedTransaction() throws Exception {
+        transaction.abort();
+
+        transaction.commit();
+    }
+
+    @Test(expected = IllegalStateException.class)
+    public void shouldThrowExceptionIfAttemptToAbortAnAlreadyCommitedTransaction() throws Exception {
+        context.checking(new Expectations() {
+            {
+                one(mockObjectStore).execute(with(Collections.<PersistenceCommand>emptyList()));
+            }
+        });
+
+        transaction.commit();
+
+        transaction.abort();
+    }
+
+    @Test(expected = IllegalStateException.class)
+    public void shouldThrowExceptionIfAttemptToCommitAnAlreadyCommitedTransaction() throws Exception {
+        context.checking(new Expectations() {
+            {
+                one(mockObjectStore).execute(with(Collections.<PersistenceCommand>emptyList()));
+            }
+        });
+        transaction.commit();
+
+        transaction.commit();
+    }
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/profiler/ProfilerTest.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/profiler/ProfilerTest.java b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/profiler/ProfilerTest.java
new file mode 100644
index 0000000..2bb3c4b
--- /dev/null
+++ b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/profiler/ProfilerTest.java
@@ -0,0 +1,111 @@
+/*
+ *  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.runtime.profiler;
+
+import junit.framework.TestCase;
+
+import org.apache.isis.core.runtime.profiler.Profiler;
+
+public class ProfilerTest extends TestCase {
+    public static void main(final String[] args) {
+        junit.textui.TestRunner.run(ProfilerTest.class);
+    }
+
+    private Profiler profiler;
+
+    @Override
+    public void setUp() {
+        Profiler.setProfilerSystem(new ProfilerTestSystem());
+        profiler = new Profiler("name");
+    }
+
+    public void testFreeMemory() {
+        assertEquals("20,300 bytes", Profiler.memoryLog());
+    }
+
+    public void testMemoryUsage() {
+        assertEquals(10300, profiler.getMemoryUsage());
+        assertEquals(20000, profiler.getMemoryUsage());
+    }
+
+    public void testMemoryUsageLog() {
+        assertEquals("10,300 bytes", profiler.memoryUsageLog());
+    }
+
+    public void testTiming() {
+        profiler.start();
+        profiler.stop();
+        assertEquals(100, profiler.getElapsedTime());
+    }
+
+    public void testTimingLog() {
+        profiler.start();
+        profiler.stop();
+        assertEquals("0.1 secs", profiler.timeLog());
+    }
+
+    public void testContinueWithStartAndStopPausesTiming() {
+        profiler.start();
+        profiler.stop();
+
+        profiler.start();
+        profiler.stop();
+        assertEquals(400, profiler.getElapsedTime());
+    }
+
+    public void testResetDuringTiming() {
+        profiler.start();
+
+        profiler.reset();
+        assertEquals(200, profiler.getElapsedTime());
+    }
+
+    public void testResetAfterStopResetsToZero() {
+        profiler.start();
+        profiler.stop();
+
+        profiler.reset();
+        assertEquals(0, profiler.getElapsedTime());
+
+        profiler.start();
+        profiler.stop();
+        assertEquals(400, profiler.getElapsedTime());
+    }
+
+    public void testZero() {
+        assertEquals(0, profiler.getElapsedTime());
+    }
+
+    public void testRepeatedElapseTimeAfterStopGivesSameTime() {
+        profiler.start();
+        profiler.stop();
+        assertEquals(100, profiler.getElapsedTime());
+        assertEquals(100, profiler.getElapsedTime());
+        assertEquals(100, profiler.getElapsedTime());
+    }
+
+    public void testRepeatedElapseTimeGivesLatestTime() {
+        profiler.start();
+        assertEquals(100, profiler.getElapsedTime());
+        assertEquals(300, profiler.getElapsedTime());
+        assertEquals(600, profiler.getElapsedTime());
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/profiler/ProfilerTestSystem.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/profiler/ProfilerTestSystem.java b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/profiler/ProfilerTestSystem.java
new file mode 100644
index 0000000..e5a6013
--- /dev/null
+++ b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/profiler/ProfilerTestSystem.java
@@ -0,0 +1,39 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.runtimes.dflt.runtime.profiler;
+
+import org.apache.isis.core.runtime.profiler.ProfilerSystem;
+
+public class ProfilerTestSystem extends ProfilerSystem {
+    long[] memory = new long[] { 10000, 20300, 30000 };
+    int memoryIndex = 0;
+    long[] time = new long[] { 1000, 1100, 1300, 1600, 2000 };
+    int timeIndex = 0;
+
+    @Override
+    protected long memory() {
+        return memory[memoryIndex++];
+    }
+
+    @Override
+    protected long time() {
+        return time[timeIndex++];
+    }
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/Interface1.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/Interface1.java b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/Interface1.java
new file mode 100644
index 0000000..12ba4d3
--- /dev/null
+++ b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/Interface1.java
@@ -0,0 +1,24 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.runtimes.dflt.runtime.system;
+
+public interface Interface1 {
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/JavaActionTestObject.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/JavaActionTestObject.java b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/JavaActionTestObject.java
new file mode 100644
index 0000000..6ee406d
--- /dev/null
+++ b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/JavaActionTestObject.java
@@ -0,0 +1,55 @@
+/*
+ *  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.runtime.system;
+
+public class JavaActionTestObject {
+    private boolean actionCalled = false;
+
+    public void actionMethod() {
+        actionCalled = true;
+    }
+
+    public static String nameMethod() {
+        return "about for test";
+    }
+
+    public boolean invisibleMethod() {
+        return true;
+    }
+
+    public String validMethod() {
+        return "invalid";
+    }
+
+    public void actionWithParam(final String str) {
+    }
+
+    public static boolean[] mandatoryMethod(final String str) {
+        return new boolean[] { true };
+    }
+
+    public static String[] labelMethod(final String str) {
+        return new String[] { "label" };
+    }
+
+    public boolean actionCalled() {
+        return actionCalled;
+    }
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/JavaObjectMarkedAsTransient.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/JavaObjectMarkedAsTransient.java b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/JavaObjectMarkedAsTransient.java
new file mode 100644
index 0000000..76a396d
--- /dev/null
+++ b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/JavaObjectMarkedAsTransient.java
@@ -0,0 +1,26 @@
+/*
+ *  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.runtime.system;
+
+import org.apache.isis.applib.marker.NonPersistable;
+
+public class JavaObjectMarkedAsTransient implements NonPersistable {
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/JavaObjectWithBasicProgramConventions.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/JavaObjectWithBasicProgramConventions.java b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/JavaObjectWithBasicProgramConventions.java
new file mode 100644
index 0000000..8b5aa21
--- /dev/null
+++ b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/JavaObjectWithBasicProgramConventions.java
@@ -0,0 +1,272 @@
+/*
+ *  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.runtime.system;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Assert;
+
+import org.apache.isis.applib.security.UserMemento;
+
+public class JavaObjectWithBasicProgramConventions implements Interface1, Interface2 {
+    public static String classActionValid;
+    public String objectActionValid;
+    private final List<Object> collection = new ArrayList<Object>();
+
+    public static String pluralName() {
+        return "Plural";
+    }
+
+    public static String singularName() {
+        return "Singular";
+    }
+
+    public static String getFour() {
+        return "";
+    }
+
+    public static void setFour(final String value) {
+    }
+
+    public String getOne() {
+        return "";
+    }
+
+    public String defaultOne() {
+        return "default value";
+    }
+
+    public String[] choicesOne() {
+        return new String[] { "four", "five", "six" };
+    }
+
+    public void setOne(final String value) {
+    }
+
+    public static boolean optionalOne() {
+        return true;
+
+    }
+
+    public static String disableOne(final UserMemento user) {
+        return "no edits";
+    }
+
+    public boolean hideFieldTwo() {
+        return true;
+    }
+
+    private JavaReferencedObject object;
+
+    public JavaReferencedObject getFieldTwo() {
+        return object;
+    }
+
+    public void setFieldTwo(final JavaReferencedObject object) {
+        this.object = object;
+    }
+
+    // field two should be hidden for the user
+    public static boolean hideFieldTwo(final UserMemento user) {
+        Assert.assertEquals("unit tester", user.getName());
+        return true;
+    }
+
+    // this field should not be persisted as it has no setter
+    public JavaReferencedObject getThree() {
+        return null;
+    }
+
+    public static boolean alwaysHideSix() {
+        return true;
+    }
+
+    public String[] choicesSix() {
+        return new String[] { "one", "two" };
+    }
+
+    public String getSix() {
+        return "";
+    }
+
+    public void setSix(final String value) {
+    }
+
+    public String disableSeven() {
+        return "no changes";
+    }
+
+    public String getSeven() {
+        return "";
+    }
+
+    public void setSeven(final String value) {
+    }
+
+    public static boolean protectEight() {
+        return true;
+    }
+
+    public String getEight() {
+        return "";
+    }
+
+    public void setEight(final String value) {
+    }
+
+    public void setValue(final String value) {
+    }
+
+    public static String nameStop() {
+        return "object action name";
+    }
+
+    public static String descriptionStop() {
+        return "object action description";
+    }
+
+    public String validateStart(final String param) {
+        return objectActionValid;
+    }
+
+    public void stop() {
+    }
+
+    public static boolean[] optionalStart() {
+        return new boolean[] { true };
+    }
+
+    public String[] defaultStart() {
+        return new String[] { "default param" };
+    }
+
+    public String[][] choicesStart() {
+        return new String[][] { { "one", "two", "three" } };
+    }
+
+    public void start2(final String name) {
+    }
+
+    public Object[] choicesStart2() {
+        return new Object[] { new String[] { "three", "two", "one" } };
+    }
+
+    public static String validateTop() {
+        return classActionValid;
+    }
+
+    public static String[] namesStart() {
+        return new String[] { "parameter name" };
+    }
+
+    public int start(final String param) {
+        return 1;
+    }
+
+    public static String nameTop() {
+        return "class action name";
+    }
+
+    public static String descriptionTop() {
+        return "class action description";
+    }
+
+    public static void top() {
+    }
+
+    public static void bottom(final String param) {
+    }
+
+    public static String actionOrder() {
+        // make sure there is an action which doesn't exist
+        return "missing, start, stop";
+    }
+
+    public static String classActionOrder() {
+        return "top, bottom";
+    }
+
+    public static String fieldOrder() {
+        return "one, field two ,three, five";
+    }
+
+    // tests the hide method with same set of paramaters
+    public static boolean alwaysHideHiddenAction(final String param) {
+        return true;
+    }
+
+    public void hiddenAction(final String param) {
+    }
+
+    // tests the hide method with no paramaters
+    public static boolean alwaysHideHiddenAction2() {
+        return true;
+    }
+
+    public void hiddenAction2(final String param1, final String param2) {
+    }
+
+    public static boolean hideHiddenToUser(final UserMemento user) {
+        Assert.assertEquals("unit tester", user.getName());
+        return true;
+    }
+
+    public void hiddenToUser() {
+    }
+
+    public List<Object> getFive() {
+        return collection;
+    }
+
+    public void addToFive(final JavaReferencedObject person) {
+    }
+
+    public void removeFromFive(final JavaReferencedObject person) {
+    }
+
+    public static String nameFive() {
+        return "five";
+    }
+
+    public List getNine() {
+        return collection;
+    }
+
+    // method that would be run on client
+    public void localRunOnClient() {
+    }
+
+    // method that would be run on the server
+    public void remoteRunOnServer() {
+    }
+
+    // method for debug access
+    public String debugTwo(final String parameter) {
+        return "action two";
+    }
+
+    // exploration method
+    public void explorationSetUp() {
+    }
+}
+
+interface Interface2 {
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/JavaObjectWithOneToOneAssociations.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/JavaObjectWithOneToOneAssociations.java b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/JavaObjectWithOneToOneAssociations.java
new file mode 100644
index 0000000..9a229a0
--- /dev/null
+++ b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/JavaObjectWithOneToOneAssociations.java
@@ -0,0 +1,47 @@
+/*
+ *  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.runtime.system;
+
+public class JavaObjectWithOneToOneAssociations {
+    boolean available = false;
+    private JavaReferencedObject object;
+    boolean valid = false;
+    boolean visible = false;
+
+    public String availableReferencedObject(final JavaReferencedObject object) {
+        return available ? null : "not available";
+    }
+
+    public JavaReferencedObject getReferencedObject() {
+        return object;
+    }
+
+    public void setReferencedObject(final JavaReferencedObject object) {
+        this.object = object;
+    }
+
+    public String validReferencedObject(final JavaReferencedObject object) {
+        return valid ? null : "not valid";
+    }
+
+    public boolean hideReferencedObject(final JavaReferencedObject object) {
+        return !visible;
+    }
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/JavaReferencedObject.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/JavaReferencedObject.java b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/JavaReferencedObject.java
new file mode 100644
index 0000000..6c638be
--- /dev/null
+++ b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/JavaReferencedObject.java
@@ -0,0 +1,35 @@
+/*
+ *  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.runtime.system;
+
+public class JavaReferencedObject {
+    private static int next;
+    private final int id = next++;
+
+    public JavaReferencedObject() {
+        super();
+    }
+
+    @Override
+    public String toString() {
+        return "JavaReferencedObject#" + id;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/MethodFinderUtilsTest.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/MethodFinderUtilsTest.java b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/MethodFinderUtilsTest.java
new file mode 100644
index 0000000..54a8482
--- /dev/null
+++ b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/MethodFinderUtilsTest.java
@@ -0,0 +1,84 @@
+/*
+ *  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.runtime.system;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.junit.Assert.assertThat;
+
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.Collection;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import org.apache.isis.core.commons.lang.MethodUtils;
+import org.apache.isis.core.metamodel.methodutils.MethodFinderUtils;
+import org.apache.isis.core.metamodel.methodutils.MethodScope;
+
+@RunWith(Parameterized.class)
+public class MethodFinderUtilsTest {
+
+    private static Method staticMethod;
+    private static Method instanceMethod;
+
+    static {
+        staticMethod = MethodUtils.findMethodElseNull(MethodFinderUtilsTest.class, "someStaticMethod");
+        instanceMethod = MethodUtils.findMethodElseNull(MethodFinderUtilsTest.class, "someInstanceMethod");
+    }
+
+    private final MethodScope methodScope;
+    private final Method method;
+    private final boolean result;
+
+    @Before
+    public void setUp() {
+        assertThat(staticMethod, is(not(nullValue())));
+        assertThat(instanceMethod, is(not(nullValue())));
+    }
+
+    @Parameters
+    public static Collection parameters() {
+        return Arrays.asList(new Object[][] { { MethodScope.OBJECT, staticMethod, false }, { MethodScope.CLASS, staticMethod, true }, { MethodScope.OBJECT, instanceMethod, true }, { MethodScope.CLASS, instanceMethod, false }, });
+    }
+
+    public static void someStaticMethod() {
+    }
+
+    public void someInstanceMethod() {
+    }
+
+    public MethodFinderUtilsTest(final MethodScope methodScope, final Method method, final boolean result) {
+        this.methodScope = methodScope;
+        this.method = method;
+        this.result = result;
+    }
+
+    @Test
+    public void all() {
+        assertThat(MethodFinderUtils.inScope(methodScope, method), is(result));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/ObjectActionImplTest.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/ObjectActionImplTest.java b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/ObjectActionImplTest.java
new file mode 100644
index 0000000..76b05ca
--- /dev/null
+++ b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/ObjectActionImplTest.java
@@ -0,0 +1,160 @@
+/*
+ *  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.runtime.system;
+
+import static org.junit.Assert.assertEquals;
+
+import org.jmock.Expectations;
+import org.jmock.auto.Mock;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.isis.applib.Identifier;
+import org.apache.isis.core.commons.authentication.AuthenticationSessionProvider;
+import org.apache.isis.core.metamodel.adapter.QuerySubmitter;
+import org.apache.isis.core.metamodel.adapter.ServicesProvider;
+import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
+import org.apache.isis.core.metamodel.deployment.DeploymentCategory;
+import org.apache.isis.core.metamodel.facets.FacetedMethod;
+import org.apache.isis.core.metamodel.facets.named.NamedFacet;
+import org.apache.isis.core.metamodel.facets.named.NamedFacetAbstract;
+import org.apache.isis.core.metamodel.spec.SpecificationLoader;
+import org.apache.isis.core.metamodel.spec.feature.ObjectMemberContext;
+import org.apache.isis.core.metamodel.specloader.collectiontyperegistry.CollectionTypeRegistry;
+import org.apache.isis.core.metamodel.specloader.specimpl.ObjectActionImpl;
+import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2;
+import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2.Mode;
+
+public class ObjectActionImplTest {
+
+    @Rule
+    public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
+    
+    
+    private ObjectActionImpl action;
+    
+    @Mock
+    private FacetedMethod mockFacetedMethod;
+
+    @Mock
+    private AuthenticationSessionProvider mockAuthenticationSessionProvider;
+    @Mock
+    private SpecificationLoader mockSpecificationLookup;
+    @Mock
+    private AdapterManager mockAdapterManager;
+    @Mock
+    private ServicesProvider mockServicesProvider;
+    @Mock
+    private QuerySubmitter mockQuerySubmitter;
+    @Mock
+    private CollectionTypeRegistry mockCollectionTypeRegistry;
+
+//    protected TestProxySystem system;
+//
+//    private TestProxyConfiguration mockConfiguration;
+//    private TestProxyReflector mockReflector;
+//    private AuthenticationSession mockAuthSession;
+//    private TestProxyPersistenceSessionFactory mockPersistenceSessionFactory;
+//    private TestProxyPersistenceSession mockPersistenceSession;
+//    private TestUserProfileStore mockUserProfileStore;
+
+    @Before
+    public void setUp() throws Exception {
+//        Logger.getRootLogger().setLevel(Level.OFF);
+//        
+//        system = new TestProxySystem();
+//        
+//        mockConfiguration = new TestProxyConfiguration();
+//        mockReflector = new TestProxyReflector();
+//        mockAuthSession = new TestProxySession();
+//        mockPersistenceSessionFactory = new TestProxyPersistenceSessionFactory();
+//        mockPersistenceSession = new TestProxyPersistenceSession(mockPersistenceSessionFactory);
+//        mockPersistenceSessionFactory.setPersistenceSessionToCreate(mockPersistenceSession);
+//        mockUserProfileStore = new TestUserProfileStore();
+//        
+//        system.openSession(mockConfiguration, mockReflector, mockAuthSession, null, null, null, mockUserProfileStore, null, mockPersistenceSessionFactory, null);
+
+        context.checking(new Expectations() {
+            {
+                one(mockFacetedMethod).getIdentifier();
+                will(returnValue(Identifier.actionIdentifier("Customer", "reduceheadcount")));
+            }
+        });
+
+        action = new ObjectActionImpl(mockFacetedMethod, new ObjectMemberContext(DeploymentCategory.PRODUCTION, mockAuthenticationSessionProvider, mockSpecificationLookup, mockAdapterManager, mockQuerySubmitter, mockCollectionTypeRegistry), mockServicesProvider);
+    }
+
+    @Ignore // DKH
+    @Test
+    public void testExecutePassedOnToPeer() {
+//        final TestProxyAdapter target = new TestProxyAdapter();
+//        target.setupSpecification(new TestSpecification());
+//        final ObjectAdapter[] parameters = new ObjectAdapter[2];
+//
+//        final TestProxyAdapter result = new TestProxyAdapter();
+//        final ActionInvocationFacet facet = new ActionInvocationFacetAbstract(mockFacetedMethod) {
+//            @Override
+//            public ObjectAdapter invoke(final ObjectAdapter target, final ObjectAdapter[] parameters) {
+//                return result;
+//            }
+//
+//            @Override
+//            public ObjectSpecification getReturnType() {
+//                return null;
+//            }
+//
+//            @Override
+//            public ObjectSpecification getOnType() {
+//                return new TestSpecification();
+//            }
+//        };
+//
+//        context.checking(new Expectations() {
+//            {
+//                exactly(2).of(mockFacetedMethod).getFacet(ActionInvocationFacet.class);
+//                will(returnValue(facet));
+//            }
+//        });
+//
+//        final ObjectAdapter returnObject = action.execute(target, parameters);
+//        assertEquals(returnObject, result);
+    }
+
+    @Test
+    public void testNameDefaultsToActionsMethodName() {
+        final NamedFacet facet = new NamedFacetAbstract("Reduceheadcount", mockFacetedMethod) {
+        };
+        context.checking(new Expectations() {
+            {
+                one(mockFacetedMethod).getFacet(NamedFacet.class);
+                will(returnValue(facet));
+            }
+        });
+        assertEquals("Reduceheadcount", action.getName());
+    }
+
+    @Test
+    public void testId() {
+        assertEquals("reduceheadcount", action.getId());
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/ObjectMemberAbstractTest.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/ObjectMemberAbstractTest.java b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/ObjectMemberAbstractTest.java
new file mode 100644
index 0000000..dfa5547
--- /dev/null
+++ b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/ObjectMemberAbstractTest.java
@@ -0,0 +1,246 @@
+/*
+ *  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.runtime.system;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.isis.applib.annotation.When;
+import org.apache.isis.applib.annotation.Where;
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.consent.Consent;
+import org.apache.isis.core.metamodel.consent.InteractionInvocationMethod;
+import org.apache.isis.core.metamodel.deployment.DeploymentCategory;
+import org.apache.isis.core.metamodel.facetapi.FeatureType;
+import org.apache.isis.core.metamodel.facets.FacetedMethod;
+import org.apache.isis.core.metamodel.facets.describedas.DescribedAsFacetAbstract;
+import org.apache.isis.core.metamodel.facets.named.NamedFacetAbstract;
+import org.apache.isis.core.metamodel.interactions.PropertyUsabilityContext;
+import org.apache.isis.core.metamodel.interactions.PropertyVisibilityContext;
+import org.apache.isis.core.metamodel.interactions.UsabilityContext;
+import org.apache.isis.core.metamodel.interactions.VisibilityContext;
+import org.apache.isis.core.metamodel.spec.Instance;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.feature.ObjectMemberContext;
+import org.apache.isis.core.metamodel.specloader.specimpl.ObjectMemberAbstract;
+import org.apache.isis.core.progmodel.facets.members.disabled.DisableForSessionFacetAbstract;
+import org.apache.isis.core.progmodel.facets.members.hidden.HiddenFacetAbstract;
+import org.apache.isis.core.progmodel.facets.members.hidden.HiddenFacetImpl;
+import org.apache.isis.core.progmodel.facets.members.hidden.HiddenFacetNever;
+import org.apache.isis.core.progmodel.facets.members.hidden.HideForContextFacetNone;
+import org.apache.isis.core.progmodel.facets.members.hidden.HideForSessionFacetAbstract;
+import org.apache.isis.core.progmodel.facets.members.hidden.staticmethod.HiddenFacetAlwaysEverywhere;
+import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2;
+import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2.Mode;
+import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.PojoAdapterBuilder;
+import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.PojoAdapterBuilder.Persistence;
+
+public class ObjectMemberAbstractTest {
+
+    @Rule
+    public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
+    
+    private ObjectMemberAbstractImpl testMember;
+    
+    private ObjectAdapter persistentAdapter;
+    private ObjectAdapter transientAdapter;
+    
+    @Before
+    public void setUp() throws Exception {
+        Logger.getRootLogger().setLevel(Level.OFF);
+
+        persistentAdapter = PojoAdapterBuilder.create().build();
+        transientAdapter = PojoAdapterBuilder.create().with(Persistence.TRANSIENT).build();
+
+        testMember = new ObjectMemberAbstractImpl("id");
+    }
+
+
+    @Test
+    public void testToString() throws Exception {
+        testMember.addFacet(new NamedFacetAbstract("", testMember) {});
+        assertTrue(testMember.toString().length() > 0);
+    }
+
+    @Test
+    public void testAvailableForUser() throws Exception {
+        testMember.addFacet(new DisableForSessionFacetAbstract(testMember) {
+            @Override
+            public String disabledReason(final AuthenticationSession session) {
+                return null;
+            }
+        });
+        final Consent usable = testMember.isUsable(null, persistentAdapter, Where.ANYWHERE);
+        final boolean allowed = usable.isAllowed();
+        assertTrue(allowed);
+    }
+
+    @Test
+    public void testVisibleWhenHiddenFacetSetToAlways() {
+        testMember.addFacet(new HideForContextFacetNone(testMember));
+        testMember.addFacet(new HiddenFacetAbstract(When.ALWAYS, Where.ANYWHERE, testMember) {
+            @Override
+            public String hiddenReason(final ObjectAdapter target, final Where whereContext) {
+                return null;
+            }
+        });
+        final Consent visible = testMember.isVisible(null, persistentAdapter, Where.ANYWHERE);
+        assertTrue(visible.isAllowed());
+    }
+
+    @Test
+    public void testVisibleWhenTargetPersistentAndHiddenFacetSetToOncePersisted() {
+        testMember.addFacet(new HideForContextFacetNone(testMember));
+        testMember.addFacet(new HiddenFacetImpl(When.ONCE_PERSISTED, Where.ANYWHERE, testMember));
+        assertFalse(testMember.isVisible(null, persistentAdapter, Where.ANYWHERE).isAllowed());
+    }
+
+    @Test
+    public void testVisibleWhenTargetPersistentAndHiddenFacetSetToUntilPersisted() {
+        testMember.addFacet(new HideForContextFacetNone(testMember));
+        testMember.addFacet(new HiddenFacetImpl(When.UNTIL_PERSISTED, Where.ANYWHERE, testMember));
+        final Consent visible = testMember.isVisible(null, persistentAdapter, Where.ANYWHERE);
+        assertTrue(visible.isAllowed());
+    }
+
+    @Test
+    public void testVisibleWhenTargetTransientAndHiddenFacetSetToUntilPersisted() {
+        testMember.addFacet(new HideForContextFacetNone(testMember));
+        testMember.addFacet(new HiddenFacetImpl(When.UNTIL_PERSISTED, Where.ANYWHERE, testMember));
+        
+        final Consent visible = testMember.isVisible(null, transientAdapter, Where.ANYWHERE);
+        assertFalse(visible.isAllowed());
+    }
+
+    @Test
+    public void testVisibleDeclarativelyByDefault() {
+        testMember.addFacet(new HiddenFacetNever(testMember) {
+        });
+        assertTrue(testMember.isVisible(null, persistentAdapter, Where.ANYWHERE).isAllowed());
+    }
+
+    @Test
+    public void testVisibleDeclaratively() {
+        testMember.addFacet(new HiddenFacetAlwaysEverywhere(testMember) {
+        });
+        assertFalse(testMember.isVisible(null, persistentAdapter, Where.ANYWHERE).isAllowed());
+    }
+
+    @Test
+    public void testVisibleForSessionByDefault() {
+        final Consent visible = testMember.isVisible(null, persistentAdapter, Where.ANYWHERE);
+        assertTrue(visible.isAllowed());
+    }
+
+    @Test
+    public void testVisibleForSession() {
+        testMember.addFacet(new HideForSessionFacetAbstract(testMember) {
+            @Override
+            public String hiddenReason(final AuthenticationSession session) {
+                return "Hidden";
+            }
+        });
+        assertFalse(testMember.isVisible(null, persistentAdapter, Where.ANYWHERE).isAllowed());
+    }
+
+    @Test
+    public void testVisibleForSessionFails() {
+        testMember.addFacet(new HideForSessionFacetAbstract(testMember) {
+            @Override
+            public String hiddenReason(final AuthenticationSession session) {
+                return "hidden";
+            }
+        });
+        assertFalse(testMember.isVisible(null, persistentAdapter, Where.ANYWHERE).isAllowed());
+    }
+
+    @Test
+    public void testName() throws Exception {
+        final String name = "action name";
+        testMember.addFacet(new NamedFacetAbstract(name, testMember) {
+        });
+        assertEquals(name, testMember.getName());
+    }
+
+    @Test
+    public void testDescription() throws Exception {
+        final String name = "description text";
+        testMember.addFacet(new DescribedAsFacetAbstract(name, testMember) {
+        });
+        assertEquals(name, testMember.getDescription());
+    }
+}
+
+class ObjectMemberAbstractImpl extends ObjectMemberAbstract {
+
+    public static class Customer {
+        private String firstName;
+
+        public String getFirstName() {
+            return firstName;
+        }
+    }
+
+    protected ObjectMemberAbstractImpl(final String id) {
+        super(FacetedMethod.createForProperty(Customer.class, "firstName"), FeatureType.PROPERTY, new ObjectMemberContext(DeploymentCategory.PRODUCTION, null, null, null, null, null));
+    }
+
+    @Override
+    public String debugData() {
+        return null;
+    }
+
+    public Consent isUsable(final ObjectAdapter target) {
+        return null;
+    }
+
+    @Override
+    public ObjectSpecification getSpecification() {
+        return null;
+    }
+
+    @Override
+    public UsabilityContext<?> createUsableInteractionContext(final AuthenticationSession session, final InteractionInvocationMethod invocationMethod, final ObjectAdapter target, Where where) {
+        return new PropertyUsabilityContext(DeploymentCategory.PRODUCTION, session, invocationMethod, target, getIdentifier(), where);
+    }
+
+    @Override
+    public VisibilityContext<?> createVisibleInteractionContext(final AuthenticationSession session, final InteractionInvocationMethod invocationMethod, final ObjectAdapter targetObjectAdapter, Where where) {
+        return new PropertyVisibilityContext(DeploymentCategory.PRODUCTION, session, invocationMethod, targetObjectAdapter, getIdentifier(), where);
+    }
+
+    // /////////////////////////////////////////////////////////////
+    // getInstance
+    // /////////////////////////////////////////////////////////////
+
+    @Override
+    public Instance getInstance(final ObjectAdapter adapter) {
+        return null;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/OneToManyAssociationImplTest.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/OneToManyAssociationImplTest.java b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/OneToManyAssociationImplTest.java
new file mode 100644
index 0000000..723e29e
--- /dev/null
+++ b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/OneToManyAssociationImplTest.java
@@ -0,0 +1,183 @@
+/*
+ *  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.runtime.system;
+
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+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.applib.Identifier;
+import org.apache.isis.core.commons.authentication.AuthenticationSessionProvider;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.QuerySubmitter;
+import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
+import org.apache.isis.core.metamodel.deployment.DeploymentCategory;
+import org.apache.isis.core.metamodel.facets.FacetedMethod;
+import org.apache.isis.core.metamodel.facets.collections.modify.CollectionAddToFacet;
+import org.apache.isis.core.metamodel.facets.named.NamedFacet;
+import org.apache.isis.core.metamodel.facets.notpersisted.NotPersistedFacet;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.SpecificationLoader;
+import org.apache.isis.core.metamodel.spec.feature.ObjectMemberContext;
+import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
+import org.apache.isis.core.metamodel.specloader.collectiontyperegistry.CollectionTypeRegistry;
+import org.apache.isis.core.metamodel.specloader.specimpl.OneToManyAssociationImpl;
+import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2;
+import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2.Mode;
+
+public class OneToManyAssociationImplTest {
+
+    private static final String COLLECTION_ID = "orders";
+
+    public static class Customer {
+    }
+
+    public static class Order {
+    }
+
+    private static final Class<?> COLLECTION_TYPE = Order.class;
+
+    @Rule
+    public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
+
+    @Mock
+    private ObjectAdapter mockOwnerAdapter;
+    @Mock
+    private ObjectAdapter mockAssociatedAdapter;
+    @Mock
+    private AuthenticationSessionProvider mockAuthenticationSessionProvider;
+    @Mock
+    private SpecificationLoader mockSpecificationLookup;
+    @Mock
+    private AdapterManager mockAdapterManager;
+    @Mock
+    private QuerySubmitter mockQuerySubmitter;
+    @Mock
+    private FacetedMethod mockPeer;
+    @Mock
+    private NamedFacet mockNamedFacet;
+    @Mock
+    private CollectionAddToFacet mockCollectionAddToFacet;
+    @Mock
+    private CollectionTypeRegistry mockCollectionTypeRegistry;
+    
+    private OneToManyAssociation association;
+
+    @Before
+    public void setUp() {
+        allowingPeerToReturnCollectionType();
+        allowingPeerToReturnIdentifier();
+        allowingSpecLoaderToReturnSpecs();
+        association = new OneToManyAssociationImpl(mockPeer, new ObjectMemberContext(DeploymentCategory.PRODUCTION, mockAuthenticationSessionProvider, mockSpecificationLookup, mockAdapterManager, mockQuerySubmitter, mockCollectionTypeRegistry));
+    }
+
+    private void allowingSpecLoaderToReturnSpecs() {
+        context.checking(new Expectations() {
+            {
+                allowing(mockSpecificationLookup).loadSpecification(Order.class);
+            }
+        });
+    }
+
+    @Test
+    public void id() {
+        assertThat(association.getId(), is(equalTo(COLLECTION_ID)));
+    }
+
+    @Test
+    public void name() {
+        expectPeerToReturnNamedFacet();
+        assertThat(association.getName(), is(equalTo("My name")));
+    }
+
+    @Test
+    public void delegatesToUnderlying() {
+        final ObjectSpecification spec = association.getSpecification();
+    }
+
+    @Test
+    public void canAddPersistable() {
+        context.checking(new Expectations() {
+            {
+                one(mockPeer).containsFacet(NotPersistedFacet.class);
+                will(returnValue(false));
+
+                one(mockOwnerAdapter).representsPersistent();
+                will(returnValue(true));
+
+                one(mockAssociatedAdapter).isTransient();
+                will(returnValue(false));
+
+                one(mockPeer).getFacet(CollectionAddToFacet.class);
+                will(returnValue(mockCollectionAddToFacet));
+
+                one(mockCollectionAddToFacet).add(mockOwnerAdapter, mockAssociatedAdapter);
+            }
+        });
+        association.addElement(mockOwnerAdapter, mockAssociatedAdapter);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void cannotRemoveNull() {
+        association.removeElement(mockOwnerAdapter, null);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void cannotAddNull() {
+        association.addElement(mockOwnerAdapter, null);
+    }
+
+    private void allowingPeerToReturnCollectionType() {
+        context.checking(new Expectations() {
+            {
+                allowing(mockPeer).getType();
+                will(returnValue(COLLECTION_TYPE));
+            }
+        });
+    }
+
+    private void allowingPeerToReturnIdentifier() {
+        context.checking(new Expectations() {
+            {
+                one(mockPeer).getIdentifier();
+                will(returnValue(Identifier.propertyOrCollectionIdentifier(Customer.class, COLLECTION_ID)));
+            }
+        });
+    }
+
+    private void expectPeerToReturnNamedFacet() {
+        context.checking(new Expectations() {
+            {
+                one(mockPeer).getFacet(NamedFacet.class);
+                will(returnValue(mockNamedFacet));
+
+                one(mockNamedFacet).value();
+                will(returnValue("My name"));
+            }
+        });
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/RuntimeTestPojo.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/RuntimeTestPojo.java b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/RuntimeTestPojo.java
new file mode 100644
index 0000000..b08eea4
--- /dev/null
+++ b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/RuntimeTestPojo.java
@@ -0,0 +1,51 @@
+/*
+ *  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.runtime.system;
+
+public class RuntimeTestPojo {
+    private static int nextId;
+    private final int id = nextId++;
+    private final String state = "pojo" + id;
+
+    @Override
+    public String toString() {
+        return "Pojo#" + id;
+    }
+
+    @Override
+    public boolean equals(final Object other) {
+        if (other == null) {
+            return false;
+        }
+        if (other == this) {
+            return true;
+        }
+        if (other.getClass() == getClass()) {
+            final RuntimeTestPojo otherTestPojo = (RuntimeTestPojo) other;
+            return otherTestPojo.state.equals(state);
+        }
+        return false;
+    }
+
+    @Override
+    public int hashCode() {
+        return state.hashCode();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/TestDomainObject.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/TestDomainObject.java b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/TestDomainObject.java
new file mode 100644
index 0000000..586d10a
--- /dev/null
+++ b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/TestDomainObject.java
@@ -0,0 +1,24 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.isis.runtimes.dflt.runtime.system;
+
+public class TestDomainObject {
+
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/TestObject.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/TestObject.java b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/TestObject.java
new file mode 100644
index 0000000..faf87d2
--- /dev/null
+++ b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/TestObject.java
@@ -0,0 +1,23 @@
+/*
+ *  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.runtime.system;
+
+public class TestObject {
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/TestObjectAsAggregated.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/TestObjectAsAggregated.java b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/TestObjectAsAggregated.java
new file mode 100644
index 0000000..c02b5bd
--- /dev/null
+++ b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/TestObjectAsAggregated.java
@@ -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.isis.runtimes.dflt.runtime.system;
+
+// import org.apache.isis.applib.Aggregated;
+
+public class TestObjectAsAggregated { // implements Aggregated {
+
+    public Object getAggregate() {
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/TestObjectAsService.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/TestObjectAsService.java b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/TestObjectAsService.java
new file mode 100644
index 0000000..7113601
--- /dev/null
+++ b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/TestObjectAsService.java
@@ -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.
+ */
+
+package org.apache.isis.runtimes.dflt.runtime.system;
+
+public class TestObjectAsService {
+
+    public String getId() {
+        return null;
+    }
+
+    public void init() {
+    }
+
+    public void action() {
+    }
+
+    public String title() {
+        return null;
+    }
+}