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 [2/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
Modified: incubator/isis/trunk/framework/viewer/wicket/wicket-viewer/src/test/java/org/apache/isis/viewer/wicket/viewer/app/wicket/AuthenticatedWebSessionForIsis_Authenticate.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/wicket/wicket-viewer/src/test/java/org/apache/isis/viewer/wicket/viewer/app/wicket/AuthenticatedWebSessionForIsis_Authenticate.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/app/wicket/AuthenticatedWebSessionForIsis_Authenticate.java
(original)
+++ incubator/isis/trunk/framework/viewer/wicket/wicket-viewer/src/test/java/org/apache/isis/viewer/wicket/viewer/app/wicket/AuthenticatedWebSessionForIsis_Authenticate.java
Sat Dec 17 14:14:28 2011
@@ -24,41 +24,55 @@ import static org.hamcrest.Matchers.not;
 import static org.hamcrest.Matchers.nullValue;
 import static org.junit.Assert.assertThat;
 
+import java.util.Locale;
+
 import org.apache.isis.core.runtime.authentication.AuthenticationManager;
 import org.apache.isis.core.runtime.authentication.AuthenticationRequest;
-import org.apache.isis.core.testsupport.jmock.FixtureMockery;
-import org.apache.isis.viewer.wicket.viewer.Fixture_AuthenticationManager_AuthenticateOk;
-import org.apache.isis.viewer.wicket.viewer.Fixture_Request_Stub;
+import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2;
+import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2.Mode;
 import org.apache.isis.viewer.wicket.viewer.integration.wicket.AuthenticatedWebSessionForIsis;
 import org.apache.wicket.Request;
 import org.jmock.Expectations;
-import org.jmock.integration.junit4.JMock;
-import org.jmock.lib.legacy.ClassImposteriser;
+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 AuthenticatedWebSessionForIsis_Authenticate {
 
-    private final FixtureMockery context = new FixtureMockery() {
-        {
-            setImposteriser(ClassImposteriser.INSTANCE);
-        }
-    };
+    @Rule
+    public final JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
 
     private AuthenticatedWebSessionForIsis webSession;
+    @Mock
     private Request stubRequest;
+    @Mock
+    private AuthenticationManager mockAuthMgr;
 
     @Before
     public void setUp() throws Exception {
-        stubRequest = context.fixture(Fixture_Request_Stub.class).object();
+        context.checking(new Expectations() {
+            {
+                // must provide explicit expectation, since Locale is final.
+                allowing(stubRequest).getLocale();
+                will(returnValue(Locale.getDefault()));
+
+                // stub everything else out
+                ignoring(stubRequest);
+            }
+        });
+
     }
 
     @Test
     public void delegatesToAuthenticationManagerAndCachesAuthSessionIfOk() {
-        final AuthenticationManager mockAuthMgr =
-            context.fixture(Fixture_AuthenticationManager_AuthenticateOk.class).object();
+
+        context.checking(new Expectations() {
+            {
+                one(mockAuthMgr).authenticate(with(any(AuthenticationRequest.class)));
+            }
+        });
+
         webSession = new AuthenticatedWebSessionForIsis(stubRequest) {
             private static final long serialVersionUID = 1L;
 
@@ -73,7 +87,6 @@ public class AuthenticatedWebSessionForI
 
     @Test
     public void delegatesToAuthenticationManagerAndHandlesIfNotAuthenticated() {
-        final AuthenticationManager mockAuthMgr = context.mock(AuthenticationManager.class);
         context.checking(new Expectations() {
             {
                 one(mockAuthMgr).authenticate(with(any(AuthenticationRequest.class)));

Modified: incubator/isis/trunk/framework/viewer/wicket/wicket-viewer/src/test/java/org/apache/isis/viewer/wicket/viewer/app/wicket/AuthenticatedWebSessionForIsis_Instantiation.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/wicket/wicket-viewer/src/test/java/org/apache/isis/viewer/wicket/viewer/app/wicket/AuthenticatedWebSessionForIsis_Instantiation.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/app/wicket/AuthenticatedWebSessionForIsis_Instantiation.java
(original)
+++ incubator/isis/trunk/framework/viewer/wicket/wicket-viewer/src/test/java/org/apache/isis/viewer/wicket/viewer/app/wicket/AuthenticatedWebSessionForIsis_Instantiation.java
Sat Dec 17 14:14:28 2011
@@ -19,27 +19,38 @@
 
 package org.apache.isis.viewer.wicket.viewer.app.wicket;
 
-import org.apache.isis.core.testsupport.jmock.FixtureMockery;
-import org.apache.isis.viewer.wicket.viewer.Fixture_Request_Stub;
+import java.util.Locale;
+
+import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2;
+import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2.Mode;
 import org.apache.isis.viewer.wicket.viewer.integration.wicket.AuthenticatedWebSessionForIsis;
 import org.apache.wicket.Request;
-import org.jmock.integration.junit4.JMock;
-import org.jmock.lib.legacy.ClassImposteriser;
+import org.jmock.Expectations;
+import org.jmock.auto.Mock;
+import org.junit.Rule;
 import org.junit.Test;
-import org.junit.runner.RunWith;
 
-@RunWith(JMock.class)
 public class AuthenticatedWebSessionForIsis_Instantiation {
 
-    private final FixtureMockery context = new FixtureMockery() {
-        {
-            setImposteriser(ClassImposteriser.INSTANCE);
-        }
-    };
+    @Rule
+    public final JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
+    
+    @Mock
+    private Request stubRequest;
 
     @Test
     public void canInstantiateIfProvideRequest() {
-        final Request stubRequest = context.fixture(Fixture_Request_Stub.class).object();
+        context.checking(new Expectations() {
+            {
+                // must provide explicit expectation, since Locale is final.
+                allowing(stubRequest).getLocale();
+                will(returnValue(Locale.getDefault()));
+
+                // stub everything else out
+                ignoring(stubRequest);
+            }
+        });
+
         new AuthenticatedWebSessionForIsis(stubRequest);
     }
 

Modified: incubator/isis/trunk/framework/viewer/wicket/wicket-viewer/src/test/java/org/apache/isis/viewer/wicket/viewer/app/wicket/AuthenticatedWebSessionForIsis_SignIn.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/wicket/wicket-viewer/src/test/java/org/apache/isis/viewer/wicket/viewer/app/wicket/AuthenticatedWebSessionForIsis_SignIn.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/app/wicket/AuthenticatedWebSessionForIsis_SignIn.java
(original)
+++ incubator/isis/trunk/framework/viewer/wicket/wicket-viewer/src/test/java/org/apache/isis/viewer/wicket/viewer/app/wicket/AuthenticatedWebSessionForIsis_SignIn.java
Sat Dec 17 14:14:28 2011
@@ -22,39 +22,54 @@ package org.apache.isis.viewer.wicket.vi
 import static org.hamcrest.Matchers.is;
 import static org.junit.Assert.assertThat;
 
+import java.util.Locale;
+
 import org.apache.isis.core.runtime.authentication.AuthenticationManager;
-import org.apache.isis.core.testsupport.jmock.FixtureMockery;
-import org.apache.isis.viewer.wicket.viewer.Fixture_AuthenticationManager_AuthenticateOk;
-import org.apache.isis.viewer.wicket.viewer.Fixture_Request_Stub;
+import org.apache.isis.core.runtime.authentication.AuthenticationRequest;
+import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2;
+import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2.Mode;
 import org.apache.isis.viewer.wicket.viewer.integration.wicket.AuthenticatedWebSessionForIsis;
 import org.apache.wicket.Request;
-import org.jmock.integration.junit4.JMock;
-import org.jmock.lib.legacy.ClassImposteriser;
+import org.jmock.Expectations;
+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 AuthenticatedWebSessionForIsis_SignIn {
 
-    private final FixtureMockery context = new FixtureMockery() {
-        {
-            setImposteriser(ClassImposteriser.INSTANCE);
-        }
-    };
+    @Rule
+    public final JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
 
     private AuthenticatedWebSessionForIsis webSession;
+    @Mock
     private Request stubRequest;
+    @Mock
+    private AuthenticationManager mockAuthMgr;
 
     @Before
     public void setUp() throws Exception {
-        stubRequest = context.fixture(Fixture_Request_Stub.class).object();
+        context.checking(new Expectations() {
+            {
+                // must provide explicit expectation, since Locale is final.
+                allowing(stubRequest).getLocale();
+                will(returnValue(Locale.getDefault()));
+
+                // stub everything else out
+                ignoring(stubRequest);
+            }
+        });
+
     }
 
     @Test
     public void signInJustDelegatesToAuthenticateAndSavesState() {
-        final AuthenticationManager mockAuthMgr =
-            context.fixture(Fixture_AuthenticationManager_AuthenticateOk.class).object();
+        context.checking(new Expectations() {
+            {
+                one(mockAuthMgr).authenticate(with(any(AuthenticationRequest.class)));
+            }
+        });
+
         webSession = new AuthenticatedWebSessionForIsis(stubRequest) {
             private static final long serialVersionUID = 1L;
 

Modified: incubator/isis/trunk/framework/viewer/wicket/wicket-viewer/src/test/java/org/apache/isis/viewer/wicket/viewer/app/wicket/AuthenticatedWebSessionForIsis_ThreadManagement.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/wicket/wicket-viewer/src/test/java/org/apache/isis/viewer/wicket/viewer/app/wicket/AuthenticatedWebSessionForIsis_ThreadManagement.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/app/wicket/AuthenticatedWebSessionForIsis_ThreadManagement.java
(original)
+++ incubator/isis/trunk/framework/viewer/wicket/wicket-viewer/src/test/java/org/apache/isis/viewer/wicket/viewer/app/wicket/AuthenticatedWebSessionForIsis_ThreadManagement.java
Sat Dec 17 14:14:28 2011
@@ -22,31 +22,41 @@ 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.viewer.wicket.viewer.Fixture_Request_Stub;
+import java.util.Locale;
+
+import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2;
+import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2.Mode;
 import org.apache.isis.viewer.wicket.viewer.integration.wicket.AuthenticatedWebSessionForIsis;
 import org.apache.wicket.Request;
-import org.jmock.integration.junit4.JMock;
-import org.jmock.lib.legacy.ClassImposteriser;
+import org.jmock.Expectations;
+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 AuthenticatedWebSessionForIsis_ThreadManagement {
 
-    private final FixtureMockery context = new FixtureMockery() {
-        {
-            setImposteriser(ClassImposteriser.INSTANCE);
-        }
-    };
+    @Rule
+    public final JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
 
     private AuthenticatedWebSessionForIsis webSession;
+    
+    @Mock
     private Request stubRequest;
 
     @Before
     public void setUp() throws Exception {
-        stubRequest = context.fixture(Fixture_Request_Stub.class).object();
+        context.checking(new Expectations() {
+            {
+                // must provide explicit expectation, since Locale is final.
+                allowing(stubRequest).getLocale();
+                will(returnValue(Locale.getDefault()));
+
+                // stub everything else out
+                ignoring(stubRequest);
+            }
+        });
+
         webSession = new AuthenticatedWebSessionForIsis(stubRequest);
     }
 

Modified: incubator/isis/trunk/framework/viewer/wicket/wicket-viewer/src/test/java/org/apache/isis/viewer/wicket/viewer/app/wicket/WebRequestCycleForIsisTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/wicket/wicket-viewer/src/test/java/org/apache/isis/viewer/wicket/viewer/app/wicket/WebRequestCycleForIsisTest.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/app/wicket/WebRequestCycleForIsisTest.java
(original)
+++ incubator/isis/trunk/framework/viewer/wicket/wicket-viewer/src/test/java/org/apache/isis/viewer/wicket/viewer/app/wicket/WebRequestCycleForIsisTest.java
Sat Dec 17 14:14:28 2011
@@ -21,15 +21,29 @@ package org.apache.isis.viewer.wicket.vi
 
 import static org.junit.Assert.fail;
 
-import org.apache.isis.core.testsupport.jmock.AbstractJMockForClassesTest;
+import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2;
+import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2.Mode;
 import org.apache.isis.viewer.wicket.viewer.integration.wicket.WebRequestCycleForIsis;
 import org.apache.wicket.Response;
 import org.apache.wicket.protocol.http.WebApplication;
 import org.apache.wicket.protocol.http.WebRequest;
+import org.jmock.auto.Mock;
 import org.junit.Ignore;
+import org.junit.Rule;
 import org.junit.Test;
 
-public class WebRequestCycleForIsisTest extends AbstractJMockForClassesTest {
+public class WebRequestCycleForIsisTest  {
+
+    @Rule
+    public final JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_ONLY);
+    
+    @Mock
+    private WebRequest mockRequest;
+    @Mock
+    private Response mockResponse;
+
+    @Mock
+    private WebApplication mockApplication;
 
     @Ignore
     @Test
@@ -43,11 +57,10 @@ public class WebRequestCycleForIsisTest 
         fail("Not yet implemented");
     }
 
+    @Ignore
     @Test
     public void testIsisWebRequestCycle() {
-        final WebApplication mockApplication = context.mockAndIgnoreAnyInteraction(WebApplication.class);
-        final WebRequest mockRequest = context.mock(WebRequest.class);
-        final Response mockResponse = context.mock(Response.class);
+        context.ignoring(mockApplication);
         new WebRequestCycleForIsis(mockApplication, mockRequest, mockResponse);
     }
 



Mime
View raw message