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 2013/02/08 19:29:52 UTC
[4/32] git commit: ISIS-323: getting unit tests to pass...
ISIS-323: getting unit tests to pass...
... and deleting some unused PersistAlgorithm implementations and ignored tests
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/8da1094b
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/8da1094b
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/8da1094b
Branch: refs/heads/master
Commit: 8da1094b3f432f51f89cf767ce08258830e1510b
Parents: 2f6223c
Author: Dan Haywood <da...@apache.org>
Authored: Mon Feb 4 22:31:04 2013 +0000
Committer: Dan Haywood <da...@apache.org>
Committed: Fri Feb 8 18:00:33 2013 +0000
----------------------------------------------------------------------
.../PersistenceMechanismInstallerAbstract.java | 3 -
.../algorithm/PersistAlgorithmTopDown.java | 108 ------
.../algorithm/PersistAlgorithmTwoPass.java | 131 --------
.../system/transaction/IsisTransaction.java | 4 +-
.../system/transaction/IsisTransactionManager.java | 9 +
.../PersistenceSessionObjectStoreTest.java | 16 +-
.../DefaultPersistAlgorithmContractTest.java | 32 ++
.../dflt/DefaultPersistAlgorithmContractTest.java | 33 --
.../dflt/DefaultPersistAlgorithmTest.java | 258 ---------------
.../TopDownPersistAlgorithmContractTest.java | 55 ---
.../TwoPassPersistAlgorithmContractTest.java | 55 ---
...StoreTransactionManager_EndTransactionTest.java | 15 +-
.../core/runtime/system/ObjectActionImplTest.java | 67 +----
.../system/transaction/IsisTransactionTest.java | 13 +
14 files changed, 88 insertions(+), 711 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/8da1094b/core/runtime/src/main/java/org/apache/isis/core/runtime/installerregistry/installerapi/PersistenceMechanismInstallerAbstract.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/installerregistry/installerapi/PersistenceMechanismInstallerAbstract.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/installerregistry/installerapi/PersistenceMechanismInstallerAbstract.java
index f5bfe2f..bfde110 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/installerregistry/installerapi/PersistenceMechanismInstallerAbstract.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/installerregistry/installerapi/PersistenceMechanismInstallerAbstract.java
@@ -97,9 +97,6 @@ public abstract class PersistenceMechanismInstallerAbstract extends InstallerAbs
private static final String LOGGING_PROPERTY = org.apache.isis.core.runtime.logging.Logger.PROPERTY_ROOT + "persistenceSession";
private static final Logger LOG = Logger.getLogger(PersistenceMechanismInstallerAbstract.class);
-
-
-
private SystemDependencyInjector installerLookup;
public PersistenceMechanismInstallerAbstract(final String name) {
http://git-wip-us.apache.org/repos/asf/isis/blob/8da1094b/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/objectstore/algorithm/PersistAlgorithmTopDown.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/objectstore/algorithm/PersistAlgorithmTopDown.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/objectstore/algorithm/PersistAlgorithmTopDown.java
deleted file mode 100644
index 4759791..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/objectstore/algorithm/PersistAlgorithmTopDown.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.runtime.persistence.objectstore.algorithm;
-
-import java.util.List;
-
-import org.apache.log4j.Logger;
-
-import org.apache.isis.core.commons.lang.ToString;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.adapter.ResolveState;
-import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
-import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacetUtils;
-import org.apache.isis.core.metamodel.facets.object.callbacks.CallbackUtils;
-import org.apache.isis.core.metamodel.facets.object.callbacks.PersistedCallbackFacet;
-import org.apache.isis.core.metamodel.facets.object.callbacks.PersistingCallbackFacet;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
-import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
-import org.apache.isis.core.runtime.persistence.ObjectPersistenceException;
-
-public class PersistAlgorithmTopDown extends PersistAlgorithmAbstract {
-
- private static final Logger LOG = Logger.getLogger(PersistAlgorithmTopDown.class);
-
- @Override
- public void makePersistent(final ObjectAdapter object, final ToPersistObjectSet toPersistObjectSet) {
- if (object.getSpecification().isParentedOrFreeCollection()) {
- makeCollectionPersistent(object, toPersistObjectSet);
- } else {
- makeObjectPersistent(object, toPersistObjectSet);
- }
- }
-
- private void makeObjectPersistent(final ObjectAdapter object, final ToPersistObjectSet toPersistObjectSet) {
- if (alreadyPersistedOrNotPersistableOrServiceOrStandalone(object)) {
- LOG.warn("can't make object persistent - either already persistent, or transient only: " + object);
- return;
- }
-
- final List<ObjectAssociation> fields = object.getSpecification().getAssociations();
- if (!object.getSpecification().isEncodeable() && fields.size() > 0) {
- LOG.info("persist " + object);
- CallbackUtils.callCallback(object, PersistingCallbackFacet.class);
- toPersistObjectSet.remapAsPersistent(object);
- toPersistObjectSet.addCreateObjectCommand(object);
- CallbackUtils.callCallback(object, PersistedCallbackFacet.class);
-
- for (int i = 0; i < fields.size(); i++) {
- final ObjectAssociation field = fields.get(i);
- if (field.isNotPersisted()) {
- continue;
- } else if (field instanceof OneToManyAssociation) {
- final ObjectAdapter collection = field.get(object);
- if (collection == null) {
- throw new ObjectPersistenceException("Collection " + field.getName() + " does not exist in " + object.getSpecification().getFullIdentifier());
- }
- makePersistent(collection, toPersistObjectSet);
- } else {
- final ObjectAdapter fieldValue = field.get(object);
- if (fieldValue == null) {
- continue;
- }
- makePersistent(fieldValue, toPersistObjectSet);
- }
- }
- }
- }
-
- private void makeCollectionPersistent(final ObjectAdapter collectionAdapter, final ToPersistObjectSet toPersistObjectSet) {
- LOG.info("persist " + collectionAdapter);
- if (collectionAdapter.isTransient()) {
- collectionAdapter.changeState(ResolveState.RESOLVED);
- }
- final CollectionFacet facet = CollectionFacetUtils.getCollectionFacetFromSpec(collectionAdapter);
- for(ObjectAdapter element: facet.iterable(collectionAdapter)) {
- makePersistent(element, toPersistObjectSet);
- }
- }
-
- @Override
- public String name() {
- return "Simple Top Down Persistence Walker";
- }
-
- @Override
- public String toString() {
- final ToString toString = new ToString(this);
- return toString.toString();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/8da1094b/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/objectstore/algorithm/PersistAlgorithmTwoPass.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/objectstore/algorithm/PersistAlgorithmTwoPass.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/objectstore/algorithm/PersistAlgorithmTwoPass.java
deleted file mode 100644
index e6ffa91..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/persistence/objectstore/algorithm/PersistAlgorithmTwoPass.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.runtime.persistence.objectstore.algorithm;
-
-import java.util.Enumeration;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-
-import org.apache.isis.core.commons.lang.ToString;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.adapter.ResolveState;
-import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
-import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacetUtils;
-import org.apache.isis.core.metamodel.facets.object.callbacks.CallbackUtils;
-import org.apache.isis.core.metamodel.facets.object.callbacks.PersistedCallbackFacet;
-import org.apache.isis.core.metamodel.facets.object.callbacks.PersistingCallbackFacet;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
-import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
-
-public class PersistAlgorithmTwoPass extends PersistAlgorithmAbstract {
- private static final Logger LOG = Logger.getLogger(PersistAlgorithmTwoPass.class);
-
- @Override
- public String name() {
- return "Two pass, bottom up persistence walker";
- }
-
- @Override
- public void makePersistent(final ObjectAdapter object, final ToPersistObjectSet toPersistObjectSet) {
- if (object.getSpecification().isParentedOrFreeCollection()) {
- makeCollectionPersistent(object, toPersistObjectSet);
- } else {
- makeObjectPersistent(object, toPersistObjectSet);
- }
- }
-
- private void makeObjectPersistent(final ObjectAdapter object, final ToPersistObjectSet toPersistObjectSet) {
- if (alreadyPersistedOrNotPersistableOrServiceOrStandalone(object)) {
- return;
- }
- final List<ObjectAssociation> fields = object.getSpecification().getAssociations();
- if (!object.getSpecification().isEncodeable() && fields.size() > 0) {
- LOG.info("persist " + object);
- CallbackUtils.callCallback(object, PersistingCallbackFacet.class);
- toPersistObjectSet.remapAsPersistent(object);
-
- for (int i = 0; i < fields.size(); i++) {
- final ObjectAssociation field = fields.get(i);
- if (field.isNotPersisted()) {
- continue;
- } else if (field.isOneToManyAssociation()) {
- // skip in first pass
- continue;
- } else {
- final ObjectAdapter fieldValue = field.get(object);
- if (fieldValue == null) {
- continue;
- }
- makePersistent(fieldValue, toPersistObjectSet);
- }
- }
-
- for (int i = 0; i < fields.size(); i++) {
- final ObjectAssociation field = fields.get(i);
- if (field.isNotPersisted()) {
- continue;
- } else if (field instanceof OneToManyAssociation) {
- final ObjectAdapter collection = field.get(object);
- makeCollectionPersistent(collection, toPersistObjectSet);
- /**
- * if (collection == null) { throw new
- * ObjectPersistenceException("Collection " +
- * field.getName() + " does not exist in " +
- * object.getSpecification().getFullName()); }
- * makePersistent(collection, toPersistObjectSet); final
- * CollectionFacet facet =
- * CollectionFacetUtils.getCollectionFacetFromSpec
- * (collection); final Enumeration elements =
- * facet.elements(collection); while
- * (elements.hasMoreElements()) {
- * makePersistent((ObjectAdapter) elements.nextElement(),
- * toPersistObjectSet); }
- */
- } else {
- // skip in second pass
- continue;
- }
- }
-
- toPersistObjectSet.addCreateObjectCommand(object);
- CallbackUtils.callCallback(object, PersistedCallbackFacet.class);
- }
- }
-
- private void makeCollectionPersistent(final ObjectAdapter collection, final ToPersistObjectSet toPersistObjectSet) {
- LOG.info("persist " + collection);
- if (collection.isTransient()) {
- collection.changeState(ResolveState.RESOLVED);
- }
- final CollectionFacet facet = CollectionFacetUtils.getCollectionFacetFromSpec(collection);
- final Enumeration elements = facet.elements(collection);
- while (elements.hasMoreElements()) {
- makePersistent((ObjectAdapter) elements.nextElement(), toPersistObjectSet);
- }
- }
-
- @Override
- public String toString() {
- final ToString toString = new ToString(this);
- return toString.toString();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/8da1094b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransaction.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransaction.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransaction.java
index 9983657..f6c306f 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransaction.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransaction.java
@@ -402,7 +402,7 @@ public class IsisTransaction implements TransactionScopedComponent {
}
// else
- final String currentUser = getAuthenticationSession().getUserName();
+ final String currentUser = getTransactionManager().getAuthenticationSession().getUserName();
final long currentTimestampEpoch = currentTimestampEpoch();
for (Entry<AdapterAndProperty, PreAndPostValues> auditEntry : changedObjectProperties) {
auditChangedProperty(currentUser, currentTimestampEpoch, auditEntry);
@@ -415,7 +415,7 @@ public class IsisTransaction implements TransactionScopedComponent {
}
// else
- final String currentUser = getAuthenticationSession().getUserName();
+ final String currentUser = getTransactionManager().getAuthenticationSession().getUserName();
final long currentTimestampEpoch = currentTimestampEpoch();
for (ObjectAdapter changedAdapter : changedAdapters) {
http://git-wip-us.apache.org/repos/asf/isis/blob/8da1094b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransactionManager.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransactionManager.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransactionManager.java
index e8a3305..567fe01 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransactionManager.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransactionManager.java
@@ -33,6 +33,7 @@ import org.apache.isis.applib.annotation.PublishedObject;
import org.apache.isis.applib.annotation.PublishedObject.EventCanonicalizer;
import org.apache.isis.applib.services.audit.AuditingService;
import org.apache.isis.applib.services.publish.PublishingService;
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
import org.apache.isis.core.commons.components.SessionScopedComponent;
import org.apache.isis.core.commons.debug.DebugBuilder;
import org.apache.isis.core.commons.exceptions.IsisException;
@@ -447,6 +448,14 @@ public class IsisTransactionManager implements SessionScopedComponent {
}
+ /**
+ * Called back by {@link IsisTransaction}.
+ */
+ protected AuthenticationSession getAuthenticationSession() {
+ return IsisContext.getAuthenticationSession();
+ }
+
+
}
http://git-wip-us.apache.org/repos/asf/isis/blob/8da1094b/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
index 523af9b..27d5420 100644
--- 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
@@ -35,6 +35,7 @@ import org.junit.Test;
import org.apache.isis.applib.services.audit.AuditingService;
import org.apache.isis.applib.services.publish.PublishingService;
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
import org.apache.isis.core.commons.config.IsisConfiguration;
import org.apache.isis.core.commons.matchers.IsisMatchers;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
@@ -91,6 +92,9 @@ public class PersistenceSessionObjectStoreTest {
private PersistenceSessionFactory mockPersistenceSessionFactory;
@Mock
+ private AuthenticationSession mockAuthenticationSession;
+
+ @Mock
private ObjectStoreSpi mockObjectStore;
@Mock
private ObjectFactory objectFactory;
@@ -173,7 +177,17 @@ public class PersistenceSessionObjectStoreTest {
};
- transactionManager = new IsisTransactionManager(persistenceSession, mockObjectStore, mockAuditingService, mockPublishingService);
+ context.checking(new Expectations(){{
+ allowing(mockAuthenticationSession).getUserName();
+ will(returnValue("sven"));
+ }});
+
+ transactionManager = new IsisTransactionManager(persistenceSession, mockObjectStore, mockAuditingService, mockPublishingService) {
+ @Override
+ public AuthenticationSession getAuthenticationSession() {
+ return mockAuthenticationSession;
+ }
+ };
persistenceSession.setTransactionManager(transactionManager);
servicesInjector.setServices(Collections.emptyList());
http://git-wip-us.apache.org/repos/asf/isis/blob/8da1094b/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/algorithm/DefaultPersistAlgorithmContractTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/algorithm/DefaultPersistAlgorithmContractTest.java b/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/algorithm/DefaultPersistAlgorithmContractTest.java
new file mode 100644
index 0000000..bee7f0f
--- /dev/null
+++ b/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/algorithm/DefaultPersistAlgorithmContractTest.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.runtime.persistence.objectstore.algorithm;
+
+import org.apache.isis.core.runtime.persistence.objectstore.algorithm.PersistAlgorithm;
+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/8da1094b/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
deleted file mode 100644
index 3b1ba62..0000000
--- a/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/algorithm/dflt/DefaultPersistAlgorithmContractTest.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-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/8da1094b/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
deleted file mode 100644
index c239c5a..0000000
--- a/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/algorithm/dflt/DefaultPersistAlgorithmTest.java
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-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/8da1094b/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
deleted file mode 100644
index 0afc914..0000000
--- a/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/algorithm/topdown/TopDownPersistAlgorithmContractTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-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/8da1094b/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
deleted file mode 100644
index f5594c6..0000000
--- a/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/algorithm/twopass/TwoPassPersistAlgorithmContractTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-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/8da1094b/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
index ae29134..645eac4 100644
--- 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
@@ -27,6 +27,7 @@ import java.util.Collections;
import org.apache.isis.applib.services.audit.AuditingService;
import org.apache.isis.applib.services.publish.PublishingService;
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
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;
@@ -47,7 +48,7 @@ public class ObjectStoreTransactionManager_EndTransactionTest {
@Mock
- private IsisSession mockSession;
+ private AuthenticationSession mockAuthenticationSession;
@Mock
private PersistenceSession mockPersistenceSession;
@Mock
@@ -62,7 +63,17 @@ public class ObjectStoreTransactionManager_EndTransactionTest {
@Before
public void setUpTransactionManager() throws Exception {
- transactionManager = new IsisTransactionManager(mockPersistenceSession, mockObjectStore, mockAuditingService, mockPublishingService);
+ context.checking(new Expectations(){{
+ allowing(mockAuthenticationSession).getUserName();
+ will(returnValue("sven"));
+ }});
+
+ transactionManager = new IsisTransactionManager(mockPersistenceSession, mockObjectStore, mockAuditingService, mockPublishingService) {
+ @Override
+ public AuthenticationSession getAuthenticationSession() {
+ return mockAuthenticationSession;
+ }
+ };
}
@Test
http://git-wip-us.apache.org/repos/asf/isis/blob/8da1094b/core/runtime/src/test/java/org/apache/isis/core/runtime/system/ObjectActionImplTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/isis/core/runtime/system/ObjectActionImplTest.java b/core/runtime/src/test/java/org/apache/isis/core/runtime/system/ObjectActionImplTest.java
index e24382e..69ca560 100644
--- a/core/runtime/src/test/java/org/apache/isis/core/runtime/system/ObjectActionImplTest.java
+++ b/core/runtime/src/test/java/org/apache/isis/core/runtime/system/ObjectActionImplTest.java
@@ -21,12 +21,6 @@ package org.apache.isis.core.runtime.system;
import static org.junit.Assert.assertEquals;
-import org.jmock.Expectations;
-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;
@@ -43,6 +37,10 @@ import org.apache.isis.core.metamodel.specloader.specimpl.ObjectActionImpl;
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.jmock.Expectations;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
public class ObjectActionImplTest {
@@ -68,30 +66,8 @@ public class ObjectActionImplTest {
@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() {
{
@@ -103,41 +79,6 @@ public class ObjectActionImplTest {
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() {
http://git-wip-us.apache.org/repos/asf/isis/blob/8da1094b/core/runtime/src/test/java/org/apache/isis/core/runtime/system/transaction/IsisTransactionTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/isis/core/runtime/system/transaction/IsisTransactionTest.java b/core/runtime/src/test/java/org/apache/isis/core/runtime/system/transaction/IsisTransactionTest.java
index c26c3fe..7407bf8 100644
--- a/core/runtime/src/test/java/org/apache/isis/core/runtime/system/transaction/IsisTransactionTest.java
+++ b/core/runtime/src/test/java/org/apache/isis/core/runtime/system/transaction/IsisTransactionTest.java
@@ -23,6 +23,7 @@ import java.util.Collections;
import org.apache.isis.applib.services.audit.AuditingService;
import org.apache.isis.applib.services.publish.PublishingService;
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
import org.apache.isis.core.commons.matchers.IsisMatchers;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.runtime.persistence.ObjectPersistenceException;
@@ -67,6 +68,8 @@ public class IsisTransactionTest {
@Mock
private IsisTransactionManager mockTransactionManager;
@Mock
+ private AuthenticationSession mockAuthenticationSession;
+ @Mock
private MessageBroker mockMessageBroker;
@Mock
private UpdateNotifier mockUpdateNotifier;
@@ -160,6 +163,16 @@ public class IsisTransactionTest {
context.ignoring(mockAuditingService);
+ context.checking(new Expectations(){{
+ allowing(mockTransactionManager).getAuthenticationSession();
+ will(returnValue(mockAuthenticationSession));
+ }});
+
+ context.checking(new Expectations(){{
+ allowing(mockAuthenticationSession).getUserName();
+ will(returnValue("sven"));
+ }});
+
transaction = new IsisTransaction(mockTransactionManager, mockMessageBroker, mockUpdateNotifier, mockObjectStore, mockAuditingService, mockPublishingService);
transientAdapter1 = PojoAdapterBuilder.create().with(Persistence.TRANSIENT).withIdentifier("1").build();