You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2013/05/25 09:55:54 UTC

[3/4] git commit: ISIS-406: more on integration tests and wrapper.

ISIS-406: more on integration tests and wrapper.


Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/6728af76
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/6728af76
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/6728af76

Branch: refs/heads/master
Commit: 6728af769d7c7a3fdfd55d3b2a692ebb55f729ef
Parents: a55c76b
Author: Dan Haywood <da...@apache.org>
Authored: Sat May 25 06:56:04 2013 +0100
Committer: Dan Haywood <da...@apache.org>
Committed: Sat May 25 07:57:12 2013 +0100

----------------------------------------------------------------------
 .../internal/DomainObjectInvocationHandler.java    |    6 +++
 .../test/java/integtests/AbstractIntegTest.java    |    4 ++
 .../test/java/integtests/ToDoItemIntegTest.java    |   30 +++++++++++---
 3 files changed, 33 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/isis/blob/6728af76/core/wrapper/src/main/java/org/apache/isis/core/wrapper/internal/DomainObjectInvocationHandler.java
----------------------------------------------------------------------
diff --git a/core/wrapper/src/main/java/org/apache/isis/core/wrapper/internal/DomainObjectInvocationHandler.java b/core/wrapper/src/main/java/org/apache/isis/core/wrapper/internal/DomainObjectInvocationHandler.java
index 6caf76e..081f82a 100644
--- a/core/wrapper/src/main/java/org/apache/isis/core/wrapper/internal/DomainObjectInvocationHandler.java
+++ b/core/wrapper/src/main/java/org/apache/isis/core/wrapper/internal/DomainObjectInvocationHandler.java
@@ -146,6 +146,11 @@ public class DomainObjectInvocationHandler<T> extends DelegatingInvocationHandle
             return getDelegate();
         }
 
+        // workaround for JDO-enhanced..
+        if(method.getName().startsWith("jdo")) {
+            return delegate(method, args);
+        }
+
         final ObjectMember objectMember = locateAndCheckMember(method);
         final List<Facet> imperativeFacets = getImperativeFacets(objectMember, method);
 
