incubator-isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danhayw...@apache.org
Subject svn commit: r1215492 [1/2] - in /incubator/isis/trunk/framework: core/testsupport/src/main/java/org/apache/isis/core/testsupport/jmock/ core/testsupport/src/main/java/org/apache/isis/core/testsupport/jmock/internal/ core/testsupport/src/main/java/org/j...
Date Sat, 17 Dec 2011 14:14:29 GMT
Author: danhaywood
Date: Sat Dec 17 14:14:28 2011
New Revision: 1215492

URL: http://svn.apache.org/viewvc?rev=1215492&view=rev
Log:
ISIS-158, ISIS-107: jmock 2.6-RC2 support; also some updates to docs (for embedded runtime)

Added:
    incubator/isis/trunk/framework/core/testsupport/src/main/java/org/apache/isis/core/testsupport/jmock/JUnitRuleMockery2.java
      - copied, changed from r1214077, incubator/isis/trunk/framework/core/testsupport/src/main/java/org/apache/isis/core/testsupport/jmock/ConvenienceMockery.java
    incubator/isis/trunk/framework/core/testsupport/src/main/java/org/apache/isis/core/testsupport/jmock/internal/
    incubator/isis/trunk/framework/core/testsupport/src/main/java/org/jmock/
    incubator/isis/trunk/framework/core/testsupport/src/main/java/org/jmock/auto/
    incubator/isis/trunk/framework/core/testsupport/src/main/java/org/jmock/auto/Auto.java
    incubator/isis/trunk/framework/core/testsupport/src/main/java/org/jmock/auto/Mock.java
    incubator/isis/trunk/framework/core/testsupport/src/main/java/org/jmock/auto/internal/
    incubator/isis/trunk/framework/core/testsupport/src/main/java/org/jmock/auto/internal/AllDeclaredFields.java
    incubator/isis/trunk/framework/core/testsupport/src/main/java/org/jmock/auto/internal/Mockomatic.java
    incubator/isis/trunk/framework/core/testsupport/src/main/java/org/jmock/integration/
    incubator/isis/trunk/framework/core/testsupport/src/main/java/org/jmock/integration/junit4/
    incubator/isis/trunk/framework/core/testsupport/src/main/java/org/jmock/integration/junit4/JUnitRuleMockery.java
    incubator/isis/trunk/framework/core/testsupport/src/test/java/org/apache/isis/core/testsupport/jmock/
    incubator/isis/trunk/framework/core/testsupport/src/test/java/org/apache/isis/core/testsupport/jmock/JUnit4RuleMockery2Test.java
    incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/IsisMetaModelTest_constructDefaults.java
      - copied, changed from r1214077, incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/GivenMetaModelWhenInstantiated.java
    incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/IsisMetaModelTest_constructWithServices.java
      - copied, changed from r1214077, incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/GivenMetaModelWhenInstantiate.java
    incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/IsisMetaModelTest_getWrapperFactory.java
      - copied, changed from r1214077, incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/GivenMetaModelWhenInitialized.java
    incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/IsisMetaModelTest_init.java
      - copied, changed from r1214077, incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/GivenMetaModelWhenInitialize.java
    incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/IsisMetaModelTest_shutdown.java
      - copied, changed from r1214077, incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/GivenMetaModelWhenShutdown.java
    incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/WrappedFactoryDefaultTest_wrappedObject.java
      - copied, changed from r1214077, incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/GivenEmbeddedViewerAndPersistentDomainObject.java
    incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/WrappedFactoryDefaultTest_wrappedObject_transient.java
Removed:
    incubator/isis/trunk/framework/core/testsupport/src/main/java/org/apache/isis/core/testsupport/jmock/AbstractJMockForClassesTest.java
    incubator/isis/trunk/framework/core/testsupport/src/main/java/org/apache/isis/core/testsupport/jmock/AbstractJMockForInterfacesTest.java
    incubator/isis/trunk/framework/core/testsupport/src/main/java/org/apache/isis/core/testsupport/jmock/AbstractJMockTest.java
    incubator/isis/trunk/framework/core/testsupport/src/main/java/org/apache/isis/core/testsupport/jmock/ConvenienceMockery.java
    incubator/isis/trunk/framework/core/testsupport/src/main/java/org/apache/isis/core/testsupport/jmock/DelegatingMockery.java
    incubator/isis/trunk/framework/core/testsupport/src/main/java/org/apache/isis/core/testsupport/jmock/Fixture.java
    incubator/isis/trunk/framework/core/testsupport/src/main/java/org/apache/isis/core/testsupport/jmock/FixtureMockery.java
    incubator/isis/trunk/framework/core/testsupport/src/main/java/org/apache/isis/core/testsupport/jmock/JMockContextBuilder.java
    incubator/isis/trunk/framework/core/testsupport/src/main/java/org/apache/isis/core/testsupport/jmock/JMockRule.java
    incubator/isis/trunk/framework/core/testsupport/src/main/java/org/apache/isis/core/testsupport/jmock/MockFixture.java
    incubator/isis/trunk/framework/core/testsupport/src/main/java/org/apache/isis/core/testsupport/jmock/MockFixtureAdapter.java
    incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/GivenEmbeddedViewerAndPersistentDomainObject.java
    incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/GivenMetaModelWhenInitialize.java
    incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/GivenMetaModelWhenInitialized.java
    incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/GivenMetaModelWhenInstantiate.java
    incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/GivenMetaModelWhenInstantiated.java
    incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/GivenMetaModelWhenShutdown.java
    incubator/isis/trunk/framework/viewer/wicket/wicket-viewer/src/test/java/org/apache/isis/viewer/wicket/viewer/Fixture_AuthenticationManager_AuthenticateOk.java
    incubator/isis/trunk/framework/viewer/wicket/wicket-viewer/src/test/java/org/apache/isis/viewer/wicket/viewer/Fixture_Request_Stub.java
    incubator/isis/trunk/framework/viewer/wicket/wicket-viewer/src/test/java/org/apache/isis/viewer/wicket/viewer/app/wicket/Fixture_AuthenticatedWebSessionForIsis_SignedIn.java
Modified:
    incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/main/java/org/apache/isis/progmodel/wrapper/metamodel/DomainObjectContainerWrapperFactory.java
    incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/main/java/org/apache/isis/progmodel/wrapper/metamodel/internal/Proxy.java
    incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/main/java/org/apache/isis/progmodel/wrapper/metamodel/internal/WrapperFactoryDefault.java
    incubator/isis/trunk/framework/runtimes/embedded/pom.xml
    incubator/isis/trunk/framework/runtimes/embedded/src/docbkx/guide/isis-embedded-runtime.xml
    incubator/isis/trunk/framework/runtimes/embedded/src/main/java/org/apache/isis/runtimes/embedded/IsisMetaModel.java
    incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/dom/employee/Employee.java
    incubator/isis/trunk/framework/viewer/wicket/wicket-viewer/src/test/java/org/apache/isis/viewer/wicket/viewer/IsisWicketApplication_Defaults.java
    incubator/isis/trunk/framework/viewer/wicket/wicket-viewer/src/test/java/org/apache/isis/viewer/wicket/viewer/IsisWicketApplication_Pages.java
    incubator/isis/trunk/framework/viewer/wicket/wicket-viewer/src/test/java/org/apache/isis/viewer/wicket/viewer/IsisWicketApplication_init.java
    incubator/isis/trunk/framework/viewer/wicket/wicket-viewer/src/test/java/org/apache/isis/viewer/wicket/viewer/app/wicket/AuthenticatedWebSessionForIsis_Authenticate.java
    incubator/isis/trunk/framework/viewer/wicket/wicket-viewer/src/test/java/org/apache/isis/viewer/wicket/viewer/app/wicket/AuthenticatedWebSessionForIsis_Instantiation.java
    incubator/isis/trunk/framework/viewer/wicket/wicket-viewer/src/test/java/org/apache/isis/viewer/wicket/viewer/app/wicket/AuthenticatedWebSessionForIsis_SignIn.java
    incubator/isis/trunk/framework/viewer/wicket/wicket-viewer/src/test/java/org/apache/isis/viewer/wicket/viewer/app/wicket/AuthenticatedWebSessionForIsis_ThreadManagement.java
    incubator/isis/trunk/framework/viewer/wicket/wicket-viewer/src/test/java/org/apache/isis/viewer/wicket/viewer/app/wicket/WebRequestCycleForIsisTest.java

Copied: incubator/isis/trunk/framework/core/testsupport/src/main/java/org/apache/isis/core/testsupport/jmock/JUnitRuleMockery2.java (from r1214077, incubator/isis/trunk/framework/core/testsupport/src/main/java/org/apache/isis/core/testsupport/jmock/ConvenienceMockery.java)
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/testsupport/src/main/java/org/apache/isis/core/testsupport/jmock/JUnitRuleMockery2.java?p2=incubator/isis/trunk/framework/core/testsupport/src/main/java/org/apache/isis/core/testsupport/jmock/JUnitRuleMockery2.java&p1=incubator/isis/trunk/framework/core/testsupport/src/main/java/org/apache/isis/core/testsupport/jmock/ConvenienceMockery.java&r1=1214077&r2=1215492&rev=1215492&view=diff
==============================================================================
--- incubator/isis/trunk/framework/core/testsupport/src/main/java/org/apache/isis/core/testsupport/jmock/ConvenienceMockery.java (original)
+++ incubator/isis/trunk/framework/core/testsupport/src/main/java/org/apache/isis/core/testsupport/jmock/JUnitRuleMockery2.java Sat Dec 17 14:14:28 2011
@@ -20,124 +20,106 @@
 package org.apache.isis.core.testsupport.jmock;
 
 import org.jmock.Expectations;
