Commit ce8596a5baaa29e194d05a6a7e2a8de721b95cda

Authored by Ednara Oliveira
1 parent cd3a3fef
Exists in master

Refatoração de testes unitários

impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/SecurityConfigTest.java
... ... @@ -5,7 +5,9 @@ import static org.junit.Assert.assertEquals;
5 5 import org.junit.Before;
6 6 import org.junit.Test;
7 7  
8   -
  8 +import br.gov.frameworkdemoiselle.security.Authenticator;
  9 +import br.gov.frameworkdemoiselle.security.Authorizer;
  10 +import br.gov.frameworkdemoiselle.security.User;
9 11  
10 12 public class SecurityConfigTest {
11 13  
... ... @@ -21,4 +23,58 @@ public class SecurityConfigTest {
21 23 assertEquals(true, config.isEnabled());
22 24 }
23 25  
  26 + @Test
  27 + public void testSetEnabled() {
  28 + config.setEnabled(false);
  29 + assertEquals(false, config.isEnabled());
  30 + }
  31 +
  32 + @Test
  33 + public void testSetAuthenticatorClass() {
  34 + Authenticator authenticator = new TestAuthenticator();
  35 + config.setAuthenticatorClass(authenticator.getClass());
  36 + assertEquals("br.gov.frameworkdemoiselle.internal.configuration.TestAuthenticator", config
  37 + .getAuthenticatorClass().getName());
  38 + }
  39 +
  40 + @Test
  41 + public void testSetAuthorizerClass() {
  42 + Authorizer authorizer = new TestAuthorizer();
  43 + config.setAuthorizerClass(authorizer.getClass());
  44 + assertEquals("br.gov.frameworkdemoiselle.internal.configuration.TestAuthorizer", config
  45 + .getAuthorizerClass().getName());
  46 + }
  47 +
24 48 }
  49 +
  50 +class TestAuthenticator implements Authenticator {
  51 +
  52 + private static final long serialVersionUID = 1L;
  53 +
  54 + @Override
  55 + public boolean authenticate() {
  56 + return false;
  57 + }
  58 +
  59 + @Override
  60 + public void unAuthenticate() {
  61 + }
  62 +
  63 + @Override
  64 + public User getUser() {
  65 + return null;
  66 + }
  67 +}
  68 +
  69 +class TestAuthorizer implements Authorizer{
  70 +
  71 + @Override
  72 + public boolean hasRole(String role) {
  73 + return false;
  74 + }
  75 +
  76 + @Override
  77 + public boolean hasPermission(String resource, String operation) {
  78 + return false;
  79 + }
  80 +}
25 81 \ No newline at end of file
... ...
impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/TransactionConfigTest.java 0 → 100644
... ... @@ -0,0 +1,23 @@
  1 +package br.gov.frameworkdemoiselle.internal.configuration;
  2 +
  3 +import junit.framework.Assert;
  4 +
  5 +import org.junit.Before;
  6 +import org.junit.Test;
  7 +
  8 +
  9 +public class TransactionConfigTest {
  10 +
  11 + TransactionConfig transactionConfig;
  12 +
  13 + @Before
  14 + public void setUp() {
  15 + transactionConfig = new TransactionConfig();
  16 + }
  17 +
  18 + @Test
  19 + public void testGetTransactionClass() {
  20 + Assert.assertNull(transactionConfig.getTransactionClass());
  21 + }
  22 +
  23 +}
... ...