You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2012/12/06 11:10:37 UTC
[47/51] [partial] ISIS-188: moving modules into core
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/main/resources/images/poweredby-logo.png
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/resources/images/poweredby-logo.png b/framework/core/runtime/src/main/resources/images/poweredby-logo.png
new file mode 100755
index 0000000..c9f66ac
Binary files /dev/null and b/framework/core/runtime/src/main/resources/images/poweredby-logo.png differ
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/main/resources/images/small-logo.png
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/resources/images/small-logo.png b/framework/core/runtime/src/main/resources/images/small-logo.png
new file mode 100755
index 0000000..bbf273c
Binary files /dev/null and b/framework/core/runtime/src/main/resources/images/small-logo.png differ
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/main/resources/images/splash-logo.png
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/resources/images/splash-logo.png b/framework/core/runtime/src/main/resources/images/splash-logo.png
new file mode 100755
index 0000000..33832a2
Binary files /dev/null and b/framework/core/runtime/src/main/resources/images/splash-logo.png differ
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/main/resources/isis-version.properties
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/resources/isis-version.properties b/framework/core/runtime/src/main/resources/isis-version.properties
new file mode 100644
index 0000000..1088fb5
--- /dev/null
+++ b/framework/core/runtime/src/main/resources/isis-version.properties
@@ -0,0 +1,22 @@
+# 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.
+# version.properties
+framework.name=Apache Isis
+framework.version=${project.version}
+framework.compile.date=${build.date}
+framework.copyright=Copyright (c) 2010~2011 Apache Software Foundation
+framework.logo=splash-logo
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/main/resources/isis.xsd
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/resources/isis.xsd b/framework/core/runtime/src/main/resources/isis.xsd
new file mode 100644
index 0000000..1785186
--- /dev/null
+++ b/framework/core/runtime/src/main/resources/isis.xsd
@@ -0,0 +1,157 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ 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.
+-->
+<xs:schema
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:nof="http://isis.apache.org/ns/0.1/metamodel"
+ targetNamespace="http://isis.apache.org/ns/0.1/metamodel"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified"
+ >
+
+ <xs:element name="title" type="xs:string"/>
+
+ <xs:element name="oids">
+ <xs:complexType>
+ <xs:sequence minOccurs="0" maxOccurs="unbounded">
+ <xs:element name="oid" type="nof:oidType"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+
+ <xs:complexType name="oidType">
+ <xs:sequence minOccurs="0" maxOccurs="unbounded">
+ <xs:choice>
+ <xs:element name="int" type="xs:int"/>
+ <xs:element name="oid" type="nof:oidType"/>
+ <xs:element name="string" type="xs:string"/>
+ <xs:element name="long" type="xs:long"/>
+ </xs:choice>
+ </xs:sequence>
+ <xs:attribute ref="nof:fqn"/>
+ </xs:complexType>
+
+ <!--
+ (not using because, although it is valid to nest the entire XML document in nof:snapshot,
+ VS.Net seems to trips over and think otherwise)
+ <xs:element name="snapshot">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:any namespace="##other" minOccurs="0"
+ maxOccurs="unbounded"
+ processContents="lax" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ -->
+
+ <xs:attribute name="feature">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="value" />
+ <xs:enumeration value="reference" />
+ <xs:enumeration value="collection" />
+ <xs:enumeration value="class" />
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:attribute>
+
+ <xs:attribute name="fqn" type="xs:string">
+ <xs:annotation>
+ <xs:documentation>
+ Fully qualified class name, used to trace the lineage of
+ elements.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+
+ <xs:attribute name="singular" type="xs:string">
+ <xs:annotation>
+ <xs:documentation>
+ Singular name for class.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+
+ <xs:attribute name="plural" type="xs:string">
+ <xs:annotation>
+ <xs:documentation>
+ Plural name for class.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+
+ <xs:attribute name="annotation" type="xs:string">
+ <xs:annotation>
+ <xs:documentation>
+ A mechanism for tagging certain elements of the snapshot.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+
+ <!-- this schema could be more precise,
+ specifically in that there are constraints as to how the feature and other attributes are combined -->
+ <xs:attribute name="isEmpty">
+ <xs:annotation>
+ <xs:documentation>
+ Indicates whether a value is empty or a reference is null.
+ Used in conjunction with nof:feature="value" or nof:feature="value"
+ </xs:documentation>
+ </xs:annotation>
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="true" />
+ <xs:enumeration value="false" />
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:attribute>
+
+ <xs:attribute name="oid" type="xs:string">
+ <xs:annotation>
+ <xs:documentation>
+ Unique in-memory identifier for this object (either the OID or the hashcode for transient objects.
+ Primarily present for an internal implementation detail to ensure objects appear only once.
+ Used in conjunction with nof:feature="class"
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="type" type="xs:QName">
+ <xs:annotation>
+ <xs:documentation>
+ Type of a reference to another object; used in combination with nof:feature="reference" or nof:feature="collection"
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="datatype" type="xs:QName">
+ <xs:annotation>
+ <xs:documentation>
+ Subclass of [[NAME]]Value, indicaing the type of a field; used in combination with nof:feature="value"
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="size" type="xs:integer">
+ <xs:annotation>
+ <xs:documentation>
+ Size of a collection; used in combination with nof:feature="collection"
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+
+
+</xs:schema>
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/main/resources/org/apache/isis/runtimes/dflt/runtime/installer-registry.properties
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/resources/org/apache/isis/runtimes/dflt/runtime/installer-registry.properties b/framework/core/runtime/src/main/resources/org/apache/isis/runtimes/dflt/runtime/installer-registry.properties
new file mode 100644
index 0000000..d32a74d
--- /dev/null
+++ b/framework/core/runtime/src/main/resources/org/apache/isis/runtimes/dflt/runtime/installer-registry.properties
@@ -0,0 +1,100 @@
+# 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.
+############################################################
+# CORE
+############################################################
+
+org.apache.isis.core.progmodel.facetdecorators.i18n.resourcebundle.I18nDecoratorUsingResourceBundleInstaller # "resource-i18n"
+org.apache.isis.core.progmodel.facetdecorators.help.file.HelpFacetDecoratorUsingFilesInstaller # "help-file"
+
+
+############################################################
+# SECURITY
+############################################################
+
+org.apache.isis.security.dflt.authentication.DefaultAuthenticationManagerInstaller # "dflt"
+org.apache.isis.security.dflt.authorization.DefaultAuthorizationManagerInstaller # "dflt"
+
+org.apache.isis.security.file.authentication.FileAuthenticationManagerInstaller # "file"
+org.apache.isis.security.file.authorization.FileAuthorizationManagerInstaller # "file"
+
+org.apache.isis.security.ldap.authorization.LdapAuthorizationManagerInstaller # "ldap"
+org.apache.isis.security.ldap.authentication.LdapAuthenticationManagerInstaller # "ldap"
+
+org.apache.isis.security.sql.authorization.SqlAuthorizationManagerInstaller # "sql"
+org.apache.isis.security.sql.authentication.SqlAuthenticationManagerInstaller # "sql"
+
+
+
+
+############################################################
+# VIEWERS
+############################################################
+
+org.apache.isis.viewer.dnd.DndViewerInstaller # "dnd"
+org.apache.isis.viewer.html.HtmlViewerInstaller # "html" (runs within embedded web server)
+org.apache.isis.viewer.restfulobjects.viewer.embedded.RestfulObjectsViewerInstaller # "restfulobjects" (runs within embedded web server)
+
+
+
+############################################################
+# PROGRAMMING MODELS
+############################################################
+
+# in default runtime only for dynamic lookup of facet decorators
+org.apache.isis.runtimes.dflt.runtime.progmodels.JavaReflectorInstaller # "java"
+
+############################################################
+# DEFAULT RUNTIME
+############################################################
+
+# image loader
+org.apache.isis.core.runtime.imageloader.awt.TemplateImageLoaderAwtInstaller # "awt"
+
+# fixture loaders
+org.apache.isis.runtimes.dflt.runtime.fixtures.FixturesInstallerFromConfiguration "configuration"
+
+# services
+org.apache.isis.runtimes.dflt.runtime.services.ServicesInstallerFromConfiguration # "configuration"
+
+# objectstores
+org.apache.isis.runtimes.dflt.objectstores.dflt.InMemoryPersistenceMechanismInstaller # "in-memory"
+org.apache.isis.runtimes.dflt.objectstores.xml.XmlPersistenceMechanismInstaller # "xml"
+org.apache.isis.runtimes.dflt.objectstores.sql.SqlPersistorInstaller # "sql"
+org.apache.isis.runtimes.dflt.objectstores.nosql.db.mongo.MongoPersistorMechanismInstaller # "mongo"
+org.apache.isis.runtimes.dflt.objectstores.nosql.db.file.FileServerPersistorMechanismInstaller # "fileserver"
+org.apache.isis.runtimes.dflt.objectstores.jdo.datanucleus.DataNucleusPersistenceMechanismInstaller # datanucleus
+
+# profilestores
+org.apache.isis.runtimes.dflt.profilestores.dflt.InMemoryUserProfileStoreInstaller # "in-memory"
+org.apache.isis.runtimes.dflt.profilestores.xml.XmlUserProfileStoreInstaller # "xml"
+org.apache.isis.runtimes.dflt.profilestores.sql.SqlUserProfileStoreInstaller # "sql"
+
+# reflector decorators
+org.apache.isis.runtimes.dflt.runtime.transaction.facetdecorator.standard.TransactionFacetDecoratorInstaller # "transaction"
+
+# viewer (runs within embedded web server)
+org.apache.isis.runtimes.dflt.webapp.monitor.WebServerMonitorInstaller # "monitor"
+
+# embedded web server
+org.apache.isis.runtimes.dflt.webserver.embedded.jetty.JettyEmbeddedWebServerInstaller # "jetty"
+
+
+
+
+####### END #########
+
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/site/apt/index.apt
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/site/apt/index.apt b/framework/core/runtime/src/site/apt/index.apt
new file mode 100644
index 0000000..05d2fd0
--- /dev/null
+++ b/framework/core/runtime/src/site/apt/index.apt
@@ -0,0 +1,76 @@
+~~ 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.
+
+Runtime
+
+ The <runtime> module is the "engine-room" of the framework, taking
+ responsibility to manage domain object (pojo) instances at runtime.
+
+ Each pojo is wrapped in an <<<ObjectAdapter>>> (cf <<<java.lang.Object>>>)
+ from which the <<<ObjectSpecification>>> (cf <<<java.lang.Class>>>) can be
+ obtained. Associated with each <<<ObjectAdapter>>> is an <<<Oid>>>: an
+ opaque serializable identifier to the object. The <runtime> module maintains
+ a 3-way {{{http://martinfowler.com/eaaCatalog/identityMap.html}identity map}}
+ between these, allowing forward and reverse lookups.
+
+ The <runtime> module defines a number of APIs the most important of which is
+ the <<<ObjectStore>>> API. The <runtime> module manages persistence
+ and transaction demarcation, with the actual storage of objects being
+ delegated to an object store implementation.
+
+ The other major API defined by the <runtime> module security API, dealing with
+ authentication and authorization.
+
+ In addition to all the above, the <runtime> module defines a command-line
+ bootstrapper, making it easy to bootstrap <Apache Isis> from a main() or a
+ JUnit test case.
+
+
+WebApp Support
+
+ The <webapp> module is a small module that provides reusable servlet context
+ listeners and filters to webapp viewers. They include:
+
+ * <<<IsisWebAppBootstrapper>>> which is a servlet context listener to bootstrap
+ an Isis runtime and bind to the servlet context
+
+ * <<<IsisSessionFilter>>> which is a filter used to
+ creating an <<<IsisSession>>> for each request (the
+ {{{http://community.jboss.org/wiki/OpenSessioninView}Open session in View}}
+ pattern)
+
+ []
+
+ Not every webapp-based viewer is required to use these classes; refer to their
+ documentation for exact details of what should reside in the <<<web.xml>>>.
+
+
+
+Identity Bytecode
+
+ The <identity> bytecode module is a no-op implementation of the bytecode
+ APIs. It is provided for those object stores that do not need the use of
+ bytecode enhancement, typically because they hook into the lazy loading
+ of the underlying ORM.
+
+
+Documentation
+
+ See the {{{../index.html}core}} documentation
+ ({{{../../../core/docbkx/html/guide/isis-core.html}HTML}} or
+ {{{../../../core/docbkx/pdf/isis-core.pdf}PDF}}).
+
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/site/apt/jottings.apt
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/site/apt/jottings.apt b/framework/core/runtime/src/site/apt/jottings.apt
new file mode 100644
index 0000000..c5d1200
--- /dev/null
+++ b/framework/core/runtime/src/site/apt/jottings.apt
@@ -0,0 +1,24 @@
+~~ Licensed to the Apache Software Foundation (ASF) under one
+~~ or more contributor license agreements. See the NOTICE file
+~~ distributed with this work for additional information
+~~ regarding copyright ownership. The ASF licenses this file
+~~ to you under the Apache License, Version 2.0 (the
+~~ "License"); you may not use this file except in compliance
+~~ with the License. You may obtain a copy of the License at
+~~
+~~ http://www.apache.org/licenses/LICENSE-2.0
+~~
+~~ Unless required by applicable law or agreed to in writing,
+~~ software distributed under the License is distributed on an
+~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+~~ KIND, either express or implied. See the License for the
+~~ specific language governing permissions and limitations
+~~ under the License.
+
+
+
+Jottings
+
+ This page is to capture any random jottings relating to this module prior
+ to being moved into formal documentation.
+
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/site/site.xml
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/site/site.xml b/framework/core/runtime/src/site/site.xml
new file mode 100644
index 0000000..559edba
--- /dev/null
+++ b/framework/core/runtime/src/site/site.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<project>
+
+ <body>
+ <breadcrumbs>
+ <item name="Runtime" href="index.html"/>
+ </breadcrumbs>
+
+ <menu name="Runtime">
+ <item name="About" href="index.html" />
+ <item name="Jottings" href="jottings.html" />
+ </menu>
+
+ <menu name="Default Runtime">
+ <item name="Implementation" href="../runtime/index.html" />
+ <item name="Objectstores" href="../objectstores/index.html" />
+ <item name="Profilestores" href="../profilestores/index.html" />
+ <item name="Bytecode" href="../bytecode/index.html" />
+ <item name="Monitoring" href="../monitoring/index.html" />
+ <item name="Webapp Support" href="../webapp/index.html" />
+ <item name="Webserver" href="../webserver/index.html" />
+ <item name="Remoting" href="../remoting/index.html" />
+ </menu>
+
+ <menu name="Maven Reports" ref="reports"/>
+ </body>
+</project>
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/test-archived/org.nakedobjects.nof.reflect.remote.spec/DummyAction.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/test-archived/org.nakedobjects.nof.reflect.remote.spec/DummyAction.java b/framework/core/runtime/src/test-archived/org.nakedobjects.nof.reflect.remote.spec/DummyAction.java
new file mode 100644
index 0000000..79f2c2c
--- /dev/null
+++ b/framework/core/runtime/src/test-archived/org.nakedobjects.nof.reflect.remote.spec/DummyAction.java
@@ -0,0 +1,328 @@
+/*
+ * 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.nof.reflect.remote.spec;
+
+import org.apache.isis.noa.adapter.ObjectAdapter;
+import org.apache.isis.noa.adapter.ObjectAdapterReference;
+import org.apache.isis.noa.facets.Facet;
+import org.apache.isis.metamodel.facets.actions.debug.DebugFacet;
+import org.apache.isis.metamodel.facets.actions.executed.ExecutedFacet;
+import org.apache.isis.metamodel.facets.actions.exploration.ExplorationFacet;
+import org.apache.isis.noa.reflect.Consent;
+import org.apache.isis.noa.reflect.ObjectAction;
+import org.apache.isis.noa.reflect.ObjectActionParameter;
+import org.apache.isis.noa.reflect.ObjectActionParameter.Filter;
+import org.apache.isis.noa.spec.ObjectSpecification;
+import org.apache.isis.nof.core.context.IsisContext;
+import org.apache.isis.nof.core.reflect.Allow;
+import org.apache.isis.nof.core.util.NameConvertor;
+import org.apache.isis.nof.core.util.NotImplementedException;
+import org.apache.isis.nof.reflect.peer.ActionPeer;
+import org.apache.isis.nof.reflect.peer.MemberIdentifier;
+import org.apache.isis.nof.reflect.spec.DefaultOneToOneActionParameter;
+import org.apache.isis.nof.reflect.spec.DefaultValueActionParameter;
+import org.apache.isis.testing.TestSession;
+
+
+public class DummyAction implements ObjectAction {
+ public final ActionPeer peer;
+
+ public DummyAction(final ActionPeer peer) {
+ this.peer = peer;
+ }
+
+ public boolean[] canParametersWrap() {
+ return null;
+ }
+
+ public String debugData() {
+ return "";
+ }
+
+ public ObjectAdapter execute(final ObjectAdapterReference object, final ObjectAdapter[] parameters) {
+ return peer.execute(object, parameters);
+ }
+
+ public ObjectAction[] getActions() {
+ return new ObjectAction[0];
+ }
+
+ public ObjectAdapter[] getDefaultParameterValues(ObjectAdapterReference target) {
+ throw new NotImplementedException();
+ }
+
+ public String getDescription() {
+ return "";
+ }
+
+ public Facet getFacet(final Class cls) {
+ return null;
+ }
+
+ public Class[] getFacetTypes() {
+ return new Class[0];
+ }
+
+ public Facet[] getFacets(Facet.Filter filter) {
+ return new Facet[]{};
+ }
+
+ public void addFacet(Facet facet) {
+ }
+
+ public void removeFacet(Facet facet) {
+ }
+
+ public String getHelp() {
+ return "";
+ }
+
+ public String getId() {
+ return NameConvertor.simpleName(peer.getIdentifier().getName());
+ }
+
+ public MemberIdentifier getIdentifier() {
+ throw new NotImplementedException();
+ }
+
+ public String getName() {
+ return "";
+ }
+
+ public ObjectSpecification getOnType() {
+ return peer.getOnType();
+ }
+
+ public ObjectAdapter[][] getOptions(ObjectAdapterReference target) {
+ return null;
+ }
+
+ public int getParameterCount() {
+ return peer.getParameterCount();
+ }
+
+ public String[] getParameterDescriptions() {
+ return null;
+ }
+
+ public int[] getParameterMaxLengths() {
+ return null;
+ }
+
+ public String[] getParameterNames() {
+ return new String[]{};
+ }
+
+ public int[] getParameterNoLines() {
+ return null;
+ }
+
+ /**
+ * Build lazily by {@link #getParameters()}.
+ */
+ private ObjectActionParameter[] parameters;
+ public ObjectActionParameter[] getParameters() {
+ if (parameters == null) {
+ parameters = new ObjectActionParameter[getParameterCount()];
+ ObjectSpecification[] parameterTypes = getParameterTypes();
+ String[] parameterNames = getParameterNames();
+ String[] parameterDescriptions = getParameterDescriptions();
+ boolean[] optionalParameters = getOptionalParameters();
+
+ int[] parameterNoLines = getParameterNoLines();
+ boolean[] canParametersWrap = canParametersWrap();
+ int[] parameterMaxLengths = getParameterMaxLengths();
+ int[] parameterTypicalLengths = getParameterTypicalLengths();
+
+ for(int i=0; i<getParameterCount(); i++) {
+ if (parameterTypes[i].getType() == ObjectSpecification.VALUE) {
+ parameters[i] = new DefaultValueActionParameter(
+ i,
+ this,
+ null,
+ parameterTypes[i],
+ parameterNames[i], parameterDescriptions[i],
+ optionalParameters[i],
+ parameterTypicalLengths[i], parameterMaxLengths[i],
+ parameterNoLines[i], canParametersWrap[i]);
+ } else if (parameterTypes[i].getType() == ObjectSpecification.OBJECT) {
+ parameters[i] = new DefaultOneToOneActionParameter(
+ i,
+ this,
+ null,
+ parameterTypes[i],
+ parameterNames[i], parameterDescriptions[i],
+ optionalParameters[i]);
+ } else if (parameterTypes[i].getType() == ObjectSpecification.COLLECTION) {
+ // TODO: not supported; should we throw an exception of some sort here?
+ parameters[i] = null;
+ }
+
+ }
+ }
+ return parameters;
+ }
+
+
+ public ObjectActionParameter[] getParameters(
+ Filter filter) {
+ ObjectActionParameter[] allParameters = getParameters();
+
+ ObjectActionParameter[] selectedParameters = new ObjectActionParameter[allParameters.length];
+ int v = 0;
+ for (int i = 0; i < allParameters.length; i++) {
+ if (filter.accept(allParameters[i])) {
+ selectedParameters[v++] = allParameters[i];
+ }
+ }
+
+ ObjectActionParameter[] parameters = new ObjectActionParameter[v];
+ System.arraycopy(selectedParameters, 0, parameters, 0, v);
+ return parameters;
+ }
+
+
+// public ObjectSpecification[] getParameterTypes() {
+// return peer.getParameterTypes();
+// }
+
+ public int[] getParameterTypicalLengths() {
+ return null;
+ }
+
+// public boolean[] getOptionalParameters() {
+// return peer.getOptionalParameters();
+// }
+
+ public ObjectSpecification getReturnType() {
+ return peer.getReturnType();
+ }
+
+ public Target getTarget() {
+ ExecutedFacet executedFacet = (ExecutedFacet) peer.getFacet(ExecutedFacet.class);
+ return executedFacet == null?ObjectAction.DEFAULT:executedFacet.getTarget();
+ }
+
+ public Type getType() {
+ DebugFacet debugFacet = (DebugFacet) peer.getFacet(DebugFacet.class);
+ if (debugFacet != null) {
+ return ObjectAction.DEBUG;
+ }
+ ExplorationFacet explorationFacet = (ExplorationFacet) peer.getFacet(ExplorationFacet.class);
+ if (explorationFacet != null) {
+ return ObjectAction.EXPLORATION;
+ }
+ return ObjectAction.USER;
+ }
+
+ public boolean hasReturn() {
+ return false;
+ }
+
+ public boolean isOnInstance() {
+ return peer.isOnInstance();
+ }
+
+ /**
+ * Delegates to {@link #isParameterSetValidDeclaratively(ObjectAdapterReference, ObjectAdapter[])} and
+ * then {@link #isParameterSetValidImperatively(ObjectAdapterReference, ObjectAdapter[])}, as per the
+ * contract in the {@link ObjectAction implemented interface}.
+ */
+ public Consent isParameterSetValid(final ObjectAdapterReference object,
+ final ObjectAdapter[] parameters) {
+ Consent consentDeclaratively = isParameterSetValidDeclaratively(object, parameters);
+ if (consentDeclaratively.isVetoed()) {
+ return consentDeclaratively;
+ }
+ return isParameterSetValidImperatively(object, parameters);
+ }
+
+ /**
+ * Always returns an {@link Allow}.
+ */
+ public Consent isParameterSetValidDeclaratively(
+ ObjectAdapterReference object,
+ ObjectAdapter[] parameters) {
+ return Allow.DEFAULT;
+ }
+
+ public Consent isParameterSetValidImperatively(
+ ObjectAdapterReference object,
+ ObjectAdapter[] parameters) {
+ return peer.isParameterSetValidImperatively(object, parameters);
+ }
+
+ public Consent isUsable(final ObjectAdapterReference target) {
+ return peer.isUsable(target);
+ }
+
+ public Consent isUsable() {
+ Consent usableDeclaratively = isUsableDeclaratively();
+ if (usableDeclaratively.isVetoed()) {
+ return usableDeclaratively;
+ }
+ return isUsableForSession();
+ }
+
+ public Consent isUsableDeclaratively() {
+ return peer.isUsableDeclaratively();
+ }
+
+ public Consent isUsableForSession() {
+ return peer.isUsableForSession(IsisContext.getSession());
+ }
+
+ public boolean isContributedMethodWithSuitableParameter() {
+ return false;
+ }
+
+ public boolean isVisible() {
+ return isVisibleDeclaratively() && isVisibleForSession();
+ }
+
+ public boolean isVisibleDeclaratively() {
+ return peer.isVisibleDeclaratively();
+ }
+
+ public boolean isVisibleForSession() {
+ return peer.isVisibleForSession(new TestSession());
+ }
+
+ public boolean isVisible(final ObjectAdapterReference target) {
+ return peer.isVisible(target);
+ }
+
+ public ObjectAdapter[] parameterStubs() {
+ throw new NotImplementedException();
+ }
+
+ public ObjectAdapterReference realTarget(ObjectAdapterReference target) {
+ return target;
+ }
+
+ public ObjectSpecification getSpecification() {
+ return null;
+ }
+
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/test-archived/org.nakedobjects.nof.reflect.remote.spec/DummyOneToManyAssociation.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/test-archived/org.nakedobjects.nof.reflect.remote.spec/DummyOneToManyAssociation.java b/framework/core/runtime/src/test-archived/org.nakedobjects.nof.reflect.remote.spec/DummyOneToManyAssociation.java
new file mode 100644
index 0000000..cfe399a
--- /dev/null
+++ b/framework/core/runtime/src/test-archived/org.nakedobjects.nof.reflect.remote.spec/DummyOneToManyAssociation.java
@@ -0,0 +1,175 @@
+/*
+ * 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.nof.reflect.remote.spec;
+
+import org.apache.isis.noa.adapter.ObjectAdapter;
+import org.apache.isis.noa.adapter.ObjectAdapterReference;
+import org.apache.isis.noa.facets.Facet;
+import org.apache.isis.noa.reflect.Consent;
+import org.apache.isis.noa.reflect.ObjectField;
+import org.apache.isis.noa.spec.ObjectSpecification;
+import org.apache.isis.nof.core.reflect.Allow;
+import org.apache.isis.nof.reflect.peer.OneToManyPeer;
+
+
+public class DummyOneToManyAssociation implements ObjectField {
+
+ private final OneToManyPeer fieldPeer;
+
+ public DummyOneToManyAssociation(final OneToManyPeer fieldPeer) {
+ this.fieldPeer = fieldPeer;
+ }
+
+ public String getBusinessKeyName() {
+ return null;
+ }
+
+ public OneToManyPeer getPeer() {
+ return fieldPeer;
+ }
+
+ public ObjectSpecification getSpecification() {
+ return null;
+ }
+
+ public boolean isCollection() {
+ return false;
+ }
+
+ public boolean isPersisted() {
+ return true;
+ }
+
+ public boolean isEmpty(final ObjectAdapter adapter) {
+ return false;
+ }
+
+ public boolean isObject() {
+ return false;
+ }
+
+ public boolean isValue() {
+ return false;
+ }
+
+ public boolean isMandatory() {
+ return false;
+ }
+
+ public boolean isOptionEnabled() {
+ return false;
+ }
+
+ public ObjectAdapter get(final ObjectAdapter fromObject) {
+ return null;
+ }
+
+ public Object getDefault(
+ ObjectAdapter adapter) {
+ return null;
+ }
+
+ public void toDefault(ObjectAdapter target) {
+ }
+
+ public Facet getFacet(final Class cls) {
+ return null;
+ }
+
+ public Class[] getFacetTypes() {
+ return null;
+ }
+
+ public Facet[] getFacets(Facet.Filter filter) {
+ return null;
+ }
+
+ public void addFacet(Facet facet) {
+ }
+
+ public void removeFacet(Facet facet) {
+ }
+
+
+ public String getName() {
+ return null;
+ }
+
+ public String getId() {
+ return fieldPeer.getIdentifier().getName();
+ }
+
+ public String getDescription() {
+ return null;
+ }
+
+ public ObjectAdapter[] getOptions(final ObjectAdapter target) {
+ return null;
+ }
+
+ public Consent isUsable() {
+ Consent usableDeclaratively = isUsableDeclaratively();
+ if (usableDeclaratively.isVetoed()) {
+ return usableDeclaratively;
+ }
+ return isUsableForSession();
+ }
+
+ public Consent isUsableDeclaratively() {
+ return Allow.DEFAULT;
+ }
+
+ public Consent isUsableForSession() {
+ return Allow.DEFAULT;
+ }
+
+ public Consent isUsable(final ObjectAdapterReference target) {
+ return null;
+ }
+
+ public boolean isVisible() {
+ return isVisibleDeclaratively() && isVisibleForSession();
+ }
+
+ public boolean isVisibleDeclaratively() {
+ return false;
+ }
+
+ public boolean isVisibleForSession() {
+ return false;
+ }
+
+ public boolean isVisible(final ObjectAdapterReference target) {
+ return true;
+ }
+
+
+ public String getHelp() {
+ return null;
+ }
+
+ public String debugData() {
+ return "";
+ }
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/test-archived/org.nakedobjects.nof.reflect.remote.spec/DummyOneToOneAssociation.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/test-archived/org.nakedobjects.nof.reflect.remote.spec/DummyOneToOneAssociation.java b/framework/core/runtime/src/test-archived/org.nakedobjects.nof.reflect.remote.spec/DummyOneToOneAssociation.java
new file mode 100644
index 0000000..04268bb
--- /dev/null
+++ b/framework/core/runtime/src/test-archived/org.nakedobjects.nof.reflect.remote.spec/DummyOneToOneAssociation.java
@@ -0,0 +1,178 @@
+/*
+ * 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.nof.reflect.remote.spec;
+
+import org.apache.isis.noa.adapter.ObjectAdapter;
+import org.apache.isis.noa.adapter.ObjectAdapterReference;
+import org.apache.isis.noa.facets.Facet;
+import org.apache.isis.noa.reflect.Consent;
+import org.apache.isis.noa.reflect.ObjectField;
+import org.apache.isis.noa.spec.ObjectSpecification;
+import org.apache.isis.nof.core.reflect.Allow;
+import org.apache.isis.nof.reflect.peer.OneToOnePeer;
+
+
+public class DummyOneToOneAssociation implements ObjectField {
+
+ private final OneToOnePeer fieldPeer;
+
+ public DummyOneToOneAssociation(final OneToOnePeer fieldPeer) {
+ this.fieldPeer = fieldPeer;
+ }
+
+ public String getBusinessKeyName() {
+ return null;
+ }
+
+ public Object getDefault(
+ ObjectAdapter adapter) {
+ return null;
+ }
+
+ public void toDefault(ObjectAdapter target) {
+ }
+
+ public ObjectAdapter[] getOptions(final ObjectAdapter target) {
+ return null;
+ }
+
+ public OneToOnePeer getPeer() {
+ return fieldPeer;
+ }
+
+ public ObjectSpecification getSpecification() {
+ return null;
+ }
+
+ public boolean isCollection() {
+ return false;
+ }
+
+ public boolean isPersisted() {
+ return true;
+ }
+
+ public boolean isEmpty(final ObjectAdapter adapter) {
+ return false;
+ }
+
+ public boolean isObject() {
+ return false;
+ }
+
+ public boolean isValue() {
+ return false;
+ }
+
+ public boolean isMandatory() {
+ return false;
+ }
+
+ public boolean isOptionEnabled() {
+ return false;
+ }
+
+
+ public ObjectAdapter get(final ObjectAdapter fromObject) {
+ return null;
+ }
+
+ public Facet getFacet(final Class cls) {
+ return null;
+ }
+
+ public Class[] getFacetTypes() {
+ return null;
+ }
+
+ public Facet[] getFacets(Facet.Filter filter) {
+ return null;
+ }
+
+ public void addFacet(Facet facet) {
+ }
+
+ public void removeFacet(Facet facet) {
+ }
+
+ public String getName() {
+ return null;
+ }
+
+ public String getId() {
+ return fieldPeer.getIdentifier().getName();
+ }
+
+ public boolean hasHint() {
+ return false;
+ }
+
+ public String getDescription() {
+ return null;
+ }
+
+ public Consent isUsable() {
+ Consent usableDeclaratively = isUsableDeclaratively();
+ if (usableDeclaratively.isVetoed()) {
+ return usableDeclaratively;
+ }
+ return isUsableForSession();
+ }
+
+ public Consent isUsableDeclaratively() {
+ return Allow.DEFAULT;
+ }
+
+ public Consent isUsableForSession() {
+ return Allow.DEFAULT;
+ }
+
+ public Consent isUsable(final ObjectAdapterReference target) {
+ return null;
+ }
+
+ public boolean isVisible() {
+ return isVisibleDeclaratively() && isVisibleForSession();
+ }
+
+ public boolean isVisibleDeclaratively() {
+ return false;
+ }
+
+ public boolean isVisibleForSession() {
+ return false;
+ }
+
+ public boolean isVisible(final ObjectAdapterReference target) {
+ return true;
+ }
+
+ public String getHelp() {
+ return null;
+ }
+
+ public String debugData() {
+ return "";
+ }
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/test-archived/org.nakedobjects.nof.reflect.remote.spec/DummyValueAssociation.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/test-archived/org.nakedobjects.nof.reflect.remote.spec/DummyValueAssociation.java b/framework/core/runtime/src/test-archived/org.nakedobjects.nof.reflect.remote.spec/DummyValueAssociation.java
new file mode 100644
index 0000000..01301e3
--- /dev/null
+++ b/framework/core/runtime/src/test-archived/org.nakedobjects.nof.reflect.remote.spec/DummyValueAssociation.java
@@ -0,0 +1,166 @@
+/*
+ * 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.nof.reflect.remote.spec;
+
+import org.apache.isis.noa.adapter.ObjectAdapter;
+import org.apache.isis.noa.adapter.ObjectAdapterReference;
+import org.apache.isis.noa.facets.Facet;
+import org.apache.isis.noa.reflect.Consent;
+import org.apache.isis.noa.reflect.ObjectField;
+import org.apache.isis.noa.spec.ObjectSpecification;
+import org.apache.isis.nof.core.reflect.Allow;
+import org.apache.isis.nof.reflect.peer.ValuePeer;
+
+
+public class DummyValueAssociation implements ObjectField {
+
+ private final ValuePeer fieldPeer;
+
+ public DummyValueAssociation(final ValuePeer fieldPeer) {
+ this.fieldPeer = fieldPeer;
+ }
+
+ public String getBusinessKeyName() {
+ return null;
+ }
+
+ public ObjectSpecification getSpecification() {
+ return null;
+ }
+
+ public Object getDefault(
+ ObjectAdapter adapter) {
+ return null;
+ }
+
+ public void toDefault(ObjectAdapter target) {
+ }
+
+ public ObjectAdapter[] getOptions(final ObjectAdapter target) {
+ return null;
+ }
+
+ public boolean isCollection() {
+ return false;
+ }
+
+ public boolean isPersisted() {
+ return true;
+ }
+
+ public boolean isEmpty(final ObjectAdapter adapter) {
+ return false;
+ }
+
+ public boolean isObject() {
+ return false;
+ }
+
+ public boolean isOptionEnabled() {
+ return false;
+ }
+
+ public boolean isValue() {
+ return false;
+ }
+
+ public boolean isMandatory() {
+ return false;
+ }
+
+
+ public ObjectAdapter get(final ObjectAdapter fromObject) {
+ return null;
+ }
+
+ public Facet getFacet(final Class cls) {
+ return null;
+ }
+
+ public Class[] getFacetTypes() {
+ return null;
+ }
+
+ public Facet[] getFacets(Facet.Filter filter) {
+ return null;
+ }
+
+ public void addFacet(Facet facet) {
+ }
+
+ public void removeFacet(Facet facet) {
+ }
+
+ public String getName() {
+ return "Id";
+ }
+
+ public String getId() {
+ return fieldPeer.getIdentifier().getName();
+ }
+
+ public String getDescription() {
+ return null;
+ }
+
+ public boolean isVisible() {
+ return isVisibleDeclaratively() && isVisibleForSession();
+ }
+
+ public boolean isVisibleDeclaratively() {
+ return false;
+ }
+
+ public boolean isVisibleForSession() {
+ return false;
+ }
+
+ public Consent isUsable() {
+ return Allow.DEFAULT;
+ }
+
+ public Consent isUsableDeclaratively() {
+ return Allow.DEFAULT;
+ }
+
+ public Consent isUsableForSession() {
+ return Allow.DEFAULT;
+ }
+
+ public Consent isUsable(final ObjectAdapterReference target) {
+ return null;
+ }
+
+ public boolean isVisible(final ObjectAdapterReference target) {
+ return true;
+ }
+
+ public String getHelp() {
+ return null;
+ }
+
+ public String debugData() {
+ return "";
+ }
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/test-archived/org.nakedobjects.nof.reflect.remote.spec/JavaFieldTest.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/test-archived/org.nakedobjects.nof.reflect.remote.spec/JavaFieldTest.java b/framework/core/runtime/src/test-archived/org.nakedobjects.nof.reflect.remote.spec/JavaFieldTest.java
new file mode 100644
index 0000000..8d7ae4c
--- /dev/null
+++ b/framework/core/runtime/src/test-archived/org.nakedobjects.nof.reflect.remote.spec/JavaFieldTest.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+package org.apache.isis.nof.reflect.remote.spec;
+
+import junit.framework.TestSuite;
+
+import org.apache.isis.noa.adapter.ObjectAdapter;
+import org.apache.isis.nof.reflect.peer.MemberIdentifierImpl;
+import org.apache.isis.nof.testsystem.ProxyTestCase;
+import org.apache.isis.nof.testsystem.TestProxySpecification;
+
+
+public class JavaFieldTest extends ProxyTestCase {
+ private static final String MEMBERS_FIELD_NAME = "members";
+
+ public static void main(final String[] args) {
+ junit.textui.TestRunner.run(new TestSuite(JavaFieldTest.class));
+ }
+
+ private JavaField field;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ MemberIdentifierImpl memberIdentifierImpl = new MemberIdentifierImpl("cls", MEMBERS_FIELD_NAME);
+
+ field = new JavaField(memberIdentifierImpl, String.class){
+ public boolean isEmpty(ObjectAdapter inObject) {
+ return true;
+ }
+ };
+
+ }
+
+ protected void tearDown() throws Exception {
+ system.shutdown();
+ }
+
+ public void testType() {
+ TestProxySpecification spec = system.getSpecification(String.class);
+ assertEquals(spec, field.getSpecification());
+ }
+
+ public void testIsEmpty() throws Exception {
+ ObjectAdapter inObject = system.createPersistentTestObject();
+ assertTrue(field.isEmpty(inObject));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/test-archived/test.org.nakedobjects.object.security/ActionAuthorisationTest.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/test-archived/test.org.nakedobjects.object.security/ActionAuthorisationTest.java b/framework/core/runtime/src/test-archived/test.org.nakedobjects.object.security/ActionAuthorisationTest.java
new file mode 100644
index 0000000..a72e452
--- /dev/null
+++ b/framework/core/runtime/src/test-archived/test.org.nakedobjects.object.security/ActionAuthorisationTest.java
@@ -0,0 +1,60 @@
+/*
+ * 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 test.org.apache.isis.object.security;
+
+import junit.framework.TestCase;
+
+import org.apache.isis.nof.core.context.StaticContext;
+import org.apache.isis.testing.NullSession;
+
+import test.org.apache.isis.object.reflect.DummyActionPeer;
+
+
+public class ActionAuthorisationTest extends TestCase {
+
+ public static void main(final String[] args) {
+ junit.textui.TestRunner.run(ActionAuthorisationTest.class);
+ }
+
+ private MockAuthorisationManager manager;
+ private ActionAuthorisation action;
+
+ protected void setUp() throws Exception {
+ StaticContext.createInstance();
+ DummyActionPeer peer = new DummyActionPeer();
+ manager = new MockAuthorisationManager();
+ action = new ActionAuthorisation(peer, manager);
+ }
+
+ public void testIsAccessible() {
+ manager.setupUsable(true);
+ manager.setupVisible(true);
+
+ assertTrue(action.isVisibleForSession(new NullSession()));
+ }
+
+ public void testIsNotAccessible() {
+ manager.setupUsable(true);
+ manager.setupVisible(false);
+
+ assertFalse(action.isVisibleForSession(new NullSession()));
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/test-archived/test.org.nakedobjects.object.security/MockAuthorisationManager.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/test-archived/test.org.nakedobjects.object.security/MockAuthorisationManager.java b/framework/core/runtime/src/test-archived/test.org.nakedobjects.object.security/MockAuthorisationManager.java
new file mode 100644
index 0000000..8e0ad4c
--- /dev/null
+++ b/framework/core/runtime/src/test-archived/test.org.nakedobjects.object.security/MockAuthorisationManager.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 test.org.apache.isis.object.security;
+
+import org.apache.isis.noa.authentication.Sessionessionession;
+import org.apache.isis.nof.reflect.peer.MemberIdentifier;
+import org.apache.isis.nof.reflect.security.AuthorisationManager;
+
+
+public class MockAuthorisationManager implements AuthorisationManager {
+ private boolean visible;
+ private boolean usable;
+
+ public boolean isUsable(final Session session, final MemberIdentifier identifier) {
+ return usable;
+ }
+
+ public boolean isVisible(final Session session, final MemberIdentifier identifier) {
+ return visible;
+ }
+
+ public void setupVisible(final boolean b) {
+ visible = b;
+ }
+
+ public void setupUsable(final boolean usable) {
+ this.usable = usable;
+ }
+
+ public void init() {}
+
+ public void shutdown() {}
+
+ public boolean isEditable(final Session session, final MemberIdentifier identifier) {
+ return false;
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/test-archived/test.org.nakedobjects.object.security/OneToManyAuthorisationTest.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/test-archived/test.org.nakedobjects.object.security/OneToManyAuthorisationTest.java b/framework/core/runtime/src/test-archived/test.org.nakedobjects.object.security/OneToManyAuthorisationTest.java
new file mode 100644
index 0000000..6d78f49
--- /dev/null
+++ b/framework/core/runtime/src/test-archived/test.org.nakedobjects.object.security/OneToManyAuthorisationTest.java
@@ -0,0 +1,62 @@
+/*
+ * 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 test.org.apache.isis.object.security;
+
+import junit.framework.TestCase;
+
+import org.apache.isis.nof.core.context.StaticContext;
+import org.apache.isis.nof.reflect.security.OneToManyAuthorisation;
+import org.apache.isis.testing.NullSession;
+
+import test.org.apache.isis.object.reflect.DummyOneToManyPeer;
+
+
+public class OneToManyAuthorisationTest extends TestCase {
+
+ public static void main(final String[] args) {
+ junit.textui.TestRunner.run(OneToManyAuthorisationTest.class);
+ }
+
+ private MockAuthorisationManager manager;
+ private OneToManyAuthorisation oneToMany;
+
+ protected void setUp() throws Exception {
+ StaticContext.createInstance();
+
+ DummyOneToManyPeer peer = new DummyOneToManyPeer();
+ manager = new MockAuthorisationManager();
+ oneToMany = new OneToManyAuthorisation(peer, manager);
+ }
+
+ public void testAccessible() {
+ manager.setupUsable(true);
+ manager.setupVisible(true);
+
+ assertTrue(oneToMany.isVisibleForSession(new NullSession()));
+ }
+
+ public void testNotAccessible() {
+ manager.setupUsable(true);
+ manager.setupVisible(false);
+
+ assertFalse(oneToMany.isVisibleForSession(new NullSession()));
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/test-archived/test.org.nakedobjects.object.security/OneToOneAuthorisationTest.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/test-archived/test.org.nakedobjects.object.security/OneToOneAuthorisationTest.java b/framework/core/runtime/src/test-archived/test.org.nakedobjects.object.security/OneToOneAuthorisationTest.java
new file mode 100644
index 0000000..8c11529
--- /dev/null
+++ b/framework/core/runtime/src/test-archived/test.org.nakedobjects.object.security/OneToOneAuthorisationTest.java
@@ -0,0 +1,57 @@
+/*
+ * 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 test.org.apache.isis.object.security;
+
+import junit.framework.TestCase;
+
+import org.apache.isis.nof.core.context.StaticContext;
+import org.apache.isis.nof.reflect.security.OneToOneAuthorisation;
+import org.apache.isis.testing.NullSession;
+
+import test.org.apache.isis.object.reflect.DummyOneToOnePeer;
+
+
+public class OneToOneAuthorisationTest extends TestCase {
+
+ public static void main(final String[] args) {
+ junit.textui.TestRunner.run(OneToOneAuthorisationTest.class);
+
+ }
+
+ private MockAuthorisationManager manager;
+ private OneToOneAuthorisation oneToOne;
+
+ protected void setUp() throws Exception {
+ StaticContext.createInstance();
+
+ DummyOneToOnePeer peer = new DummyOneToOnePeer();
+ manager = new MockAuthorisationManager();
+ oneToOne = new OneToOneAuthorisation(peer, manager);
+ }
+
+ public void testGetHint() {
+
+ manager.setupUsable(true);
+ manager.setupVisible(true);
+
+ assertTrue(oneToOne.isVisibleForSession(new NullSession()));
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/authentication/standard/AuthenticatorAbstractForDfltRuntimeTest.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/authentication/standard/AuthenticatorAbstractForDfltRuntimeTest.java b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/authentication/standard/AuthenticatorAbstractForDfltRuntimeTest.java
new file mode 100644
index 0000000..95cf828
--- /dev/null
+++ b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/authentication/standard/AuthenticatorAbstractForDfltRuntimeTest.java
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.runtimes.dflt.runtime.authentication.standard;
+
+import static org.hamcrest.CoreMatchers.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.commons.config.IsisConfiguration;
+import org.apache.isis.core.runtime.authentication.AuthenticationRequest;
+import org.apache.isis.runtimes.dflt.runtime.authentication.AuthenticatorAbstractForDfltRuntime;
+import org.apache.isis.runtimes.dflt.runtime.system.DeploymentType;
+
+@RunWith(JMock.class)
+public class AuthenticatorAbstractForDfltRuntimeTest {
+
+ private final Mockery mockery = new JUnit4Mockery();
+
+ private IsisConfiguration mockConfiguration;
+ private AuthenticatorAbstractForDfltRuntime authenticator;
+
+ @Before
+ public void setUp() {
+ mockConfiguration = mockery.mock(IsisConfiguration.class);
+
+ authenticator = new AuthenticatorAbstractForDfltRuntime(mockConfiguration) {
+
+ @Override
+ public boolean isValid(final AuthenticationRequest request) {
+ return false;
+ }
+
+ @Override
+ public boolean canAuthenticate(final Class<? extends AuthenticationRequest> authenticationRequestClass) {
+ return false;
+ }
+ };
+ }
+
+ @Test
+ public void getConfiguration() throws Exception {
+ assertThat(authenticator.getConfiguration(), is(mockConfiguration));
+ }
+
+ @Test
+ public void getDeploymentTypeForExploration() throws Exception {
+ final DeploymentType deploymentType = DeploymentType.EXPLORATION;
+ mockery.checking(new Expectations() {
+ {
+ allowing(mockConfiguration).getString("isis.deploymentType");
+ will(returnValue(deploymentType.name()));
+ }
+ });
+ assertThat(authenticator.getDeploymentType(), is(deploymentType));
+ }
+
+ @Test
+ public void getDeploymentTypeForPrototype() throws Exception {
+ final DeploymentType deploymentType = DeploymentType.PROTOTYPE;
+ mockery.checking(new Expectations() {
+ {
+ allowing(mockConfiguration).getString("isis.deploymentType");
+ will(returnValue(deploymentType.name()));
+ }
+ });
+ assertThat(authenticator.getDeploymentType(), is(deploymentType));
+ }
+
+ @Test
+ public void getDeploymentTypeForServer() throws Exception {
+ final DeploymentType deploymentType = DeploymentType.SERVER;
+ mockery.checking(new Expectations() {
+ {
+ allowing(mockConfiguration).getString("isis.deploymentType");
+ will(returnValue(deploymentType.name()));
+ }
+ });
+ assertThat(authenticator.getDeploymentType(), is(deploymentType));
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void expectsThereToBeADeploymentTypeInIsisConfiguration() throws Exception {
+ mockery.checking(new Expectations() {
+ {
+ allowing(mockConfiguration).getString("isis.deploymentType");
+ will(returnValue(null));
+ }
+ });
+ authenticator.getDeploymentType();
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void expectsThereToBeAValidDeploymentTypeInIsisConfiguration() throws Exception {
+ mockery.checking(new Expectations() {
+ {
+ allowing(mockConfiguration).getString("isis.deploymentType");
+ will(returnValue("GARBAGE"));
+ }
+ });
+ authenticator.getDeploymentType();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/authentication/standard/MultiUserExplorationSessionTest.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/authentication/standard/MultiUserExplorationSessionTest.java b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/authentication/standard/MultiUserExplorationSessionTest.java
new file mode 100644
index 0000000..3195bf0
--- /dev/null
+++ b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/authentication/standard/MultiUserExplorationSessionTest.java
@@ -0,0 +1,210 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.runtimes.dflt.runtime.authentication.standard;
+
+import static org.hamcrest.CoreMatchers.*;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.util.List;
+import java.util.Set;
+
+import junit.framework.Assert;
+
+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.commons.config.IsisConfiguration;
+import org.apache.isis.core.runtime.authentication.standard.SimpleSession;
+import org.apache.isis.runtimes.dflt.runtime.authentication.exploration.AuthenticationRequestExploration;
+import org.apache.isis.runtimes.dflt.runtime.authentication.exploration.ExplorationAuthenticator;
+import org.apache.isis.runtimes.dflt.runtime.authentication.exploration.ExplorationAuthenticatorConstants;
+import org.apache.isis.runtimes.dflt.runtime.authentication.exploration.ExplorationSession;
+import org.apache.isis.runtimes.dflt.runtime.authentication.exploration.MultiUserExplorationSession;
+import org.apache.isis.runtimes.dflt.runtime.system.DeploymentType;
+import org.apache.isis.runtimes.dflt.runtime.system.SystemConstants;
+
+@RunWith(JMock.class)
+public class MultiUserExplorationSessionTest {
+
+ private final Mockery mockery = new JUnit4Mockery();
+
+ private MultiUserExplorationSession session;
+ private IsisConfiguration mockConfiguration;
+ private ExplorationAuthenticator authenticator;
+
+ @Before
+ public void setUp() {
+ mockConfiguration = mockery.mock(IsisConfiguration.class);
+ mockery.checking(new Expectations() {
+ {
+ allowing(mockConfiguration).getString(SystemConstants.DEPLOYMENT_TYPE_KEY);
+ will(returnValue(DeploymentType.EXPLORATION.name()));
+ }
+ });
+ }
+
+ @Test
+ public void testNameDefaultsToFirstUser() throws Exception {
+ mockery.checking(new Expectations() {
+ {
+ allowing(mockConfiguration).getString(ExplorationAuthenticatorConstants.USERS);
+ will(returnValue("fred, sven:admin|sales|marketing, bob:sales, dick"));
+ }
+ });
+ authenticator = new ExplorationAuthenticator(mockConfiguration);
+ final AuthenticationSession session = authenticator.authenticate(new AuthenticationRequestExploration(), "");
+
+ Assert.assertEquals("fred", session.getUserName());
+ }
+
+ @Test
+ public void testValidateCode() throws Exception {
+ mockery.checking(new Expectations() {
+ {
+ allowing(mockConfiguration).getString(ExplorationAuthenticatorConstants.USERS);
+ will(returnValue("fred, sven:admin|sales|marketing, bob:sales, dick"));
+ }
+ });
+ authenticator = new ExplorationAuthenticator(mockConfiguration);
+ final AuthenticationSession session = authenticator.authenticate(new AuthenticationRequestExploration(), "xxx");
+
+ Assert.assertEquals("xxx", session.getValidationCode());
+ }
+
+ @Test
+ public void testNoRolesSpecifiedForFirstUser() throws Exception {
+ mockery.checking(new Expectations() {
+ {
+ allowing(mockConfiguration).getString(ExplorationAuthenticatorConstants.USERS);
+ will(returnValue("fred, sven:admin|sales|marketing, bob:sales, dick"));
+ }
+ });
+ authenticator = new ExplorationAuthenticator(mockConfiguration);
+ final AuthenticationSession session = authenticator.authenticate(new AuthenticationRequestExploration(), "");
+
+ Assert.assertEquals(0, session.getRoles().size());
+ }
+
+ @Test
+ public void testForMultipleUser() throws Exception {
+ mockery.checking(new Expectations() {
+ {
+ allowing(mockConfiguration).getString(ExplorationAuthenticatorConstants.USERS);
+ will(returnValue("fred, sven:admin|sales|marketing, bob:sales, dick"));
+ }
+ });
+ authenticator = new ExplorationAuthenticator(mockConfiguration);
+ final AuthenticationSession authSession = authenticator.authenticate(new AuthenticationRequestExploration(), "");
+
+ assertThat(authSession, is(instanceOf(MultiUserExplorationSession.class)));
+
+ assertThat(authSession.getUserName(), is(equalTo("fred")));
+ }
+
+ @Test
+ public void testForSingleUser() throws Exception {
+ mockery.checking(new Expectations() {
+ {
+ allowing(mockConfiguration).getString(ExplorationAuthenticatorConstants.USERS);
+ will(returnValue("sven"));
+ }
+ });
+ authenticator = new ExplorationAuthenticator(mockConfiguration);
+ final AuthenticationSession authSession = authenticator.authenticate(new AuthenticationRequestExploration(), "");
+ assertThat(authSession, is(instanceOf(SimpleSession.class)));
+
+ assertThat(authSession.getUserName(), is(equalTo("sven")));
+ }
+
+ @Test
+ public void testNoUsersSpecified() throws Exception {
+ mockery.checking(new Expectations() {
+ {
+ allowing(mockConfiguration).getString(ExplorationAuthenticatorConstants.USERS);
+ will(returnValue(null));
+ }
+ });
+ authenticator = new ExplorationAuthenticator(mockConfiguration);
+
+ final AuthenticationSession authSession = authenticator.authenticate(new AuthenticationRequestExploration(), "");
+ assertThat(authSession, is(instanceOf(ExplorationSession.class)));
+ }
+
+ @Test
+ public void testOtherUsers() throws Exception {
+ mockery.checking(new Expectations() {
+ {
+ allowing(mockConfiguration).getString(ExplorationAuthenticatorConstants.USERS);
+ will(returnValue("fred, sven:admin|sales|marketing, bob:sales, dick"));
+ }
+ });
+ authenticator = new ExplorationAuthenticator(mockConfiguration);
+ this.session = (MultiUserExplorationSession) authenticator.authenticate(new AuthenticationRequestExploration(), "");
+
+ final Set<String> availableSessions = session.getUserNames();
+ Assert.assertEquals(4, availableSessions.size());
+ Assert.assertTrue(availableSessions.contains("fred"));
+ Assert.assertTrue(availableSessions.contains("sven"));
+ Assert.assertTrue(availableSessions.contains("bob"));
+ Assert.assertTrue(availableSessions.contains("dick"));
+ }
+
+ @Test
+ public void testChangeUser() throws Exception {
+ mockery.checking(new Expectations() {
+ {
+ allowing(mockConfiguration).getString(ExplorationAuthenticatorConstants.USERS);
+ will(returnValue("fred, sven:admin|sales|marketing, bob:sales, dick"));
+ }
+ });
+ authenticator = new ExplorationAuthenticator(mockConfiguration);
+ this.session = (MultiUserExplorationSession) authenticator.authenticate(new AuthenticationRequestExploration(), "");
+
+ session.setCurrentSession("bob");
+ Assert.assertEquals("bob", session.getUserName());
+ }
+
+ @Test
+ public void testRolesExist() throws Exception {
+ mockery.checking(new Expectations() {
+ {
+ allowing(mockConfiguration).getString(ExplorationAuthenticatorConstants.USERS);
+ will(returnValue("fred, sven:admin|sales|marketing, bob:sales, dick"));
+ }
+ });
+ authenticator = new ExplorationAuthenticator(mockConfiguration);
+ this.session = (MultiUserExplorationSession) authenticator.authenticate(new AuthenticationRequestExploration(), "");
+
+ session.setCurrentSession("sven");
+ final List<String> roles = session.getRoles();
+ Assert.assertEquals(3, roles.size());
+ Assert.assertEquals("admin", roles.get(0));
+ Assert.assertEquals("sales", roles.get(1));
+ Assert.assertEquals("marketing", roles.get(2));
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/authentication/standard/SimpleSessionEncodabilityNoRolesTest.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/authentication/standard/SimpleSessionEncodabilityNoRolesTest.java b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/authentication/standard/SimpleSessionEncodabilityNoRolesTest.java
new file mode 100644
index 0000000..08a0431
--- /dev/null
+++ b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/authentication/standard/SimpleSessionEncodabilityNoRolesTest.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.runtimes.dflt.runtime.authentication.standard;
+
+import org.jmock.integration.junit4.JMock;
+import org.junit.runner.RunWith;
+
+import org.apache.isis.core.commons.encoding.Encodable;
+import org.apache.isis.core.runtime.authentication.standard.SimpleSession;
+
+@RunWith(JMock.class)
+public class SimpleSessionEncodabilityNoRolesTest extends SimpleSessionEncodabilityTestAbstract {
+
+ @Override
+ protected Encodable createEncodable() {
+ return new SimpleSession("joe", new String[] {});
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/authentication/standard/SimpleSessionEncodabilityTestAbstract.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/authentication/standard/SimpleSessionEncodabilityTestAbstract.java b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/authentication/standard/SimpleSessionEncodabilityTestAbstract.java
new file mode 100644
index 0000000..fe4c618
--- /dev/null
+++ b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/authentication/standard/SimpleSessionEncodabilityTestAbstract.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.runtimes.dflt.runtime.authentication.standard;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import org.apache.isis.core.commons.encoding.EncodabilityContractTest;
+import org.apache.isis.core.runtime.authentication.standard.SimpleSession;
+
+public abstract class SimpleSessionEncodabilityTestAbstract extends EncodabilityContractTest {
+
+ @Override
+ protected void assertRoundtripped(final Object decodedEncodable, final Object originalEncodable) {
+ final SimpleSession decoded = (SimpleSession) decodedEncodable;
+ final SimpleSession original = (SimpleSession) originalEncodable;
+
+ assertThat(decoded.getUserName(), is(equalTo(original.getUserName())));
+ assertThat(decoded.getRoles(), is(equalTo(original.getRoles())));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/authentication/standard/SimpleSessionEncodabilityWithRolesTest.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/authentication/standard/SimpleSessionEncodabilityWithRolesTest.java b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/authentication/standard/SimpleSessionEncodabilityWithRolesTest.java
new file mode 100644
index 0000000..7c6b688
--- /dev/null
+++ b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/authentication/standard/SimpleSessionEncodabilityWithRolesTest.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.runtimes.dflt.runtime.authentication.standard;
+
+import org.jmock.integration.junit4.JMock;
+import org.junit.runner.RunWith;
+
+import org.apache.isis.core.commons.encoding.Encodable;
+import org.apache.isis.core.runtime.authentication.standard.SimpleSession;
+
+@RunWith(JMock.class)
+public class SimpleSessionEncodabilityWithRolesTest extends SimpleSessionEncodabilityTestAbstract {
+
+ @Override
+ protected Encodable createEncodable() {
+ return new SimpleSession("joe", new String[] { "role1", "role2" });
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/authentication/standard/StandardAuthenticationManager_AuthenticationTest.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/authentication/standard/StandardAuthenticationManager_AuthenticationTest.java b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/authentication/standard/StandardAuthenticationManager_AuthenticationTest.java
new file mode 100644
index 0000000..d47a6f9
--- /dev/null
+++ b/framework/core/runtime/src/test/java/org/apache/isis/runtimes/dflt/runtime/authentication/standard/StandardAuthenticationManager_AuthenticationTest.java
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.runtimes.dflt.runtime.authentication.standard;
+
+import static org.hamcrest.CoreMatchers.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.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.commons.matchers.IsisMatchers;
+import org.apache.isis.core.runtime.authentication.AuthenticationRequest;
+import org.apache.isis.core.runtime.authentication.AuthenticationRequestPassword;
+import org.apache.isis.core.runtime.authentication.standard.AuthenticationManagerStandard;
+import org.apache.isis.core.runtime.authentication.standard.Authenticator;
+import org.apache.isis.core.runtime.authentication.standard.RandomCodeGenerator;
+
+@RunWith(JMock.class)
+public class StandardAuthenticationManager_AuthenticationTest {
+
+ private final Mockery mockery = new JUnit4Mockery();
+
+ private AuthenticationManagerStandard authenticationManager;
+
+ private IsisConfiguration mockConfiguration;
+ private RandomCodeGenerator mockRandomCodeGenerator;
+ private Authenticator mockAuthenticator;
+ private AuthenticationSession mockAuthSession;
+
+ @Before
+ public void setUp() throws Exception {
+ mockConfiguration = mockery.mock(IsisConfiguration.class);
+ mockRandomCodeGenerator = mockery.mock(RandomCodeGenerator.class);
+ mockAuthenticator = mockery.mock(Authenticator.class);
+ mockAuthSession = mockery.mock(AuthenticationSession.class);
+
+ authenticationManager = new AuthenticationManagerStandard(mockConfiguration);
+ authenticationManager.addAuthenticator(mockAuthenticator);
+ authenticationManager.setRandomCodeGenerator(mockRandomCodeGenerator);
+
+ mockery.checking(new Expectations() {
+ {
+ allowing(mockAuthenticator).canAuthenticate(with(IsisMatchers.anySubclassOf(AuthenticationRequest.class)));
+ will(returnValue(true));
+
+ allowing(mockAuthenticator).authenticate(with(any(AuthenticationRequest.class)), with(any(String.class)));
+ will(returnValue(mockAuthSession));
+
+ allowing(mockRandomCodeGenerator).generateRandomCode();
+ will(returnValue("123456"));
+
+ allowing(mockAuthSession).getValidationCode();
+ will(returnValue("123456"));
+
+ allowing(mockAuthSession).hasUserNameOf("foo");
+ will(returnValue(true));
+
+ allowing(mockAuthSession).getUserName();
+ will(returnValue("foo"));
+ }
+ });
+ }
+
+ @Test
+ public void newlyCreatedAuthenticationSessionShouldBeValid() throws Exception {
+ final AuthenticationRequestPassword request = new AuthenticationRequestPassword("foo", "bar");
+ final AuthenticationSession session = authenticationManager.authenticate(request);
+
+ assertThat(authenticationManager.isSessionValid(session), is(true));
+ }
+
+}