You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2012/12/13 08:30:05 UTC
[56/58] [partial] ISIS-188: renaming packages in line with
groupId:artifactId
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/core/objectstore-inmemory/src/test/java/org/apache/isis/core/objectstore/internal/ObjectStoreInstances_save.java
----------------------------------------------------------------------
diff --git a/core/objectstore-inmemory/src/test/java/org/apache/isis/core/objectstore/internal/ObjectStoreInstances_save.java b/core/objectstore-inmemory/src/test/java/org/apache/isis/core/objectstore/internal/ObjectStoreInstances_save.java
new file mode 100644
index 0000000..14b5d2a
--- /dev/null
+++ b/core/objectstore-inmemory/src/test/java/org/apache/isis/core/objectstore/internal/ObjectStoreInstances_save.java
@@ -0,0 +1,126 @@
+/*
+ * 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.objectstore.internal;
+
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.jmock.Expectations;
+import org.jmock.Mockery;
+import org.jmock.integration.junit4.JMock;
+import org.jmock.integration.junit4.JUnit4Mockery;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.oid.Oid;
+import org.apache.isis.core.metamodel.adapter.version.Version;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.objectstore.internal.ObjectStoreInstances;
+
+/**
+ * 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_save {
+
+ private ObjectStoreInstances instances;
+
+ private final Mockery context = new JUnit4Mockery();
+
+ private ObjectSpecification mockSpec;
+ private ObjectAdapter mockAdapter;
+ private AuthenticationSession mockAuthSession;
+
+ @Before
+ public void setUp() throws Exception {
+ mockSpec = context.mock(ObjectSpecification.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);
+ }
+ });
+ }
+
+ @Test
+ public void saveUpdatesTheOptimisticLock() throws Exception {
+ allowingGetOidAndGetObjectAndTitleStringFromAdapter();
+ context.checking(new Expectations() {
+ {
+ one(mockAdapter).setVersion(with(any(Version.class)));
+ }
+ });
+ instances.save(mockAdapter);
+
+ }
+
+ @Test
+ public void saveStoresObject() throws Exception {
+ allowingGetOidAndGetObjectAndTitleStringFromAdapter();
+ ignoringInteractionsWithAdapter();
+ instances.save(mockAdapter);
+
+ final Map<Oid, Object> objectInstances = instances.getObjectInstances();
+ assertThat(objectInstances.size(), is(1));
+
+ final Set<Oid> oids = instances.getOids();
+ assertThat(oids.size(), is(1));
+
+ assertThat(instances.hasInstances(), is(true));
+
+ }
+
+ private void ignoringInteractionsWithAdapter() {
+ context.checking(new Expectations() {
+ {
+ ignoring(mockAdapter);
+ }
+ });
+ }
+
+ private void allowingGetOidAndGetObjectAndTitleStringFromAdapter() {
+ context.checking(new Expectations() {
+ {
+ allowing(mockAdapter).getOid();
+ allowing(mockAdapter).getObject();
+ allowing(mockAdapter).titleString();
+ }
+ });
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/core/objectstore-inmemory/src/test/java/org/apache/isis/core/objectstore/internal/ObjectStorePersistedObjectsDefault_instances.java
----------------------------------------------------------------------
diff --git a/core/objectstore-inmemory/src/test/java/org/apache/isis/core/objectstore/internal/ObjectStorePersistedObjectsDefault_instances.java b/core/objectstore-inmemory/src/test/java/org/apache/isis/core/objectstore/internal/ObjectStorePersistedObjectsDefault_instances.java
new file mode 100644
index 0000000..0e67fba
--- /dev/null
+++ b/core/objectstore-inmemory/src/test/java/org/apache/isis/core/objectstore/internal/ObjectStorePersistedObjectsDefault_instances.java
@@ -0,0 +1,94 @@
+/*
+ * 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.objectstore.internal;
+
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+import org.jmock.Expectations;
+import org.jmock.Mockery;
+import org.jmock.integration.junit4.JMock;
+import org.jmock.integration.junit4.JUnit4Mockery;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.objectstore.internal.ObjectStoreInstances;
+import org.apache.isis.core.objectstore.internal.ObjectStorePersistedObjectsDefault;
+
+@RunWith(JMock.class)
+public class ObjectStorePersistedObjectsDefault_instances {
+
+ private ObjectStorePersistedObjectsDefault persistedObjects;
+
+ private final Mockery context = new JUnit4Mockery();
+
+ private ObjectSpecification mockSpec;
+
+ @Before
+ public void setUp() throws Exception {
+ persistedObjects = new ObjectStorePersistedObjectsDefault();
+ mockSpec = context.mock(ObjectSpecification.class);
+ }
+
+ @Test
+ public void instancesLazilyPopulatedWhenAskForThem() throws Exception {
+ neverInteractsWithSpec();
+
+ // no instances
+ final Iterable<ObjectStoreInstances> instancesBefore = persistedObjects.instances();
+ assertThat(instancesBefore.iterator().hasNext(), is(false));
+
+ ensureThereAreSomeInstances();
+
+ // now there are
+ final Iterable<ObjectStoreInstances> instancesAfter = persistedObjects.instances();
+ assertThat(instancesAfter.iterator().hasNext(), is(true));
+ }
+
+ @Test
+ public void clearZapsTheInstances() throws Exception {
+ neverInteractsWithSpec();
+
+ ensureThereAreSomeInstances();
+ final Iterable<ObjectStoreInstances> instancesAfter = persistedObjects.instances();
+ assertThat(instancesAfter.iterator().hasNext(), is(true));
+
+ persistedObjects.clear();
+
+ // now there are no more instances
+ final Iterable<ObjectStoreInstances> instancesBefore = persistedObjects.instances();
+ assertThat(instancesBefore.iterator().hasNext(), is(false));
+ }
+
+ private void ensureThereAreSomeInstances() {
+ persistedObjects.instancesFor(mockSpec);
+ }
+
+ private void neverInteractsWithSpec() {
+ context.checking(new Expectations() {
+ {
+ never(mockSpec);
+ }
+ });
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/core/objectstore-inmemory/src/test/java/org/apache/isis/core/objectstore/internal/ObjectStorePersistedObjectsDefault_savesOidGeneratorAsMemento.java
----------------------------------------------------------------------
diff --git a/core/objectstore-inmemory/src/test/java/org/apache/isis/core/objectstore/internal/ObjectStorePersistedObjectsDefault_savesOidGeneratorAsMemento.java b/core/objectstore-inmemory/src/test/java/org/apache/isis/core/objectstore/internal/ObjectStorePersistedObjectsDefault_savesOidGeneratorAsMemento.java
new file mode 100644
index 0000000..cbe37b6
--- /dev/null
+++ b/core/objectstore-inmemory/src/test/java/org/apache/isis/core/objectstore/internal/ObjectStorePersistedObjectsDefault_savesOidGeneratorAsMemento.java
@@ -0,0 +1,66 @@
+/*
+ * 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.objectstore.internal;
+
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.nullValue;
+import static org.junit.Assert.assertThat;
+
+import org.jmock.Mockery;
+import org.jmock.integration.junit4.JUnit4Mockery;
+import org.jmock.lib.legacy.ClassImposteriser;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.apache.isis.core.objectstore.internal.ObjectStorePersistedObjectsDefault;
+import org.apache.isis.core.runtime.system.persistence.IdentifierGeneratorDefault;
+
+public class ObjectStorePersistedObjectsDefault_savesOidGeneratorAsMemento {
+
+ private ObjectStorePersistedObjectsDefault persistedObjects;
+
+ private final Mockery context = new JUnit4Mockery() {
+ {
+ setImposteriser(ClassImposteriser.INSTANCE);
+ }
+ };
+
+ private IdentifierGeneratorDefault.Memento mockMemento;
+
+ @Before
+ public void setUp() throws Exception {
+ persistedObjects = new ObjectStorePersistedObjectsDefault();
+ mockMemento = context.mock(IdentifierGeneratorDefault.Memento.class);
+ }
+
+ @Test
+ public void noOidGeneratorInitially() throws Exception {
+ final IdentifierGeneratorDefault.Memento oidGeneratorMemento = persistedObjects.getOidGeneratorMemento();
+ assertThat(oidGeneratorMemento, is(nullValue()));
+ }
+
+ @Test
+ public void oidGeneratorStoredOnceSaved() throws Exception {
+ persistedObjects.saveOidGeneratorMemento(mockMemento);
+ final IdentifierGeneratorDefault.Memento oidGeneratorMemento = persistedObjects.getOidGeneratorMemento();
+ assertThat(oidGeneratorMemento, is(mockMemento));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/core/objectstore-inmemory/src/test/java/org/apache/isis/core/objectstore/internal/ObjectStorePersistedObjectsDefault_services.java
----------------------------------------------------------------------
diff --git a/core/objectstore-inmemory/src/test/java/org/apache/isis/core/objectstore/internal/ObjectStorePersistedObjectsDefault_services.java b/core/objectstore-inmemory/src/test/java/org/apache/isis/core/objectstore/internal/ObjectStorePersistedObjectsDefault_services.java
new file mode 100644
index 0000000..d7694e9
--- /dev/null
+++ b/core/objectstore-inmemory/src/test/java/org/apache/isis/core/objectstore/internal/ObjectStorePersistedObjectsDefault_services.java
@@ -0,0 +1,81 @@
+/*
+ * 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.objectstore.internal;
+
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.nullValue;
+import static org.junit.Assert.assertThat;
+
+import org.jmock.Mockery;
+import org.jmock.integration.junit4.JMock;
+import org.jmock.integration.junit4.JUnit4Mockery;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import org.apache.isis.core.metamodel.adapter.oid.Oid;
+import org.apache.isis.core.metamodel.spec.ObjectSpecId;
+import org.apache.isis.core.objectstore.internal.ObjectStorePersistedObjectsDefault;
+import org.apache.isis.core.unittestsupport.jmock.auto.Mock;
+import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2;
+import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2.Mode;
+
+public class ObjectStorePersistedObjectsDefault_services {
+
+ @Rule
+ public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
+
+ @Mock
+ private Oid mockOidForFooService;
+ @Mock
+ private Oid mockOidForBarService;
+
+ private ObjectStorePersistedObjectsDefault persistedObjects;
+
+ @Before
+ public void setUp() throws Exception {
+ persistedObjects = new ObjectStorePersistedObjectsDefault();
+ }
+
+ @Test
+ public void noServicesInitially() throws Exception {
+ final Oid service = persistedObjects.getService(ObjectSpecId.of("fooService"));
+ assertThat(service, is(nullValue()));
+ }
+
+ @Test
+ public void registerServicesMakesAvailable() throws Exception {
+ persistedObjects.registerService(ObjectSpecId.of("fooService"), mockOidForFooService);
+
+ final Oid service = persistedObjects.getService(ObjectSpecId.of("fooService"));
+ assertThat(service, is(mockOidForFooService));
+ }
+
+ @Test
+ public void registerServicesWhenMoreThanOnePullsOutTheCorrectOne() throws Exception {
+ persistedObjects.registerService(ObjectSpecId.of("fooService"), mockOidForFooService);
+ persistedObjects.registerService(ObjectSpecId.of("barService"), mockOidForBarService);
+
+ final Oid service = persistedObjects.getService(ObjectSpecId.of("fooService"));
+ assertThat(service, is(mockOidForFooService));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/core/objectstore-inmemory/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/ObjectStoreInstances_findInstancesAndAdd.java
----------------------------------------------------------------------
diff --git a/core/objectstore-inmemory/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/ObjectStoreInstances_findInstancesAndAdd.java b/core/objectstore-inmemory/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/ObjectStoreInstances_findInstancesAndAdd.java
deleted file mode 100644
index 03521d3..0000000
--- a/core/objectstore-inmemory/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/ObjectStoreInstances_findInstancesAndAdd.java
+++ /dev/null
@@ -1,114 +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.runtimes.dflt.objectstores.dflt.internal;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-import java.util.List;
-
-import com.google.common.collect.Lists;
-
-import org.jmock.Expectations;
-import org.jmock.auto.Mock;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-import org.apache.isis.core.commons.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.AdapterManagerSpi;
-
-public class ObjectStoreInstances_findInstancesAndAdd {
-
- private ObjectStoreInstances instances;
-
- @Rule
- public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
-
- @Mock
- private ObjectSpecification mockSpec;
- @Mock
- private PersistenceQueryBuiltIn mockPersistenceQueryBuiltIn;
- @Mock
- private AuthenticationSession mockAuthSession;
- @Mock
- private AdapterManagerSpi mockAdapterManager;
-
- @Mock
- private ObjectAdapter mockAdapter1;
- @Mock
- private ObjectAdapter mockAdapter2;
-
- @Before
- public void setUp() throws Exception {
- instances = new ObjectStoreInstances(mockSpec) {
- @Override
- protected AuthenticationSession getAuthenticationSession() {
- return mockAuthSession;
- }
- @Override
- protected AdapterManagerSpi getAdapterManager() {
- return mockAdapterManager;
- }
- };
- context.ignoring(mockAuthSession);
- }
-
- @Test
- public void findInstancesAndAdd_whenEmpty() throws Exception {
- context.never(mockPersistenceQueryBuiltIn);
- final List<ObjectAdapter> foundInstances = Lists.newArrayList();
- instances.findInstancesAndAdd(mockPersistenceQueryBuiltIn, foundInstances);
- }
-
- @Test
- public void findInstancesAndAdd_whenNotEmpty() throws Exception {
- context.ignoring(mockAdapter1, mockAdapter2);
- context.checking(new Expectations() {
- {
- 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));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/core/objectstore-inmemory/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/ObjectStoreInstances_init.java
----------------------------------------------------------------------
diff --git a/core/objectstore-inmemory/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/ObjectStoreInstances_init.java b/core/objectstore-inmemory/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/ObjectStoreInstances_init.java
deleted file mode 100644
index 940ea16..0000000
--- a/core/objectstore-inmemory/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/ObjectStoreInstances_init.java
+++ /dev/null
@@ -1,68 +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.runtimes.dflt.objectstores.dflt.internal;
-
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
-
-import java.util.Map;
-import java.util.Set;
-
-import org.jmock.Mockery;
-import org.jmock.integration.junit4.JMock;
-import org.jmock.integration.junit4.JUnit4Mockery;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import org.apache.isis.core.metamodel.adapter.oid.Oid;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-
-/**
- * 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_init {
-
- private ObjectStoreInstances instances;
-
- private final Mockery context = new JUnit4Mockery();
-
- private ObjectSpecification mockSpec;
-
- @Before
- public void setUp() throws Exception {
- mockSpec = context.mock(ObjectSpecification.class);
- instances = new ObjectStoreInstances(mockSpec);
- }
-
- @Test
- public void initiallyEmpty() throws Exception {
- final Map<Oid, Object> objectInstances = instances.getObjectInstances();
- assertThat(objectInstances.size(), is(0));
-
- final Set<Oid> oids = instances.getOids();
- assertThat(oids.size(), is(0));
-
- assertThat(instances.hasInstances(), is(false));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/core/objectstore-inmemory/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/ObjectStoreInstances_save.java
----------------------------------------------------------------------
diff --git a/core/objectstore-inmemory/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/ObjectStoreInstances_save.java b/core/objectstore-inmemory/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/ObjectStoreInstances_save.java
deleted file mode 100644
index 01a53e0..0000000
--- a/core/objectstore-inmemory/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/ObjectStoreInstances_save.java
+++ /dev/null
@@ -1,125 +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.runtimes.dflt.objectstores.dflt.internal;
-
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
-
-import java.util.Map;
-import java.util.Set;
-
-import org.jmock.Expectations;
-import org.jmock.Mockery;
-import org.jmock.integration.junit4.JMock;
-import org.jmock.integration.junit4.JUnit4Mockery;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import org.apache.isis.core.commons.authentication.AuthenticationSession;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.adapter.oid.Oid;
-import org.apache.isis.core.metamodel.adapter.version.Version;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-
-/**
- * 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_save {
-
- private ObjectStoreInstances instances;
-
- private final Mockery context = new JUnit4Mockery();
-
- private ObjectSpecification mockSpec;
- private ObjectAdapter mockAdapter;
- private AuthenticationSession mockAuthSession;
-
- @Before
- public void setUp() throws Exception {
- mockSpec = context.mock(ObjectSpecification.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);
- }
- });
- }
-
- @Test
- public void saveUpdatesTheOptimisticLock() throws Exception {
- allowingGetOidAndGetObjectAndTitleStringFromAdapter();
- context.checking(new Expectations() {
- {
- one(mockAdapter).setVersion(with(any(Version.class)));
- }
- });
- instances.save(mockAdapter);
-
- }
-
- @Test
- public void saveStoresObject() throws Exception {
- allowingGetOidAndGetObjectAndTitleStringFromAdapter();
- ignoringInteractionsWithAdapter();
- instances.save(mockAdapter);
-
- final Map<Oid, Object> objectInstances = instances.getObjectInstances();
- assertThat(objectInstances.size(), is(1));
-
- final Set<Oid> oids = instances.getOids();
- assertThat(oids.size(), is(1));
-
- assertThat(instances.hasInstances(), is(true));
-
- }
-
- private void ignoringInteractionsWithAdapter() {
- context.checking(new Expectations() {
- {
- ignoring(mockAdapter);
- }
- });
- }
-
- private void allowingGetOidAndGetObjectAndTitleStringFromAdapter() {
- context.checking(new Expectations() {
- {
- allowing(mockAdapter).getOid();
- allowing(mockAdapter).getObject();
- allowing(mockAdapter).titleString();
- }
- });
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/core/objectstore-inmemory/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/ObjectStorePersistedObjectsDefault_instances.java
----------------------------------------------------------------------
diff --git a/core/objectstore-inmemory/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/ObjectStorePersistedObjectsDefault_instances.java b/core/objectstore-inmemory/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/ObjectStorePersistedObjectsDefault_instances.java
deleted file mode 100644
index b56f4d4..0000000
--- a/core/objectstore-inmemory/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/ObjectStorePersistedObjectsDefault_instances.java
+++ /dev/null
@@ -1,92 +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.runtimes.dflt.objectstores.dflt.internal;
-
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
-
-import org.jmock.Expectations;
-import org.jmock.Mockery;
-import org.jmock.integration.junit4.JMock;
-import org.jmock.integration.junit4.JUnit4Mockery;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-
-@RunWith(JMock.class)
-public class ObjectStorePersistedObjectsDefault_instances {
-
- private ObjectStorePersistedObjectsDefault persistedObjects;
-
- private final Mockery context = new JUnit4Mockery();
-
- private ObjectSpecification mockSpec;
-
- @Before
- public void setUp() throws Exception {
- persistedObjects = new ObjectStorePersistedObjectsDefault();
- mockSpec = context.mock(ObjectSpecification.class);
- }
-
- @Test
- public void instancesLazilyPopulatedWhenAskForThem() throws Exception {
- neverInteractsWithSpec();
-
- // no instances
- final Iterable<ObjectStoreInstances> instancesBefore = persistedObjects.instances();
- assertThat(instancesBefore.iterator().hasNext(), is(false));
-
- ensureThereAreSomeInstances();
-
- // now there are
- final Iterable<ObjectStoreInstances> instancesAfter = persistedObjects.instances();
- assertThat(instancesAfter.iterator().hasNext(), is(true));
- }
-
- @Test
- public void clearZapsTheInstances() throws Exception {
- neverInteractsWithSpec();
-
- ensureThereAreSomeInstances();
- final Iterable<ObjectStoreInstances> instancesAfter = persistedObjects.instances();
- assertThat(instancesAfter.iterator().hasNext(), is(true));
-
- persistedObjects.clear();
-
- // now there are no more instances
- final Iterable<ObjectStoreInstances> instancesBefore = persistedObjects.instances();
- assertThat(instancesBefore.iterator().hasNext(), is(false));
- }
-
- private void ensureThereAreSomeInstances() {
- persistedObjects.instancesFor(mockSpec);
- }
-
- private void neverInteractsWithSpec() {
- context.checking(new Expectations() {
- {
- never(mockSpec);
- }
- });
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/core/objectstore-inmemory/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/ObjectStorePersistedObjectsDefault_savesOidGeneratorAsMemento.java
----------------------------------------------------------------------
diff --git a/core/objectstore-inmemory/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/ObjectStorePersistedObjectsDefault_savesOidGeneratorAsMemento.java b/core/objectstore-inmemory/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/ObjectStorePersistedObjectsDefault_savesOidGeneratorAsMemento.java
deleted file mode 100644
index 0765409..0000000
--- a/core/objectstore-inmemory/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/ObjectStorePersistedObjectsDefault_savesOidGeneratorAsMemento.java
+++ /dev/null
@@ -1,65 +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.runtimes.dflt.objectstores.dflt.internal;
-
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.nullValue;
-import static org.junit.Assert.assertThat;
-
-import org.jmock.Mockery;
-import org.jmock.integration.junit4.JUnit4Mockery;
-import org.jmock.lib.legacy.ClassImposteriser;
-import org.junit.Before;
-import org.junit.Test;
-
-import org.apache.isis.runtimes.dflt.runtime.system.persistence.IdentifierGeneratorDefault;
-
-public class ObjectStorePersistedObjectsDefault_savesOidGeneratorAsMemento {
-
- private ObjectStorePersistedObjectsDefault persistedObjects;
-
- private final Mockery context = new JUnit4Mockery() {
- {
- setImposteriser(ClassImposteriser.INSTANCE);
- }
- };
-
- private IdentifierGeneratorDefault.Memento mockMemento;
-
- @Before
- public void setUp() throws Exception {
- persistedObjects = new ObjectStorePersistedObjectsDefault();
- mockMemento = context.mock(IdentifierGeneratorDefault.Memento.class);
- }
-
- @Test
- public void noOidGeneratorInitially() throws Exception {
- final IdentifierGeneratorDefault.Memento oidGeneratorMemento = persistedObjects.getOidGeneratorMemento();
- assertThat(oidGeneratorMemento, is(nullValue()));
- }
-
- @Test
- public void oidGeneratorStoredOnceSaved() throws Exception {
- persistedObjects.saveOidGeneratorMemento(mockMemento);
- final IdentifierGeneratorDefault.Memento oidGeneratorMemento = persistedObjects.getOidGeneratorMemento();
- assertThat(oidGeneratorMemento, is(mockMemento));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/core/objectstore-inmemory/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/ObjectStorePersistedObjectsDefault_services.java
----------------------------------------------------------------------
diff --git a/core/objectstore-inmemory/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/ObjectStorePersistedObjectsDefault_services.java b/core/objectstore-inmemory/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/ObjectStorePersistedObjectsDefault_services.java
deleted file mode 100644
index 06e66c5..0000000
--- a/core/objectstore-inmemory/src/test/java/org/apache/isis/runtimes/dflt/objectstores/dflt/internal/ObjectStorePersistedObjectsDefault_services.java
+++ /dev/null
@@ -1,80 +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.runtimes.dflt.objectstores.dflt.internal;
-
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.nullValue;
-import static org.junit.Assert.assertThat;
-
-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.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import org.apache.isis.core.metamodel.adapter.oid.Oid;
-import org.apache.isis.core.metamodel.spec.ObjectSpecId;
-import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2;
-import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2.Mode;
-
-public class ObjectStorePersistedObjectsDefault_services {
-
- @Rule
- public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
-
- @Mock
- private Oid mockOidForFooService;
- @Mock
- private Oid mockOidForBarService;
-
- private ObjectStorePersistedObjectsDefault persistedObjects;
-
- @Before
- public void setUp() throws Exception {
- persistedObjects = new ObjectStorePersistedObjectsDefault();
- }
-
- @Test
- public void noServicesInitially() throws Exception {
- final Oid service = persistedObjects.getService(ObjectSpecId.of("fooService"));
- assertThat(service, is(nullValue()));
- }
-
- @Test
- public void registerServicesMakesAvailable() throws Exception {
- persistedObjects.registerService(ObjectSpecId.of("fooService"), mockOidForFooService);
-
- final Oid service = persistedObjects.getService(ObjectSpecId.of("fooService"));
- assertThat(service, is(mockOidForFooService));
- }
-
- @Test
- public void registerServicesWhenMoreThanOnePullsOutTheCorrectOne() throws Exception {
- persistedObjects.registerService(ObjectSpecId.of("fooService"), mockOidForFooService);
- persistedObjects.registerService(ObjectSpecId.of("barService"), mockOidForBarService);
-
- final Oid service = persistedObjects.getService(ObjectSpecId.of("fooService"));
- assertThat(service, is(mockOidForFooService));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/core/profilestore-inmemory/pom.xml
----------------------------------------------------------------------
diff --git a/core/profilestore-inmemory/pom.xml b/core/profilestore-inmemory/pom.xml
index 3ad2f97..425de25 100644
--- a/core/profilestore-inmemory/pom.xml
+++ b/core/profilestore-inmemory/pom.xml
@@ -27,7 +27,7 @@
</parent>
<artifactId>isis-core-profilestore</artifactId>
- <name>Isis Core In-memory ProfileStore</name>
+ <name>Isis Core (In-memory) ProfileStore</name>
<properties>
<siteBaseDir>..</siteBaseDir>
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/core/profilestore-inmemory/src/main/java/org/apache/isis/core/profilestore/InMemoryUserProfileStore.java
----------------------------------------------------------------------
diff --git a/core/profilestore-inmemory/src/main/java/org/apache/isis/core/profilestore/InMemoryUserProfileStore.java b/core/profilestore-inmemory/src/main/java/org/apache/isis/core/profilestore/InMemoryUserProfileStore.java
new file mode 100644
index 0000000..477ef6c
--- /dev/null
+++ b/core/profilestore-inmemory/src/main/java/org/apache/isis/core/profilestore/InMemoryUserProfileStore.java
@@ -0,0 +1,61 @@
+/*
+ * 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.profilestore;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.isis.core.commons.debug.DebugBuilder;
+import org.apache.isis.core.commons.debug.DebuggableWithTitle;
+import org.apache.isis.core.runtime.userprofile.UserProfile;
+import org.apache.isis.core.runtime.userprofile.UserProfileStore;
+
+public class InMemoryUserProfileStore implements UserProfileStore, DebuggableWithTitle {
+
+ private static final Map<String, UserProfile> profiles = new HashMap<String, UserProfile>();
+
+ @Override
+ public boolean isFixturesInstalled() {
+ return false;
+ }
+
+ @Override
+ public UserProfile getUserProfile(final String name) {
+ return profiles.get(name);
+ }
+
+ @Override
+ public void save(final String name, final UserProfile userProfile) {
+ profiles.put(name, userProfile);
+ }
+
+ @Override
+ public void debugData(final DebugBuilder debug) {
+ for (final String name : profiles.keySet()) {
+ debug.appendln(name, profiles.get(name));
+ }
+ }
+
+ @Override
+ public String debugTitle() {
+ return "InMemoryUserProfileStore";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/core/profilestore-inmemory/src/main/java/org/apache/isis/core/profilestore/InMemoryUserProfileStoreInstaller.java
----------------------------------------------------------------------
diff --git a/core/profilestore-inmemory/src/main/java/org/apache/isis/core/profilestore/InMemoryUserProfileStoreInstaller.java b/core/profilestore-inmemory/src/main/java/org/apache/isis/core/profilestore/InMemoryUserProfileStoreInstaller.java
new file mode 100644
index 0000000..5dbba1c
--- /dev/null
+++ b/core/profilestore-inmemory/src/main/java/org/apache/isis/core/profilestore/InMemoryUserProfileStoreInstaller.java
@@ -0,0 +1,44 @@
+/*
+ * 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.profilestore;
+
+import java.util.List;
+
+import org.apache.isis.core.commons.config.InstallerAbstract;
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.runtime.userprofile.UserProfileStore;
+import org.apache.isis.core.runtime.userprofile.UserProfileStoreInstaller;
+
+public class InMemoryUserProfileStoreInstaller extends InstallerAbstract implements UserProfileStoreInstaller {
+
+ public InMemoryUserProfileStoreInstaller() {
+ super(UserProfileStoreInstaller.TYPE, "in-memory");
+ }
+
+ @Override
+ public UserProfileStore createUserProfileStore(final IsisConfiguration objectConfiguration) {
+ return new InMemoryUserProfileStore();
+ }
+
+ @Override
+ public List<Class<?>> getTypes() {
+ return listOf(UserProfileStore.class);
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/core/profilestore-inmemory/src/main/java/org/apache/isis/runtimes/dflt/profilestores/dflt/InMemoryUserProfileStore.java
----------------------------------------------------------------------
diff --git a/core/profilestore-inmemory/src/main/java/org/apache/isis/runtimes/dflt/profilestores/dflt/InMemoryUserProfileStore.java b/core/profilestore-inmemory/src/main/java/org/apache/isis/runtimes/dflt/profilestores/dflt/InMemoryUserProfileStore.java
deleted file mode 100644
index ac625ee..0000000
--- a/core/profilestore-inmemory/src/main/java/org/apache/isis/runtimes/dflt/profilestores/dflt/InMemoryUserProfileStore.java
+++ /dev/null
@@ -1,61 +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.runtimes.dflt.profilestores.dflt;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.isis.core.commons.debug.DebugBuilder;
-import org.apache.isis.core.commons.debug.DebuggableWithTitle;
-import org.apache.isis.core.runtime.userprofile.UserProfile;
-import org.apache.isis.core.runtime.userprofile.UserProfileStore;
-
-public class InMemoryUserProfileStore implements UserProfileStore, DebuggableWithTitle {
-
- private static final Map<String, UserProfile> profiles = new HashMap<String, UserProfile>();
-
- @Override
- public boolean isFixturesInstalled() {
- return false;
- }
-
- @Override
- public UserProfile getUserProfile(final String name) {
- return profiles.get(name);
- }
-
- @Override
- public void save(final String name, final UserProfile userProfile) {
- profiles.put(name, userProfile);
- }
-
- @Override
- public void debugData(final DebugBuilder debug) {
- for (final String name : profiles.keySet()) {
- debug.appendln(name, profiles.get(name));
- }
- }
-
- @Override
- public String debugTitle() {
- return "InMemoryUserProfileStore";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/core/profilestore-inmemory/src/main/java/org/apache/isis/runtimes/dflt/profilestores/dflt/InMemoryUserProfileStoreInstaller.java
----------------------------------------------------------------------
diff --git a/core/profilestore-inmemory/src/main/java/org/apache/isis/runtimes/dflt/profilestores/dflt/InMemoryUserProfileStoreInstaller.java b/core/profilestore-inmemory/src/main/java/org/apache/isis/runtimes/dflt/profilestores/dflt/InMemoryUserProfileStoreInstaller.java
deleted file mode 100644
index 12b4d15..0000000
--- a/core/profilestore-inmemory/src/main/java/org/apache/isis/runtimes/dflt/profilestores/dflt/InMemoryUserProfileStoreInstaller.java
+++ /dev/null
@@ -1,44 +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.runtimes.dflt.profilestores.dflt;
-
-import java.util.List;
-
-import org.apache.isis.core.commons.config.InstallerAbstract;
-import org.apache.isis.core.commons.config.IsisConfiguration;
-import org.apache.isis.core.runtime.userprofile.UserProfileStore;
-import org.apache.isis.runtimes.dflt.runtime.userprofile.UserProfileStoreInstaller;
-
-public class InMemoryUserProfileStoreInstaller extends InstallerAbstract implements UserProfileStoreInstaller {
-
- public InMemoryUserProfileStoreInstaller() {
- super(UserProfileStoreInstaller.TYPE, "in-memory");
- }
-
- @Override
- public UserProfileStore createUserProfileStore(final IsisConfiguration objectConfiguration) {
- return new InMemoryUserProfileStore();
- }
-
- @Override
- public List<Class<?>> getTypes() {
- return listOf(UserProfileStore.class);
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/core/runtime/src/main/java/org/apache/isis/Isis.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/Isis.java b/core/runtime/src/main/java/org/apache/isis/Isis.java
index 830863d..ab83165 100644
--- a/core/runtime/src/main/java/org/apache/isis/Isis.java
+++ b/core/runtime/src/main/java/org/apache/isis/Isis.java
@@ -22,6 +22,6 @@ package org.apache.isis;
public class Isis {
public static void main(final String[] args) {
- org.apache.isis.runtimes.dflt.runtime.Isis.main(args);
+ org.apache.isis.core.runtime.Isis.main(args);
}
}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/core/runtime/src/main/java/org/apache/isis/core/runtime/Isis.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/Isis.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/Isis.java
new file mode 100644
index 0000000..6f16ba9
--- /dev/null
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/Isis.java
@@ -0,0 +1,58 @@
+/*
+ * 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;
+
+import org.apache.isis.core.runtime.runner.IsisRunner;
+import org.apache.isis.core.runtime.runner.opts.OptionHandlerDeploymentTypeIsis;
+import org.apache.isis.core.runtime.runner.opts.OptionHandlerPassword;
+import org.apache.isis.core.runtime.runner.opts.OptionHandlerUser;
+import org.apache.isis.core.runtime.runner.opts.OptionValidatorUserAndPasswordCombo;
+import org.apache.isis.core.runtime.system.SystemConstants;
+
+public class Isis {
+
+ static final String DEFAULT_EMBEDDED_WEBSERVER = SystemConstants.WEBSERVER_DEFAULT;
+
+ public static void main(final String[] args) {
+ new Isis().run(args);
+ }
+
+ private void run(final String[] args) {
+ final IsisRunner runner = new IsisRunner(args, new OptionHandlerDeploymentTypeIsis());
+
+ addOptionHandlersAndValidators(runner);
+
+ if (!runner.parseAndValidate()) {
+ return;
+ }
+ runner.bootstrap(new RuntimeBootstrapper());
+ }
+
+ private void addOptionHandlersAndValidators(final IsisRunner runner) {
+ final OptionHandlerUser optionHandlerUser = new OptionHandlerUser();
+ final OptionHandlerPassword optionHandlerPassword = new OptionHandlerPassword();
+
+ runner.addOptionHandler(optionHandlerUser);
+ runner.addOptionHandler(optionHandlerPassword);
+
+ runner.addValidator(new OptionValidatorUserAndPasswordCombo(optionHandlerUser, optionHandlerPassword));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/core/runtime/src/main/java/org/apache/isis/core/runtime/IsisInstallerRegistry.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/IsisInstallerRegistry.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/IsisInstallerRegistry.java
new file mode 100644
index 0000000..7f0bbee
--- /dev/null
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/IsisInstallerRegistry.java
@@ -0,0 +1,33 @@
+package org.apache.isis.core.runtime;
+
+import java.io.InputStream;
+
+/**
+ * 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.
+ */
+
+public final class IsisInstallerRegistry {
+
+ public final static String INSTALLER_REGISTRY_FILE = "installer-registry.properties";
+
+ private IsisInstallerRegistry() {
+ }
+
+ public static InputStream getPropertiesAsStream() {
+ return IsisInstallerRegistry.class.getResourceAsStream(IsisInstallerRegistry.INSTALLER_REGISTRY_FILE);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/core/runtime/src/main/java/org/apache/isis/core/runtime/RuntimeBootstrapper.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/RuntimeBootstrapper.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/RuntimeBootstrapper.java
new file mode 100644
index 0000000..dd9b0a0
--- /dev/null
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/RuntimeBootstrapper.java
@@ -0,0 +1,133 @@
+/*
+ * 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;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.google.inject.Injector;
+
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.collections.Predicate;
+
+import org.apache.isis.core.commons.lang.Threads;
+import org.apache.isis.core.runtime.installerregistry.InstallerLookup;
+import org.apache.isis.core.runtime.installerregistry.installerapi.EmbeddedWebServerInstaller;
+import org.apache.isis.core.runtime.runner.IsisBootstrapper;
+import org.apache.isis.core.runtime.runner.IsisModule.ViewerList;
+import org.apache.isis.core.runtime.system.IsisSystem;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.core.runtime.viewer.IsisViewer;
+import org.apache.isis.core.runtime.viewer.web.WebAppSpecification;
+import org.apache.isis.core.runtime.web.EmbeddedWebServer;
+
+final class RuntimeBootstrapper implements IsisBootstrapper {
+
+ @Override
+ public void bootstrap(final Injector injector) {
+
+ bootstrapSystem(injector);
+ bootstrapViewers(injector);
+ }
+
+ private void bootstrapSystem(final Injector injector) {
+
+ // sufficient just to look it up
+ @SuppressWarnings("unused")
+ final IsisSystem system = injector.getInstance(IsisSystem.class);
+ }
+
+ private void bootstrapViewers(final Injector injector) {
+ final List<IsisViewer> viewers = lookupViewers(injector);
+
+ // split viewers into web viewers and non-web viewers
+ final List<IsisViewer> webViewers = findWebViewers(viewers);
+ final List<IsisViewer> nonWebViewers = findNonWebViewers(viewers, webViewers);
+
+ startNonWebViewers(nonWebViewers);
+ startWebViewers(injector, webViewers);
+ }
+
+ private List<IsisViewer> lookupViewers(final Injector injector) {
+ final List<IsisViewer> viewers = injector.getInstance(ViewerList.class).getViewers();
+
+ // looking up viewers may have merged in some further config files,
+ // so update the NOContext global
+ // REVIEW: would rather inject this
+ final InstallerLookup installerLookup = injector.getInstance(InstallerLookup.class);
+ IsisContext.setConfiguration(installerLookup.getConfiguration());
+
+ return viewers;
+ }
+
+ private List<IsisViewer> findWebViewers(final List<IsisViewer> viewers) {
+ final List<IsisViewer> webViewers = new ArrayList<IsisViewer>(viewers);
+ CollectionUtils.filter(webViewers, new Predicate() {
+ @Override
+ public boolean evaluate(final Object object) {
+ final IsisViewer viewer = (IsisViewer) object;
+ return viewer.getWebAppSpecification() != null;
+ }
+ });
+ return webViewers;
+ }
+
+ private List<IsisViewer> findNonWebViewers(final List<IsisViewer> viewers, final List<IsisViewer> webViewers) {
+ final List<IsisViewer> nonWebViewers = new ArrayList<IsisViewer>(viewers);
+ nonWebViewers.removeAll(webViewers);
+ return nonWebViewers;
+ }
+
+ /**
+ * Starts each (non web) {@link IsisViewer viewer} in its own thread.
+ */
+ private void startNonWebViewers(final List<IsisViewer> viewers) {
+ for (final IsisViewer viewer : viewers) {
+ final Runnable target = new Runnable() {
+ @Override
+ public void run() {
+ viewer.init();
+ }
+ };
+ Threads.startThread(target, "Viewer");
+ }
+ }
+
+ /**
+ * Starts all the web {@link IsisViewer viewer}s in an instance of an
+ * {@link EmbeddedWebServer}.
+ */
+ private void startWebViewers(final Injector injector, final List<IsisViewer> webViewers) {
+ if (webViewers.size() == 0) {
+ return;
+ }
+
+ final InstallerLookup installerLookup = injector.getInstance(InstallerLookup.class);
+
+ // TODO: we could potentially offer pluggability here
+ final EmbeddedWebServerInstaller webServerInstaller = installerLookup.embeddedWebServerInstaller(Isis.DEFAULT_EMBEDDED_WEBSERVER);
+ final EmbeddedWebServer embeddedWebServer = webServerInstaller.createEmbeddedWebServer();
+ for (final IsisViewer viewer : webViewers) {
+ final WebAppSpecification webContainerRequirements = viewer.getWebAppSpecification();
+ embeddedWebServer.addWebAppSpecification(webContainerRequirements);
+ }
+ embeddedWebServer.init();
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/core/runtime/src/main/java/org/apache/isis/core/runtime/authentication/AuthenticationManagerStandardForDfltRuntime.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/authentication/AuthenticationManagerStandardForDfltRuntime.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/authentication/AuthenticationManagerStandardForDfltRuntime.java
new file mode 100644
index 0000000..5e4d1ab
--- /dev/null
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/authentication/AuthenticationManagerStandardForDfltRuntime.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.runtime.authentication;
+
+import org.apache.isis.applib.fixtures.LogonFixture;
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.runtime.authentication.exploration.ExplorationAuthenticator;
+import org.apache.isis.core.runtime.authentication.exploration.ExplorationSession;
+import org.apache.isis.core.runtime.authentication.fixture.LogonFixtureAuthenticator;
+import org.apache.isis.core.runtime.authentication.standard.AuthenticationManagerStandard;
+import org.apache.isis.core.runtime.system.DeploymentType;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+
+/**
+ * A refinement of the {@link AuthenticationManagerStandard}, which adds support
+ * to make it easier without the palava of logging in when running in either
+ * {@link DeploymentType#EXPLORATION exploration} mode or in
+ * {@link DeploymentType#PROTOTYPE prototype} mode.
+ *
+ * <p>
+ * Specifically:
+ * <ul>
+ * <li>the {@link ExplorationAuthenticator} will always provide a special
+ * {@link ExplorationSession} if running in the {@link DeploymentType} of
+ * {@link DeploymentType#EXPLORATION exploration}.
+ * <li>the {@link LogonFixtureAuthenticator} will set up a session using the
+ * login provided by a {@link LogonFixture}, provided that the
+ * {@link DeploymentType} is {@link DeploymentType#EXPLORATION exploration} or
+ * {@link DeploymentType#PROTOTYPE prototyping}
+ * </ul>
+ */
+public class AuthenticationManagerStandardForDfltRuntime extends AuthenticationManagerStandard {
+
+ public AuthenticationManagerStandardForDfltRuntime(final IsisConfiguration configuration) {
+ super(configuration);
+ }
+
+ // //////////////////////////////////////////////////////////
+ // init
+ // //////////////////////////////////////////////////////////
+
+ @Override
+ protected void addDefaultAuthenticators() {
+ // we add to start to ensure that these special case authenticators
+ // are always consulted first
+ addAuthenticatorToStart(new ExplorationAuthenticator(getConfiguration()));
+ addAuthenticatorToStart(new LogonFixtureAuthenticator(getConfiguration()));
+ }
+
+ // //////////////////////////////////////////////////////////
+ // Session Management (including authenticate)
+ // //////////////////////////////////////////////////////////
+
+ @Override
+ public void closeSession(final AuthenticationSession session) {
+ super.closeSession(session);
+ IsisContext.closeSession();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/core/runtime/src/main/java/org/apache/isis/core/runtime/authentication/AuthenticationManagerStandardInstallerAbstractForDfltRuntime.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/authentication/AuthenticationManagerStandardInstallerAbstractForDfltRuntime.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/authentication/AuthenticationManagerStandardInstallerAbstractForDfltRuntime.java
new file mode 100644
index 0000000..6948431
--- /dev/null
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/authentication/AuthenticationManagerStandardInstallerAbstractForDfltRuntime.java
@@ -0,0 +1,36 @@
+/*
+ * 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.authentication;
+
+import org.apache.isis.core.runtime.authentication.standard.AuthenticationManagerStandard;
+import org.apache.isis.core.runtime.authentication.standard.AuthenticationManagerStandardInstallerAbstract;
+
+public abstract class AuthenticationManagerStandardInstallerAbstractForDfltRuntime extends AuthenticationManagerStandardInstallerAbstract {
+
+ public AuthenticationManagerStandardInstallerAbstractForDfltRuntime(final String name) {
+ super(name);
+ }
+
+ @Override
+ protected AuthenticationManagerStandard createAuthenticationManagerStandard() {
+ return new AuthenticationManagerStandardForDfltRuntime(getConfiguration());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/core/runtime/src/main/java/org/apache/isis/core/runtime/authentication/AuthenticatorAbstractForDfltRuntime.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/authentication/AuthenticatorAbstractForDfltRuntime.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/authentication/AuthenticatorAbstractForDfltRuntime.java
new file mode 100644
index 0000000..40e8b2c
--- /dev/null
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/authentication/AuthenticatorAbstractForDfltRuntime.java
@@ -0,0 +1,49 @@
+/*
+ * 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.authentication;
+
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.runtime.authentication.standard.AuthenticatorAbstract;
+import org.apache.isis.core.runtime.system.DeploymentType;
+import org.apache.isis.core.runtime.system.SystemConstants;
+
+public abstract class AuthenticatorAbstractForDfltRuntime extends AuthenticatorAbstract {
+
+ public AuthenticatorAbstractForDfltRuntime(final IsisConfiguration configuration) {
+ super(configuration);
+ }
+
+ // //////////////////////////////////////////////////////
+ // Helpers
+ // //////////////////////////////////////////////////////
+
+ /**
+ * Helper method for convenience of implementations that depend on the
+ * {@link DeploymentType}.
+ */
+ public DeploymentType getDeploymentType() {
+ final String deploymentTypeStr = getConfiguration().getString(SystemConstants.DEPLOYMENT_TYPE_KEY);
+ if (deploymentTypeStr == null) {
+ throw new IllegalStateException("Expect value for '" + SystemConstants.DEPLOYMENT_TYPE_KEY + "' to be bound into IsisConfiguration");
+ }
+ return DeploymentType.lookup(deploymentTypeStr);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/core/runtime/src/main/java/org/apache/isis/core/runtime/authentication/exploration/AuthenticationRequestExploration.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/authentication/exploration/AuthenticationRequestExploration.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/authentication/exploration/AuthenticationRequestExploration.java
new file mode 100644
index 0000000..21ff2ea
--- /dev/null
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/authentication/exploration/AuthenticationRequestExploration.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.runtime.authentication.exploration;
+
+import java.util.List;
+
+import org.apache.isis.applib.fixtures.LogonFixture;
+import org.apache.isis.core.runtime.authentication.AuthenticationRequestAbstract;
+
+/**
+ * For testing purposes, requests corresponding to an {@link ExplorationSession}
+ * .
+ */
+public class AuthenticationRequestExploration extends AuthenticationRequestAbstract {
+
+ private static final String EXPLORATION_USER = "exploration";
+
+ private final LogonFixture logonFixture;
+
+ public AuthenticationRequestExploration() {
+ this(null);
+ }
+
+ public AuthenticationRequestExploration(final LogonFixture logonFixture) {
+ super(logonFixture != null ? logonFixture.getUsername() : EXPLORATION_USER);
+ this.logonFixture = logonFixture;
+ }
+
+ @Override
+ public List<String> getRoles() {
+ return logonFixture != null ? logonFixture.getRoles() : super.getRoles();
+ }
+
+ public boolean isDefaultUser() {
+ return EXPLORATION_USER.equals(getName());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/core/runtime/src/main/java/org/apache/isis/core/runtime/authentication/exploration/ExplorationAuthenticator.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/authentication/exploration/ExplorationAuthenticator.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/authentication/exploration/ExplorationAuthenticator.java
new file mode 100644
index 0000000..e9d68d0
--- /dev/null
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/authentication/exploration/ExplorationAuthenticator.java
@@ -0,0 +1,138 @@
+/*
+ * 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.authentication.exploration;
+
+import java.util.ArrayList;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.runtime.authentication.AuthenticationRequest;
+import org.apache.isis.core.runtime.authentication.AuthenticatorAbstractForDfltRuntime;
+import org.apache.isis.core.runtime.authentication.standard.SimpleSession;
+import org.apache.isis.core.runtime.system.DeploymentType;
+
+/**
+ * Creates a session suitable for {@link DeploymentType#EXPLORATION exploration}
+ * mode.
+ *
+ * <p>
+ * If the {@link IsisConfiguration} contains the key
+ * {@value ExplorationAuthenticatorConstants#USERS} then returns a
+ * {@link MultiUserExplorationSession} which encapsulates the details of several
+ * users (and their roles). Viewers that are aware of this capability can offer
+ * the convenient ability to switch between these users. For viewers that are
+ * not aware, the {@link MultiUserExplorationSession} appears as a regular
+ * {@link SimpleSession session}, with the Id of the first user listed.
+ *
+ * <p>
+ * The format of the {@value ExplorationAuthenticatorConstants#USERS} key should
+ * be:
+ *
+ * <pre>
+ * &lt:userName> [:<role>[|<role>]...], <userName>...
+ * </pre>
+ */
+public class ExplorationAuthenticator extends AuthenticatorAbstractForDfltRuntime {
+
+ private final Set<SimpleSession> registeredSessions = new LinkedHashSet<SimpleSession>();;
+ private final String users;
+
+ // //////////////////////////////////////////////////////////////////
+ // Constructor
+ // //////////////////////////////////////////////////////////////////
+
+ public ExplorationAuthenticator(final IsisConfiguration configuration) {
+ super(configuration);
+ users = getConfiguration().getString(ExplorationAuthenticatorConstants.USERS);
+ if (users != null) {
+ registeredSessions.addAll(parseUsers(users));
+ }
+ }
+
+ private List<SimpleSession> parseUsers(final String users) {
+ final List<SimpleSession> registeredUsers = new ArrayList<SimpleSession>();
+
+ final StringTokenizer st = new StringTokenizer(users, ",");
+ while (st.hasMoreTokens()) {
+ final String token = st.nextToken();
+ final int end = token.indexOf(':');
+ final List<String> roles = new ArrayList<String>();
+ final String userName;
+ if (end == -1) {
+ userName = token.trim();
+ } else {
+ userName = token.substring(0, end).trim();
+ final String roleList = token.substring(end + 1);
+ final StringTokenizer st2 = new StringTokenizer(roleList, "|");
+ while (st2.hasMoreTokens()) {
+ final String role = st2.nextToken().trim();
+ roles.add(role);
+ }
+ }
+ registeredUsers.add(createSimpleSession(userName, roles));
+ }
+ return registeredUsers;
+ }
+
+ private SimpleSession createSimpleSession(final String userName, final List<String> roles) {
+ return new SimpleSession(userName, roles.toArray(new String[roles.size()]));
+ }
+
+ // //////////////////////////////////////////////////////////////////
+ // API
+ // //////////////////////////////////////////////////////////////////
+
+ /**
+ * Can authenticate if a {@link AuthenticationRequestExploration}.
+ */
+ @Override
+ public final boolean canAuthenticate(final Class<? extends AuthenticationRequest> authenticationRequestClass) {
+ return AuthenticationRequestExploration.class.isAssignableFrom(authenticationRequestClass);
+ }
+
+ /**
+ * Valid providing running in {@link DeploymentType#isExploring()
+ * exploration} mode.
+ */
+ @Override
+ public final boolean isValid(final AuthenticationRequest request) {
+ return getDeploymentType().isExploring();
+ }
+
+ @Override
+ public AuthenticationSession authenticate(final AuthenticationRequest request, final String code) {
+ final AuthenticationRequestExploration authenticationRequestExploration = (AuthenticationRequestExploration) request;
+ if (!authenticationRequestExploration.isDefaultUser()) {
+ registeredSessions.add(createSimpleSession(authenticationRequestExploration.getName(), authenticationRequestExploration.getRoles()));
+ }
+ if (registeredSessions.size() > 1) {
+ return new MultiUserExplorationSession(registeredSessions, code);
+ } else if (registeredSessions.size() == 1) {
+ return registeredSessions.iterator().next();
+ } else {
+ return new ExplorationSession(code);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/core/runtime/src/main/java/org/apache/isis/core/runtime/authentication/exploration/ExplorationAuthenticatorConstants.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/authentication/exploration/ExplorationAuthenticatorConstants.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/authentication/exploration/ExplorationAuthenticatorConstants.java
new file mode 100644
index 0000000..36c2c16
--- /dev/null
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/authentication/exploration/ExplorationAuthenticatorConstants.java
@@ -0,0 +1,31 @@
+/*
+ * 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.authentication.exploration;
+
+import org.apache.isis.core.commons.config.ConfigurationConstants;
+
+public final class ExplorationAuthenticatorConstants {
+
+ public static final String USERS = ConfigurationConstants.ROOT + "exploration.users";
+
+ private ExplorationAuthenticatorConstants() {
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/951a0fe4/core/runtime/src/main/java/org/apache/isis/core/runtime/authentication/exploration/ExplorationSession.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/authentication/exploration/ExplorationSession.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/authentication/exploration/ExplorationSession.java
new file mode 100644
index 0000000..144a2b2
--- /dev/null
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/authentication/exploration/ExplorationSession.java
@@ -0,0 +1,61 @@
+/*
+ * 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.authentication.exploration;
+
+import java.io.IOException;
+
+import org.apache.isis.core.commons.authentication.AuthenticationSessionAbstract;
+import org.apache.isis.core.commons.encoding.DataInputExtended;
+import org.apache.isis.core.commons.encoding.DataOutputExtended;
+import org.apache.isis.core.commons.encoding.Encodable;
+
+public final class ExplorationSession extends AuthenticationSessionAbstract implements Encodable {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final String DEFAULT_USER_NAME = "exploration";
+
+ /**
+ * Defaults validation code to <tt>""</tt>.
+ */
+ public ExplorationSession() {
+ this("");
+ }
+
+ public ExplorationSession(final String code) {
+ super(DEFAULT_USER_NAME, code);
+ initialized();
+ }
+
+ public ExplorationSession(final DataInputExtended input) throws IOException {
+ super(input);
+ initialized();
+ }
+
+ @Override
+ public void encode(final DataOutputExtended output) throws IOException {
+ super.encode(output);
+ }
+
+ private void initialized() {
+ // nothing to do
+ }
+
+}