-import org.jmock.Mockery;
+import org.jmock.integration.junit4.JUnitRuleMockery;
+import org.jmock.lib.legacy.ClassImposteriser;
+import org.junit.runners.model.FrameworkMethod;
+import org.junit.runners.model.Statement;
 
 /**
- * Adds some convenience methods to {@link Mockery}.
+ * Use as a <tt>@Rule</tt>, meaning that the <tt>@RunWith(JMock.class)</tt>
+ * can be ignored.
+ * 
+ * <pre>
+ * public class MyTest {
+ * 
+ *     @Rule
+ *     public final Junit4Mockery2 context = Junit4Mockery2.createFor(Mode.INTERFACES);
+ *
+ * }
+ * </pre>
+ * 
+ * <p>
+ * The class also adds some convenience methods, and uses a factory method
+ * to make it explicit whether the context can mock only interfaces or
+ * interfaces and classes.
  */
-public abstract class ConvenienceMockery extends Mockery {
+public class JUnitRuleMockery2 extends JUnitRuleMockery {
+    
+    public static enum Mode {
+        INTERFACES_ONLY,
+        INTERFACES_AND_CLASSES;
+    }
 
     /**
+     * Factory method.
+     */
+    public static JUnitRuleMockery2 createFor(Mode mode) {
+        JUnitRuleMockery2 jUnitRuleMockery2 = new JUnitRuleMockery2();
+        if(mode == Mode.INTERFACES_AND_CLASSES) {
+            jUnitRuleMockery2.setImposteriser(ClassImposteriser.INSTANCE);
+        }
+        return jUnitRuleMockery2;
+    }
+    
+    private JUnitRuleMockery2() {}
+    
+    /**
      * Ignoring any interaction with the mock; an allowing/ignoring mock will be returned in turn.
      */
-    public void ignoring(final Object mock) {
+    public <T> T ignoring(final T mock) {
         checking(new Expectations() {
             {
                 ignoring(mock);
             }
         });
+        return mock;
     }
 
     /**
      * Allow any interaction with the mock; an allowing mock will be returned in turn.
      */
-    public void allowing(final Object mock) {
+    public <T> T allowing(final T mock) {
         checking(new Expectations() {
             {
                 allowing(mock);
             }
         });
+        return mock;
     }
 
     /**
      * Prohibit any interaction with the mock.
      */
-    public void never(final Object mock) {
+    public <T> T never(final T mock) {
         checking(new Expectations() {
             {
                 never(mock);
             }
         });
-    }
-
-    /**
-     * Same as {@link #never(Object)}.
-     */
-    public void prohibit(final Object mock) {
-        never(mock);
-    }
-
-    public <T> T mockAndIgnoreAnyInteraction(final Class<T> typeToMock) {
-        final T mock = mock(typeToMock);
-        checking(new Expectations() {
-            {
-                ignoring(mock);
-            }
-        });
         return mock;
     }
 
-    public <T> T mockAndIgnoreAnyInteraction(final Class<T> typeToMock, final String name) {
-        final T mock = mock(typeToMock, name);
-        checking(new Expectations() {
-            {
-                ignoring(mock);
-            }
-        });
-        return mock;
+    public <T> T mockAndIgnoring(final Class<T> typeToMock) {
+        return ignoring(mock(typeToMock));
     }
 
-    public <T> T mockAndAllowAnyInteraction(final Class<T> typeToMock) {
-        final T mock = mock(typeToMock);
-        checking(new Expectations() {
-            {
-                allowing(mock);
-            }
-        });
-        return mock;
+    public <T> T mockAndIgnoring(final Class<T> typeToMock, final String name) {
+        return ignoring(mock(typeToMock, name));
     }
 
-    public <T> T mockAndAllowAnyInteraction(final Class<T> typeToMock, final String name) {
-        final T mock = mock(typeToMock, name);
-        checking(new Expectations() {
-            {
-                allowing(mock);
-            }
-        });
-        return mock;
+    public <T> T mockAndAllowing(final Class<T> typeToMock) {
+        return allowing(mock(typeToMock));
     }
 
-    public <T> T mockAndNeverAnyInteraction(final Class<T> typeToMock) {
-        final T mock = mock(typeToMock);
-        checking(new Expectations() {
-            {
-                never(mock);
-            }
-        });
-        return mock;
+    public <T> T mockAndAllowing(final Class<T> typeToMock, final String name) {
+        return allowing(mock(typeToMock, name));
     }
 
-    public <T> T mockAndNeverAnyInteraction(final Class<T> typeToMock, final String name) {
-        final T mock = mock(typeToMock, name);
-        checking(new Expectations() {
-            {
-                never(mock);
-            }
-        });
-        return mock;
+    public <T> T mockAndNever(final Class<T> typeToMock) {
+        return never(mock(typeToMock));
     }
 
-    /**
-     * Same as {@link #mockAndNeverAnyInteraction(Class)}.
-     */
-    public <T> T mockAndProhibitAnyInteraction(final Class<T> typeToMock) {
-        return mockAndNeverAnyInteraction(typeToMock);
-    }
-
-    /**
-     * Same as {@link #mockAndNeverAnyInteraction(Class, String)}.
-     */
-    public <T> T mockAndProhibitAnyInteraction(final Class<T> typeToMock, final String name) {
-        return mockAndNeverAnyInteraction(typeToMock, name);
+    public <T> T mockAndNever(final Class<T> typeToMock, final String name) {
+        return never(mock(typeToMock, name));
     }
 }

Added: incubator/isis/trunk/framework/core/testsupport/src/main/java/org/jmock/auto/Auto.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/testsupport/src/main/java/org/jmock/auto/Auto.java?rev=1215492&view=auto
==============================================================================
--- incubator/isis/trunk/framework/core/testsupport/src/main/java/org/jmock/auto/Auto.java (added)
+++ incubator/isis/trunk/framework/core/testsupport/src/main/java/org/jmock/auto/Auto.java Sat Dec 17 14:14:28 2011
@@ -0,0 +1,39 @@
+/**
+Copyright (c) 2000-2007, jMock.org
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of
+conditions and the following disclaimer. Redistributions in binary form must reproduce
+the above copyright notice, this list of conditions and the following disclaimer in
+the documentation and/or other materials provided with the distribution.
+
+Neither the name of jMock nor the names of its contributors may be used to endorse
+or promote products derived from this software without specific prior written
+permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
+WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGE.
+*/
+package org.jmock.auto;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+@Retention(RUNTIME)
+@Target(FIELD)
+public @interface Auto {
+}
\ No newline at end of file

Added: incubator/isis/trunk/framework/core/testsupport/src/main/java/org/jmock/auto/Mock.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/testsupport/src/main/java/org/jmock/auto/Mock.java?rev=1215492&view=auto
==============================================================================
--- incubator/isis/trunk/framework/core/testsupport/src/main/java/org/jmock/auto/Mock.java (added)
+++ incubator/isis/trunk/framework/core/testsupport/src/main/java/org/jmock/auto/Mock.java Sat Dec 17 14:14:28 2011
@@ -0,0 +1,40 @@
+/**
+Copyright (c) 2000-2007, jMock.org
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of
+conditions and the following disclaimer. Redistributions in binary form must reproduce
+the above copyright notice, this list of conditions and the following disclaimer in
+the documentation and/or other materials provided with the distribution.
+
+Neither the name of jMock nor the names of its contributors may be used to endorse
+or promote products derived from this software without specific prior written
+permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
+WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGE.
+*/
+package org.jmock.auto;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+
+@Retention(RUNTIME)
+@Target(FIELD)
+public @interface Mock {
+}
\ No newline at end of file

Added: incubator/isis/trunk/framework/core/testsupport/src/main/java/org/jmock/auto/internal/AllDeclaredFields.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/testsupport/src/main/java/org/jmock/auto/internal/AllDeclaredFields.java?rev=1215492&view=auto
==============================================================================
--- incubator/isis/trunk/framework/core/testsupport/src/main/java/org/jmock/auto/internal/AllDeclaredFields.java (added)
+++ incubator/isis/trunk/framework/core/testsupport/src/main/java/org/jmock/auto/internal/AllDeclaredFields.java Sat Dec 17 14:14:28 2011
@@ -0,0 +1,44 @@
+/**
+Copyright (c) 2000-2007, jMock.org
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of
+conditions and the following disclaimer. Redistributions in binary form must reproduce
+the above copyright notice, this list of conditions and the following disclaimer in
+the documentation and/or other materials provided with the distribution.
+
+Neither the name of jMock nor the names of its contributors may be used to endorse
+or promote products derived from this software without specific prior written
+permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
+WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGE.
+*/
+package org.jmock.auto.internal;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.List;
+
+import static java.util.Arrays.asList;
+
+public class AllDeclaredFields {
+    public static List<Field> in(Class<?> clazz) {
+        final ArrayList<Field> fields = new ArrayList<Field>();
+        for (Class<?> c = clazz; c != Object.class; c = c.getSuperclass()) {
+            fields.addAll(asList(c.getDeclaredFields()));
+        }
+        return fields;
+    }
+}
\ No newline at end of file

Added: incubator/isis/trunk/framework/core/testsupport/src/main/java/org/jmock/auto/internal/Mockomatic.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/testsupport/src/main/java/org/jmock/auto/internal/Mockomatic.java?rev=1215492&view=auto
==============================================================================
--- incubator/isis/trunk/framework/core/testsupport/src/main/java/org/jmock/auto/internal/Mockomatic.java (added)
+++ incubator/isis/trunk/framework/core/testsupport/src/main/java/org/jmock/auto/internal/Mockomatic.java Sat Dec 17 14:14:28 2011
@@ -0,0 +1,103 @@
+/**
+Copyright (c) 2000-2007, jMock.org
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of
+conditions and the following disclaimer. Redistributions in binary form must reproduce
+the above copyright notice, this list of conditions and the following disclaimer in
+the documentation and/or other materials provided with the distribution.
+
+Neither the name of jMock nor the names of its contributors may be used to endorse
+or promote products derived from this software without specific prior written
+permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
+WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGE.
+*/
+package org.jmock.auto.internal;
+
+import java.lang.reflect.Field;
+import java.util.List;
+
+import org.jmock.Mockery;
+import org.jmock.Sequence;
+import org.jmock.States;
+import org.jmock.auto.Auto;
+import org.jmock.auto.Mock;
+
+
+public class Mockomatic {
+    private final Mockery mockery;
+
+    public Mockomatic(Mockery mockery) {
+        this.mockery = mockery;
+    }
+
+    public void fillIn(Object object) {
+        fillIn(object, AllDeclaredFields.in(object.getClass()));
+    }
+
+    public void fillIn(Object object, final List<Field> knownFields) {
+        for (Field field : knownFields) {
+            if (field.isAnnotationPresent(Mock.class)) {
+                autoMock(object, field);
+            }
+            else if (field.isAnnotationPresent(Auto.class)) {
+                autoInstantiate(object, field);
+            }
+        }
+    }
+
+    private void autoMock(Object object, Field field) {
+        setAutoField(field, object, 
+                     mockery.mock(field.getType(), field.getName()),
+                     "auto-mock field " + field.getName());
+    }
+
+    private void autoInstantiate(Object object, Field field) {
+        final Class<?> type = field.getType();
+        if (type == States.class) {
+            autoInstantiateStates(field, object);
+        }
+        else if (type == Sequence.class) {
+            autoInstantiateSequence(field, object);
+        }
+        else {
+            throw new IllegalStateException("cannot auto-instantiate field of type " + type.getName());
+        }
+    }
+
+    private void autoInstantiateStates(Field field, Object object) {
+        setAutoField(field, object, 
+                     mockery.states(field.getName()), 
+                     "auto-instantiate States field " + field.getName());
+    }
+    
+    private void autoInstantiateSequence(Field field, Object object) {
+        setAutoField(field, object, 
+                     mockery.sequence(field.getName()), 
+                     "auto-instantiate Sequence field " + field.getName());
+    }
+
+    private void setAutoField(Field field, Object object, Object value, String description) {
+        try {
+            field.setAccessible(true);
+            field.set(object, value);
+        }
+        catch (IllegalAccessException e) {
+            throw new IllegalStateException("cannot " + description, e);
+        }
+    }
+
+}
\ No newline at end of file

Added: incubator/isis/trunk/framework/core/testsupport/src/main/java/org/jmock/integration/junit4/JUnitRuleMockery.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/testsupport/src/main/java/org/jmock/integration/junit4/JUnitRuleMockery.java?rev=1215492&view=auto
==============================================================================
--- incubator/isis/trunk/framework/core/testsupport/src/main/java/org/jmock/integration/junit4/JUnitRuleMockery.java (added)
+++ incubator/isis/trunk/framework/core/testsupport/src/main/java/org/jmock/integration/junit4/JUnitRuleMockery.java Sat Dec 17 14:14:28 2011
@@ -0,0 +1,104 @@
+/**
+Copyright (c) 2000-2007, jMock.org
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of
+conditions and the following disclaimer. Redistributions in binary form must reproduce
+the above copyright notice, this list of conditions and the following disclaimer in
+the documentation and/or other materials provided with the distribution.
+
+Neither the name of jMock nor the names of its contributors may be used to endorse
+or promote products derived from this software without specific prior written
+permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
+WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGE.
+ */
+package org.jmock.integration.junit4;
+
+import org.jmock.auto.internal.AllDeclaredFields;
+import org.jmock.auto.internal.Mockomatic;
+import org.jmock.integration.junit4.JUnit4Mockery;
+import org.junit.rules.MethodRule;
+import org.junit.runners.model.FrameworkMethod;
+import org.junit.runners.model.Statement;
+
+import java.lang.reflect.Field;
+import java.util.List;
+
+import static org.junit.Assert.fail;
+
+/**
+ * A <code>JUnitRuleMockery</code> is a JUnit Rule that manages JMock expectations
+ * and allowances, and asserts that expectations have been met after each test
+ * has finished. To use it, add a field to the test class (note that you don't 
+ * have to specify <code>@RunWith(JMock.class)</code> any more). For example,  
+ * 
+ * <pre>public class ATestWithSatisfiedExpectations {
+ *  @Rule public final JUnitRuleMockery context = new JUnitRuleMockery();
+ *  private final Runnable runnable = context.mock(Runnable.class);
+ *     
+ *  @Test
+ *  public void doesSatisfyExpectations() {
+ *    context.checking(new Expectations() {{
+ *      oneOf (runnable).run();
+ *    }});
+ *          
+ *    runnable.run();
+ *  }
+ *}</pre>
+ *
+ * Note that the Rule field must be declared public and as a <code>JUnitRuleMockery</code>
+ * (not a <code>Mockery</code>) for JUnit to recognise it, as it's checked statically.
+ * 
+ * @author smgf
+ */
+public class JUnitRuleMockery extends JUnit4Mockery implements MethodRule {
+    private final Mockomatic mockomatic = new Mockomatic(this);
+
+    @Override
+    public Statement apply(final Statement base, FrameworkMethod method, final Object target) {
+        return new Statement() {
+            @Override
+            public void evaluate() throws Throwable {
+                prepare(target);
+                base.evaluate();
+                assertIsSatisfied();
+            }
+
+            private void prepare(final Object target) {
+                List<Field> allFields = AllDeclaredFields.in(target.getClass());
+                assertOnlyOneJMockContextIn(allFields);
+                fillInAutoMocks(target, allFields);
+            }
+
+            private void assertOnlyOneJMockContextIn(List<Field> allFields) {
+                Field contextField = null;
+                for (Field field : allFields) {
+                    if (JUnitRuleMockery.class.isAssignableFrom(field.getType())) {
+                        if (null != contextField) {
+                            fail("Test class should only have one JUnitRuleMockery field, found "
+                                  + contextField.getName() + " and " + field.getName());
+                        }
+                        contextField = field;
+                    }
+                }
+            }
+
+            private void fillInAutoMocks(final Object target, List<Field> allFields) {
+                mockomatic.fillIn(target, allFields);
+            }
+        };
+    }
+}
\ No newline at end of file

Added: incubator/isis/trunk/framework/core/testsupport/src/test/java/org/apache/isis/core/testsupport/jmock/JUnit4RuleMockery2Test.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/core/testsupport/src/test/java/org/apache/isis/core/testsupport/jmock/JUnit4RuleMockery2Test.java?rev=1215492&view=auto
==============================================================================
--- incubator/isis/trunk/framework/core/testsupport/src/test/java/org/apache/isis/core/testsupport/jmock/JUnit4RuleMockery2Test.java (added)
+++ incubator/isis/trunk/framework/core/testsupport/src/test/java/org/apache/isis/core/testsupport/jmock/JUnit4RuleMockery2Test.java Sat Dec 17 14:14:28 2011
@@ -0,0 +1,40 @@
+package org.apache.isis.core.testsupport.jmock;
+
+import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2.Mode;
+import org.jmock.Expectations;
+import org.jmock.auto.Mock;
+import org.junit.Rule;
+import org.junit.Test;
+
+public class JUnit4RuleMockery2Test {
+
+    @Rule
+    public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
+
+    public static class Collaborator {
+        public void doOtherStuff() {
+        }
+    }
+    public static class ClassUnderTest {
+        private final Collaborator collaborator;
+
+        private ClassUnderTest(Collaborator collaborator) {
+            this.collaborator = collaborator;
+        }
+        
+        public void doStuff() {
+            collaborator.doOtherStuff();
+        }
+    }
+    
+    @Mock
+    private Collaborator collaborator;
+    
+    @Test
+    public void poke() {
+        context.checking(new Expectations(){{
+            one(collaborator).doOtherStuff();
+        }});
+        new ClassUnderTest(collaborator).doStuff();
+    }
+}

Modified: incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/main/java/org/apache/isis/progmodel/wrapper/metamodel/DomainObjectContainerWrapperFactory.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/main/java/org/apache/isis/progmodel/wrapper/metamodel/DomainObjectContainerWrapperFactory.java?rev=1215492&r1=1215491&r2=1215492&view=diff
==============================================================================
--- incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/main/java/org/apache/isis/progmodel/wrapper/metamodel/DomainObjectContainerWrapperFactory.java (original)
+++ incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/main/java/org/apache/isis/progmodel/wrapper/metamodel/DomainObjectContainerWrapperFactory.java Sat Dec 17 14:14:28 2011
@@ -103,9 +103,9 @@ public class DomainObjectContainerWrappe
     }
 
     @Override
-    public void setAdapterMap(final AdapterMap adapterManager) {
-        super.setAdapterMap(adapterManager);
-        wrapperFactoryDelegate.setAdapterMap(adapterManager);
+    public void setAdapterMap(final AdapterMap adapterMap) {
+        super.setAdapterMap(adapterMap);
+        wrapperFactoryDelegate.setAdapterMap(adapterMap);
     }
 
     @Override

Modified: incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/main/java/org/apache/isis/progmodel/wrapper/metamodel/internal/Proxy.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/main/java/org/apache/isis/progmodel/wrapper/metamodel/internal/Proxy.java?rev=1215492&r1=1215491&r2=1215492&view=diff
==============================================================================
--- incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/main/java/org/apache/isis/progmodel/wrapper/metamodel/internal/Proxy.java (original)
+++ incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/main/java/org/apache/isis/progmodel/wrapper/metamodel/internal/Proxy.java Sat Dec 17 14:14:28 2011
@@ -19,10 +19,15 @@
 
 package org.apache.isis.progmodel.wrapper.metamodel.internal;
 
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.nullValue;
+
 import java.util.Collection;
 import java.util.Map;
 
 import org.apache.isis.core.commons.authentication.AuthenticationSessionProvider;
+import org.apache.isis.core.commons.ensure.Ensure;
 import org.apache.isis.core.metamodel.adapter.ObjectPersistor;
 import org.apache.isis.core.metamodel.adapter.map.AdapterMap;
 import org.apache.isis.core.metamodel.spec.SpecificationLookup;
@@ -32,12 +37,19 @@ import org.apache.isis.progmodel.wrapper
 
 public class Proxy {
 
-    public static <T> T proxy(final T domainObject, final WrapperFactory embeddedViewer, final ExecutionMode mode,
+    public static <T> T proxy(final T domainObject, final WrapperFactory wrapperFactory, final ExecutionMode mode,
         final AuthenticationSessionProvider authenticationSessionProvider,
         final SpecificationLookup specificationLookup, final AdapterMap adapterManager,
         final ObjectPersistor objectPersistor) {
+        
+        Ensure.ensureThatArg(wrapperFactory, is(not(nullValue())));
+        Ensure.ensureThatArg(authenticationSessionProvider, is(not(nullValue())));
+        Ensure.ensureThatArg(specificationLookup, is(not(nullValue())));
+        Ensure.ensureThatArg(adapterManager, is(not(nullValue())));
+        Ensure.ensureThatArg(objectPersistor, is(not(nullValue())));
+        
         final DomainObjectInvocationHandler<T> invocationHandler =
-            new DomainObjectInvocationHandler<T>(domainObject, embeddedViewer, mode, authenticationSessionProvider,
+            new DomainObjectInvocationHandler<T>(domainObject, wrapperFactory, mode, authenticationSessionProvider,
                 specificationLookup, adapterManager, objectPersistor);
 
         final CgLibProxy<T> cglibProxy = new CgLibProxy<T>(invocationHandler);

Modified: incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/main/java/org/apache/isis/progmodel/wrapper/metamodel/internal/WrapperFactoryDefault.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/main/java/org/apache/isis/progmodel/wrapper/metamodel/internal/WrapperFactoryDefault.java?rev=1215492&r1=1215491&r2=1215492&view=diff
==============================================================================
--- incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/main/java/org/apache/isis/progmodel/wrapper/metamodel/internal/WrapperFactoryDefault.java (original)
+++ incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/main/java/org/apache/isis/progmodel/wrapper/metamodel/internal/WrapperFactoryDefault.java Sat Dec 17 14:14:28 2011
@@ -272,8 +272,8 @@ public class WrapperFactoryDefault imple
     }
 
     @Override
-    public void setAdapterMap(final AdapterMap adapterManager) {
-        this.adapterManager = adapterManager;
+    public void setAdapterMap(final AdapterMap adapterMap) {
+        this.adapterManager = adapterMap;
     }
 
     @Override

Modified: incubator/isis/trunk/framework/runtimes/embedded/pom.xml
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/embedded/pom.xml?rev=1215492&r1=1215491&r2=1215492&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/embedded/pom.xml (original)
+++ incubator/isis/trunk/framework/runtimes/embedded/pom.xml Sat Dec 17 14:14:28 2011
@@ -122,6 +122,13 @@
             <groupId>org.apache.isis.runtimes.dflt.bytecode</groupId>
             <artifactId>identity</artifactId>
         </dependency>
+        
+        <dependency>
+            <groupId>org.apache.isis.core</groupId>
+            <artifactId>testsupport</artifactId>
+            <scope>test</scope>
+        </dependency>
+        
 	</dependencies>
 
 </project>

Modified: incubator/isis/trunk/framework/runtimes/embedded/src/docbkx/guide/isis-embedded-runtime.xml
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/embedded/src/docbkx/guide/isis-embedded-runtime.xml?rev=1215492&r1=1215491&r2=1215492&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/embedded/src/docbkx/guide/isis-embedded-runtime.xml (original)
+++ incubator/isis/trunk/framework/runtimes/embedded/src/docbkx/guide/isis-embedded-runtime.xml Sat Dec 17 14:14:28 2011
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
-"file:./src/docbkx/dtd-4.5/docbookx.dtd">
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+"file:./src/docbkx/dtd-4.5/docbookx.dtd">
 <!--
   Licensed to the Apache Software Foundation (ASF) under one
   or more contributor license agreements.  See the NOTICE file
@@ -22,12 +22,15 @@
 <book>
   <bookinfo>
     <title><?eval ${docbkxGuideTitle}?></title>
+
     <subtitle><?eval ${docbkxGuideSubTitle}?></subtitle>
+
     <releaseinfo><?eval ${project.version}?></releaseinfo>
 
     <authorgroup>
       <author>
         <firstname>Dan</firstname>
+
         <surname>Haywood</surname>
       </author>
     </authorgroup>
@@ -49,16 +52,34 @@
     <para><emphasis>Apache Isis</emphasis> is designed to allow programmers
     rapidly develop domain-driven applications following the <ulink
     url="http://en.wikipedia.org/wiki/Naked_Objects">Naked Objects</ulink>
-    pattern. It is made up of a core framework plus a number of alternate
-    implementations, and supports various viewers and object stores.  Apache 
-    Isis is hosted at the 
-    <ulink url="http://incubator.apache.org/isis">Apache Foundation</ulink>,
-    and is licensed under <ulink
+    pattern. It is made up of a core framework plus a number of modules for
+    such concerns as presentation logic, security and persistence. These
+    modules define APIs to provide pluggability of alternative
+    implementations.</para>
+
+    <para>The runtime module is responsible for managing the lifecycle and
+    persistence of domain objects, broadly equivalent to a
+    <acronym>JPA</acronym> <classname>PersistenceContext</classname>. The
+    default runtime implementation manages the majority of the lifecycle
+    concerns, and defines its own sub APIs to support persistence and
+    remoting.</para>
+
+    <para>This implementation, though, is the <emphasis>embedded</emphasis>
+    runtime. It exists to allow the "unique stuff" of Isis - namely its
+    metamodel and optionally its viewers - to be embedded or hosted within
+    some other existing runtime (eg Spring, CDI, Maven plugin etc). As such,
+    it is a very thin layer; it basically consolidates all the dependencies of
+    the metamodel into a single interface.</para>
+
+    <para>This guide is written for developers and architects who wish to use
+    the embedded runtime as a means of embedding Isis within some other
+    framework.</para>
+
+    <para><emphasis>Isis</emphasis> is hosted at the <ulink
+    url="http://incubator.apache.org/isis">Apache Foundation</ulink>, and is
+    licensed under <ulink
     url="http://www.apache.org/licenses/LICENSE-2.0.html">Apache Software
     License v2</ulink>.</para>
-
-
-    <para>This guide is written for ...</para>
   </preface>
 
   <!-- main content -->
@@ -74,11 +95,35 @@
       <title>***</title>
 
       <para><emphasis>*** yada yada</emphasis></para>
+
+      <para></para>
+
+      <para></para>
+
+      <para>The IsisMetaModel class.</para>
+
+      <para>-</para>
+
+      <para></para>
+
+      <para></para>
+
+      <para>WrapperFactory, and wrapped objects.</para>
+
+      <para></para>
+
+      <para></para>
+
+      <para>The Wrapped Objects</para>
+
+      <para>- how they handle save(), how they hand title()</para>
+
+      <para></para>
     </sect1>
   </chapter>
 
   <chapter>
-    <title>***</title>
+    <title>EmbeddedContext API</title>
 
     <abstract>
       <para>*** yada yada</para>
@@ -88,9 +133,73 @@
       <title>***</title>
 
       <para><emphasis>*** yada yada</emphasis></para>
+
+      <para></para>
+
+      <para></para>
+
+      <para></para>
+
+      <programlisting>public interface EmbeddedContext {
+
+    AuthenticationSession getAuthenticationSession();
+    Localization getLocalization();
+
+    Object instantiate(Class&lt;?&gt; type);
+    
+    void resolve(Object parent);
+    void resolve(Object parent, Object field);
+    void objectChanged(Object object);
+
+    void makePersistent(Object object);
+    void remove(Object object);
+    PersistenceState getPersistenceState(Object object);
+
+    &lt;T&gt; List&lt;T&gt; allMatchingQuery(Query&lt;T&gt; query);
+    &lt;T&gt; T firstMatchingQuery(Query&lt;T&gt; query);
+
+    boolean flush();
+    void commit();
+
+    void informUser(String message);
+    void warnUser(String message);
+    void raiseError(String message);
+}</programlisting>
+
+      <para></para>
+
+      <para></para>
+
+      <para></para>
     </sect1>
   </chapter>
 
+  <chapter>
+    <title>Writing and Deploying an Implementation</title>
+
+    <para></para>
+
+    <para></para>
+
+    <para>instantiate IsisMetaModel via Spring.</para>
+
+    <para></para>
+
+    <para>Provide some copy-n-paste example code here...</para>
+
+    <para></para>
+
+    <para>The IsisMetaModel creates a DomainObjectContainerWrapperFactory. The
+    EmbeddedContext implementation should take this and inject into entities
+    as required.</para>
+
+    <para></para>
+
+    <para></para>
+
+    <para></para>
+  </chapter>
+
   <appendix>
     <title>***</title>
 

Modified: incubator/isis/trunk/framework/runtimes/embedded/src/main/java/org/apache/isis/runtimes/embedded/IsisMetaModel.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/embedded/src/main/java/org/apache/isis/runtimes/embedded/IsisMetaModel.java?rev=1215492&r1=1215491&r2=1215492&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/embedded/src/main/java/org/apache/isis/runtimes/embedded/IsisMetaModel.java (original)
+++ incubator/isis/trunk/framework/runtimes/embedded/src/main/java/org/apache/isis/runtimes/embedded/IsisMetaModel.java Sat Dec 17 14:14:28 2011
@@ -24,7 +24,6 @@ import static org.apache.isis.core.commo
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.notNullValue;
 
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
@@ -34,12 +33,10 @@ import java.util.TreeSet;
 import org.apache.isis.core.commons.components.ApplicationScopedComponent;
 import org.apache.isis.core.commons.config.IsisConfiguration;
 import org.apache.isis.core.commons.config.IsisConfigurationDefault;
-import org.apache.isis.core.commons.exceptions.IsisException;
 import org.apache.isis.core.metamodel.facetdecorator.FacetDecorator;
 import org.apache.isis.core.metamodel.layout.MemberLayoutArranger;
 import org.apache.isis.core.metamodel.progmodel.ProgrammingModel;
 import org.apache.isis.core.metamodel.services.ServicesInjector;
-import org.apache.isis.core.metamodel.services.container.DomainObjectContainerDefault;
 import org.apache.isis.core.metamodel.spec.ObjectSpecification;
 import org.apache.isis.core.metamodel.spec.SpecificationLoader;
 import org.apache.isis.core.metamodel.specloader.ObjectReflectorDefault;
@@ -53,11 +50,12 @@ import org.apache.isis.core.progmodel.la
 import org.apache.isis.core.progmodel.metamodelvalidator.dflt.MetaModelValidatorDefault;
 import org.apache.isis.progmodel.wrapper.applib.WrapperFactory;
 import org.apache.isis.progmodel.wrapper.metamodel.DomainObjectContainerWrapperFactory;
-import org.apache.isis.progmodel.wrapper.metamodel.internal.WrapperFactoryDefault;
 import org.apache.isis.progmodels.dflt.ProgrammingModelFacetsJava5;
 import org.apache.isis.runtimes.dflt.bytecode.identity.classsubstitutor.ClassSubstitutorIdentity;
 import org.apache.isis.runtimes.embedded.internal.RuntimeContextForEmbeddedMetaModel;
 
+import com.google.common.collect.Lists;
+
 /**
  * Facade for the entire Isis metamodel and supporting components.
  */
@@ -67,7 +65,7 @@ public class IsisMetaModel implements Ap
         NOT_INITIALIZED, INITIALIZED, SHUTDOWN;
     }
 
-    private final List<Class<?>> serviceTypes = new ArrayList<Class<?>>();
+    private final List<Object> services = Lists.newArrayList();
     private State state = State.NOT_INITIALIZED;
 
     private ObjectReflectorDefault reflector;
@@ -82,13 +80,15 @@ public class IsisMetaModel implements Ap
     private Set<FacetDecorator> facetDecorators;
     private MetaModelValidator metaModelValidator;
 
-    private WrapperFactory viewer;
+    private WrapperFactory wrapperFactory;
     private final EmbeddedContext context;
-    private List<Object> services;
 
-    public IsisMetaModel(final EmbeddedContext context, final Class<?>... serviceTypes) {
+    public IsisMetaModel(final EmbeddedContext context, final Object... services) {
+        this(context, Arrays.asList(services));
+    }
 
-        this.serviceTypes.addAll(Arrays.asList(serviceTypes));
+    public IsisMetaModel(final EmbeddedContext context, final List<Object> services) {
+        this.services.addAll(services);
         setConfiguration(new IsisConfigurationDefault());
         setClassSubstitutor(new ClassSubstitutorIdentity());
         setCollectionTypeRegistry(new CollectionTypeRegistryDefault());
@@ -96,9 +96,9 @@ public class IsisMetaModel implements Ap
         setMemberLayoutArranger(new MemberLayoutArrangerDefault());
         setFacetDecorators(new TreeSet<FacetDecorator>());
         setProgrammingModelFacets(new ProgrammingModelFacetsJava5());
-
+        
         setMetaModelValidator(new MetaModelValidatorDefault());
-
+        
         this.context = context;
     }
 
@@ -110,8 +110,8 @@ public class IsisMetaModel implements Ap
      * To obtain the instantiated services, use the {@link ServicesInjector#getRegisteredServices()} (available from
      * {@link #getServicesInjector()}).
      */
-    public List<Class<?>> getServiceTypes() {
-        return Collections.unmodifiableList(serviceTypes);
+    public List<Object> getServices() {
+        return Collections.unmodifiableList(services);
     }
 
     // ///////////////////////////////////////////////////////
@@ -125,9 +125,8 @@ public class IsisMetaModel implements Ap
             new ObjectReflectorDefault(configuration, classSubstitutor, collectionTypeRegistry, specificationTraverser,
                 memberLayoutArranger, programmingModel, facetDecorators, metaModelValidator);
 
-        services = createServices(serviceTypes);
         runtimeContext = new RuntimeContextForEmbeddedMetaModel(context, services);
-        final DomainObjectContainerDefault container = new DomainObjectContainerWrapperFactory();
+        final DomainObjectContainerWrapperFactory container = new DomainObjectContainerWrapperFactory();
 
         runtimeContext.injectInto(container);
         runtimeContext.setContainer(container);
@@ -137,13 +136,13 @@ public class IsisMetaModel implements Ap
         reflector.init();
         runtimeContext.init();
 
-        for (final Class<?> serviceType : serviceTypes) {
-            final ObjectSpecification serviceSpec = reflector.loadSpecification(serviceType);
+        for (final Object service : services) {
+            final ObjectSpecification serviceSpec = reflector.loadSpecification(service.getClass());
             serviceSpec.markAsService();
         }
         state = State.INITIALIZED;
 
-        viewer = new WrapperFactoryDefault();
+        wrapperFactory = container;
     }
 
     @Override
@@ -152,20 +151,6 @@ public class IsisMetaModel implements Ap
         state = State.SHUTDOWN;
     }
 
-    private List<Object> createServices(final List<Class<?>> serviceTypes) {
-        final List<Object> services = new ArrayList<Object>();
-        for (final Class<?> serviceType : serviceTypes) {
-            try {
-                services.add(serviceType.newInstance());
-            } catch (final InstantiationException e) {
-                throw new IsisException("Unable to instantiate service", e);
-            } catch (final IllegalAccessException e) {
-                throw new IsisException("Unable to instantiate service", e);
-            }
-        }
-        return services;
-    }
-
     // ///////////////////////////////////////////////////////
     // SpecificationLoader
     // ///////////////////////////////////////////////////////
@@ -184,9 +169,9 @@ public class IsisMetaModel implements Ap
     /**
      * Available once {@link #init() initialized}.
      */
-    public WrapperFactory getViewer() {
+    public WrapperFactory getWrapperFactory() {
         ensureInitialized();
-        return viewer;
+        return wrapperFactory;
     }
 
     // ///////////////////////////////////////////////////////

Copied: incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/IsisMetaModelTest_constructDefaults.java (from r1214077, incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/GivenMetaModelWhenInstantiated.java)
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/IsisMetaModelTest_constructDefaults.java?p2=incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/IsisMetaModelTest_constructDefaults.java&p1=incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/GivenMetaModelWhenInstantiated.java&r1=1214077&r2=1215492&rev=1215492&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/GivenMetaModelWhenInstantiated.java (original)
+++ incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/IsisMetaModelTest_constructDefaults.java Sat Dec 17 14:14:28 2011
@@ -23,25 +23,25 @@ import static org.hamcrest.CoreMatchers.
 import static org.hamcrest.CoreMatchers.notNullValue;
 import static org.junit.Assert.assertThat;
 
-import org.jmock.Mockery;
-import org.jmock.integration.junit4.JMock;
-import org.jmock.integration.junit4.JUnit4Mockery;
+import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2;
+import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2.Mode;
+import org.jmock.auto.Mock;
 import org.junit.Before;
+import org.junit.Rule;
 import org.junit.Test;
-import org.junit.runner.RunWith;
 
-@RunWith(JMock.class)
-public class GivenMetaModelWhenInstantiated {
+public class IsisMetaModelTest_constructDefaults {
 
-    private final Mockery mockery = new JUnit4Mockery();
+    @Rule
+    public final JUnitRuleMockery2 mockery = JUnitRuleMockery2.createFor(Mode.INTERFACES_ONLY);
 
+    @Mock
     private EmbeddedContext mockContext;
 
     private IsisMetaModel metaModel;
 
     @Before
     public void setUp() {
-        mockContext = mockery.mock(EmbeddedContext.class);
         metaModel = new IsisMetaModel(mockContext);
     }
 

Copied: incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/IsisMetaModelTest_constructWithServices.java (from r1214077, incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/GivenMetaModelWhenInstantiate.java)
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/IsisMetaModelTest_constructWithServices.java?p2=incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/IsisMetaModelTest_constructWithServices.java&p1=incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/GivenMetaModelWhenInstantiate.java&r1=1214077&r2=1215492&rev=1215492&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/GivenMetaModelWhenInstantiate.java (original)
+++ incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/IsisMetaModelTest_constructWithServices.java Sat Dec 17 14:14:28 2011
@@ -26,6 +26,9 @@ import java.util.List;
 
 import org.apache.isis.runtimes.embedded.dom.claim.ClaimRepositoryImpl;
 import org.apache.isis.runtimes.embedded.dom.employee.EmployeeRepositoryImpl;
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+import org.hamcrest.TypeSafeMatcher;
 import org.jmock.Mockery;
 import org.jmock.integration.junit4.JMock;
 import org.jmock.integration.junit4.JUnit4Mockery;
@@ -34,7 +37,7 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 
 @RunWith(JMock.class)
-public class GivenMetaModelWhenInstantiate {
+public class IsisMetaModelTest_constructWithServices {
 
     private final Mockery mockery = new JUnit4Mockery();
 
@@ -54,11 +57,31 @@ public class GivenMetaModelWhenInstantia
 
     @Test
     public void shouldBeAbleToRegisterServices() {
-        metaModel = new IsisMetaModel(mockContext, EmployeeRepositoryImpl.class, ClaimRepositoryImpl.class);
-        final List<Class<?>> serviceTypes = metaModel.getServiceTypes();
-        assertThat(serviceTypes.size(), is(2));
-        assertThat(serviceTypes.contains(EmployeeRepositoryImpl.class), is(true));
-        assertThat(serviceTypes.contains(ClaimRepositoryImpl.class), is(true));
+        metaModel = new IsisMetaModel(mockContext, new EmployeeRepositoryImpl(), new ClaimRepositoryImpl());
+        final List<Object> services = metaModel.getServices();
+        assertThat(services.size(), is(2));
+        assertThat(services, contains(EmployeeRepositoryImpl.class));
+        assertThat(services, contains(ClaimRepositoryImpl.class));
+    }
+
+    private Matcher<List<Object>> contains(final Class<?> cls) {
+        return new TypeSafeMatcher<List<Object>>() {
+
+            @Override
+            public void describeTo(Description desc) {
+                desc.appendText("contains instance of type " + cls.getName());
+            }
+
+            @Override
+            public boolean matchesSafely(List<Object> items) {
+                for (Object object : items) {
+                    if(cls.isAssignableFrom(object.getClass())) {
+                        return true;
+                    }
+                }
+                return false;
+            }
+        };
     }
 
 }

Copied: incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/IsisMetaModelTest_getWrapperFactory.java (from r1214077, incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/GivenMetaModelWhenInitialized.java)
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/IsisMetaModelTest_getWrapperFactory.java?p2=incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/IsisMetaModelTest_getWrapperFactory.java&p1=incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/GivenMetaModelWhenInitialized.java&r1=1214077&r2=1215492&rev=1215492&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/GivenMetaModelWhenInitialized.java (original)
+++ incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/IsisMetaModelTest_getWrapperFactory.java Sat Dec 17 14:14:28 2011
@@ -33,7 +33,7 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 
 @RunWith(JMock.class)
-public class GivenMetaModelWhenInitialized {
+public class IsisMetaModelTest_getWrapperFactory {
 
     private final Mockery mockery = new JUnit4Mockery();
 
@@ -45,13 +45,13 @@ public class GivenMetaModelWhenInitializ
     public void setUp() {
         mockContext = mockery.mock(EmbeddedContext.class);
 
-        metaModel = new IsisMetaModel(mockContext, EmployeeRepositoryImpl.class, ClaimRepositoryImpl.class);
+        metaModel = new IsisMetaModel(mockContext);
         metaModel.init();
     }
 
     @Test
-    public void shouldBeAbleToGetViewer() {
-        assertThat(metaModel.getViewer(), is(notNullValue()));
+    public void happyCase() {
+        assertThat(metaModel.getWrapperFactory(), is(notNullValue()));
     }
 
 }

Copied: incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/IsisMetaModelTest_init.java (from r1214077, incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/GivenMetaModelWhenInitialize.java)
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/IsisMetaModelTest_init.java?p2=incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/IsisMetaModelTest_init.java&p1=incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/GivenMetaModelWhenInitialize.java&r1=1214077&r2=1215492&rev=1215492&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/GivenMetaModelWhenInitialize.java (original)
+++ incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/IsisMetaModelTest_init.java Sat Dec 17 14:14:28 2011
@@ -36,7 +36,7 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 
 @RunWith(JMock.class)
-public class GivenMetaModelWhenInitialize {
+public class IsisMetaModelTest_init {
 
     private final Mockery mockery = new JUnit4Mockery();
 
@@ -58,7 +58,7 @@ public class GivenMetaModelWhenInitializ
         mockFacetDecorator = mockery.mock(FacetDecorator.class);
         mockClassSubstitutor = mockery.mock(ClassSubstitutor.class);
 
-        metaModel = new IsisMetaModel(mockContext, EmployeeRepositoryImpl.class, ClaimRepositoryImpl.class);
+        metaModel = new IsisMetaModel(mockContext);
     }
 
     @Test

Copied: incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/IsisMetaModelTest_shutdown.java (from r1214077, incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/GivenMetaModelWhenShutdown.java)
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/IsisMetaModelTest_shutdown.java?p2=incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/IsisMetaModelTest_shutdown.java&p1=incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/GivenMetaModelWhenShutdown.java&r1=1214077&r2=1215492&rev=1215492&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/GivenMetaModelWhenShutdown.java (original)
+++ incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/IsisMetaModelTest_shutdown.java Sat Dec 17 14:14:28 2011
@@ -36,7 +36,7 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 
 @RunWith(JMock.class)
-public class GivenMetaModelWhenShutdown {
+public class IsisMetaModelTest_shutdown {
 
     private final Mockery mockery = new JUnit4Mockery();
 
@@ -58,7 +58,7 @@ public class GivenMetaModelWhenShutdown 
         mockFacetDecorator = mockery.mock(FacetDecorator.class);
         mockClassSubstitutor = mockery.mock(ClassSubstitutor.class);
 
-        metaModel = new IsisMetaModel(mockContext, EmployeeRepositoryImpl.class, ClaimRepositoryImpl.class);
+        metaModel = new IsisMetaModel(mockContext);
     }
 
     @Test

Copied: incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/WrappedFactoryDefaultTest_wrappedObject.java (from r1214077, incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/GivenEmbeddedViewerAndPersistentDomainObject.java)
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/WrappedFactoryDefaultTest_wrappedObject.java?p2=incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/WrappedFactoryDefaultTest_wrappedObject.java&p1=incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/GivenEmbeddedViewerAndPersistentDomainObject.java&r1=1214077&r2=1215492&rev=1215492&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/GivenEmbeddedViewerAndPersistentDomainObject.java (original)
+++ incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/WrappedFactoryDefaultTest_wrappedObject.java Sat Dec 17 14:14:28 2011
@@ -28,8 +28,10 @@ import org.apache.isis.progmodel.wrapper
 import org.apache.isis.progmodel.wrapper.applib.HiddenException;
 import org.apache.isis.progmodel.wrapper.applib.InvalidException;
 import org.apache.isis.progmodel.wrapper.applib.WrapperFactory;
+import org.apache.isis.runtimes.embedded.dom.claim.ClaimRepository;
 import org.apache.isis.runtimes.embedded.dom.claim.ClaimRepositoryImpl;
 import org.apache.isis.runtimes.embedded.dom.employee.Employee;
+import org.apache.isis.runtimes.embedded.dom.employee.EmployeeRepository;
 import org.apache.isis.runtimes.embedded.dom.employee.EmployeeRepositoryImpl;
 import org.apache.isis.runtimes.embedded.internal.PersistenceState;
 import org.jmock.Expectations;
@@ -42,27 +44,37 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 
 @RunWith(JMock.class)
-public class GivenEmbeddedViewerAndPersistentDomainObject {
+public class WrappedFactoryDefaultTest_wrappedObject {
 
+//    @Rule
+//    public JMockRule rule = new JMockRule();
+    
     private final Mockery mockery = new JUnit4Mockery();
 
+    // @Mock
     private EmbeddedContext mockContext;
-
+    // @Mock
     private AuthenticationSession mockAuthenticationSession;
 
-    private IsisMetaModel metaModel;
-
-    private WrapperFactory viewer;
-
+    private EmployeeRepository employeeRepository;
+    private ClaimRepository claimRepository;
+    
     private Employee employeeDO;
+    private Employee employeeWO;
 
-    private Employee employeeVO;
+    private IsisMetaModel metaModel;
+    private WrapperFactory wrapperFactory;
 
+    
     @Before
     public void setUp() {
 
+        employeeRepository = new EmployeeRepositoryImpl();
+        claimRepository = new ClaimRepositoryImpl();
+
         employeeDO = new Employee();
         employeeDO.setName("Smith");
+        employeeDO.setEmployeeRepository(employeeRepository); // would be done by the EmbeddedContext impl
 
         mockContext = mockery.mock(EmbeddedContext.class);
         mockAuthenticationSession = mockery.mock(AuthenticationSession.class);
@@ -80,87 +92,85 @@ public class GivenEmbeddedViewerAndPersi
             }
         });
 
-        metaModel = new IsisMetaModel(mockContext, EmployeeRepositoryImpl.class, ClaimRepositoryImpl.class);
+        metaModel = new IsisMetaModel(mockContext, employeeRepository, claimRepository);
         metaModel.init();
 
-        viewer = metaModel.getViewer();
+        //employeeDO.setEmployeeRepository(employeeRepository);
+        wrapperFactory = metaModel.getWrapperFactory();
+        employeeWO = wrapperFactory.wrap(employeeDO);
     }
 
     @Test
-    public void shouldBeAbleToGetViewOfDomainObject() {
-        employeeVO = viewer.wrap(employeeDO);
-        assertThat(employeeVO, is(notNullValue()));
+    public void shouldWrapDomainObject() {
+        // then
+        assertThat(employeeWO, is(notNullValue()));
     }
 
     @Test
-    public void shouldBeAbleToReadVisibleProperty() {
-        employeeVO = viewer.wrap(employeeDO);
+    public void shouldBeAbleToInjectIntoDomainObjects() {
 
-        assertThat(employeeVO.getName(), is(employeeDO.getName()));
+        // given
+        assertThat(employeeDO.getEmployeeRepository(), is(notNullValue()));
+        
+        // then
+        assertThat(employeeWO.getEmployeeRepository(), is(notNullValue()));
+    }
+
+
+    @Test
+    public void shouldBeAbleToReadVisibleProperty() {
+        // then
+        assertThat(employeeWO.getName(), is(employeeDO.getName()));
     }
 
     @Test(expected = HiddenException.class)
     public void shouldNotBeAbleToViewHiddenProperty() {
-        employeeVO = viewer.wrap(employeeDO);
-
+        // given
         employeeDO.whetherHideName = true;
-        employeeVO.getName(); // should throw exception
+        // when
+        employeeWO.getName(); 
+        // then should throw exception
     }
 
     @Test
     public void shouldBeAbleToModifyEnabledPropertyUsingSetter() {
-        employeeVO = viewer.wrap(employeeDO);
-
-        employeeVO.setName("Jones");
+        // when
+        employeeWO.setName("Jones");
+        // then
         assertThat(employeeDO.getName(), is("Jones"));
-        assertThat(employeeVO.getName(), is(employeeDO.getName()));
+        assertThat(employeeWO.getName(), is(employeeDO.getName()));
     }
 
     @Test(expected = DisabledException.class)
     public void shouldNotBeAbleToModifyDisabledProperty() {
-        employeeVO = viewer.wrap(employeeDO);
-
+        // given
         employeeDO.reasonDisableName = "sorry, no change allowed";
-        employeeVO.setName("Jones");
+        // when
+        employeeWO.setName("Jones");
+        // then should throw exception
     }
 
     @Test(expected = UnsupportedOperationException.class)
     public void shouldNotBeAbleToModifyPropertyUsingModify() {
-        employeeVO = viewer.wrap(employeeDO);
-
-        employeeVO.modifyName("Jones"); // should throw exception
+        // when
+        employeeWO.modifyName("Jones");
+        // then should throw exception
     }
 
     @Test(expected = UnsupportedOperationException.class)
     public void shouldNotBeAbleToModifyPropertyUsingClear() {
-        employeeVO = viewer.wrap(employeeDO);
-
-        employeeVO.clearName(); // should throw exception
+        // when
+        employeeWO.clearName();
+        // then should throw exception
     }
 
     @Test(expected = InvalidException.class)
     public void shouldNotBeAbleToModifyPropertyIfInvalid() {
-        employeeVO = viewer.wrap(employeeDO);
-
+        // given
         employeeDO.reasonValidateName = "sorry, invalid data";
-        employeeVO.setName("Jones");
-    }
-
-    @Test(expected = DisabledException.class)
-    public void shouldNotBeAbleToModifyPropertyForTransientOnly() {
-        employeeVO = viewer.wrap(employeeDO);
-
-        employeeVO.setPassword("12345678");
-    }
-
-    @Ignore("incomplete")
-    @Test
-    public void shouldBeAbleToInjectIntoDomainObjects() {
-
-        // TODO: also ... be able to inject EmbeddedViewer as a service itself, if required.
-
-        employeeVO.setPassword("12345678");
-
+        // when
+        employeeWO.setName("Jones");
+        // then should throw exception
     }
 
 }

Added: incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/WrappedFactoryDefaultTest_wrappedObject_transient.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/WrappedFactoryDefaultTest_wrappedObject_transient.java?rev=1215492&view=auto
==============================================================================
--- incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/WrappedFactoryDefaultTest_wrappedObject_transient.java (added)
+++ incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/WrappedFactoryDefaultTest_wrappedObject_transient.java Sat Dec 17 14:14:28 2011
@@ -0,0 +1,123 @@
+/*
+ *  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.embedded;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2;
+import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2.Mode;
+import org.apache.isis.progmodel.wrapper.applib.DisabledException;
+import org.apache.isis.progmodel.wrapper.applib.WrapperFactory;
+import org.apache.isis.runtimes.embedded.dom.claim.ClaimRepository;
+import org.apache.isis.runtimes.embedded.dom.claim.ClaimRepositoryImpl;
+import org.apache.isis.runtimes.embedded.dom.employee.Employee;
+import org.apache.isis.runtimes.embedded.dom.employee.EmployeeRepository;
+import org.apache.isis.runtimes.embedded.dom.employee.EmployeeRepositoryImpl;
+import org.apache.isis.runtimes.embedded.internal.PersistenceState;
+import org.jmock.Expectations;
+import org.jmock.auto.Mock;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+public class WrappedFactoryDefaultTest_wrappedObject_transient {
+
+    @Rule
+    public final JUnitRuleMockery2 mockery = JUnitRuleMockery2.createFor(Mode.INTERFACES_ONLY);
+
+    @Mock
+    private EmbeddedContext mockContext;
+    @Mock
+    private AuthenticationSession mockAuthenticationSession;
+
+    private EmployeeRepository employeeRepository;
+    private ClaimRepository claimRepository;
+    
+    private Employee employeeDO;
+    private Employee employeeWO;
+
+    private IsisMetaModel metaModel;
+    private WrapperFactory wrapperFactory;
+
+    
+    @Before
+    public void setUp() {
+
+        employeeRepository = new EmployeeRepositoryImpl();
+        claimRepository = new ClaimRepositoryImpl();
+
+        employeeDO = new Employee();
+        employeeDO.setName("Smith");
+        employeeDO.setEmployeeRepository(employeeRepository); // would be done by the EmbeddedContext impl
+    }
+
+
+    @Test(expected = DisabledException.class)
+    public void shouldNotBeAbleToModifyPropertyIfPersistent() {
+        
+        // given
+        initializedMetaModelWhereEmployeeIs(PersistenceState.PERSISTENT);
+        
+        // when
+        employeeWO.setPassword("12345678");
+        // then should throw exception
+    }
+
+
+    @Test
+    public void canModifyPropertyIfTransient() {
+        // given
+        initializedMetaModelWhereEmployeeIs(PersistenceState.TRANSIENT);
+        
+        // when
+        employeeWO.setPassword("12345678");
+        // then be allowed
+        assertThat(employeeWO.getPassword(), is("12345678"));
+    }
+
+    
+    private void initializedMetaModelWhereEmployeeIs(final PersistenceState persistentState) {
+        mockery.checking(new Expectations() {
+            {
+                allowing(mockContext).getPersistenceState(with(any(Employee.class)));
+                will(returnValue(persistentState));
+            }
+        });
+        mockery.checking(new Expectations() {
+            {
+                allowing(mockContext).getPersistenceState(with(any(String.class)));
+                will(returnValue(PersistenceState.STANDALONE));
+
+                allowing(mockContext).getAuthenticationSession();
+                will(returnValue(mockAuthenticationSession));
+            }
+        });
+        metaModel = new IsisMetaModel(mockContext, employeeRepository, claimRepository);
+        metaModel.init();
+
+        wrapperFactory = metaModel.getWrapperFactory();
+
+        employeeWO = wrapperFactory.wrap(employeeDO);
+    }
+
+
+}

Modified: incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/dom/employee/Employee.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/dom/employee/Employee.java?rev=1215492&r1=1215491&r2=1215492&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/dom/employee/Employee.java (original)
+++ incubator/isis/trunk/framework/runtimes/embedded/src/test/java/org/apache/isis/runtimes/embedded/dom/employee/Employee.java Sat Dec 17 14:14:28 2011
@@ -104,4 +104,16 @@ public class Employee extends AbstractDo
     }
     // }}
 
+    
+    // {{ injected: EmployeeRepository
+    private EmployeeRepository employeeRepository;
+    public EmployeeRepository getEmployeeRepository() {
+        return employeeRepository;
+    }
+    public void setEmployeeRepository(final EmployeeRepository employeeRepository) {
+        this.employeeRepository = employeeRepository;
+    }
+    // }}
+
+
 }

Modified: incubator/isis/trunk/framework/viewer/wicket/wicket-viewer/src/test/java/org/apache/isis/viewer/wicket/viewer/IsisWicketApplication_Defaults.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/wicket/wicket-viewer/src/test/java/org/apache/isis/viewer/wicket/viewer/IsisWicketApplication_Defaults.java?rev=1215492&r1=1215491&r2=1215492&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/wicket/wicket-viewer/src/test/java/org/apache/isis/viewer/wicket/viewer/IsisWicketApplication_Defaults.java (original)
+++ incubator/isis/trunk/framework/viewer/wicket/wicket-viewer/src/test/java/org/apache/isis/viewer/wicket/viewer/IsisWicketApplication_Defaults.java Sat Dec 17 14:14:28 2011
@@ -25,7 +25,8 @@ import static org.hamcrest.Matchers.null
 import static org.junit.Assert.assertThat;
 
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.testsupport.jmock.FixtureMockery;
+import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2;
+import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2.Mode;
 import org.apache.isis.viewer.wicket.model.mementos.ObjectAdapterMemento;
 import org.apache.isis.viewer.wicket.viewer.integration.wicket.AuthenticatedWebSessionForIsis;
 import org.apache.isis.viewer.wicket.viewer.integration.wicket.WebRequestCycleForIsis;
@@ -34,21 +35,15 @@ import org.apache.wicket.RequestCycle;
 import org.apache.wicket.Response;
 import org.apache.wicket.authentication.AuthenticatedWebSession;
 import org.apache.wicket.protocol.http.WebRequest;
-import org.jmock.integration.junit4.JMock;
-import org.jmock.lib.legacy.ClassImposteriser;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.Rule;
 import org.junit.Test;
-import org.junit.runner.RunWith;
 
-@RunWith(JMock.class)
 public class IsisWicketApplication_Defaults {
 
-    private final FixtureMockery context = new FixtureMockery() {
-        {
-            setImposteriser(ClassImposteriser.INSTANCE);
-        }
-    };
+    @Rule
+    public final JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
 
     private IsisWicketApplication application;
 

Modified: incubator/isis/trunk/framework/viewer/wicket/wicket-viewer/src/test/java/org/apache/isis/viewer/wicket/viewer/IsisWicketApplication_Pages.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/wicket/wicket-viewer/src/test/java/org/apache/isis/viewer/wicket/viewer/IsisWicketApplication_Pages.java?rev=1215492&r1=1215491&r2=1215492&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/wicket/wicket-viewer/src/test/java/org/apache/isis/viewer/wicket/viewer/IsisWicketApplication_Pages.java (original)
+++ incubator/isis/trunk/framework/viewer/wicket/wicket-viewer/src/test/java/org/apache/isis/viewer/wicket/viewer/IsisWicketApplication_Pages.java Sat Dec 17 14:14:28 2011
@@ -22,7 +22,8 @@ package org.apache.isis.viewer.wicket.vi
 import static org.hamcrest.Matchers.is;
 import static org.junit.Assert.assertThat;
 
-import org.apache.isis.core.testsupport.jmock.FixtureMockery;
+import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2;
+import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2.Mode;
 import org.apache.isis.viewer.wicket.ui.pages.PageClassRegistry;
 import org.apache.isis.viewer.wicket.ui.pages.PageType;
 import org.apache.isis.viewer.wicket.ui.pages.home.HomePage;
@@ -30,18 +31,14 @@ import org.apache.wicket.Page;
 import org.apache.wicket.markup.html.WebPage;
 import org.jmock.Expectations;
 import org.jmock.integration.junit4.JMock;
-import org.jmock.lib.legacy.ClassImposteriser;
+import org.junit.Rule;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
-@RunWith(JMock.class)
 public class IsisWicketApplication_Pages {
 
-    private final FixtureMockery context = new FixtureMockery() {
-        {
-            setImposteriser(ClassImposteriser.INSTANCE);
-        }
-    };
+    @Rule
+    public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_ONLY);
 
     private IsisWicketApplication application;
 

Modified: incubator/isis/trunk/framework/viewer/wicket/wicket-viewer/src/test/java/org/apache/isis/viewer/wicket/viewer/IsisWicketApplication_init.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/wicket/wicket-viewer/src/test/java/org/apache/isis/viewer/wicket/viewer/IsisWicketApplication_init.java?rev=1215492&r1=1215491&r2=1215492&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/wicket/wicket-viewer/src/test/java/org/apache/isis/viewer/wicket/viewer/IsisWicketApplication_init.java (original)
+++ incubator/isis/trunk/framework/viewer/wicket/wicket-viewer/src/test/java/org/apache/isis/viewer/wicket/viewer/IsisWicketApplication_init.java Sat Dec 17 14:14:28 2011
@@ -23,16 +23,22 @@ import static org.hamcrest.Matchers.is;
 import static org.hamcrest.Matchers.notNullValue;
 import static org.junit.Assert.assertThat;
 
-import org.apache.isis.core.testsupport.jmock.AbstractJMockForInterfacesTest;
+import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2;
+import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2.Mode;
 import org.apache.wicket.settings.IResourceSettings;
 import org.apache.wicket.settings.ISecuritySettings;
 import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Rule;
 import org.junit.Test;
 
 import com.google.inject.Injector;
 
-public class IsisWicketApplication_init extends AbstractJMockForInterfacesTest {
+public class IsisWicketApplication_init {
 
+    @Rule
+    public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_ONLY);
+    
     private IsisWicketApplication application;
 
     private ISecuritySettings mockSecuritySettings;
@@ -40,10 +46,8 @@ public class IsisWicketApplication_init 
 
     @Before
     public void setUp() throws Exception {
-        mockSecuritySettings = context.mock(ISecuritySettings.class);
-        mockResourceSettings = context.mock(IResourceSettings.class);
-        ignoring(mockSecuritySettings);
-        ignoring(mockResourceSettings);
+        mockSecuritySettings = context.mockAndIgnoring(ISecuritySettings.class);
+        mockResourceSettings = context.mockAndIgnoring(IResourceSettings.class);
 
         application = new IsisWicketApplication() {
             private static final long serialVersionUID = 1L;
@@ -65,18 +69,21 @@ public class IsisWicketApplication_init 
         };
     }
 
+    @Ignore
     @Test
     public void injectedApplicationCssUrl() {
         application.init();
         assertThat(application.getApplicationCssUrl(), is(notNullValue()));
     }
 
+    @Ignore
     @Test
     public void injectedComponentFactoryRegistry() {
         application.init();
         assertThat(application.getComponentFactoryRegistry(), is(notNullValue()));
     }
 
+    @Ignore
     @Test
     public void injectedImageCache() {
         application.init();



Mime
View raw message