diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/DefaultAuthenticatorTest.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/DefaultAuthenticatorTest.java index 6d0eb58..3c58a6d 100644 --- a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/DefaultAuthenticatorTest.java +++ b/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/DefaultAuthenticatorTest.java @@ -1,74 +1,65 @@ -//package br.gov.frameworkdemoiselle.internal.implementation; -// -//import static org.easymock.EasyMock.expect; -//import static org.junit.Assert.assertTrue; -//import static org.powermock.api.easymock.PowerMock.mockStatic; -//import static org.powermock.api.easymock.PowerMock.replay; -// -//import java.util.Locale; -// -//import org.junit.After; -//import org.junit.Before; -//import org.junit.Test; -//import org.junit.runner.RunWith; -//import org.powermock.core.classloader.annotations.PrepareForTest; -//import org.powermock.modules.junit4.PowerMockRunner; -// -//import br.gov.frameworkdemoiselle.DemoiselleException; -//import br.gov.frameworkdemoiselle.util.ResourceBundle; -// -///** -// * @author SERPRO -// * @see DefaultAuthenticator -// */ -//@RunWith(PowerMockRunner.class) -//@PrepareForTest(CoreBundle.class) -//public class DefaultAuthenticatorTest { -// -// private DefaultAuthenticator authenticator; -// -// @Before -// public void setUp() throws Exception { -// authenticator = new DefaultAuthenticator(); -// -// mockStatic(CoreBundle.class); -// -// ResourceBundle bundle = new ResourceBundle("demoiselle-core-bundle", Locale.getDefault()); -// expect(CoreBundle.get()).andReturn(bundle); -// -// replay(CoreBundle.class); -// } -// -// @After -// public void tearDown() { -// authenticator = null; -// } -// -// @Test -// public void testAuthenticate() { -// try { -// authenticator.authenticate(); -// } catch (Exception e) { -// assertTrue(e instanceof DemoiselleException); -// } -// } -// -// @Test -// public void testUnAuthenticate() { -// try { -// authenticator.unAuthenticate(); -// } catch (Exception e) { -// assertTrue(e instanceof DemoiselleException); -// } -// } -// -// @Test -// public void testGetUser() { -// try { -// authenticator.getUser(); -// } catch (Exception e) { -// assertTrue(e instanceof DemoiselleException); -// } -// } -// -//} +package br.gov.frameworkdemoiselle.internal.implementation; + +import static org.easymock.EasyMock.expect; +import static org.junit.Assert.assertTrue; +import static org.powermock.api.easymock.PowerMock.mockStatic; +import static org.powermock.api.easymock.PowerMock.replay; + +import java.util.Locale; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import br.gov.frameworkdemoiselle.DemoiselleException; +import br.gov.frameworkdemoiselle.util.Beans; + +/** + * @author SERPRO + * @see DefaultAuthenticator + */ +@RunWith(PowerMockRunner.class) +@PrepareForTest(Beans.class) +public class DefaultAuthenticatorTest { + + private DefaultAuthenticator authenticator; + + @Before + public void setUp() throws Exception { + authenticator = new DefaultAuthenticator(); + + mockStatic(Beans.class); + + expect(Beans.getReference(Locale.class)).andReturn(Locale.getDefault()); + + replay(Beans.class); + } + + @After + public void tearDown() { + authenticator = null; + } + + @Test + public void testAuthenticate() { + try { + authenticator.authenticate(); + } catch (Exception e) { + assertTrue(e instanceof DemoiselleException); + } + } + + @Test(expected = DemoiselleException.class) + public void testUnAuthenticate() { + authenticator.unAuthenticate(); + } + + @Test(expected = DemoiselleException.class) + public void testGetUser() { + authenticator.getUser(); + } + +} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/DefaultAuthorizerTest.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/DefaultAuthorizerTest.java index 514410a..ff47af5 100644 --- a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/DefaultAuthorizerTest.java +++ b/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/DefaultAuthorizerTest.java @@ -1,65 +1,56 @@ -//package br.gov.frameworkdemoiselle.internal.implementation; -// -//import static org.easymock.EasyMock.expect; -//import static org.junit.Assert.assertTrue; -//import static org.powermock.api.easymock.PowerMock.mockStatic; -//import static org.powermock.api.easymock.PowerMock.replay; -// -//import java.util.Locale; -// -//import org.junit.After; -//import org.junit.Before; -//import org.junit.Test; -//import org.junit.runner.RunWith; -//import org.powermock.core.classloader.annotations.PrepareForTest; -//import org.powermock.modules.junit4.PowerMockRunner; -// -//import br.gov.frameworkdemoiselle.DemoiselleException; -//import br.gov.frameworkdemoiselle.util.ResourceBundle; -// -///** -// * @author SERPRO -// * @see DefaultAuthorizer -// */ -//@RunWith(PowerMockRunner.class) -//@PrepareForTest(CoreBundle.class) -//public class DefaultAuthorizerTest { -// -// private DefaultAuthorizer authorizer; -// -// @Before -// public void setUp() throws Exception { -// authorizer = new DefaultAuthorizer(); -// -// mockStatic(CoreBundle.class); -// -// ResourceBundle bundle = new ResourceBundle("demoiselle-core-bundle", Locale.getDefault()); -// expect(CoreBundle.get()).andReturn(bundle); -// -// replay(CoreBundle.class); -// } -// -// @After -// public void tearDown() { -// authorizer = null; -// } -// -// @Test -// public void testHasRole() { -// try { -// authorizer.hasRole(null); -// } catch (Exception e) { -// assertTrue(e instanceof DemoiselleException); -// } -// } -// -// @Test -// public void testHasPermission() { -// try { -// authorizer.hasPermission(null, null); -// } catch (Exception e) { -// assertTrue(e instanceof DemoiselleException); -// } -// } -// -//} +package br.gov.frameworkdemoiselle.internal.implementation; + +import static org.easymock.EasyMock.expect; +import static org.junit.Assert.assertTrue; +import static org.powermock.api.easymock.PowerMock.mockStatic; +import static org.powermock.api.easymock.PowerMock.replay; + +import java.util.Locale; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import br.gov.frameworkdemoiselle.DemoiselleException; +import br.gov.frameworkdemoiselle.util.Beans; + +/** + * @author SERPRO + * @see DefaultAuthorizer + */ +@RunWith(PowerMockRunner.class) +@PrepareForTest(Beans.class) +public class DefaultAuthorizerTest { + + private DefaultAuthorizer authorizer; + + @Before + public void setUp() throws Exception { + authorizer = new DefaultAuthorizer(); + + mockStatic(Beans.class); + + expect(Beans.getReference(Locale.class)).andReturn(Locale.getDefault()); + + replay(Beans.class); + } + + @After + public void tearDown() { + authorizer = null; + } + + @Test(expected = DemoiselleException.class) + public void testHasRole() { + authorizer.hasRole(null); + } + + @Test(expected = DemoiselleException.class) + public void testHasPermission() { + authorizer.hasPermission(null, null); + } + +} diff --git a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/DefaultTransactionTest.java b/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/DefaultTransactionTest.java index e193096..3bc93ac 100644 --- a/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/DefaultTransactionTest.java +++ b/impl/core/src/test/java/br/gov/frameworkdemoiselle/internal/implementation/DefaultTransactionTest.java @@ -1,136 +1,112 @@ -///* -// * Demoiselle Framework -// * Copyright (C) 2010 SERPRO -// * ---------------------------------------------------------------------------- -// * This file is part of Demoiselle Framework. -// * -// * Demoiselle Framework is free software; you can redistribute it and/or -// * modify it under the terms of the GNU Lesser General Public License version 3 -// * as published by the Free Software Foundation. -// * -// * This program is distributed in the hope that it will be useful, -// * but WITHOUT ANY WARRANTY; without even the implied warranty of -// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// * GNU General Public License for more details. -// * -// * You should have received a copy of the GNU Lesser General Public License version 3 -// * along with this program; if not, see -// * or write to the Free Software Foundation, Inc., 51 Franklin Street, -// * Fifth Floor, Boston, MA 02110-1301, USA. -// * ---------------------------------------------------------------------------- -// * Este arquivo é parte do Framework Demoiselle. -// * -// * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou -// * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação -// * do Software Livre (FSF). -// * -// * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA -// * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou -// * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português -// * para maiores detalhes. -// * -// * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título -// * "LICENCA.txt", junto com esse programa. Se não, acesse -// * ou escreva para a Fundação do Software Livre (FSF) Inc., -// * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. -// */ -//package br.gov.frameworkdemoiselle.internal.implementation; -// -//import static org.easymock.EasyMock.expect; -//import static org.junit.Assert.assertTrue; -//import static org.powermock.api.easymock.PowerMock.mockStatic; -//import static org.powermock.api.easymock.PowerMock.replay; -// -//import java.util.Locale; -// -//import org.junit.After; -//import org.junit.Before; -//import org.junit.Test; -//import org.junit.runner.RunWith; -//import org.powermock.core.classloader.annotations.PrepareForTest; -//import org.powermock.modules.junit4.PowerMockRunner; -// -//import br.gov.frameworkdemoiselle.DemoiselleException; -//import br.gov.frameworkdemoiselle.util.ResourceBundle; -// -///** -// * @author SERPRO -// * @see DefaultTransaction -// */ -//@RunWith(PowerMockRunner.class) -//@PrepareForTest(CoreBundle.class) -//public class DefaultTransactionTest { -// -// private DefaultTransaction tx; -// -// @Before -// public void setUp() throws Exception { -// tx = new DefaultTransaction(); -// -// mockStatic(CoreBundle.class); -// -// ResourceBundle bundle = new ResourceBundle("demoiselle-core-bundle", Locale.getDefault()); -// expect(CoreBundle.get()).andReturn(bundle); -// -// replay(CoreBundle.class); -// } -// -// @After -// public void tearDown() { -// tx = null; -// } -// -// @Test -// public void testBegin() { -// try { -// tx.begin(); -// } catch (Exception e) { -// assertTrue(e instanceof DemoiselleException); -// } -// } -// -// @Test -// public void testCommit() { -// try { -// tx.commit(); -// } catch (Exception e) { -// assertTrue(e instanceof DemoiselleException); -// } -// } -// -// @Test -// public void testIsActive() { -// try { -// tx.isActive(); -// } catch (Exception e) { -// assertTrue(e instanceof DemoiselleException); -// } -// } -// -// @Test -// public void testIsMarkedRollback() { -// try { -// tx.isMarkedRollback(); -// } catch (Exception e) { -// assertTrue(e instanceof DemoiselleException); -// } -// } -// -// @Test -// public void testRollback() { -// try { -// tx.rollback(); -// } catch (Exception e) { -// assertTrue(e instanceof DemoiselleException); -// } -// } -// -// @Test -// public void testSetRollbackOnly() { -// try { -// tx.setRollbackOnly(); -// } catch (Exception e) { -// assertTrue(e instanceof DemoiselleException); -// } -// } -//} +/* + * Demoiselle Framework + * Copyright (C) 2010 SERPRO + * ---------------------------------------------------------------------------- + * This file is part of Demoiselle Framework. + * + * Demoiselle Framework is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License version 3 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License version 3 + * along with this program; if not, see + * or write to the Free Software Foundation, Inc., 51 Franklin Street, + * Fifth Floor, Boston, MA 02110-1301, USA. + * ---------------------------------------------------------------------------- + * Este arquivo é parte do Framework Demoiselle. + * + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação + * do Software Livre (FSF). + * + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português + * para maiores detalhes. + * + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título + * "LICENCA.txt", junto com esse programa. Se não, acesse + * ou escreva para a Fundação do Software Livre (FSF) Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. + */ +package br.gov.frameworkdemoiselle.internal.implementation; + +import static org.easymock.EasyMock.expect; +import static org.junit.Assert.assertTrue; +import static org.powermock.api.easymock.PowerMock.mockStatic; +import static org.powermock.api.easymock.PowerMock.replay; + +import java.util.Locale; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import br.gov.frameworkdemoiselle.DemoiselleException; +import br.gov.frameworkdemoiselle.util.Beans; +import br.gov.frameworkdemoiselle.util.ResourceBundle; + +/** + * @author SERPRO + * @see DefaultTransaction + */ +@RunWith(PowerMockRunner.class) +@PrepareForTest(Beans.class) +public class DefaultTransactionTest { + + private DefaultTransaction tx; + + @Before + public void setUp() throws Exception { + tx = new DefaultTransaction(); + + mockStatic(Beans.class); + + expect(Beans.getReference(Locale.class)).andReturn(Locale.getDefault()); + + replay(Beans.class); + } + + @After + public void tearDown() { + tx = null; + } + + @Test(expected=DemoiselleException.class) + public void testBegin() { + tx.begin(); + } + + @Test(expected=DemoiselleException.class) + public void testCommit() { + tx.commit(); + } + + @Test(expected=DemoiselleException.class) + public void testIsActive() { + tx.isActive(); + } + + @Test(expected=DemoiselleException.class) + public void testIsMarkedRollback() { + tx.isMarkedRollback(); + } + + @Test(expected=DemoiselleException.class) + public void testRollback() { + tx.rollback(); + } + + @Test(expected=DemoiselleException.class) + public void testSetRollbackOnly() { + tx.setRollbackOnly(); + } +} -- libgit2 0.21.2