Skip to content

Commit

Permalink
added externalContextShouldBeAbleToBeStubbed test
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukas Fryc committed Nov 17, 2011
1 parent 8eec33b commit 7e7019c
Showing 1 changed file with 11 additions and 0 deletions.
@@ -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;

Expand All @@ -9,6 +10,7 @@
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;

public class TestMockExternalContext {

Expand Down Expand Up @@ -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());
}
}

0 comments on commit 7e7019c

Please sign in to comment.