@@ -578,6 +583,7 @@ public class DomainObjectInvocationHandler<T> extends DelegatingInvocationHandle
     private ObjectMember locateAndCheckMember(final Method method) {
         final ObjectSpecificationDefault objectSpecificationDefault = getJavaSpecificationOfOwningClass(method);
         final ObjectMember member = objectSpecificationDefault.getMember(method);
+        
         if (member == null) {
             final String methodName = method.getName();
             throw new UnsupportedOperationException("Method '" + methodName + "' being invoked does not correspond to any of the object's fields or actions.");

http://git-wip-us.apache.org/repos/asf/isis/blob/6728af76/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integtests/AbstractIntegTest.java
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integtests/AbstractIntegTest.java b/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integtests/AbstractIntegTest.java
index 44510bd..16284d2 100644
--- a/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integtests/AbstractIntegTest.java
+++ b/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integtests/AbstractIntegTest.java
@@ -31,6 +31,7 @@ import org.junit.rules.MethodRule;
 import org.junit.runners.model.FrameworkMethod;
 import org.junit.runners.model.Statement;
 
+import org.apache.isis.applib.DomainObjectContainer;
 import org.apache.isis.applib.services.wrapper.WrapperFactory;
 import org.apache.isis.core.commons.config.IsisConfiguration;
 import org.apache.isis.core.commons.config.IsisConfigurationDefault;
@@ -44,6 +45,7 @@ public class AbstractIntegTest {
 
     protected ToDoItems toDoItems;
     protected WrapperFactory wrapperFactory;
+    protected DomainObjectContainer container;
     
     @Rule
     public IsisSystemForTestRule rule = new IsisSystemForTestRule();
@@ -62,6 +64,7 @@ public class AbstractIntegTest {
     public void init() {
         toDoItems = getIsft().getService(ToDoItemsJdo.class);
         wrapperFactory = getIsft().getService(WrapperFactoryDefault.class);
+        container = getIsft().container;
     }
 
     protected <T> T wrap(T obj) {
@@ -85,6 +88,7 @@ public class AbstractIntegTest {
             withLoggingAt(Level.INFO);
             with(testConfiguration());
             with(new DataNucleusPersistenceMechanismInstaller());
+            
             withServices(
                     new ToDoItemsJdo(),
                     new WrapperFactoryDefault(),

http://git-wip-us.apache.org/repos/asf/isis/blob/6728af76/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integtests/ToDoItemIntegTest.java
----------------------------------------------------------------------
diff --git a/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integtests/ToDoItemIntegTest.java b/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integtests/ToDoItemIntegTest.java
index 5aab2d8..380dc79 100644
--- a/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integtests/ToDoItemIntegTest.java
+++ b/example/application/quickstart_wicket_restful_jdo/integtests/src/test/java/integtests/ToDoItemIntegTest.java
@@ -18,6 +18,7 @@
  */
 package integtests;
 
+import static org.hamcrest.CoreMatchers.*;
 import static org.hamcrest.CoreMatchers.is;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.fail;
@@ -36,13 +37,13 @@ import org.apache.isis.applib.services.wrapper.DisabledException;
 public class ToDoItemIntegTest extends AbstractIntegTest {
 
     @Test
-    public void t01_findNotYetCompleted() throws Exception {
+    public void t010_findNotYetCompleted() throws Exception {
         final List<ToDoItem> all = wrap(toDoItems).notYetComplete();
         assertThat(all.size(), is(5));
     }
 
     @Test
-    public void t02_update() throws Exception {
+    public void t020_updateDescription() throws Exception {
         // given
         final List<ToDoItem> all = wrap(toDoItems).notYetComplete();
         final ToDoItem toDoItem = wrap(all.get(0));
@@ -58,27 +59,39 @@ public class ToDoItemIntegTest extends AbstractIntegTest {
 
 
     @Test
-    public void t03_complete() throws Exception {
+    public void t030_complete_and_notYetComplete() throws Exception {
         // given
-        final List<ToDoItem> all = wrap(toDoItems).notYetComplete();
+        List<ToDoItem> all = wrap(toDoItems).notYetComplete();
         final ToDoItem toDoItem = wrap(all.get(0));
         
         assertThat(toDoItem.getDescription(), is("Buy milk and butter"));
         assertThat(toDoItem.isComplete(), is(false));
+        assertThat(container.titleOf(toDoItem), is("foo"));
         
         // when
         toDoItem.completed();
         
         // then
         assertThat(toDoItem.isComplete(), is(true));
+        assertThat(container.titleOf(toDoItem), is("foo"));
+
+        all = wrap(toDoItems).notYetComplete();
+        assertThat(all.size(), is(4));
+        
+        // and when
+        toDoItem.notYetCompleted();
+        
+        // then
+        assertThat(toDoItem.isComplete(), is(false));
+        assertThat(container.titleOf(toDoItem), is("foo"));
 
-        final List<ToDoItem> all2 = wrap(toDoItems).notYetComplete();
-        assertThat(all2.size(), is(4));
+        all = wrap(toDoItems).notYetComplete();
+        assertThat(all.size(), is(5));
     }
 
 
     @Test
-    public void t04_cannotCompleteAndObjectAlreadyCompleted() throws Exception {
+    public void t040_cannotCompleteAndObjectAlreadyCompleted() throws Exception {
         // given
         final List<ToDoItem> all = wrap(toDoItems).notYetComplete(); // 4 left
         final ToDoItem toDoItem = wrap(all.get(0));
@@ -92,6 +105,9 @@ public class ToDoItemIntegTest extends AbstractIntegTest {
         } catch(DisabledException ex) {
             assertThat(ex.getMessage(), is("Already completed"));
         }
+        
+        // reset
+        toDoItem.notYetCompleted();
     }
 
 }
\ No newline at end of file