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/13 08:30:03 UTC
[3/58] ISIS-188: renaming packages, now builds ok (not yet tested)
http://git-wip-us.apache.org/repos/asf/isis/blob/978f79af/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/PersistenceSessionObjectStoreTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/PersistenceSessionObjectStoreTest.java b/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/PersistenceSessionObjectStoreTest.java
new file mode 100644
index 0000000..524e47c
--- /dev/null
+++ b/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/PersistenceSessionObjectStoreTest.java
@@ -0,0 +1,248 @@
+/*
+ * 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.core.runtime.persistence.objectstore;
+
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.assertThat;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.jmock.Expectations;
+import org.jmock.Sequence;
+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.matchers.IsisMatchers;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapterFactory;
+import org.apache.isis.core.metamodel.adapter.version.Version;
+import org.apache.isis.core.metamodel.runtimecontext.RuntimeContext;
+import org.apache.isis.core.metamodel.services.ServicesInjectorDefault;
+import org.apache.isis.core.metamodel.services.container.DomainObjectContainerDefault;
+import org.apache.isis.core.metamodel.spec.SpecificationLoaderSpi;
+import org.apache.isis.core.progmodel.app.IsisMetaModel;
+import org.apache.isis.core.runtime.persistence.adapter.PojoAdapter;
+import org.apache.isis.core.runtime.persistence.adapter.PojoAdapterFactory;
+import org.apache.isis.core.runtime.persistence.adaptermanager.AdapterManagerDefault;
+import org.apache.isis.core.runtime.persistence.adaptermanager.PojoRecreatorDefault;
+import org.apache.isis.core.runtime.persistence.internal.RuntimeContextFromSession;
+import org.apache.isis.core.runtime.persistence.objectstore.ObjectStoreSpi;
+import org.apache.isis.core.runtime.persistence.objectstore.algorithm.PersistAlgorithm;
+import org.apache.isis.core.runtime.persistence.objectstore.transaction.CreateObjectCommand;
+import org.apache.isis.core.runtime.persistence.objectstore.transaction.DestroyObjectCommand;
+import org.apache.isis.core.runtime.persistence.objectstore.transaction.PersistenceCommand;
+import org.apache.isis.core.runtime.persistence.objectstore.transaction.PojoAdapterBuilder;
+import org.apache.isis.core.runtime.persistence.objectstore.transaction.SaveObjectCommand;
+import org.apache.isis.core.runtime.persistence.objectstore.transaction.PojoAdapterBuilder.Persistence;
+import org.apache.isis.core.runtime.system.persistence.AdapterManagerSpi;
+import org.apache.isis.core.runtime.system.persistence.IdentifierGeneratorDefault;
+import org.apache.isis.core.runtime.system.persistence.ObjectFactory;
+import org.apache.isis.core.runtime.system.persistence.OidGenerator;
+import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
+import org.apache.isis.core.runtime.system.persistence.PersistenceSessionFactory;
+import org.apache.isis.core.runtime.system.transaction.IsisTransactionManager;
+import org.apache.isis.core.unittestsupport.jmock.auto.Mock;
+import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2;
+import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2.Mode;
+import org.apache.isis.progmodels.dflt.ProgrammingModelFacetsJava5;
+
+public class PersistenceSessionObjectStoreTest {
+
+ @Rule
+ public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
+
+ private ServicesInjectorDefault servicesInjector;
+ private AdapterManagerSpi adapterManager;
+ private ObjectAdapterFactory adapterFactory;
+
+
+ private PersistenceSession persistenceSession;
+ private IsisTransactionManager transactionManager;
+
+ private ObjectAdapter persistentAdapter;
+ private PojoAdapter transientAdapter;
+
+ @Mock
+ private PersistenceSessionFactory mockPersistenceSessionFactory;
+
+ @Mock
+ private ObjectStoreSpi mockObjectStore;
+ @Mock
+ private ObjectFactory objectFactory;
+ @Mock
+ private PersistAlgorithm mockPersistAlgorithm;
+
+ @Mock
+ private CreateObjectCommand createObjectCommand;
+ @Mock
+ private SaveObjectCommand saveObjectCommand;
+ @Mock
+ private DestroyObjectCommand destroyObjectCommand;
+
+ @Mock
+ private Version mockVersion;
+
+ @Mock
+ private RuntimeContext mockRuntimeContext;
+
+ @Mock
+ private IsisConfiguration mockConfiguration;
+
+
+ private IsisMetaModel isisMetaModel;
+
+
+
+ public static class Customer {
+ }
+
+ public static class CustomerRepository {
+ public Customer x() {return null;}
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ Logger.getRootLogger().setLevel(Level.OFF);
+
+ context.ignoring(mockRuntimeContext);
+ context.ignoring(mockConfiguration);
+
+ isisMetaModel = new IsisMetaModel(mockRuntimeContext, new ProgrammingModelFacetsJava5(), new CustomerRepository());
+ isisMetaModel.init();
+
+ context.checking(new Expectations() {
+ {
+ ignoring(mockObjectStore).open();
+ ignoring(mockObjectStore).close();
+ ignoring(mockObjectStore).name();
+ ignoring(mockPersistAlgorithm).name();
+
+ ignoring(createObjectCommand);
+ ignoring(saveObjectCommand);
+ ignoring(destroyObjectCommand);
+ ignoring(mockVersion);
+ }
+ });
+
+ final RuntimeContextFromSession runtimeContext = new RuntimeContextFromSession();
+ final DomainObjectContainerDefault container = new DomainObjectContainerDefault();
+
+ runtimeContext.injectInto(container);
+ runtimeContext.setContainer(container);
+
+ servicesInjector = new ServicesInjectorDefault();
+ servicesInjector.setContainer(container);
+
+ adapterManager = new AdapterManagerDefault(new PojoRecreatorDefault());
+ adapterFactory = new PojoAdapterFactory();
+ persistenceSession = new PersistenceSession(mockPersistenceSessionFactory, adapterFactory, objectFactory, servicesInjector, new OidGenerator(new IdentifierGeneratorDefault()), adapterManager, mockPersistAlgorithm, mockObjectStore) {
+ @Override
+ protected SpecificationLoaderSpi getSpecificationLoader() {
+ return isisMetaModel.getSpecificationLoader();
+ }
+
+ };
+
+ transactionManager = new IsisTransactionManager(persistenceSession, mockObjectStore);
+ persistenceSession.setTransactionManager(transactionManager);
+
+ servicesInjector.setServices(Collections.emptyList());
+
+ persistentAdapter = PojoAdapterBuilder.create().withOid("CUS|1").withPojo(new Customer()).with(Persistence.PERSISTENT).with(mockVersion).with(isisMetaModel.getSpecificationLoader()).build();
+ transientAdapter = PojoAdapterBuilder.create().withOid("CUS|2").withPojo(new Customer()).with(Persistence.TRANSIENT).with(isisMetaModel.getSpecificationLoader()).build();
+ }
+
+
+ @Test
+ public void destroyObjectThenAbort() {
+
+ final Sequence tran = context.sequence("tran");
+ context.checking(new Expectations() {
+ {
+ one(mockObjectStore).startTransaction();
+ inSequence(tran);
+
+ one(mockObjectStore).createDestroyObjectCommand(persistentAdapter);
+ inSequence(tran);
+
+ one(mockObjectStore).abortTransaction();
+ inSequence(tran);
+ }
+ });
+
+ transactionManager.startTransaction();
+ persistenceSession.destroyObject(persistentAdapter);
+ transactionManager.abortTransaction();
+ }
+
+ @Test
+ public void destroyObject_thenCommit() {
+
+ final Sequence tran = context.sequence("tran");
+ context.checking(new Expectations() {
+ {
+ one(mockObjectStore).startTransaction();
+ inSequence(tran);
+
+ one(mockObjectStore).createDestroyObjectCommand(persistentAdapter);
+ inSequence(tran);
+ will(returnValue(destroyObjectCommand));
+
+ one(mockObjectStore).execute(with(IsisMatchers.listContaining((PersistenceCommand)destroyObjectCommand)));
+ inSequence(tran);
+
+ one(mockObjectStore).endTransaction();
+ inSequence(tran);
+ }
+
+ });
+
+ transactionManager.startTransaction();
+ persistenceSession.destroyObject(persistentAdapter);
+ transactionManager.endTransaction();
+ }
+
+ @Test
+ public void makePersistent_happyCase() {
+
+ final Sequence tran = context.sequence("tran");
+ context.checking(new Expectations() {
+ {
+ one(mockObjectStore).startTransaction();
+ inSequence(tran);
+ one(mockPersistAlgorithm).makePersistent(transientAdapter, persistenceSession);
+ inSequence(tran);
+ one(mockObjectStore).execute(with(equalTo(Collections.<PersistenceCommand>emptyList())));
+ inSequence(tran);
+ one(mockObjectStore).endTransaction();
+ inSequence(tran);
+ }
+ });
+
+ transactionManager.startTransaction();
+ persistenceSession.makePersistent(transientAdapter);
+ transactionManager.endTransaction();
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/978f79af/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/algorithm/PersistAlgorithmContractTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/algorithm/PersistAlgorithmContractTest.java b/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/algorithm/PersistAlgorithmContractTest.java
new file mode 100644
index 0000000..9ca9a3b
--- /dev/null
+++ b/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/algorithm/PersistAlgorithmContractTest.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.core.runtime.persistence.objectstore.algorithm;
+
+import org.jmock.Expectations;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
+import org.apache.isis.core.metamodel.adapter.oid.Oid;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.Persistability;
+import org.apache.isis.core.runtime.persistence.NotPersistableException;
+import org.apache.isis.core.runtime.persistence.adapter.PojoAdapter;
+import org.apache.isis.core.runtime.persistence.objectstore.algorithm.PersistAlgorithm;
+import org.apache.isis.core.runtime.persistence.objectstore.algorithm.ToPersistObjectSet;
+import org.apache.isis.core.runtime.persistence.objectstore.transaction.PojoAdapterBuilder;
+import org.apache.isis.core.runtime.persistence.objectstore.transaction.PojoAdapterBuilder.Persistence;
+import org.apache.isis.core.runtime.persistence.objectstore.transaction.PojoAdapterBuilder.Type;
+import org.apache.isis.core.unittestsupport.jmock.auto.Mock;
+import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2;
+import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2.Mode;
+
+public abstract class PersistAlgorithmContractTest {
+
+ @Rule
+ public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
+
+ @Mock
+ private ToPersistObjectSet mockAdder;
+
+ @Mock
+ private ObjectSpecification objectSpec;
+
+ @Mock
+ private AdapterManager mockObjectAdapterLookup;
+
+ private PersistAlgorithm persistAlgorithm;
+
+
+
+ @Before
+ public void setUp() throws Exception {
+ persistAlgorithm = createPersistAlgorithm();
+ }
+
+ /**
+ * Hook for any implementation to implement.
+ *
+ * @return
+ */
+ protected abstract PersistAlgorithm createPersistAlgorithm();
+
+ @Test
+ public void makePersistent_skipsValueObjects() {
+
+ context.checking(new Expectations() {
+ {
+ allowing(objectSpec).isParentedOrFreeCollection();
+ will(returnValue(false));
+
+ allowing(objectSpec).persistability();
+ will(returnValue(Persistability.USER_PERSISTABLE));
+
+ never(mockAdder);
+ }
+ });
+
+ final PojoAdapter valueAdapter = PojoAdapterBuilder.create().with(Type.VALUE).with(objectSpec).build();
+ persistAlgorithm.makePersistent(valueAdapter, mockAdder);
+ }
+
+
+ @Test(expected=NotPersistableException.class)
+ public void makePersistent_failsIfObjectIsAggregated() {
+ final PojoAdapter rootAdapter = PojoAdapterBuilder.create().with(Type.ROOT).with(Persistence.TRANSIENT).with(objectSpec).build();
+ context.checking(new Expectations() {
+ {
+ allowing(objectSpec).isService();
+ will(returnValue(false));
+
+ allowing(objectSpec).isParentedOrFreeCollection();
+ will(returnValue(false));
+
+ allowing(objectSpec).persistability();
+ will(returnValue(Persistability.USER_PERSISTABLE));
+
+ allowing(mockObjectAdapterLookup).getAdapterFor(with(any(Oid.class)));
+ will(returnValue(rootAdapter));
+
+ never(mockAdder);
+ }
+ });
+
+
+ final PojoAdapter aggregatedAdapter = PojoAdapterBuilder.create().with(Type.AGGREGATED).with(Persistence.TRANSIENT).with(objectSpec).with(mockObjectAdapterLookup).build();
+ persistAlgorithm.makePersistent(aggregatedAdapter, mockAdder);
+ }
+
+ @Test(expected=NotPersistableException.class)
+ public void makePersistent_failsIfObjectAlreadyPersistent() {
+ context.checking(new Expectations() {
+ {
+ allowing(objectSpec).isService();
+ will(returnValue(false));
+
+ allowing(objectSpec).isParentedOrFreeCollection();
+ will(returnValue(false));
+
+ allowing(objectSpec).persistability();
+ will(returnValue(Persistability.PROGRAM_PERSISTABLE));
+
+ never(mockAdder);
+ }
+ });
+
+ final PojoAdapter rootAdapter = PojoAdapterBuilder.create().with(Type.ROOT).with(Persistence.PERSISTENT).with(objectSpec).build();
+ persistAlgorithm.makePersistent(rootAdapter, mockAdder);
+ }
+
+
+ @Test(expected=NotPersistableException.class)
+ public void makePersistent_failsIfObjectMustBeTransient() {
+ context.checking(new Expectations() {
+ {
+ allowing(objectSpec).isService();
+ will(returnValue(false));
+
+ allowing(objectSpec).isParentedOrFreeCollection();
+ will(returnValue(false));
+
+ allowing(objectSpec).persistability();
+ will(returnValue(Persistability.TRANSIENT));
+
+ never(mockAdder);
+ }
+ });
+
+ final PojoAdapter rootAdapter = PojoAdapterBuilder.create().with(Type.ROOT).with(Persistence.TRANSIENT).with(objectSpec).build();
+ persistAlgorithm.makePersistent(rootAdapter, mockAdder);
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/978f79af/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/algorithm/dflt/DefaultPersistAlgorithmContractTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/algorithm/dflt/DefaultPersistAlgorithmContractTest.java b/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/algorithm/dflt/DefaultPersistAlgorithmContractTest.java
new file mode 100644
index 0000000..3b1ba62
--- /dev/null
+++ b/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/algorithm/dflt/DefaultPersistAlgorithmContractTest.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.core.runtime.persistence.objectstore.algorithm.dflt;
+
+import org.apache.isis.core.runtime.persistence.objectstore.algorithm.PersistAlgorithm;
+import org.apache.isis.core.runtime.persistence.objectstore.algorithm.PersistAlgorithmContractTest;
+import org.apache.isis.core.runtime.persistence.objectstore.algorithm.PersistAlgorithmDefault;
+
+public class DefaultPersistAlgorithmContractTest extends PersistAlgorithmContractTest {
+
+ @Override
+ protected PersistAlgorithm createPersistAlgorithm() {
+ return new PersistAlgorithmDefault();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/978f79af/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/algorithm/dflt/DefaultPersistAlgorithmTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/algorithm/dflt/DefaultPersistAlgorithmTest.java b/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/algorithm/dflt/DefaultPersistAlgorithmTest.java
new file mode 100644
index 0000000..c239c5a
--- /dev/null
+++ b/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/algorithm/dflt/DefaultPersistAlgorithmTest.java
@@ -0,0 +1,258 @@
+/*
+ * 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.core.runtime.persistence.objectstore.algorithm.dflt;
+
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import org.apache.isis.core.runtime.persistence.objectstore.algorithm.PersistAlgorithmDefault;
+
+public class DefaultPersistAlgorithmTest {
+
+// private final static class PersistedObjectAdderSpy implements ToPersistObjectSet {
+// private final List<ObjectAdapter> persistedObjects = new ArrayList<ObjectAdapter>();
+//
+// public List<ObjectAdapter> getPersistedObjects() {
+// return persistedObjects;
+// }
+//
+// @Override
+// public void addPersistedObject(final ObjectAdapter object) {
+// persistedObjects.add(object);
+// }
+//
+// @Override
+// public void remapAsPersistent(final ObjectAdapter object) {
+// object.changeState(ResolveState.RESOLVED);
+// }
+// }
+//
+// private final String objectType = "CUS";
+//
+ private PersistAlgorithmDefault algorithm;
+
+// private PersistedObjectAdderSpy adder;
+// private ObjectAdapter object;
+// private TestProxyAdapter fieldsObject;
+//
+// protected TestProxySystem system;
+// private int nextId;
+//
+// private TestProxyConfiguration mockConfiguration;
+// private TestProxyReflector mockReflector;
+// private AuthenticationSession mockAuthSession;
+// private TestProxyPersistenceSessionFactory mockPersistenceSessionFactory;
+// private TestProxyPersistenceSession mockPersistenceSession;
+// private TestUserProfileStore mockUserProfileStore;
+//
+//
+// @Override
+// protected void setUp() throws Exception {
+// Logger.getRootLogger().setLevel(Level.OFF);
+// system = new TestProxySystem();
+// nextId = 0;
+//
+// 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);
+//
+//
+// algorithm = new DefaultPersistAlgorithm();
+// final RuntimeTestPojo transientTestPojo = new RuntimeTestPojo();
+// final RootOidDefault transientTestOid = RootOidDefault.createTransient("CUS", ""+ (nextId++));
+// final ObjectAdapter adapterForTransient = ((AdapterManagerTestSupport) mockPersistenceSession.getAdapterManager()).testCreateTransient(transientTestPojo, transientTestOid);
+// Assert.assertEquals("", ResolveState.TRANSIENT, adapterForTransient.getResolveState());
+//
+// object = adapterForTransient;
+// // object.setupResolveState(ResolveState.TRANSIENT);
+//
+// final TestProxySpecification spec = (TestProxySpecification) object.getSpecification();
+// final List<ObjectAssociation> fields = Arrays.asList((ObjectAssociation) new OneToOneAssociationTest() {
+//
+// @Override
+// public void initAssociation(final ObjectAdapter inObject, final ObjectAdapter associate) {
+// }
+//
+// @Override
+// public Consent isAssociationValid(final ObjectAdapter inObject, final ObjectAdapter associate) {
+// return null;
+// }
+//
+// @Override
+// public void setAssociation(final ObjectAdapter inObject, final ObjectAdapter associate) {
+// }
+//
+// @Override
+// public void set(final ObjectAdapter owner, final ObjectAdapter newValue) {
+// }
+//
+// @Override
+// public ObjectAdapter get(final ObjectAdapter target) {
+// return null;
+// }
+//
+// @Override
+// public ObjectSpecification getSpecification() {
+// return null;
+// }
+//
+// @Override
+// public String debugData() {
+// return null;
+// }
+//
+// @Override
+// public String getId() {
+// return null;
+// }
+//
+// @Override
+// public String getName() {
+// return null;
+// }
+//
+// @Override
+// public FeatureType getFeatureType() {
+// return FeatureType.PROPERTY;
+// }
+//
+// });
+// spec.setupFields(fields);
+//
+// fieldsObject = new TestProxyAdapter();
+// fieldsObject.setupResolveState(ResolveState.TRANSIENT);
+// fieldsObject.setupSpecification((TestProxySpecification) mockReflector.loadSpecification(String.class));
+//
+// adder = new PersistedObjectAdderSpy();
+// }
+
+
+ @Before
+ public void setUp() throws Exception {
+ algorithm = new PersistAlgorithmDefault();
+ }
+
+
+ @Ignore //DKH
+ @Test
+ public void testMakePersistent() {
+// algorithm.makePersistent(object, adder);
+// assertEquals(ResolveState.RESOLVED, object.getResolveState());
+// assertTrue(adder.getPersistedObjects().contains(object));
+ }
+
+ @Ignore //DKH
+ @Test
+ public void testMakePersistentRecursesThroughReferenceFields() {
+// /*
+// * fieldControl.expectAndReturn(oneToOneAssociation.isPersisted(),
+// * true); fieldControl.expectAndReturn(oneToOneAssociation.isValue(),
+// * false); fieldControl.expectAndReturn(oneToOneAssociation.get(object),
+// * fieldsObject);
+// * IsisContext.getObjectPersistor().getIdentityMap().madePersistent
+// * (object);
+// * IsisContext.getObjectPersistor().getIdentityMap().madePersistent
+// * (fieldsObject);
+// *
+// * adder.addPersistedObject(object);
+// * adder.addPersistedObject(fieldsObject);
+// */
+//
+// // replay();
+// algorithm.makePersistent(object, adder);
+// // verify();
+ }
+
+ @Ignore //DKH
+ @Test
+ public void testMakePersistentRecursesThroughReferenceFieldsSkippingNullReferences() {
+// /*
+// * fieldControl.expectAndReturn(oneToOneAssociation.isPersisted(),
+// * true); fieldControl.expectAndReturn(oneToOneAssociation.isValue(),
+// * false); fieldControl.expectAndReturn(oneToOneAssociation.get(object),
+// * null);
+// *
+// * IsisContext.getObjectPersistor().getIdentityMap().madePersistent(object
+// * );
+// *
+// * adder.addPersistedObject(object);
+// */
+// algorithm.makePersistent(object, adder);
+ }
+
+ @Ignore //DKH
+ @Test
+ public void testMakePersistentRecursesThroughReferenceFieldsSkippingNonPersistentFields() {
+// /*
+// * fieldControl.expectAndReturn(oneToOneAssociation.isPersisted(),
+// * false);
+// *
+// * IsisContext.getObjectPersistor().getIdentityMap().madePersistent(object
+// * );
+// *
+// * adder.addPersistedObject(object);
+// */
+// algorithm.makePersistent(object, adder);
+ }
+
+ @Ignore //DKH
+ @Test
+ public void testMakePersistentRecursesThroughReferenceFieldsSkippingObjectsThatAreAlreadyPersistent() {
+// /*
+// * fieldControl.expectAndReturn(oneToOneAssociation.isPersisted(),
+// * true); fieldControl.expectAndReturn(oneToOneAssociation.isValue(),
+// * false); fieldControl.expectAndReturn(oneToOneAssociation.get(object),
+// * fieldsObject); fieldsObject.setupResolveState(ResolveState.RESOLVED);
+// *
+// * IsisContext.getObjectPersistor().getIdentityMap().madePersistent(object
+// * );
+// *
+// * adder.addPersistedObject(object);
+// */
+// algorithm.makePersistent(object, adder);
+ }
+
+ @Ignore //DKH
+ @Test
+ public void testMakePersistentSkipsAggregatedObjects() {
+// class DefaultPersistAlgorithmSubclassForTesting extends DefaultPersistAlgorithm {
+// @Override
+// protected void persist(final ObjectAdapter object, final ToPersistObjectSet persistor) {
+// super.persist(object, persistor);
+// }
+//
+// public void sensingPersist(final ObjectAdapter object, final ToPersistObjectSet persistor) {
+// persist(object, persistor);
+// }
+// }
+// final PojoAdapter aggregatedObject = new PojoAdapter(new Object(), RootOidDefault.createTransient(objectType, ""+1));
+// aggregatedObject.changeState(ResolveState.VALUE);
+// new DefaultPersistAlgorithmSubclassForTesting().sensingPersist(aggregatedObject, adder);
+// assertEquals(0, adder.getPersistedObjects().size());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/978f79af/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/algorithm/topdown/TopDownPersistAlgorithmContractTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/algorithm/topdown/TopDownPersistAlgorithmContractTest.java b/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/algorithm/topdown/TopDownPersistAlgorithmContractTest.java
new file mode 100644
index 0000000..0afc914
--- /dev/null
+++ b/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/algorithm/topdown/TopDownPersistAlgorithmContractTest.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.core.runtime.persistence.objectstore.algorithm.topdown;
+
+import org.junit.Ignore;
+import org.junit.Test;
+
+import org.apache.isis.core.runtime.persistence.NotPersistableException;
+import org.apache.isis.core.runtime.persistence.objectstore.algorithm.PersistAlgorithm;
+import org.apache.isis.core.runtime.persistence.objectstore.algorithm.PersistAlgorithmContractTest;
+import org.apache.isis.core.runtime.persistence.objectstore.algorithm.PersistAlgorithmTopDown;
+
+public class TopDownPersistAlgorithmContractTest extends PersistAlgorithmContractTest {
+
+ @Override
+ protected PersistAlgorithm createPersistAlgorithm() {
+ return new PersistAlgorithmTopDown();
+ }
+
+ @Ignore
+ @Test(expected=NotPersistableException.class)
+ public void makePersistent_failsIfObjectIsAggregated() {
+ // does not pass...
+ }
+
+ @Ignore
+ @Test(expected=NotPersistableException.class)
+ public void makePersistent_failsIfObjectAlreadyPersistent() {
+ // does not pass...
+ }
+
+ @Ignore
+ @Test(expected=NotPersistableException.class)
+ public void makePersistent_failsIfObjectMustBeTransient() {
+ // does not pass...
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/978f79af/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/algorithm/twopass/TwoPassPersistAlgorithmContractTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/algorithm/twopass/TwoPassPersistAlgorithmContractTest.java b/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/algorithm/twopass/TwoPassPersistAlgorithmContractTest.java
new file mode 100644
index 0000000..f5594c6
--- /dev/null
+++ b/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/algorithm/twopass/TwoPassPersistAlgorithmContractTest.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.core.runtime.persistence.objectstore.algorithm.twopass;
+
+import org.junit.Ignore;
+import org.junit.Test;
+
+import org.apache.isis.core.runtime.persistence.NotPersistableException;
+import org.apache.isis.core.runtime.persistence.objectstore.algorithm.PersistAlgorithm;
+import org.apache.isis.core.runtime.persistence.objectstore.algorithm.PersistAlgorithmContractTest;
+import org.apache.isis.core.runtime.persistence.objectstore.algorithm.PersistAlgorithmTwoPass;
+
+public class TwoPassPersistAlgorithmContractTest extends PersistAlgorithmContractTest {
+
+ @Override
+ protected PersistAlgorithm createPersistAlgorithm() {
+ return new PersistAlgorithmTwoPass();
+ }
+
+ @Ignore
+ @Test(expected=NotPersistableException.class)
+ public void makePersistent_failsIfObjectIsAggregated() {
+ // does not pass...
+ }
+
+ @Ignore
+ @Test(expected=NotPersistableException.class)
+ public void makePersistent_failsIfObjectAlreadyPersistent() {
+ // does not pass...
+ }
+
+ @Ignore
+ @Test(expected=NotPersistableException.class)
+ public void makePersistent_failsIfObjectMustBeTransient() {
+ // does not pass...
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/978f79af/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/transaction/ObjectStoreTransactionManagerAbstractTestCase.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/transaction/ObjectStoreTransactionManagerAbstractTestCase.java b/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/transaction/ObjectStoreTransactionManagerAbstractTestCase.java
new file mode 100644
index 0000000..b22455e
--- /dev/null
+++ b/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/transaction/ObjectStoreTransactionManagerAbstractTestCase.java
@@ -0,0 +1,67 @@
+/*
+ * 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.core.runtime.persistence.objectstore.transaction;
+
+import org.jmock.Expectations;
+import org.junit.Rule;
+
+import org.apache.isis.core.runtime.persistence.objectstore.transaction.TransactionalResource;
+import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
+import org.apache.isis.core.runtime.system.session.IsisSession;
+import org.apache.isis.core.runtime.system.transaction.IsisTransactionManager;
+import org.apache.isis.core.unittestsupport.jmock.auto.Mock;
+import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2;
+import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2.Mode;
+
+public abstract class ObjectStoreTransactionManagerAbstractTestCase {
+
+ @Rule
+ public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
+
+ protected IsisTransactionManager transactionManager;
+ @Mock
+ protected IsisSession mockSession;
+ @Mock
+ protected PersistenceSession mockPersistenceSession;
+ @Mock
+ protected TransactionalResource mockObjectStore;
+
+
+ // //////////////////////////////////////////////////
+ // Helpers
+ // //////////////////////////////////////////////////
+
+ protected void ignoreCallsToPersistenceSession() {
+ context.checking(new Expectations() {
+ {
+ ignoring(mockPersistenceSession);
+ }
+ });
+ }
+
+ protected void ignoreCallsToObjectStore() {
+ context.checking(new Expectations() {
+ {
+ ignoring(mockObjectStore);
+ }
+ });
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/978f79af/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/transaction/ObjectStoreTransactionManager_EndTransactionTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/transaction/ObjectStoreTransactionManager_EndTransactionTest.java b/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/transaction/ObjectStoreTransactionManager_EndTransactionTest.java
new file mode 100644
index 0000000..8bb1461
--- /dev/null
+++ b/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/transaction/ObjectStoreTransactionManager_EndTransactionTest.java
@@ -0,0 +1,108 @@
+/*
+ * 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.core.runtime.persistence.objectstore.transaction;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.util.Collections;
+
+import org.jmock.Expectations;
+import org.jmock.Sequence;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.apache.isis.core.runtime.persistence.objectstore.transaction.PersistenceCommand;
+import org.apache.isis.core.runtime.system.transaction.IsisTransactionManager;
+
+public class ObjectStoreTransactionManager_EndTransactionTest extends ObjectStoreTransactionManagerAbstractTestCase {
+
+ @Before
+ public void setUpTransactionManager() throws Exception {
+ transactionManager = new IsisTransactionManager(mockPersistenceSession, mockObjectStore);
+ }
+
+ @Test
+ public void endTransactionDecrementsTransactionLevel() throws Exception {
+ // setup
+ ignoreCallsToObjectStore();
+ transactionManager.startTransaction();
+ transactionManager.startTransaction();
+
+ assertThat(transactionManager.getTransactionLevel(), is(2));
+ transactionManager.endTransaction();
+ assertThat(transactionManager.getTransactionLevel(), is(1));
+ }
+
+ @Test
+ public void endTransactionCommitsTransactionWhenLevelDecrementsDownToZero() throws Exception {
+ // setup
+ ignoreCallsToObjectStore();
+ transactionManager.startTransaction();
+
+ context.checking(new Expectations() {
+ {
+ one(mockPersistenceSession).objectChangedAllDirty();
+ }
+ });
+ assertThat(transactionManager.getTransactionLevel(), is(1));
+ transactionManager.endTransaction();
+ assertThat(transactionManager.getTransactionLevel(), is(0));
+ }
+
+ @Test
+ public void startTransactionInteractsWithObjectStore() throws Exception {
+ // setup
+ ignoreCallsToPersistenceSession();
+
+ context.checking(new Expectations() {
+ {
+ one(mockObjectStore).startTransaction();
+ }
+ });
+ transactionManager.startTransaction();
+
+ }
+
+ @Test
+ public void endTransactionInteractsWithObjectStore() throws Exception {
+ // setup
+ ignoreCallsToPersistenceSession();
+
+ context.checking(new Expectations() {
+ {
+ final Sequence transactionOrdering = context.sequence("transactionOrdering");
+ one(mockObjectStore).startTransaction();
+ inSequence(transactionOrdering);
+
+ one(mockObjectStore).execute(with(equalTo(Collections.<PersistenceCommand>emptyList())));
+ inSequence(transactionOrdering);
+
+ one(mockObjectStore).endTransaction();
+ inSequence(transactionOrdering);
+ }
+ });
+
+ transactionManager.startTransaction();
+ transactionManager.endTransaction();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/978f79af/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/transaction/ObjectStoreTransactionManager_InstantiationTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/transaction/ObjectStoreTransactionManager_InstantiationTest.java b/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/transaction/ObjectStoreTransactionManager_InstantiationTest.java
new file mode 100644
index 0000000..fbff96e
--- /dev/null
+++ b/core/runtime/src/test/java/org/apache/isis/core/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.core.runtime.persistence.objectstore.transaction;
+
+import org.junit.Test;
+
+import org.apache.isis.core.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/978f79af/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/transaction/ObjectStoreTransactionManager_StartTransactionTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/transaction/ObjectStoreTransactionManager_StartTransactionTest.java b/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/transaction/ObjectStoreTransactionManager_StartTransactionTest.java
new file mode 100644
index 0000000..c7205ab
--- /dev/null
+++ b/core/runtime/src/test/java/org/apache/isis/core/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.core.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.core.runtime.system.transaction.IsisTransaction;
+import org.apache.isis.core.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/978f79af/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/transaction/PojoAdapterBuilder.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/transaction/PojoAdapterBuilder.java b/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/transaction/PojoAdapterBuilder.java
new file mode 100644
index 0000000..d4bd2fc
--- /dev/null
+++ b/core/runtime/src/test/java/org/apache/isis/core/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.core.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.core.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/978f79af/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/transaction/TransactionTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/transaction/TransactionTest.java b/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/transaction/TransactionTest.java
new file mode 100644
index 0000000..b78c7d2
--- /dev/null
+++ b/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/transaction/TransactionTest.java
@@ -0,0 +1,323 @@
+/*
+ * 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.core.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.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.runtime.persistence.ObjectPersistenceException;
+import org.apache.isis.core.runtime.persistence.objectstore.ObjectStoreSpi;
+import org.apache.isis.core.runtime.persistence.objectstore.transaction.CreateObjectCommand;
+import org.apache.isis.core.runtime.persistence.objectstore.transaction.DestroyObjectCommand;
+import org.apache.isis.core.runtime.persistence.objectstore.transaction.PersistenceCommand;
+import org.apache.isis.core.runtime.persistence.objectstore.transaction.PersistenceCommandContext;
+import org.apache.isis.core.runtime.persistence.objectstore.transaction.SaveObjectCommand;
+import org.apache.isis.core.runtime.persistence.objectstore.transaction.PojoAdapterBuilder.Persistence;
+import org.apache.isis.core.runtime.system.transaction.IsisTransaction;
+import org.apache.isis.core.runtime.system.transaction.IsisTransactionManager;
+import org.apache.isis.core.runtime.system.transaction.MessageBroker;
+import org.apache.isis.core.runtime.system.transaction.UpdateNotifier;
+import org.apache.isis.core.unittestsupport.jmock.auto.Mock;
+import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2;
+import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2.Mode;
+
+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/978f79af/core/runtime/src/test/java/org/apache/isis/core/runtime/profiler/ProfilerTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/isis/core/runtime/profiler/ProfilerTest.java b/core/runtime/src/test/java/org/apache/isis/core/runtime/profiler/ProfilerTest.java
new file mode 100644
index 0000000..39b2a3a
--- /dev/null
+++ b/core/runtime/src/test/java/org/apache/isis/core/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.core.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/978f79af/core/runtime/src/test/java/org/apache/isis/core/runtime/profiler/ProfilerTestSystem.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/isis/core/runtime/profiler/ProfilerTestSystem.java b/core/runtime/src/test/java/org/apache/isis/core/runtime/profiler/ProfilerTestSystem.java
new file mode 100644
index 0000000..331e016
--- /dev/null
+++ b/core/runtime/src/test/java/org/apache/isis/core/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.core.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/978f79af/core/runtime/src/test/java/org/apache/isis/core/runtime/system/Interface1.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/isis/core/runtime/system/Interface1.java b/core/runtime/src/test/java/org/apache/isis/core/runtime/system/Interface1.java
new file mode 100644
index 0000000..4b31145
--- /dev/null
+++ b/core/runtime/src/test/java/org/apache/isis/core/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.core.runtime.system;
+
+public interface Interface1 {
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/978f79af/core/runtime/src/test/java/org/apache/isis/core/runtime/system/JavaActionTestObject.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/isis/core/runtime/system/JavaActionTestObject.java b/core/runtime/src/test/java/org/apache/isis/core/runtime/system/JavaActionTestObject.java
new file mode 100644
index 0000000..7080ee8
--- /dev/null
+++ b/core/runtime/src/test/java/org/apache/isis/core/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.core.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/978f79af/core/runtime/src/test/java/org/apache/isis/core/runtime/system/JavaObjectMarkedAsTransient.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/isis/core/runtime/system/JavaObjectMarkedAsTransient.java b/core/runtime/src/test/java/org/apache/isis/core/runtime/system/JavaObjectMarkedAsTransient.java
new file mode 100644
index 0000000..1c00c7a
--- /dev/null
+++ b/core/runtime/src/test/java/org/apache/isis/core/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.core.runtime.system;
+
+import org.apache.isis.applib.marker.NonPersistable;
+
+public class JavaObjectMarkedAsTransient implements NonPersistable {
+
+}