Commit 892df7e69e524baf94f139afb19204abd3a6aabe
1 parent
551723da
Exists in
master
Refatoração da ativação e desativação do contexto
Showing
1 changed file
with
13 additions
and
4 deletions
Show diff stats
impl/core/src/test/java/security/interceptor/loggedin/LoggedInInterceptorTest.java
... | ... | @@ -46,6 +46,8 @@ import javax.inject.Inject; |
46 | 46 | import org.jboss.arquillian.container.test.api.Deployment; |
47 | 47 | import org.jboss.arquillian.junit.Arquillian; |
48 | 48 | import org.jboss.shrinkwrap.api.spec.JavaArchive; |
49 | +import org.junit.After; | |
50 | +import org.junit.Before; | |
49 | 51 | import org.junit.Test; |
50 | 52 | import org.junit.runner.RunWith; |
51 | 53 | |
... | ... | @@ -77,6 +79,12 @@ public class LoggedInInterceptorTest { |
77 | 79 | return deployment; |
78 | 80 | } |
79 | 81 | |
82 | + @Before | |
83 | + public void activeContext(){ | |
84 | + SessionContext ctx = Beans.getReference(SessionContext.class); | |
85 | + ctx.activate(); | |
86 | + } | |
87 | + | |
80 | 88 | @Test |
81 | 89 | public void callProtectedClassAttribNotLogged() { |
82 | 90 | try { |
... | ... | @@ -89,12 +97,13 @@ public class LoggedInInterceptorTest { |
89 | 97 | |
90 | 98 | @Test |
91 | 99 | public void callProtectedClassAttribLogged() { |
92 | - SessionContext ctx = Beans.getReference(SessionContext.class); | |
93 | - ctx.activate(); | |
94 | - | |
95 | 100 | context.login(); |
96 | 101 | protectedClass.getDummyAttrib(); |
97 | - | |
102 | + } | |
103 | + | |
104 | + @After | |
105 | + public void deactiveContext(){ | |
106 | + SessionContext ctx = Beans.getReference(SessionContext.class); | |
98 | 107 | ctx.deactivate(); |
99 | 108 | } |
100 | 109 | } | ... | ... |