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/03/29 01:58:58 UTC
svn commit: r1306647 - in /incubator/isis/branches/0.3.0-incubating-NEW-OIDs:
core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/oid/
core/testsupport/src/main/java/org/apache/isis/core/testsupport/jmock/
runtimes/dflt/objectstores/dfl...
Author: danhaywood
Date: Wed Mar 28 23:58:57 2012
New Revision: 1306647
URL: http://svn.apache.org/viewvc?rev=1306647&view=rev
Log:
ISIS-216: more reworking of tests for new OIDs
Added:
incubator/isis/branches/0.3.0-incubating-NEW-OIDs/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/oid/ParentedOid.java (with props)
incubator/isis/branches/0.3.0-incubating-NEW-OIDs/core/testsupport/src/main/java/org/apache/isis/core/testsupport/jmock/IsisActions.java (with props)
incubator/isis/branches/0.3.0-incubating-NEW-OIDs/core/testsupport/src/main/java/org/apache/isis/core/testsupport/jmock/ReturnEachAction.java (with props)
incubator/isis/branches/0.3.0-incubating-NEW-OIDs/security/dflt/src/main/java/org/apache/isis/security/dflt/authentication/AuthenticationRequestDefault.java (with props)
Removed:
incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/algorithm/dummy/
incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/oidgenerator/simple/
incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStoreTest_interactionWithAdapterManager.java
Modified:
incubator/isis/branches/0.3.0-incubating-NEW-OIDs/core/testsupport/src/main/java/org/apache/isis/core/testsupport/jmock/JUnitRuleMockery2.java
incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStore.java
incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/objectstores/dflt/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/ObjectStoreInstances_findInstancesAndAdd.java
incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/objectstores/xml/pom.xml
incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/adapterfactory/pojo/PojoAdapter.java
incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/adaptermanager/AdapterManagerDefault.java
incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/algorithm/PersistAlgorithmAbstract.java
incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/runtime/src/main/resources/org/apache/isis/runtimes/dflt/runtime/installer-registry.properties
incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/PersistenceSessionObjectStoreTest.java
incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/algorithm/PersistAlgorithmContractTest.java
incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/algorithm/dflt/DefaultPersistAlgorithmTest.java
incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/TypeExtractorMethodReturnTest.java
incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/main/java/org/apache/isis/runtimes/dflt/testsupport/IsisSystemWithFixtures.java
incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/main/java/org/apache/isis/runtimes/dflt/testsupport/domain/ExamplePojoWithValues.java
incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStoreTestAbstract.java
incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStoreTest_debug.java
incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStoreTest_init.java
incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStoreTest_openAndClose.java
incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStoreTest_persist.java
incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStoreTest_reset.java
incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStoreTest_retrieve.java
incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStoreTest_serviceRegistry.java
Added: incubator/isis/branches/0.3.0-incubating-NEW-OIDs/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/oid/ParentedOid.java
URL: http://svn.apache.org/viewvc/incubator/isis/branches/0.3.0-incubating-NEW-OIDs/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/oid/ParentedOid.java?rev=1306647&view=auto
==============================================================================
--- incubator/isis/branches/0.3.0-incubating-NEW-OIDs/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/oid/ParentedOid.java (added)
+++ incubator/isis/branches/0.3.0-incubating-NEW-OIDs/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/oid/ParentedOid.java Wed Mar 28 23:58:57 2012
@@ -0,0 +1,93 @@
+/*
+ * 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.metamodel.adapter.oid;
+
+import java.io.IOException;
+import java.io.Serializable;
+
+import org.apache.isis.core.commons.encoding.DataInputExtended;
+import org.apache.isis.core.commons.encoding.DataOutputExtended;
+
+/**
+ * Base type of the {@link Oid} for collections, values and <tt>@Aggregated</tt>
+ * types.
+ *
+ * @see AggregatedOid
+ */
+public abstract class ParentedOid implements Oid, Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private final Oid parentOid;
+
+ // /////////////////////////////////////////////////////////
+ // Constructor
+ // /////////////////////////////////////////////////////////
+
+ public ParentedOid(final Oid parentOid) {
+ this.parentOid = parentOid;
+ }
+
+
+ // ////////////////////////////////////////////
+ // Encodeable
+ // ////////////////////////////////////////////
+
+ public ParentedOid(final DataInputExtended input) throws IOException {
+ final String type = input.readUTF();
+ this.parentOid = recreateParentOid(type, input);
+ }
+
+ @Override
+ public void encode(final DataOutputExtended output) throws IOException {
+ final String type = determineParentType();
+ output.writeUTF(type);
+ this.parentOid.encode(output);
+ }
+
+
+ private String determineParentType() {
+ if(parentOid instanceof RootOid) { return "R"; }
+ if(parentOid instanceof AggregatedOid) { return "A"; }
+ throw new IllegalStateException("Unknown parent Oid type; parentOid class is: " + parentOid.getClass().getName());
+ }
+
+ private static Oid recreateParentOid(String type, DataInputExtended input) throws IOException {
+ if(type.equals("R")) { return new RootOidDefault(input); }
+ if(type.equals("A")) { return new AggregatedOid(input); }
+ throw new IllegalArgumentException("Unknown parent Oid type: " + type);
+ }
+
+
+ // /////////////////////////////////////////////////////////
+ // Properties
+ // /////////////////////////////////////////////////////////
+
+ public Oid getParentOid() {
+ return parentOid;
+ }
+
+ @Override
+ public boolean isTransient() {
+ return getParentOid().isTransient();
+ }
+
+
+}
Propchange: incubator/isis/branches/0.3.0-incubating-NEW-OIDs/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/oid/ParentedOid.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/isis/branches/0.3.0-incubating-NEW-OIDs/core/testsupport/src/main/java/org/apache/isis/core/testsupport/jmock/IsisActions.java
URL: http://svn.apache.org/viewvc/incubator/isis/branches/0.3.0-incubating-NEW-OIDs/core/testsupport/src/main/java/org/apache/isis/core/testsupport/jmock/IsisActions.java?rev=1306647&view=auto
==============================================================================
--- incubator/isis/branches/0.3.0-incubating-NEW-OIDs/core/testsupport/src/main/java/org/apache/isis/core/testsupport/jmock/IsisActions.java (added)
+++ incubator/isis/branches/0.3.0-incubating-NEW-OIDs/core/testsupport/src/main/java/org/apache/isis/core/testsupport/jmock/IsisActions.java Wed Mar 28 23:58:57 2012
@@ -0,0 +1,23 @@
+package org.apache.isis.core.testsupport.jmock;
+
+import org.jmock.api.Action;
+
+public final class IsisActions {
+
+ private IsisActions() {
+ }
+
+ public static Action injectInto() {
+ return InjectIntoJMockAction.injectInto();
+ }
+
+ public static <T> Action returnEach(final T... values) {
+ return ReturnEachAction.returnEach(values);
+ }
+
+ public static Action returnArgument(final int i) {
+ return ReturnArgumentJMockAction.returnArgument(i);
+ }
+
+
+}
Propchange: incubator/isis/branches/0.3.0-incubating-NEW-OIDs/core/testsupport/src/main/java/org/apache/isis/core/testsupport/jmock/IsisActions.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/isis/branches/0.3.0-incubating-NEW-OIDs/core/testsupport/src/main/java/org/apache/isis/core/testsupport/jmock/JUnitRuleMockery2.java
URL: http://svn.apache.org/viewvc/incubator/isis/branches/0.3.0-incubating-NEW-OIDs/core/testsupport/src/main/java/org/apache/isis/core/testsupport/jmock/JUnitRuleMockery2.java?rev=1306647&r1=1306646&r2=1306647&view=diff
==============================================================================
--- incubator/isis/branches/0.3.0-incubating-NEW-OIDs/core/testsupport/src/main/java/org/apache/isis/core/testsupport/jmock/JUnitRuleMockery2.java (original)
+++ incubator/isis/branches/0.3.0-incubating-NEW-OIDs/core/testsupport/src/main/java/org/apache/isis/core/testsupport/jmock/JUnitRuleMockery2.java Wed Mar 28 23:58:57 2012
@@ -98,4 +98,13 @@ public class JUnitRuleMockery2 extends J
});
return mock;
}
+
+ /**
+ * Ignore a set of mocks.
+ */
+ public void ignoring(Object... mocks) {
+ for (Object mock : mocks) {
+ ignoring(mock);
+ }
+ }
}
Added: incubator/isis/branches/0.3.0-incubating-NEW-OIDs/core/testsupport/src/main/java/org/apache/isis/core/testsupport/jmock/ReturnEachAction.java
URL: http://svn.apache.org/viewvc/incubator/isis/branches/0.3.0-incubating-NEW-OIDs/core/testsupport/src/main/java/org/apache/isis/core/testsupport/jmock/ReturnEachAction.java?rev=1306647&view=auto
==============================================================================
--- incubator/isis/branches/0.3.0-incubating-NEW-OIDs/core/testsupport/src/main/java/org/apache/isis/core/testsupport/jmock/ReturnEachAction.java (added)
+++ incubator/isis/branches/0.3.0-incubating-NEW-OIDs/core/testsupport/src/main/java/org/apache/isis/core/testsupport/jmock/ReturnEachAction.java Wed Mar 28 23:58:57 2012
@@ -0,0 +1,40 @@
+package org.apache.isis.core.testsupport.jmock;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.hamcrest.Description;
+import org.jmock.api.Action;
+import org.jmock.api.Invocation;
+
+public class ReturnEachAction<T> implements Action {
+
+ private final Collection<T> collection;
+ private final Iterator<T> iterator;
+
+ public ReturnEachAction(Collection<T> collection) {
+ this.collection = collection;
+ this.iterator = collection.iterator();
+ }
+
+ public ReturnEachAction(T... array) {
+ this(Arrays.asList(array));
+ }
+
+ public T invoke(Invocation invocation) throws Throwable {
+ return iterator.next();
+ }
+
+ public void describeTo(Description description) {
+ description.appendValueList("return iterator.next() over ", ", ", "", collection);
+ }
+
+ /**
+ * Factory
+ */
+ public static <T> Action returnEach(final T... values) {
+ return new ReturnEachAction<T>(values);
+ }
+
+}
Propchange: incubator/isis/branches/0.3.0-incubating-NEW-OIDs/core/testsupport/src/main/java/org/apache/isis/core/testsupport/jmock/ReturnEachAction.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStore.java
URL: http://svn.apache.org/viewvc/incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStore.java?rev=1306647&r1=1306646&r2=1306647&view=diff
==============================================================================
--- incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStore.java (original)
+++ incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/objectstores/dflt/src/main/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStore.java Wed Mar 28 23:58:57 2012
@@ -315,7 +315,6 @@ public class InMemoryObjectStore impleme
for (int i = 0; i < subclasses.size(); i++) {
findInstances(subclasses.get(i), persistenceQuery, foundInstances);
}
-
}
private ObjectAdapter[] toInstancesArray(final Vector<ObjectAdapter> instances) {
Modified: incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/objectstores/dflt/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/ObjectStoreInstances_findInstancesAndAdd.java
URL: http://svn.apache.org/viewvc/incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/objectstores/dflt/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/ObjectStoreInstances_findInstancesAndAdd.java?rev=1306647&r1=1306646&r2=1306647&view=diff
==============================================================================
--- incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/objectstores/dflt/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/ObjectStoreInstances_findInstancesAndAdd.java (original)
+++ incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/objectstores/dflt/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/ObjectStoreInstances_findInstancesAndAdd.java Wed Mar 28 23:58:57 2012
@@ -19,83 +19,104 @@
package org.apache.isis.runtimes.dflt.objectstores.dflt.internal;
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.assertThat;
+
import java.util.List;
import com.google.common.collect.Lists;
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+import org.hamcrest.TypeSafeMatcher;
import org.jmock.Expectations;
import org.jmock.Mockery;
+import org.jmock.auto.Mock;
import org.jmock.integration.junit4.JMock;
import org.jmock.integration.junit4.JUnit4Mockery;
import org.junit.Before;
import org.junit.Ignore;
+import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
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.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.testsupport.jmock.IsisActions;
+import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2;
+import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2.Mode;
import org.apache.isis.runtimes.dflt.runtime.persistence.query.PersistenceQueryBuiltIn;
+import org.apache.isis.runtimes.dflt.runtime.system.persistence.AdapterManager;
-/**
- * Tested in style of <i>Working Effectively with Legacy Code</i> (Feathers) and
- * <i>Growing Object-Oriented Software</i> (Freeman & Pryce).
- */
-@RunWith(JMock.class)
public class ObjectStoreInstances_findInstancesAndAdd {
private ObjectStoreInstances instances;
- private final Mockery context = new JUnit4Mockery();
+ @Rule
+ public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
+ @Mock
private ObjectSpecification mockSpec;
+ @Mock
private PersistenceQueryBuiltIn mockPersistenceQueryBuiltIn;
- // private ObjectAdapter mockAdapter;
+ @Mock
private AuthenticationSession mockAuthSession;
+ @Mock
+ private AdapterManager mockAdapterManager;
+
+ @Mock
+ private ObjectAdapter mockAdapter1;
+ @Mock
+ private ObjectAdapter mockAdapter2;
@Before
public void setUp() throws Exception {
- mockSpec = context.mock(ObjectSpecification.class);
- mockPersistenceQueryBuiltIn = context.mock(PersistenceQueryBuiltIn.class);
- // mockAdapter = context.mock(ObjectAdapter.class);
- mockAuthSession = context.mock(AuthenticationSession.class);
instances = new ObjectStoreInstances(mockSpec) {
@Override
protected AuthenticationSession getAuthenticationSession() {
return mockAuthSession;
}
- };
- ignoreAuthenticationSession();
- }
-
- private void ignoreAuthenticationSession() {
- context.checking(new Expectations() {
- {
- ignoring(mockAuthSession);
+ @Override
+ protected AdapterManager getAdapterManager() {
+ return mockAdapterManager;
}
- });
+ };
+ context.ignoring(mockAuthSession);
}
@Test
- public void findInstancesAndAddWhenEmpty() throws Exception {
- neverInteractsWithPersistenceQueryBuiltIn();
+ public void findInstancesAndAdd_whenEmpty() throws Exception {
+ context.never(mockPersistenceQueryBuiltIn);
final List<ObjectAdapter> foundInstances = Lists.newArrayList();
instances.findInstancesAndAdd(mockPersistenceQueryBuiltIn, foundInstances);
}
- @Ignore
- // not yet implemented
@Test
- public void findInstancesAndNotEmpty() throws Exception {
-
- }
-
- private void neverInteractsWithPersistenceQueryBuiltIn() {
+ public void findInstancesAndAdd_whenNotEmpty() throws Exception {
+ context.ignoring(mockAdapter1, mockAdapter2);
context.checking(new Expectations() {
{
- never(mockPersistenceQueryBuiltIn);
+ one(mockPersistenceQueryBuiltIn).matches(mockAdapter1);
+ will(returnValue(false));
+
+ one(mockPersistenceQueryBuiltIn).matches(mockAdapter2);
+ will(returnValue(true));
+
+ allowing(mockAdapterManager).getAdapterFor(with(any(Object.class)));
+ will(IsisActions.returnEach(mockAdapter1, mockAdapter2));
}
});
+
+ instances.save(mockAdapter1);
+ instances.save(mockAdapter2);
+
+ final List<ObjectAdapter> foundInstances = Lists.newArrayList();
+ instances.findInstancesAndAdd(mockPersistenceQueryBuiltIn, foundInstances);
+
+ assertThat(foundInstances.size(), is(1));
+ assertThat(foundInstances, IsisMatchers.listContaining(mockAdapter2));
}
}
Modified: incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/objectstores/xml/pom.xml
URL: http://svn.apache.org/viewvc/incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/objectstores/xml/pom.xml?rev=1306647&r1=1306646&r2=1306647&view=diff
==============================================================================
--- incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/objectstores/xml/pom.xml (original)
+++ incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/objectstores/xml/pom.xml Wed Mar 28 23:58:57 2012
@@ -95,12 +95,14 @@
<groupId>org.apache.isis.runtimes.dflt</groupId>
<artifactId>runtime</artifactId>
</dependency>
+ <!--
<dependency>
<groupId>org.apache.isis.runtimes.dflt</groupId>
<artifactId>runtime</artifactId>
<type>test-jar</type>
<scope>test</scope>
</dependency>
+ -->
<dependency>
<groupId>org.apache.isis.runtimes.dflt</groupId>
<artifactId>testsupport</artifactId>
Modified: incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/adapterfactory/pojo/PojoAdapter.java
URL: http://svn.apache.org/viewvc/incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/adapterfactory/pojo/PojoAdapter.java?rev=1306647&r1=1306646&r2=1306647&view=diff
==============================================================================
--- incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/adapterfactory/pojo/PojoAdapter.java (original)
+++ incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/adapterfactory/pojo/PojoAdapter.java Wed Mar 28 23:58:57 2012
@@ -136,6 +136,10 @@ public class PojoAdapter extends Instanc
@Override
public void changeState(final ResolveState newState) {
+
+ if(isAggregated()) {
+ return; // no-op for aggregated objects.
+ }
final boolean validToChangeTo = resolveState.isValidToChangeTo(newState);
// don't call toString() since that could hit titleString() and we might
@@ -235,8 +239,7 @@ public class PojoAdapter extends Instanc
}
ParentedOid parentedOid = (ParentedOid) oid;
final Oid parentOid = parentedOid.getParentOid();
- final ObjectAdapter parentAdapter = objectAdapterLookup.getAdapterFor(parentOid);
- return parentAdapter;
+ return objectAdapterLookup.getAdapterFor(parentOid);
}
@@ -309,8 +312,7 @@ public class PojoAdapter extends Instanc
}
private String objectTitleString() {
- final ResolveState resolveState = getResolveState();
- if (resolveState.isNew()) {
+ if (getResolveState().isNew()) {
return "";
}
if (getObject() instanceof String) {
@@ -384,7 +386,7 @@ public class PojoAdapter extends Instanc
}
protected void toString(final ToString str) {
- str.append(resolveState.code());
+ str.append(getResolveState().code());
final Oid oid = getOid();
if (oid != null) {
str.append(":");
Modified: incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/adaptermanager/AdapterManagerDefault.java
URL: http://svn.apache.org/viewvc/incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/adaptermanager/AdapterManagerDefault.java?rev=1306647&r1=1306646&r2=1306647&view=diff
==============================================================================
--- incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/adaptermanager/AdapterManagerDefault.java (original)
+++ incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/adaptermanager/AdapterManagerDefault.java Wed Mar 28 23:58:57 2012
@@ -290,11 +290,6 @@ public class AdapterManagerDefault exten
return objSpec.containsFacet(AggregatedFacet.class);
}
- private static boolean isAggregated(final ObjectAssociation association) {
- return association.containsFacet(AggregatedFacet.class);
- }
-
-
// //////////////////////////////////////////////////////////////////
// Recreate adapter
@@ -410,10 +405,10 @@ public class AdapterManagerDefault exten
}
if (LOG.isDebugEnabled()) {
- LOG.debug("removing aggregate adapter(s) from oid map");
+ LOG.debug("removing collection adapter(s) from oid map");
}
- for (final ObjectAdapter aggregateAdapter : rootAndCollectionAdapters) {
- final Oid collectionOid = aggregateAdapter.getOid();
+ for (final ObjectAdapter collectionAdapter : rootAndCollectionAdapters) {
+ final Oid collectionOid = collectionAdapter.getOid();
removed = getOidAdapterMap().remove(collectionOid);
if (!removed) {
LOG.warn("could not remove collectionOid: " + collectionOid);
Modified: incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/algorithm/PersistAlgorithmAbstract.java
URL: http://svn.apache.org/viewvc/incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/algorithm/PersistAlgorithmAbstract.java?rev=1306647&r1=1306646&r2=1306647&view=diff
==============================================================================
--- incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/algorithm/PersistAlgorithmAbstract.java (original)
+++ incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/algorithm/PersistAlgorithmAbstract.java Wed Mar 28 23:58:57 2012
@@ -60,7 +60,7 @@ public abstract class PersistAlgorithmAb
* existing code that throws an exception if the latter is not fulfilled.
* <b><i>REVIEW: should try to combine and remove the other method</i></b>.
*/
- protected boolean alreadyPersistedOrNotPersistableOrServiceOrStandalone(final ObjectAdapter adapter) {
+ protected static boolean alreadyPersistedOrNotPersistableOrServiceOrStandalone(final ObjectAdapter adapter) {
return objectIsStandalone(adapter) || objectSpecIsService(adapter) || alreadyPersistedOrNotPersistable(adapter);
}
@@ -71,7 +71,7 @@ public abstract class PersistAlgorithmAb
*
* @see #alreadyPersistedOrNotPersistableOrServiceOrStandalone(ObjectAdapter)
*/
- protected boolean alreadyPersistedOrNotPersistable(final ObjectAdapter adapter) {
+ protected static boolean alreadyPersistedOrNotPersistable(final ObjectAdapter adapter) {
return adapter.isPersistent() || objectSpecNotPersistable(adapter);
}
@@ -79,21 +79,21 @@ public abstract class PersistAlgorithmAb
* As per {@link #alreadyPersistedOrNotPersistable(ObjectAdapter)}, ensures
* object can be persisted else throws {@link NotPersistableException}.
*/
- protected void assertObjectNotPersistentAndPersistable(final ObjectAdapter object) {
+ protected static void assertObjectNotPersistentAndPersistable(final ObjectAdapter object) {
if (alreadyPersistedOrNotPersistable(object)) {
throw new NotPersistableException("can't make object persistent - either already persistent, " + "or transient only: " + object);
}
}
- private boolean objectIsStandalone(final ObjectAdapter adapter) {
+ private static boolean objectIsStandalone(final ObjectAdapter adapter) {
return adapter.getResolveState().isValue();
}
- private boolean objectSpecNotPersistable(final ObjectAdapter adapter) {
+ private static boolean objectSpecNotPersistable(final ObjectAdapter adapter) {
return !adapter.getSpecification().persistability().isPersistable() || adapter.isParented();
}
- private boolean objectSpecIsService(final ObjectAdapter adapter) {
+ private static boolean objectSpecIsService(final ObjectAdapter adapter) {
return adapter.getSpecification().isService();
}
Modified: incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/runtime/src/main/resources/org/apache/isis/runtimes/dflt/runtime/installer-registry.properties
URL: http://svn.apache.org/viewvc/incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/runtime/src/main/resources/org/apache/isis/runtimes/dflt/runtime/installer-registry.properties?rev=1306647&r1=1306646&r2=1306647&view=diff
==============================================================================
--- incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/runtime/src/main/resources/org/apache/isis/runtimes/dflt/runtime/installer-registry.properties (original)
+++ incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/runtime/src/main/resources/org/apache/isis/runtimes/dflt/runtime/installer-registry.properties Wed Mar 28 23:58:57 2012
@@ -58,7 +58,7 @@ org.apache.isis.viewer.json.viewer.embed
############################################################
# in default runtime only for dynamic lookup of facet decorators
-org.apache.isis.runtimes.dflt.progmodels.JavaReflectorInstaller # "java"
+org.apache.isis.runtimes.dflt.runtime.progmodels.JavaReflectorInstaller # "java"
############################################################
# DEFAULT RUNTIME
Modified: incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/PersistenceSessionObjectStoreTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/PersistenceSessionObjectStoreTest.java?rev=1306647&r1=1306646&r2=1306647&view=diff
==============================================================================
--- incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/PersistenceSessionObjectStoreTest.java (original)
+++ incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/PersistenceSessionObjectStoreTest.java Wed Mar 28 23:58:57 2012
@@ -19,6 +19,9 @@
package org.apache.isis.runtimes.dflt.runtime.persistence.objectstore;
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.assertThat;
+
import java.util.Collections;
import org.apache.log4j.Level;
@@ -43,7 +46,9 @@ import org.apache.isis.runtimes.dflt.run
import org.apache.isis.runtimes.dflt.runtime.persistence.adaptermanager.AdapterManagerDefault;
import org.apache.isis.runtimes.dflt.runtime.persistence.adaptermanager.AdapterManagerExtended;
import org.apache.isis.runtimes.dflt.runtime.persistence.internal.RuntimeContextFromSession;
-import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.algorithm.dummy.DummyPersistAlgorithm;
+import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.algorithm.PersistAlgorithm;
+import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.algorithm.ToPersistObjectSet;
+import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.algorithm.dflt.DefaultPersistAlgorithm;
import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.CreateObjectCommand;
import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.DestroyObjectCommand;
import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.ObjectStoreTransactionManager;
@@ -75,10 +80,13 @@ public class PersistenceSessionObjectSto
@Mock
private PersistenceSessionFactory mockPersistenceSessionFactory;
+
@Mock
private ObjectStore mockObjectStore;
@Mock
private ObjectFactory objectFactory;
+ @Mock
+ private PersistAlgorithm mockPersistAlgorithm;
@Mock
private CreateObjectCommand createObjectCommand;
@@ -93,6 +101,8 @@ public class PersistenceSessionObjectSto
@Mock
private EmbeddedContext mockMetaModelContext;
+
+
private IsisMetaModel isisMetaModel;
@@ -114,6 +124,8 @@ public class PersistenceSessionObjectSto
{
ignoring(mockObjectStore).open();
ignoring(mockObjectStore).close();
+ ignoring(mockObjectStore).name();
+ ignoring(mockPersistAlgorithm).name();
ignoring(createObjectCommand);
ignoring(saveObjectCommand);
@@ -133,7 +145,7 @@ public class PersistenceSessionObjectSto
adapterManager = new AdapterManagerDefault();
adapterFactory = new PojoAdapterFactory();
- persistenceSession = new PersistenceSessionObjectStore(mockPersistenceSessionFactory, adapterFactory, objectFactory, servicesInjector, new RootOidGenerator(), adapterManager, new DummyPersistAlgorithm(), mockObjectStore);
+ persistenceSession = new PersistenceSessionObjectStore(mockPersistenceSessionFactory, adapterFactory, objectFactory, servicesInjector, new RootOidGenerator(), adapterManager, mockPersistAlgorithm, mockObjectStore);
transactionManager = new ObjectStoreTransactionManager(persistenceSession, mockObjectStore);
transactionManager.injectInto(persistenceSession);
@@ -196,28 +208,20 @@ public class PersistenceSessionObjectSto
}
@Test
- public void makePersistent() {
+ public void makePersistent_happyCase() {
final Sequence tran = context.sequence("tran");
context.checking(new Expectations() {
{
one(mockObjectStore).startTransaction();
inSequence(tran);
-
- one(mockObjectStore).createCreateObjectCommand(with(any(ObjectAdapter.class)));
- inSequence(tran);
- will(returnValue(createObjectCommand));
-
- one(mockObjectStore).execute(with(IsisMatchers.listContaining((PersistenceCommand)createObjectCommand)));
+ one(mockPersistAlgorithm).makePersistent(transientAdapter, persistenceSession);
inSequence(tran);
-
one(mockObjectStore).endTransaction();
inSequence(tran);
}
});
- // note that the persist algorithm also gets a look-in (not tested here...)
-
transactionManager.startTransaction();
persistenceSession.makePersistent(transientAdapter);
transactionManager.endTransaction();
Modified: incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/algorithm/PersistAlgorithmContractTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/algorithm/PersistAlgorithmContractTest.java?rev=1306647&r1=1306646&r2=1306647&view=diff
==============================================================================
--- incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/algorithm/PersistAlgorithmContractTest.java (original)
+++ incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/algorithm/PersistAlgorithmContractTest.java Wed Mar 28 23:58:57 2012
@@ -25,12 +25,16 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapterLookup;
+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.testsupport.jmock.JUnitRuleMockery2;
import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2.Mode;
+import org.apache.isis.runtimes.dflt.runtime.persistence.NotPersistableException;
import org.apache.isis.runtimes.dflt.runtime.persistence.adapterfactory.pojo.PojoAdapter;
import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.PojoAdapterBuilder;
+import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.PojoAdapterBuilder.Persistence;
import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.PojoAdapterBuilder.Type;
public abstract class PersistAlgorithmContractTest {
@@ -44,7 +48,11 @@ public abstract class PersistAlgorithmCo
@Mock
private ObjectSpecification objectSpec;
+ @Mock
+ private ObjectAdapterLookup mockObjectAdapterLookup;
+
private PersistAlgorithm persistAlgorithm;
+
@Before
@@ -60,7 +68,7 @@ public abstract class PersistAlgorithmCo
protected abstract PersistAlgorithm createPersistAlgorithm();
@Test
- public void makePersistent_SkipsValueObjects() {
+ public void makePersistent_skipsValueObjects() {
context.checking(new Expectations() {
{
@@ -73,9 +81,69 @@ public abstract class PersistAlgorithmCo
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).isCollection();
+ 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).isCollection();
+ 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).isCollection();
+ 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);
+ }
}
Modified: incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/algorithm/dflt/DefaultPersistAlgorithmTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/algorithm/dflt/DefaultPersistAlgorithmTest.java?rev=1306647&r1=1306646&r2=1306647&view=diff
==============================================================================
--- incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/algorithm/dflt/DefaultPersistAlgorithmTest.java (original)
+++ incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/algorithm/dflt/DefaultPersistAlgorithmTest.java Wed Mar 28 23:58:57 2012
@@ -19,6 +19,7 @@
package org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.algorithm.dflt;
+import org.junit.Before;
import org.junit.Test;
import org.apache.isis.applib.annotation.Ignore;
@@ -45,7 +46,8 @@ public class DefaultPersistAlgorithmTest
//
// private final String objectType = "CUS";
//
-// private DefaultPersistAlgorithm algorithm;
+ private DefaultPersistAlgorithm algorithm;
+
// private PersistedObjectAdderSpy adder;
// private ObjectAdapter object;
// private TestProxyAdapter fieldsObject;
@@ -147,26 +149,12 @@ public class DefaultPersistAlgorithmTest
// adder = new PersistedObjectAdderSpy();
// }
- @Ignore //DKH
- @Test
- public void testMakePersistentFailsIfObjectAlreadyPersistent() {
-// object.changeState(ResolveState.RESOLVED);
-// try {
-// algorithm.makePersistent(object, adder);
-// fail();
-// } catch (final NotPersistableException expected) {
-// }
- }
-
- @Ignore //DKH
- @Test
- public void testMakePersistentFailsIfObjectMustBeTransient() {
-// try {
-// ((TestProxySpecification) object.getSpecification()).setupPersistable(Persistability.TRANSIENT);
-// algorithm.makePersistent(object, adder);
-// } catch (final NotPersistableException expected) {
-// }
+
+ @Before
+ public void setUp() throws Exception {
+ algorithm = new DefaultPersistAlgorithm();
}
+
@Ignore //DKH
@Test
Modified: incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/TypeExtractorMethodReturnTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/TypeExtractorMethodReturnTest.java?rev=1306647&r1=1306646&r2=1306647&view=diff
==============================================================================
--- incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/TypeExtractorMethodReturnTest.java (original)
+++ incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/system/TypeExtractorMethodReturnTest.java Wed Mar 28 23:58:57 2012
@@ -50,9 +50,10 @@ public class TypeExtractorMethodReturnTe
final TypeExtractorMethodReturn extractor = new TypeExtractorMethodReturn(method);
- assertThat(extractor.getClasses().size(), is(2));
- assertThat(extractor.getClasses(), containsElementThat(equalTo(java.util.List.class)));
- assertThat(extractor.getClasses(), containsElementThat(equalTo(Customer.class)));
+ final List<Class<?>> classes = extractor.getClasses();
+ assertThat(classes.size(), is(2));
+ assertThat(classes, containsElementThat(equalTo((Class<?>)java.util.List.class)));
+ assertThat(classes, containsElementThat(equalTo((Class<?>)Customer.class)));
}
@Test
Modified: incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/main/java/org/apache/isis/runtimes/dflt/testsupport/IsisSystemWithFixtures.java
URL: http://svn.apache.org/viewvc/incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/main/java/org/apache/isis/runtimes/dflt/testsupport/IsisSystemWithFixtures.java?rev=1306647&r1=1306646&r2=1306647&view=diff
==============================================================================
--- incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/main/java/org/apache/isis/runtimes/dflt/testsupport/IsisSystemWithFixtures.java (original)
+++ incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/main/java/org/apache/isis/runtimes/dflt/testsupport/IsisSystemWithFixtures.java Wed Mar 28 23:58:57 2012
@@ -19,6 +19,10 @@
package org.apache.isis.runtimes.dflt.testsupport;
+import static org.junit.Assert.assertEquals;
+
+import java.util.Collections;
+
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.junit.After;
@@ -31,9 +35,11 @@ import org.apache.isis.core.commons.auth
import org.apache.isis.core.commons.config.IsisConfiguration;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.metamodel.adapter.oid.RootOid;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
import org.apache.isis.core.runtime.authentication.AuthenticationManager;
import org.apache.isis.core.runtime.authentication.AuthenticationRequest;
import org.apache.isis.runtimes.dflt.runtime.installerregistry.installerapi.PersistenceMechanismInstaller;
+import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.PersistenceCommand;
import org.apache.isis.runtimes.dflt.runtime.system.DeploymentType;
import org.apache.isis.runtimes.dflt.runtime.system.IsisSystemException;
import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
@@ -137,14 +143,11 @@ public class IsisSystemWithFixtures impl
public void setUpSystem() throws Exception {
Logger.getRootLogger().setLevel(Level.OFF);
- if(isisSystem == null) {
+ boolean firstTime = isisSystem == null;
+ if(firstTime) {
fixtures = new Fixtures();
isisSystem = createIsisSystem(fixtures.testPojoRepository, fixtures.examplePojoRepository);
isisSystem.init();
-
- if(fixturesInitialization == Fixtures.Initialization.INIT) {
- fixtures.init(container);
- }
IsisContext.closeSession();
}
@@ -152,8 +155,14 @@ public class IsisSystemWithFixtures impl
authenticationSession = authenticationManager.authenticate(createAuthenticationRequest());
IsisContext.openSession(authenticationSession);
-
- container = IsisContext.getPersistenceSession().getServicesInjector().getContainer();
+ container = getContainer();
+ if(firstTime && fixturesInitialization == Fixtures.Initialization.INIT) {
+ fixtures.init(container);
+ }
+ }
+
+ private DomainObjectContainer getContainer() {
+ return IsisContext.getPersistenceSession().getServicesInjector().getContainer();
}
/**
@@ -163,6 +172,11 @@ public class IsisSystemWithFixtures impl
IsisContext.closeSession();
}
+ public void bounceSystem() throws Exception {
+ tearDownSystem();
+ setUpSystem();
+ }
+
private IsisSystemDefault createIsisSystem(Object... services) {
return new IsisSystemDefault(DeploymentType.UNIT_TESTING, services) {
@@ -225,13 +239,24 @@ public class IsisSystemWithFixtures impl
// Convenience for tests
////////////////////////////////////////////////////////////
+ public ObjectSpecification specificationFor(Class<?> cls) {
+ return getIsisSystem().getSessionFactory().getSpecificationLoader().loadSpecification(cls);
+ }
+
public ObjectAdapter persist(Object domainObject) {
ensureSessionInProgress();
- ensureObjectNotPersistent(domainObject);
+ ensureObjectIsNotPersistent(domainObject);
container.persist(domainObject);
return adapterFor(domainObject);
}
+ public ObjectAdapter destroy(Object domainObject ) {
+ ensureSessionInProgress();
+ ensureObjectIsPersistent(domainObject);
+ container.remove(domainObject);
+ return adapterFor(domainObject);
+ }
+
public ObjectAdapter adapterFor(Object domainObject) {
ensureSessionInProgress();
return IsisContext.getPersistenceSession().getAdapterManager().adapterFor(domainObject);
@@ -248,12 +273,18 @@ public class IsisSystemWithFixtures impl
}
}
- private void ensureObjectNotPersistent(Object domainObject) {
+ private void ensureObjectIsNotPersistent(Object domainObject) {
if(container.isPersistent(domainObject)) {
throw new IllegalArgumentException("domain object is already persistent");
}
}
+ private void ensureObjectIsPersistent(Object domainObject) {
+ if(!container.isPersistent(domainObject)) {
+ throw new IllegalArgumentException("domain object is not persistent");
+ }
+ }
+
////////////////////////////////////////////////////////////
// JUnit @Rule integration
////////////////////////////////////////////////////////////
@@ -275,5 +306,8 @@ public class IsisSystemWithFixtures impl
+
+
+
}
Modified: incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/main/java/org/apache/isis/runtimes/dflt/testsupport/domain/ExamplePojoWithValues.java
URL: http://svn.apache.org/viewvc/incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/main/java/org/apache/isis/runtimes/dflt/testsupport/domain/ExamplePojoWithValues.java?rev=1306647&r1=1306646&r2=1306647&view=diff
==============================================================================
--- incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/main/java/org/apache/isis/runtimes/dflt/testsupport/domain/ExamplePojoWithValues.java (original)
+++ incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/main/java/org/apache/isis/runtimes/dflt/testsupport/domain/ExamplePojoWithValues.java Wed Mar 28 23:58:57 2012
@@ -23,11 +23,18 @@ import org.apache.isis.applib.annotation
import org.apache.isis.applib.annotation.NotPersisted;
import org.apache.isis.applib.annotation.ObjectType;
import org.apache.isis.applib.annotation.Optional;
+import org.apache.isis.applib.util.TitleBuffer;
import org.apache.isis.core.commons.exceptions.UnexpectedCallException;
@ObjectType("EPV")
public class ExamplePojoWithValues extends ExamplePojo {
+
+ public String title() {
+ return getName();
+ }
+
+
// {{ Name
private String name;
Modified: incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStoreTestAbstract.java
URL: http://svn.apache.org/viewvc/incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStoreTestAbstract.java?rev=1306647&r1=1306646&r2=1306647&view=diff
==============================================================================
--- incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStoreTestAbstract.java (original)
+++ incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStoreTestAbstract.java Wed Mar 28 23:58:57 2012
@@ -19,12 +19,44 @@
package org.apache.isis.runtimes.dflt.objectstores.dflt;
-import org.apache.isis.runtimes.dflt.testsupport.TestSystemWithObjectStoreTestAbstract;
+import org.junit.Before;
+import org.junit.Rule;
-public abstract class InMemoryObjectStoreTestAbstract extends TestSystemWithObjectStoreTestAbstract {
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.runtimes.dflt.runtime.installerregistry.installerapi.PersistenceMechanismInstaller;
+import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.PersistenceSessionObjectStore;
+import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
+import org.apache.isis.runtimes.dflt.testsupport.IsisSystemWithFixtures;
+import org.apache.isis.runtimes.dflt.testsupport.domain.ExamplePojoWithValues;
- protected InMemoryPersistenceMechanismInstaller createPersistenceMechanismInstaller() {
- return new InMemoryPersistenceMechanismInstaller();
+
+public abstract class InMemoryObjectStoreTestAbstract {
+
+ @Rule
+ public IsisSystemWithFixtures iswf = new IsisSystemWithFixtures() {
+ protected PersistenceMechanismInstaller obtainPersistenceMechanismInstaller(IsisConfiguration configuration) {
+ final InMemoryPersistenceMechanismInstaller installer = new InMemoryPersistenceMechanismInstaller();
+ installer.setConfiguration(configuration);
+ return installer;
+ };
+ };
+
+ protected ObjectAdapter epv2Adapter;
+ protected ObjectSpecification epvSpecification;
+
+ protected InMemoryObjectStore getStore() {
+ PersistenceSessionObjectStore psos = (PersistenceSessionObjectStore)IsisContext.getPersistenceSession();
+ return (InMemoryObjectStore) psos.getObjectStore();
+ }
+
+ @Before
+ public void setUpFixtures() throws Exception {
+ epv2Adapter = iswf.adapterFor(iswf.fixtures.epv2);
+ epvSpecification = iswf.specificationFor(ExamplePojoWithValues.class);
}
+
+
}
Modified: incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStoreTest_debug.java
URL: http://svn.apache.org/viewvc/incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStoreTest_debug.java?rev=1306647&r1=1306646&r2=1306647&view=diff
==============================================================================
--- incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStoreTest_debug.java (original)
+++ incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStoreTest_debug.java Wed Mar 28 23:58:57 2012
@@ -22,13 +22,11 @@ package org.apache.isis.runtimes.dflt.ob
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
-import java.util.Collections;
-
+import org.hamcrest.CoreMatchers;
import org.junit.Test;
import org.apache.isis.core.commons.debug.DebugString;
-import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.CreateObjectCommand;
-import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.PersistenceCommand;
+import org.apache.isis.core.commons.matchers.IsisMatchers;
public class InMemoryObjectStoreTest_debug extends InMemoryObjectStoreTestAbstract {
@@ -37,7 +35,7 @@ public class InMemoryObjectStoreTest_deb
public void debugTitle() throws Exception {
// when
- final String debugTitle = store.debugTitle();
+ final String debugTitle = getStore().debugTitle();
// then
assertThat(debugTitle, is("In-Memory Object Store"));
@@ -45,26 +43,27 @@ public class InMemoryObjectStoreTest_deb
@Test
- public void debugXxx_whenHasCommand() throws Exception {
+ public void debugXxx_whenHasObject() throws Exception {
// given
- final CreateObjectCommand command = store.createCreateObjectCommand(adapter1);
- store.execute(Collections.<PersistenceCommand> singletonList(command));
+ iswf.persist(iswf.fixtures.epv1);
// when
final DebugString debug = new DebugString();
- store.debugData(debug);
+ getStore().debugData(debug);
+
// then
- assertThat(debug.toString(), is("\nDomain Objects\n--------------\norg.apache.isis.runtimes.dflt.testsupport.domain.TestPojo\n TOID:CUS#1: Pojo#24 (object 1)\n\n\n"));
+ assertThat(debug.toString(), IsisMatchers.containsStripNewLines("OID:EPV#3"));
}
+
@Test
public void testEmpty() throws Exception {
// when
final DebugString debug = new DebugString();
- store.debugData(debug);
+ getStore().debugData(debug);
// then
assertThat(debug.toString(), is("\nDomain Objects\n--------------\n\n"));
Modified: incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStoreTest_init.java
URL: http://svn.apache.org/viewvc/incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStoreTest_init.java?rev=1306647&r1=1306646&r2=1306647&view=diff
==============================================================================
--- incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStoreTest_init.java (original)
+++ incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStoreTest_init.java Wed Mar 28 23:58:57 2012
@@ -28,7 +28,7 @@ public class InMemoryObjectStoreTest_ini
@Test
public void testStartsUpInUnitializedSate() throws Exception {
- assertFalse(store.isFixturesInstalled());
+ assertFalse(getStore().isFixturesInstalled());
}
}
Modified: incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStoreTest_openAndClose.java
URL: http://svn.apache.org/viewvc/incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStoreTest_openAndClose.java?rev=1306647&r1=1306646&r2=1306647&view=diff
==============================================================================
--- incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStoreTest_openAndClose.java (original)
+++ incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStoreTest_openAndClose.java Wed Mar 28 23:58:57 2012
@@ -39,7 +39,6 @@ import org.apache.isis.runtimes.dflt.run
*/
public class InMemoryObjectStoreTest_openAndClose {
-
@Rule
public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
@@ -74,17 +73,9 @@ public class InMemoryObjectStoreTest_ope
};
}
- private void neverInteractsDirectlyWithPersistenceSession() {
- context.checking(new Expectations() {
- {
- never(mockPersistenceSession);
- }
- });
- }
-
@Test
public void whenOpenForFirstTimeThenCreatesPersistedObjects() throws Exception {
- neverInteractsDirectlyWithPersistenceSession();
+ context.never(mockPersistenceSession);
context.checking(new Expectations() {
{
one(mockInMemoryPersistenceSessionFactory).getPersistedObjects();
@@ -99,7 +90,7 @@ public class InMemoryObjectStoreTest_ope
@Test
public void whenOpenSubsequentlyThenObtainsPersistedObjectsFromObjectStoreFactoryAndRecreatesAdapters() throws Exception {
- neverInteractsDirectlyWithPersistenceSession();
+ context.never(mockPersistenceSession);
context.checking(new Expectations() {
{
one(mockInMemoryPersistenceSessionFactory).getPersistedObjects();
@@ -114,8 +105,7 @@ public class InMemoryObjectStoreTest_ope
@Test
public void whenCloseThenGivesObjectsBackToObjectStoreFactory() throws Exception {
- neverInteractsDirectlyWithPersistenceSession();
-
+ context.never(mockPersistenceSession);
whenOpenSubsequentlyThenObtainsPersistedObjectsFromObjectStoreFactoryAndRecreatesAdapters();
context.checking(new Expectations() {
Modified: incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStoreTest_persist.java
URL: http://svn.apache.org/viewvc/incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStoreTest_persist.java?rev=1306647&r1=1306646&r2=1306647&view=diff
==============================================================================
--- incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStoreTest_persist.java (original)
+++ incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStoreTest_persist.java Wed Mar 28 23:58:57 2012
@@ -21,7 +21,6 @@ package org.apache.isis.runtimes.dflt.ob
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertSame;
import java.util.Collections;
@@ -30,6 +29,7 @@ import org.junit.Test;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.PersistenceCommand;
import org.apache.isis.runtimes.dflt.runtime.persistence.query.PersistenceQueryFindByTitle;
+import org.apache.isis.runtimes.dflt.testsupport.domain.ExamplePojoWithValues;
import org.apache.isis.runtimes.dflt.testsupport.domain.TestPojo;
public class InMemoryObjectStoreTest_persist extends InMemoryObjectStoreTestAbstract {
@@ -38,38 +38,33 @@ public class InMemoryObjectStoreTest_per
@Test
public void getInstances_usingFindByTitle() throws Exception {
- final String titleString = adapter2.titleString();
-
- // given not yet persisted
+ final String titleString = epv2Adapter.titleString();
// when locate
- ObjectAdapter[] retrievedInstance = store.getInstances(new PersistenceQueryFindByTitle(specification, titleString));
+ ObjectAdapter[] retrievedInstance = getStore().getInstances(new PersistenceQueryFindByTitle(epvSpecification, titleString));
// then none
assertEquals(0, retrievedInstance.length);
-
// given now persisted
- final PersistenceCommand command = store.createCreateObjectCommand(adapter2);
- assertEquals(adapter2, command.onObject());
- store.execute(Collections.<PersistenceCommand> singletonList(command));
+ iswf.persist(iswf.fixtures.epv2);
- system.resetMaps();
+ iswf.bounceSystem();
// when locate
- retrievedInstance = store.getInstances(new PersistenceQueryFindByTitle(specification, titleString));
+ retrievedInstance = getStore().getInstances(new PersistenceQueryFindByTitle(epvSpecification, titleString));
// then find
assertEquals(1, retrievedInstance.length);
final ObjectAdapter retrievedAdapter = retrievedInstance[0];
- assertNotSame(adapter2, retrievedAdapter);
- assertEquals(((TestPojo)adapter2.getObject()).getPropertyUsedForTitle(), ((TestPojo)retrievedAdapter.getObject()).getPropertyUsedForTitle());
- assertEquals(adapter2.getOid(), retrievedAdapter.getOid());
+ assertNotSame(epv2Adapter, retrievedAdapter);
+ assertEquals(((ExamplePojoWithValues)epv2Adapter.getObject()).getName(), ((ExamplePojoWithValues)retrievedAdapter.getObject()).getName());
+ assertEquals(epv2Adapter.getOid(), retrievedAdapter.getOid());
// and then don't find by other title
- retrievedInstance = store.getInstances(new PersistenceQueryFindByTitle(specification, "some other title"));
+ retrievedInstance = getStore().getInstances(new PersistenceQueryFindByTitle(epvSpecification, "some other title"));
assertEquals(0, retrievedInstance.length);
}
@@ -78,42 +73,39 @@ public class InMemoryObjectStoreTest_per
public void saveInstance() throws Exception {
// given persisted
- persistToObjectStore(adapter2);
- system.resetMaps();
+ iswf.persist(iswf.fixtures.epv2);
- // when save
- testPojo2.setPropertyUsedForTitle("changed");
+ iswf.bounceSystem();
- final PersistenceCommand command = store.createSaveObjectCommand(adapter2);
- assertEquals(adapter2, command.onObject());
- store.execute(Collections.<PersistenceCommand> singletonList(command));
+ // when change (xactn is implicitly committed here)
+ iswf.fixtures.epv2.setName("changed");
- system.resetMaps();
+ iswf.bounceSystem();
// then found
- ObjectAdapter[] retrievedInstance = store.getInstances(new PersistenceQueryFindByTitle(specification, "changed"));
+ ObjectAdapter[] retrievedInstance = getStore().getInstances(new PersistenceQueryFindByTitle(epvSpecification, "changed"));
assertEquals(1, retrievedInstance.length);
final ObjectAdapter retrievedAdapter = retrievedInstance[0];
- assertNotSame(adapter2, retrievedAdapter);
- assertEquals(((TestPojo)adapter2.getObject()).getPropertyUsedForTitle(), ((TestPojo)retrievedAdapter.getObject()).getPropertyUsedForTitle());
- assertEquals(adapter2.getOid(), retrievedAdapter.getOid());
+ assertNotSame(epv2Adapter, retrievedAdapter);
+ assertEquals(((ExamplePojoWithValues)epv2Adapter.getObject()).getName(), ((ExamplePojoWithValues)retrievedAdapter.getObject()).getName());
+ assertEquals(epv2Adapter.getOid(), retrievedAdapter.getOid());
}
@Test
public void removeInstance() throws Exception {
// given persisted
- persistToObjectStore(adapter2);
- system.resetMaps();
+ iswf.persist(iswf.fixtures.epv2);
+
+ iswf.bounceSystem();
// when destroy
- final PersistenceCommand command = store.createDestroyObjectCommand(adapter2);
- assertEquals(adapter2, command.onObject());
- store.execute(Collections.<PersistenceCommand> singletonList(command));
- system.resetMaps();
+ iswf.destroy(iswf.fixtures.epv2);
+
+ iswf.bounceSystem();
// then not found
- assertEquals(false, store.hasInstances(specification));
+ assertEquals(false, getStore().hasInstances(epvSpecification));
}
}
Modified: incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStoreTest_reset.java
URL: http://svn.apache.org/viewvc/incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStoreTest_reset.java?rev=1306647&r1=1306646&r2=1306647&view=diff
==============================================================================
--- incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStoreTest_reset.java (original)
+++ incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStoreTest_reset.java Wed Mar 28 23:58:57 2012
@@ -36,13 +36,14 @@ public class InMemoryObjectStoreTest_res
@Test
public void rest_ClearsAdapterFromLoader() throws Exception {
- persistToObjectStore(adapter2);
+ iswf.persist(iswf.fixtures.epv2);
+ iswf.bounceSystem();
- assertNotNull(getAdapterManager().getAdapterFor(adapter2.getObject()));
+ assertNotNull(getAdapterManager().getAdapterFor(epv2Adapter.getObject()));
IsisContext.getPersistenceSession().testReset();
- assertNull(getAdapterManager().getAdapterFor(adapter2.getObject()));
+ assertNull(getAdapterManager().getAdapterFor(epv2Adapter.getObject()));
}
Modified: incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStoreTest_retrieve.java
URL: http://svn.apache.org/viewvc/incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStoreTest_retrieve.java?rev=1306647&r1=1306646&r2=1306647&view=diff
==============================================================================
--- incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStoreTest_retrieve.java (original)
+++ incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStoreTest_retrieve.java Wed Mar 28 23:58:57 2012
@@ -28,20 +28,19 @@ import org.junit.Test;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.metamodel.adapter.oid.Oid;
import org.apache.isis.core.metamodel.adapter.oid.RootOidDefault;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
import org.apache.isis.runtimes.dflt.runtime.persistence.ObjectNotFoundException;
import org.apache.isis.runtimes.dflt.runtime.persistence.query.PersistenceQueryFindAllInstances;
import org.apache.isis.runtimes.dflt.runtime.persistence.query.PersistenceQueryFindByTitle;
+import org.apache.isis.runtimes.dflt.testsupport.domain.ExamplePojoWithValues;
import org.apache.isis.runtimes.dflt.testsupport.domain.TestPojo;
public class InMemoryObjectStoreTest_retrieve extends InMemoryObjectStoreTestAbstract {
@Test
public void getObject_whenDoesNotExist() {
- final ObjectSpecification spec = system.loadSpecification(TestPojo.class);
- final Oid oid = RootOidDefault.create("CUS|10");
+ final Oid oid = RootOidDefault.create("EPV|10");
try {
- store.getObject(oid, spec);
+ getStore().getObject(oid, epvSpecification);
fail();
} catch (final ObjectNotFoundException expected) {
}
@@ -51,71 +50,69 @@ public class InMemoryObjectStoreTest_ret
public void getObject_whenExists_returnsAdapter() throws Exception {
// given
- persistToObjectStore(adapter2);
- system.resetMaps();
+ iswf.persist(iswf.fixtures.epv2);
+ iswf.bounceSystem();
- final ObjectSpecification specification = adapter2.getSpecification();
+ final ObjectAdapter retrievedAdapter = getStore().getObject(epv2Adapter.getOid(), epvSpecification);
- final ObjectAdapter retrievedAdapter = store.getObject(adapter2.getOid(), specification);
-
- assertNotSame(adapter2, retrievedAdapter);
- assertEquals(((TestPojo)adapter2.getObject()).getPropertyUsedForTitle(), ((TestPojo)retrievedAdapter.getObject()).getPropertyUsedForTitle());
- assertEquals(adapter2.getOid(), retrievedAdapter.getOid());
+ assertNotSame(epv2Adapter, retrievedAdapter);
+ assertEquals(((ExamplePojoWithValues)epv2Adapter.getObject()).getName(), ((ExamplePojoWithValues)retrievedAdapter.getObject()).getName());
+ assertEquals(epv2Adapter.getOid(), retrievedAdapter.getOid());
}
@Test
public void getInstances_whenDoesNotExist() throws Exception {
- final ObjectAdapter[] retrievedAdapters = store.getInstances(new PersistenceQueryFindByTitle(specification, adapter2.titleString()));
+ final ObjectAdapter[] retrievedAdapters = getStore().getInstances(new PersistenceQueryFindByTitle(epvSpecification, epv2Adapter.titleString()));
assertEquals(0, retrievedAdapters.length);
}
@Test
public void getInstances_findByTitle() throws Exception {
// given
- persistToObjectStore(adapter2);
- system.resetMaps();
+ iswf.persist(iswf.fixtures.epv2);
+ iswf.bounceSystem();
// when
- final ObjectAdapter[] retrievedAdapters = store.getInstances(new PersistenceQueryFindByTitle(specification, adapter2.titleString()));
+ final ObjectAdapter[] retrievedAdapters = getStore().getInstances(new PersistenceQueryFindByTitle(epvSpecification, epv2Adapter.titleString()));
// then
assertEquals(1, retrievedAdapters.length);
final ObjectAdapter retrievedAdapter = retrievedAdapters[0];
- assertNotSame(adapter2, retrievedAdapter);
- assertEquals(((TestPojo)adapter2.getObject()).getPropertyUsedForTitle(), ((TestPojo)retrievedAdapter.getObject()).getPropertyUsedForTitle());
- assertEquals(adapter2.getOid(), retrievedAdapter.getOid());
+ assertNotSame(epv2Adapter, retrievedAdapter);
+ assertEquals(((ExamplePojoWithValues)epv2Adapter.getObject()).getName(), ((ExamplePojoWithValues)retrievedAdapter.getObject()).getName());
+ assertEquals(epv2Adapter.getOid(), retrievedAdapter.getOid());
}
@Test
public void getInstances_findAll() throws Exception {
// given
- persistToObjectStore(adapter2);
- system.resetMaps();
+ iswf.persist(iswf.fixtures.epv2);
+ iswf.bounceSystem();
// when
- final ObjectAdapter[] retrievedAdapters = store.getInstances(new PersistenceQueryFindAllInstances(specification));
+ final ObjectAdapter[] retrievedAdapters = getStore().getInstances(new PersistenceQueryFindAllInstances(epvSpecification));
// then
assertEquals(1, retrievedAdapters.length);
final ObjectAdapter retrievedAdapter = retrievedAdapters[0];
- assertNotSame(adapter2, retrievedAdapter);
- assertEquals(((TestPojo)adapter2.getObject()).getPropertyUsedForTitle(), ((TestPojo)retrievedAdapter.getObject()).getPropertyUsedForTitle());
- assertEquals(adapter2.getOid(), retrievedAdapter.getOid());
+ assertNotSame(epv2Adapter, retrievedAdapter);
+ assertEquals(((ExamplePojoWithValues)epv2Adapter.getObject()).getName(), ((ExamplePojoWithValues)retrievedAdapter.getObject()).getName());
+ assertEquals(epv2Adapter.getOid(), retrievedAdapter.getOid());
}
@Test
public void hasInstances_whenEmpty() throws Exception {
- assertEquals(false, store.hasInstances(specification));
+ assertEquals(false, getStore().hasInstances(epvSpecification));
}
@Test
public void hasInstances_whenHasSome() throws Exception {
- persistToObjectStore(adapter2);
- system.resetMaps();
+ iswf.persist(iswf.fixtures.epv2);
+ iswf.bounceSystem();
- assertEquals(true, store.hasInstances(specification));
+ assertEquals(true, getStore().hasInstances(epvSpecification));
}
Modified: incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStoreTest_serviceRegistry.java
URL: http://svn.apache.org/viewvc/incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStoreTest_serviceRegistry.java?rev=1306647&r1=1306646&r2=1306647&view=diff
==============================================================================
--- incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStoreTest_serviceRegistry.java (original)
+++ incubator/isis/branches/0.3.0-incubating-NEW-OIDs/runtimes/dflt/testsupport/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/InMemoryObjectStoreTest_serviceRegistry.java Wed Mar 28 23:58:57 2012
@@ -20,50 +20,22 @@
package org.apache.isis.runtimes.dflt.objectstores.dflt;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-import java.util.Collections;
-
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.jmock.auto.Mock;
-import org.junit.After;
-import org.junit.Before;
import org.junit.Test;
-import org.apache.isis.core.commons.authentication.AuthenticationSession;
-import org.apache.isis.core.commons.config.IsisConfiguration;
-import org.apache.isis.core.commons.exceptions.IsisException;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.metamodel.adapter.oid.Oid;
import org.apache.isis.core.metamodel.adapter.oid.RootOidDefault;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.specloader.ObjectReflector;
-import org.apache.isis.core.runtime.userprofile.UserProfileStore;
-import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2;
-import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2.Mode;
-import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.transaction.PersistenceCommand;
-import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
-import org.apache.isis.runtimes.dflt.runtime.system.persistence.PersistenceSession;
-import org.apache.isis.runtimes.dflt.runtime.system.persistence.PersistenceSessionFactory;
-import org.apache.isis.runtimes.dflt.testsupport.TestSystemExpectations;
-import org.apache.isis.runtimes.dflt.testsupport.TestSystem;
+import org.apache.isis.runtimes.dflt.testsupport.domain.TestPojoRepository;
public class InMemoryObjectStoreTest_serviceRegistry extends InMemoryObjectStoreTestAbstract {
@Test
- public void getOidForServices_whenEmpty() throws Exception {
- final Oid oidForService = store.getOidForService(serviceSpecification);
- assertEquals(null, oidForService);
+ public void getOidForServices() throws Exception {
+ final Oid oidForService = getStore().getOidForService(iswf.specificationFor(TestPojoRepository.class));
+ assertEquals(RootOidDefault.create(TestPojoRepository.class.getName(), "1"), oidForService);
}
- @Test
- public void xx() throws Exception {
- fail(); // review the stuff below, commented out;
-
- }
-
// @Test
// public void registerService_canBeRetrieved() throws Exception {
// registerService14();
Added: incubator/isis/branches/0.3.0-incubating-NEW-OIDs/security/dflt/src/main/java/org/apache/isis/security/dflt/authentication/AuthenticationRequestDefault.java
URL: http://svn.apache.org/viewvc/incubator/isis/branches/0.3.0-incubating-NEW-OIDs/security/dflt/src/main/java/org/apache/isis/security/dflt/authentication/AuthenticationRequestDefault.java?rev=1306647&view=auto
==============================================================================
--- incubator/isis/branches/0.3.0-incubating-NEW-OIDs/security/dflt/src/main/java/org/apache/isis/security/dflt/authentication/AuthenticationRequestDefault.java (added)
+++ incubator/isis/branches/0.3.0-incubating-NEW-OIDs/security/dflt/src/main/java/org/apache/isis/security/dflt/authentication/AuthenticationRequestDefault.java Wed Mar 28 23:58:57 2012
@@ -0,0 +1,11 @@
+package org.apache.isis.security.dflt.authentication;
+
+import org.apache.isis.core.runtime.authentication.AuthenticationRequestAbstract;
+
+public class AuthenticationRequestDefault extends AuthenticationRequestAbstract {
+
+ public AuthenticationRequestDefault(String name) {
+ super(name);
+ }
+
+}
Propchange: incubator/isis/branches/0.3.0-incubating-NEW-OIDs/security/dflt/src/main/java/org/apache/isis/security/dflt/authentication/AuthenticationRequestDefault.java
------------------------------------------------------------------------------
svn:eol-style = native