From 7e7019caafda55538aac6dc1b796cceaef38f14a Mon Sep 17 00:00:00 2001 From: Lukas Fryc Date: Thu, 17 Nov 2011 19:56:55 +0100 Subject: [PATCH] added externalContextShouldBeAbleToBeStubbed test --- .../test/faces/mockito/TestMockExternalContext.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/jsf-mockito/src/test/java/org/jboss/test/faces/mockito/TestMockExternalContext.java b/jsf-mockito/src/test/java/org/jboss/test/faces/mockito/TestMockExternalContext.java index ad923b8..a1ad9d0 100644 --- a/jsf-mockito/src/test/java/org/jboss/test/faces/mockito/TestMockExternalContext.java +++ b/jsf-mockito/src/test/java/org/jboss/test/faces/mockito/TestMockExternalContext.java @@ -1,5 +1,6 @@ package org.jboss.test.faces.mockito; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; @@ -9,6 +10,7 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.mockito.Mockito; public class TestMockExternalContext { @@ -39,4 +41,13 @@ public void testExternalContext() { assertTrue(FacesContext.getCurrentInstance().getExternalContext() instanceof ExternalContext); assertSame(environment.getFacesContext().getExternalContext(), FacesContext.getCurrentInstance().getExternalContext()); } + + @Test + public void externalContextShouldBeAbleToBeStubbed() { + environment.withExternalContext(); + ExternalContext externalContext = environment.getExternalContext(); + Mockito.when(externalContext.getAuthType()).thenReturn("customAuthType"); + + assertEquals("customAuthType", FacesContext.getCurrentInstance().getExternalContext().getAuthType()); + } }