diff --git a/impl/core/src/test/java/management/testclasses/DummyNotificationListener.java b/impl/core/src/test/java/management/testclasses/DummyNotificationListener.java index 7ba3493..94fa38a 100644 --- a/impl/core/src/test/java/management/testclasses/DummyNotificationListener.java +++ b/impl/core/src/test/java/management/testclasses/DummyNotificationListener.java @@ -46,7 +46,7 @@ import br.gov.frameworkdemoiselle.management.ManagementNotificationEvent; import br.gov.frameworkdemoiselle.management.NotificationManager; /** - * Dummy class to test receiving of notifications sent by the {@link NotificationManager} + * Bean class to test receiving of notifications sent by the {@link NotificationManager} * * @author SERPRO * diff --git a/impl/core/src/test/java/management/testclasses/ManagedClassStore.java b/impl/core/src/test/java/management/testclasses/ManagedClassStore.java index 1359014..f6097ab 100644 --- a/impl/core/src/test/java/management/testclasses/ManagedClassStore.java +++ b/impl/core/src/test/java/management/testclasses/ManagedClassStore.java @@ -47,7 +47,7 @@ import br.gov.frameworkdemoiselle.internal.implementation.Management; import br.gov.frameworkdemoiselle.util.Beans; /** - * Dummy class that stores managed types detected by the management bootstrap + * Bean class that stores managed types detected by the management bootstrap * and can read/write properties and invoke operations on them, simulating a management * extension like JMX or SNMP. * diff --git a/impl/core/src/test/java/util/ExceptionsTest.java b/impl/core/src/test/java/util/ExceptionsTest.java deleted file mode 100644 index 5da0052..0000000 --- a/impl/core/src/test/java/util/ExceptionsTest.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * 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 util; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import org.junit.Test; - -import br.gov.frameworkdemoiselle.exception.ApplicationException; -import br.gov.frameworkdemoiselle.util.Exceptions; - -public class ExceptionsTest { - - @Test - public void testIsApplicationException() { - assertTrue(Exceptions.isApplicationException(new MyException())); - assertFalse(Exceptions.isApplicationException(new Exception())); - } - - @Test - public void testHandleRuntimeException() { - try { - Exceptions.handleToRuntimeException(new SomeRuntimeException()); - fail(); - } catch (Throwable t) { - if (!RuntimeException.class.isInstance(t)) { - fail(); - } - } - - try { - Exceptions.handleToRuntimeException(new Exception()); - fail(); - } catch (Throwable t) { - if (!RuntimeException.class.isInstance(t)) { - fail(); - } - } - - } - -} - -@ApplicationException -class MyException extends Exception { - - private static final long serialVersionUID = 1L; -} - -class SomeRuntimeException extends RuntimeException { - - private static final long serialVersionUID = 1L; - -} diff --git a/impl/core/src/test/java/util/ReflectionsTest.java b/impl/core/src/test/java/util/ReflectionsTest.java deleted file mode 100644 index 69284bb..0000000 --- a/impl/core/src/test/java/util/ReflectionsTest.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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 util; - -import static org.junit.Assert.assertEquals; - -import java.lang.reflect.Member; - -import org.junit.Test; - -import br.gov.frameworkdemoiselle.util.Reflections; - -public class ReflectionsTest { - - @Test - public void testGetGenericTypeArgumentClass() { - assertEquals(Long.class, Reflections.getGenericTypeArgument(OtherClass.class, 0)); - assertEquals(String.class, Reflections.getGenericTypeArgument(OtherClass.class, 1)); - } - - @Test - public void testGetGenericTypeArgumentMember() throws SecurityException, NoSuchFieldException { - Member[] members = OtherClass.class.getFields(); - assertEquals(Long.class, Reflections.getGenericTypeArgument(members[0], 0)); - assertEquals(String.class, Reflections.getGenericTypeArgument(members[1], 0)); - } -} - -class SomeClass { - - public void setNumber(final T t) { - - } -} - -class OtherClass extends SomeClass { - - public Class number; - - public Class text; -} diff --git a/impl/core/src/test/java/util/ResourceBundleTest.java b/impl/core/src/test/java/util/ResourceBundleTest.java deleted file mode 100644 index 7eb6953..0000000 --- a/impl/core/src/test/java/util/ResourceBundleTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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 util; - -import static org.junit.Assert.assertEquals; - -import java.util.Locale; - -import org.junit.Before; -import org.junit.Test; - -import br.gov.frameworkdemoiselle.util.ResourceBundle; - -public class ResourceBundleTest { - - private ResourceBundle resourceBundle; - - @Before - public void setUp() throws Exception { - resourceBundle = new ResourceBundle("resourcebundle/resource-bundle", new Locale("pt")); - } - - @Test - public void getString() { - assertEquals("no params", resourceBundle.getString("msgWithoutParams")); - - assertEquals("params: a, b", resourceBundle.getString("msgWithParams", "a", "b")); - - assertEquals("params: {0}, {1}", resourceBundle.getString("msgWithParams")); - } - -} diff --git a/impl/core/src/test/java/util/StringsTest.java b/impl/core/src/test/java/util/StringsTest.java deleted file mode 100644 index 294daa3..0000000 --- a/impl/core/src/test/java/util/StringsTest.java +++ /dev/null @@ -1,202 +0,0 @@ -/* - * 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 util; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -import br.gov.frameworkdemoiselle.annotation.Ignore; -import br.gov.frameworkdemoiselle.util.Strings; - -public class StringsTest { - - @Test - public void getString() { - testEqualsGetString("teste", "teste"); - testEqualsGetString("", ""); - testEqualsGetString(null, null); - testEqualsGetString(null, null, "teste"); - testEqualsGetString("{0}", "teste", "teste"); - testEqualsGetString("teste", "teste", (Object[]) null); - testEqualsGetString("teste {0}", "teste 1", "1"); - testEqualsGetString("{0} teste", "Um teste", "Um"); - testEqualsGetString("{1} testando {0}", "Apenas testando novamente", "novamente", "Apenas"); - testEqualsGetString("{0} testando {1}", "Apenas testando {1}", "Apenas", null); - testEqualsGetString("testando {1} novamente", "testando isto novamente", "aquilo", "isto"); - testEqualsGetString("teste", "teste", "1", "2"); - testEqualsGetString("teste {0}.", "teste \\.", "\\"); - } - - @Test - public void isEmpty() { - assertTrue(Strings.isEmpty(null)); - assertTrue(Strings.isEmpty("")); - assertTrue(Strings.isEmpty(" ")); - assertTrue(Strings.isEmpty(" ")); - - assertFalse(Strings.isEmpty(" _ ")); - assertFalse(Strings.isEmpty(".")); - assertFalse(Strings.isEmpty("null")); - } - - @Test - public void isResourceBundleKeyFormat() { - assertTrue(Strings.isResourceBundleKeyFormat("{x}")); - assertTrue(Strings.isResourceBundleKeyFormat("{.}")); - assertTrue(Strings.isResourceBundleKeyFormat("{*}")); - assertTrue(Strings.isResourceBundleKeyFormat("{$}")); - assertFalse(Strings.isResourceBundleKeyFormat("{}")); - assertFalse(Strings.isResourceBundleKeyFormat("")); - assertFalse(Strings.isResourceBundleKeyFormat(" ")); - assertFalse(Strings.isResourceBundleKeyFormat(null)); - assertFalse(Strings.isResourceBundleKeyFormat("a{a}a")); - assertFalse(Strings.isResourceBundleKeyFormat("a{a}")); - assertFalse(Strings.isResourceBundleKeyFormat("{a}a")); - assertFalse(Strings.isResourceBundleKeyFormat(" {a} ")); - assertFalse(Strings.isResourceBundleKeyFormat("{a")); - assertFalse(Strings.isResourceBundleKeyFormat("a}")); - } - - @Test - public void camelCaseToSymbolSeparated() { - assertEquals(null, Strings.camelCaseToSymbolSeparated(null, null)); - assertEquals(null, Strings.camelCaseToSymbolSeparated(null, ".")); - assertEquals("myvar", Strings.camelCaseToSymbolSeparated("myVar", null)); - assertEquals("myvar", Strings.camelCaseToSymbolSeparated("myVar", "")); - assertEquals("my.var", Strings.camelCaseToSymbolSeparated("myVar", ".")); - assertEquals("my-var", Strings.camelCaseToSymbolSeparated("MyVar", "-")); - assertEquals("my?var?name", Strings.camelCaseToSymbolSeparated("myVarName", "?")); - assertEquals("my___var___name", Strings.camelCaseToSymbolSeparated("myVarName", "___")); - } - - @Test - public void firstToUpper() { - assertNull(Strings.firstToUpper(null)); - assertEquals("", Strings.firstToUpper("")); - assertEquals("A", Strings.firstToUpper("a")); - assertEquals("A", Strings.firstToUpper("A")); - assertEquals("Ab", Strings.firstToUpper("Ab")); - assertEquals("AB", Strings.firstToUpper("AB")); - assertEquals("Ab", Strings.firstToUpper("ab")); - assertEquals("AB", Strings.firstToUpper("aB")); - } - - @Test - public void toStringWhenObjectIsNull() { - assertEquals("", Strings.toString(null)); - } - - @Test - public void classToString() throws SecurityException, NoSuchFieldException { - @SuppressWarnings("unused") - class Test { - - private String name = "myName"; - - private String lastname = "myLastname"; - - private String nullField = null; - - @Ignore - private String ignore = "ignoreMe"; - - } - - String result = Strings.toString(new Test()); - assertTrue(result.contains("Test [name=myName, lastname=myLastname, nullField=null, this")); - } - - private void testEqualsGetString(final String in, final String expected, final Object... params) { - String out = Strings.getString(in, params); - assertEquals(expected, out); - } - - @Test - public void removeBraces() { - assertNull(Strings.removeBraces(null)); - assertEquals("", Strings.removeBraces("")); - assertEquals(" ", Strings.removeBraces(" ")); - assertEquals(" {x} ", Strings.removeBraces(" {x} ")); - assertEquals("{x} ", Strings.removeBraces("{x} ")); - assertEquals(" {x}", Strings.removeBraces(" {x}")); - assertEquals("x", Strings.removeBraces("{x}")); - assertEquals("a b c", Strings.removeBraces("{a b c}")); - assertEquals("{}", Strings.removeBraces("{}")); - assertEquals("{}", Strings.removeBraces("{{}}")); - assertEquals("?", Strings.removeBraces("{?}")); - assertEquals("*", Strings.removeBraces("{*}")); - } - - @Test - public void insertBraces() { - assertNull(Strings.insertBraces(null)); - assertEquals("", Strings.insertBraces("")); - assertEquals(" ", Strings.insertBraces(" ")); - assertEquals("{ x }", Strings.insertBraces(" x ")); - assertEquals("{ {x} }", Strings.insertBraces(" {x} ")); - assertEquals("{{x}", Strings.insertBraces("{x")); - assertEquals("{*}", Strings.insertBraces("*")); - assertEquals("{?}", Strings.insertBraces("?")); - } - - @Test - public void removeCharsWhenStringIsNull() { - assertEquals(null, Strings.removeChars(null, 'a')); - } - - @Test - public void removeCharsWhenStringIsNotNull() { - String string = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus lobortis."; - string = Strings.removeChars(string, 'L', 'l'); - assertEquals(-1, string.indexOf('L')); - assertEquals(-1, string.indexOf('l')); - } - - @Test - public void insertZeros() { - String string = "Lorem ipsum"; - assertEquals("00000", Strings.insertZeros(null, 5)); - assertEquals(string, Strings.insertZeros(string, string.length() - 1)); - assertEquals(string, Strings.insertZeros(string, string.length())); - assertEquals("0" + string, Strings.insertZeros(string, string.length() + 1)); - assertEquals("00" + string, Strings.insertZeros(string, string.length() + 2)); - } -} diff --git a/impl/core/src/test/java/util/beans/BeansTest.java b/impl/core/src/test/java/util/beans/BeansTest.java deleted file mode 100644 index a64ec55..0000000 --- a/impl/core/src/test/java/util/beans/BeansTest.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * 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 util.beans; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; - -import java.util.NoSuchElementException; - -import org.jboss.arquillian.container.test.api.Deployment; -import org.jboss.arquillian.junit.Arquillian; -import org.jboss.shrinkwrap.api.spec.JavaArchive; -import org.junit.Test; -import org.junit.runner.RunWith; - -import test.Tests; -import br.gov.frameworkdemoiselle.DemoiselleException; -import br.gov.frameworkdemoiselle.util.Beans; - -@RunWith(Arquillian.class) -public class BeansTest { - - @Deployment - public static JavaArchive createDeployment() { - JavaArchive deployment = Tests.createDeployment(BeansTest.class); - return deployment; - } - - @Test - public void beanClassAndQualifierTest() { - assertEquals(DummyQualifiedOne.class, - (Beans.getReference(DummyQualified.class, DummyQualifiedOne.class.getAnnotations())).getClass()); - assertEquals(DummyQualifiedTwo.class, - (Beans.getReference(DummyQualified.class, DummyQualifiedTwo.class.getAnnotations())).getClass()); - } - - @Test - public void beanClassAndQualifierExceptionTest() { - try { - Beans.getReference(DummyQualified.class, DummyQualifiedOne.class.getAnnotations()[0], - DummyQualifiedTwo.class.getAnnotations()[0]); - fail(); - } catch (DemoiselleException cause) { - assertEquals(NoSuchElementException.class, cause.getCause().getClass()); - } - } - - @Test - public void beanClassTest() { - assertEquals(DummyImplementation.class, Beans.getReference(Dummy.class).getClass()); - } - - @Test - public void beanClassExceptionTest() { - try { - Beans.getReference(InexistentImplementationInterface.class); - fail(); - } catch (DemoiselleException cause) { - assertEquals(NoSuchElementException.class, cause.getCause().getClass()); - } - } - - @Test - public void beanNameTest() { - assertEquals(DummyEL.class, Beans.getReference("DummyClass").getClass()); - } - - @Test - public void beanNameExceptionTest() { - try { - Beans.getReference("DummyEL"); - fail(); - } catch (DemoiselleException cause) { - assertEquals(NoSuchElementException.class, cause.getCause().getClass()); - } - } -} diff --git a/impl/core/src/test/java/util/beans/Dummy.java b/impl/core/src/test/java/util/beans/Dummy.java deleted file mode 100644 index 054b1dc..0000000 --- a/impl/core/src/test/java/util/beans/Dummy.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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 util.beans; - -public interface Dummy { - - public void dummyMethod(); -} diff --git a/impl/core/src/test/java/util/beans/DummyEL.java b/impl/core/src/test/java/util/beans/DummyEL.java deleted file mode 100644 index 8ed159e..0000000 --- a/impl/core/src/test/java/util/beans/DummyEL.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 util.beans; - -import javax.inject.Named; - -@Named("DummyClass") -public class DummyEL { -} diff --git a/impl/core/src/test/java/util/beans/DummyImplementation.java b/impl/core/src/test/java/util/beans/DummyImplementation.java deleted file mode 100644 index 2b71869..0000000 --- a/impl/core/src/test/java/util/beans/DummyImplementation.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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 util.beans; - -import br.gov.frameworkdemoiselle.annotation.Priority; - -@Priority(value = 1) -public class DummyImplementation implements Dummy { - - @Override - public void dummyMethod() { - } -} diff --git a/impl/core/src/test/java/util/beans/DummyQualified.java b/impl/core/src/test/java/util/beans/DummyQualified.java deleted file mode 100644 index fc30c88..0000000 --- a/impl/core/src/test/java/util/beans/DummyQualified.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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 util.beans; - -public interface DummyQualified { -} diff --git a/impl/core/src/test/java/util/beans/DummyQualifiedOne.java b/impl/core/src/test/java/util/beans/DummyQualifiedOne.java deleted file mode 100644 index 9ec1c5a..0000000 --- a/impl/core/src/test/java/util/beans/DummyQualifiedOne.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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 util.beans; - -import javax.enterprise.inject.Alternative; - -@Alternative -@QualifierOne -public class DummyQualifiedOne implements DummyQualified { -} diff --git a/impl/core/src/test/java/util/beans/DummyQualifiedTwo.java b/impl/core/src/test/java/util/beans/DummyQualifiedTwo.java deleted file mode 100644 index 395927d..0000000 --- a/impl/core/src/test/java/util/beans/DummyQualifiedTwo.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 util.beans; - -@QualifierTwo -public class DummyQualifiedTwo implements DummyQualified{ -} diff --git a/impl/core/src/test/java/util/beans/InexistentImplementationInterface.java b/impl/core/src/test/java/util/beans/InexistentImplementationInterface.java deleted file mode 100644 index 5264bad..0000000 --- a/impl/core/src/test/java/util/beans/InexistentImplementationInterface.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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 util.beans; - -public interface InexistentImplementationInterface { -} diff --git a/impl/core/src/test/java/util/beans/QualifierOne.java b/impl/core/src/test/java/util/beans/QualifierOne.java deleted file mode 100644 index 7e4a06d..0000000 --- a/impl/core/src/test/java/util/beans/QualifierOne.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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 util.beans; - -import static java.lang.annotation.ElementType.FIELD; -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.ElementType.PARAMETER; -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -import javax.inject.Qualifier; - -@Qualifier -@Target({TYPE, METHOD, PARAMETER, FIELD}) -@Retention(RUNTIME) -public @interface QualifierOne { -} diff --git a/impl/core/src/test/java/util/beans/QualifierTwo.java b/impl/core/src/test/java/util/beans/QualifierTwo.java deleted file mode 100644 index 7364bf6..0000000 --- a/impl/core/src/test/java/util/beans/QualifierTwo.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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 util.beans; - -import static java.lang.annotation.ElementType.FIELD; -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.ElementType.PARAMETER; -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -import javax.inject.Qualifier; - -@Qualifier -@Target({TYPE, METHOD, PARAMETER, FIELD}) -@Retention(RUNTIME) -public @interface QualifierTwo { -} \ No newline at end of file diff --git a/impl/core/src/test/java/util/beans/qualifier/QualifiedBean.java b/impl/core/src/test/java/util/beans/qualifier/QualifiedBean.java new file mode 100644 index 0000000..8ca1e14 --- /dev/null +++ b/impl/core/src/test/java/util/beans/qualifier/QualifiedBean.java @@ -0,0 +1,40 @@ +/* + * 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 util.beans.qualifier; + +public interface QualifiedBean { +} diff --git a/impl/core/src/test/java/util/beans/qualifier/QualifiedBeanOne.java b/impl/core/src/test/java/util/beans/qualifier/QualifiedBeanOne.java new file mode 100644 index 0000000..2e232cc --- /dev/null +++ b/impl/core/src/test/java/util/beans/qualifier/QualifiedBeanOne.java @@ -0,0 +1,41 @@ +/* + * 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 util.beans.qualifier; + +@QualifierOne +public class QualifiedBeanOne implements QualifiedBean { +} diff --git a/impl/core/src/test/java/util/beans/qualifier/QualifiedBeanTwo.java b/impl/core/src/test/java/util/beans/qualifier/QualifiedBeanTwo.java new file mode 100644 index 0000000..4ba97d6 --- /dev/null +++ b/impl/core/src/test/java/util/beans/qualifier/QualifiedBeanTwo.java @@ -0,0 +1,41 @@ +/* + * 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 util.beans.qualifier; + +@QualifierTwo +public class QualifiedBeanTwo implements QualifiedBean{ +} diff --git a/impl/core/src/test/java/util/beans/qualifier/QualifiedBeansTest.java b/impl/core/src/test/java/util/beans/qualifier/QualifiedBeansTest.java new file mode 100644 index 0000000..3c4da2b --- /dev/null +++ b/impl/core/src/test/java/util/beans/qualifier/QualifiedBeansTest.java @@ -0,0 +1,81 @@ +/* + * 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 util.beans.qualifier; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +import java.util.NoSuchElementException; + +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.junit.Test; +import org.junit.runner.RunWith; + +import test.Tests; +import br.gov.frameworkdemoiselle.DemoiselleException; +import br.gov.frameworkdemoiselle.util.Beans; + +@RunWith(Arquillian.class) +public class QualifiedBeansTest { + + @Deployment + public static JavaArchive createDeployment() { + JavaArchive deployment = Tests.createDeployment(QualifiedBeansTest.class); + return deployment; + } + + @Test + public void beanClassAndQualifierTest() { + assertEquals(QualifiedBeanOne.class, + (Beans.getReference(QualifiedBean.class, QualifiedBeanOne.class.getAnnotations())).getClass()); + assertEquals(QualifiedBeanTwo.class, + (Beans.getReference(QualifiedBean.class, QualifiedBeanTwo.class.getAnnotations())).getClass()); + } + + @Test + public void beanClassAndQualifierExceptionTest() { + try { + Beans.getReference(QualifiedBean.class, QualifiedBeanOne.class.getAnnotations()[0], + QualifiedBeanTwo.class.getAnnotations()[0]); + fail(); + } catch (DemoiselleException cause) { + assertEquals(NoSuchElementException.class, cause.getCause().getClass()); + } + } +} diff --git a/impl/core/src/test/java/util/beans/qualifier/QualifierOne.java b/impl/core/src/test/java/util/beans/qualifier/QualifierOne.java new file mode 100644 index 0000000..e8cc715 --- /dev/null +++ b/impl/core/src/test/java/util/beans/qualifier/QualifierOne.java @@ -0,0 +1,54 @@ +/* + * 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 util.beans.qualifier; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import javax.inject.Qualifier; + +@Qualifier +@Target({TYPE, METHOD, PARAMETER, FIELD}) +@Retention(RUNTIME) +public @interface QualifierOne { +} diff --git a/impl/core/src/test/java/util/beans/qualifier/QualifierTwo.java b/impl/core/src/test/java/util/beans/qualifier/QualifierTwo.java new file mode 100644 index 0000000..5084391 --- /dev/null +++ b/impl/core/src/test/java/util/beans/qualifier/QualifierTwo.java @@ -0,0 +1,54 @@ +/* + * 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 util.beans.qualifier; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import javax.inject.Qualifier; + +@Qualifier +@Target({TYPE, METHOD, PARAMETER, FIELD}) +@Retention(RUNTIME) +public @interface QualifierTwo { +} \ No newline at end of file diff --git a/impl/core/src/test/java/util/beans/simple/AloneBean.java b/impl/core/src/test/java/util/beans/simple/AloneBean.java new file mode 100644 index 0000000..3701a30 --- /dev/null +++ b/impl/core/src/test/java/util/beans/simple/AloneBean.java @@ -0,0 +1,40 @@ +/* + * 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 util.beans.simple; + +public interface AloneBean { +} diff --git a/impl/core/src/test/java/util/beans/simple/Bean.java b/impl/core/src/test/java/util/beans/simple/Bean.java new file mode 100644 index 0000000..d3e207a --- /dev/null +++ b/impl/core/src/test/java/util/beans/simple/Bean.java @@ -0,0 +1,42 @@ +/* + * 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 util.beans.simple; + +public interface Bean { + + public void dummyMethod(); +} diff --git a/impl/core/src/test/java/util/beans/simple/BeanImpl.java b/impl/core/src/test/java/util/beans/simple/BeanImpl.java new file mode 100644 index 0000000..540f078 --- /dev/null +++ b/impl/core/src/test/java/util/beans/simple/BeanImpl.java @@ -0,0 +1,47 @@ +/* + * 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 util.beans.simple; + +import br.gov.frameworkdemoiselle.annotation.Priority; + +@Priority(value = 1) +public class BeanImpl implements Bean { + + @Override + public void dummyMethod() { + } +} diff --git a/impl/core/src/test/java/util/beans/simple/NamedBean.java b/impl/core/src/test/java/util/beans/simple/NamedBean.java new file mode 100644 index 0000000..744d729 --- /dev/null +++ b/impl/core/src/test/java/util/beans/simple/NamedBean.java @@ -0,0 +1,43 @@ +/* + * 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 util.beans.simple; + +import javax.inject.Named; + +@Named("DummyClass") +public class NamedBean { +} diff --git a/impl/core/src/test/java/util/beans/simple/SimpleBeansTest.java b/impl/core/src/test/java/util/beans/simple/SimpleBeansTest.java new file mode 100644 index 0000000..e3763f3 --- /dev/null +++ b/impl/core/src/test/java/util/beans/simple/SimpleBeansTest.java @@ -0,0 +1,92 @@ +/* + * 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 util.beans.simple; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +import java.util.NoSuchElementException; + +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.junit.Test; +import org.junit.runner.RunWith; + +import test.Tests; +import br.gov.frameworkdemoiselle.DemoiselleException; +import br.gov.frameworkdemoiselle.util.Beans; + +@RunWith(Arquillian.class) +public class SimpleBeansTest { + + @Deployment + public static JavaArchive createDeployment() { + JavaArchive deployment = Tests.createDeployment(SimpleBeansTest.class); + return deployment; + } + + @Test + public void beanClassTest() { + assertEquals(BeanImpl.class, Beans.getReference(Bean.class).getClass()); + } + + @Test + public void beanClassExceptionTest() { + try { + Beans.getReference(AloneBean.class); + fail(); + } catch (DemoiselleException cause) { + assertEquals(NoSuchElementException.class, cause.getCause().getClass()); + } + } + + @Test + public void beanNameTest() { + assertEquals(NamedBean.class, Beans.getReference("DummyClass").getClass()); + } + + @Test + public void beanNameExceptionTest() { + try { + Beans.getReference("NamedBean"); + fail(); + } catch (DemoiselleException cause) { + assertEquals(NoSuchElementException.class, cause.getCause().getClass()); + } + } +} diff --git a/impl/core/src/test/java/util/exception/ExceptionsTest.java b/impl/core/src/test/java/util/exception/ExceptionsTest.java new file mode 100644 index 0000000..e8da804 --- /dev/null +++ b/impl/core/src/test/java/util/exception/ExceptionsTest.java @@ -0,0 +1,90 @@ +/* + * 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 util.exception; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import org.junit.Test; + +import br.gov.frameworkdemoiselle.exception.ApplicationException; +import br.gov.frameworkdemoiselle.util.Exceptions; + +public class ExceptionsTest { + + @Test + public void testIsApplicationException() { + assertTrue(Exceptions.isApplicationException(new MyException())); + assertFalse(Exceptions.isApplicationException(new Exception())); + } + + @Test + public void testHandleRuntimeException() { + try { + Exceptions.handleToRuntimeException(new SomeRuntimeException()); + fail(); + } catch (Throwable t) { + if (!RuntimeException.class.isInstance(t)) { + fail(); + } + } + + try { + Exceptions.handleToRuntimeException(new Exception()); + fail(); + } catch (Throwable t) { + if (!RuntimeException.class.isInstance(t)) { + fail(); + } + } + + } + +} + +@ApplicationException +class MyException extends Exception { + + private static final long serialVersionUID = 1L; +} + +class SomeRuntimeException extends RuntimeException { + + private static final long serialVersionUID = 1L; + +} diff --git a/impl/core/src/test/java/util/reflection/ReflectionsTest.java b/impl/core/src/test/java/util/reflection/ReflectionsTest.java new file mode 100644 index 0000000..3dab853 --- /dev/null +++ b/impl/core/src/test/java/util/reflection/ReflectionsTest.java @@ -0,0 +1,75 @@ +/* + * 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 util.reflection; + +import static org.junit.Assert.assertEquals; + +import java.lang.reflect.Member; + +import org.junit.Test; + +import br.gov.frameworkdemoiselle.util.Reflections; + +public class ReflectionsTest { + + @Test + public void testGetGenericTypeArgumentClass() { + assertEquals(Long.class, Reflections.getGenericTypeArgument(OtherClass.class, 0)); + assertEquals(String.class, Reflections.getGenericTypeArgument(OtherClass.class, 1)); + } + + @Test + public void testGetGenericTypeArgumentMember() throws SecurityException, NoSuchFieldException { + Member[] members = OtherClass.class.getFields(); + assertEquals(Long.class, Reflections.getGenericTypeArgument(members[0], 0)); + assertEquals(String.class, Reflections.getGenericTypeArgument(members[1], 0)); + } +} + +class SomeClass { + + public void setNumber(final T t) { + + } +} + +class OtherClass extends SomeClass { + + public Class number; + + public Class text; +} diff --git a/impl/core/src/test/java/util/resourcebundle/ResourceBundleTest.java b/impl/core/src/test/java/util/resourcebundle/ResourceBundleTest.java new file mode 100644 index 0000000..521d5d0 --- /dev/null +++ b/impl/core/src/test/java/util/resourcebundle/ResourceBundleTest.java @@ -0,0 +1,66 @@ +/* + * 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 util.resourcebundle; + +import static org.junit.Assert.assertEquals; + +import java.util.Locale; + +import org.junit.Before; +import org.junit.Test; + +import br.gov.frameworkdemoiselle.util.ResourceBundle; + +public class ResourceBundleTest { + + private ResourceBundle resourceBundle; + + @Before + public void setUp() throws Exception { + resourceBundle = new ResourceBundle("resourcebundle/resource-bundle", new Locale("pt")); + } + + @Test + public void getString() { + assertEquals("no params", resourceBundle.getString("msgWithoutParams")); + + assertEquals("params: a, b", resourceBundle.getString("msgWithParams", "a", "b")); + + assertEquals("params: {0}, {1}", resourceBundle.getString("msgWithParams")); + } + +} diff --git a/impl/core/src/test/java/util/string/StringsTest.java b/impl/core/src/test/java/util/string/StringsTest.java new file mode 100644 index 0000000..987ea22 --- /dev/null +++ b/impl/core/src/test/java/util/string/StringsTest.java @@ -0,0 +1,202 @@ +/* + * 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 util.string; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +import br.gov.frameworkdemoiselle.annotation.Ignore; +import br.gov.frameworkdemoiselle.util.Strings; + +public class StringsTest { + + @Test + public void getString() { + testEqualsGetString("teste", "teste"); + testEqualsGetString("", ""); + testEqualsGetString(null, null); + testEqualsGetString(null, null, "teste"); + testEqualsGetString("{0}", "teste", "teste"); + testEqualsGetString("teste", "teste", (Object[]) null); + testEqualsGetString("teste {0}", "teste 1", "1"); + testEqualsGetString("{0} teste", "Um teste", "Um"); + testEqualsGetString("{1} testando {0}", "Apenas testando novamente", "novamente", "Apenas"); + testEqualsGetString("{0} testando {1}", "Apenas testando {1}", "Apenas", null); + testEqualsGetString("testando {1} novamente", "testando isto novamente", "aquilo", "isto"); + testEqualsGetString("teste", "teste", "1", "2"); + testEqualsGetString("teste {0}.", "teste \\.", "\\"); + } + + @Test + public void isEmpty() { + assertTrue(Strings.isEmpty(null)); + assertTrue(Strings.isEmpty("")); + assertTrue(Strings.isEmpty(" ")); + assertTrue(Strings.isEmpty(" ")); + + assertFalse(Strings.isEmpty(" _ ")); + assertFalse(Strings.isEmpty(".")); + assertFalse(Strings.isEmpty("null")); + } + + @Test + public void isResourceBundleKeyFormat() { + assertTrue(Strings.isResourceBundleKeyFormat("{x}")); + assertTrue(Strings.isResourceBundleKeyFormat("{.}")); + assertTrue(Strings.isResourceBundleKeyFormat("{*}")); + assertTrue(Strings.isResourceBundleKeyFormat("{$}")); + assertFalse(Strings.isResourceBundleKeyFormat("{}")); + assertFalse(Strings.isResourceBundleKeyFormat("")); + assertFalse(Strings.isResourceBundleKeyFormat(" ")); + assertFalse(Strings.isResourceBundleKeyFormat(null)); + assertFalse(Strings.isResourceBundleKeyFormat("a{a}a")); + assertFalse(Strings.isResourceBundleKeyFormat("a{a}")); + assertFalse(Strings.isResourceBundleKeyFormat("{a}a")); + assertFalse(Strings.isResourceBundleKeyFormat(" {a} ")); + assertFalse(Strings.isResourceBundleKeyFormat("{a")); + assertFalse(Strings.isResourceBundleKeyFormat("a}")); + } + + @Test + public void camelCaseToSymbolSeparated() { + assertEquals(null, Strings.camelCaseToSymbolSeparated(null, null)); + assertEquals(null, Strings.camelCaseToSymbolSeparated(null, ".")); + assertEquals("myvar", Strings.camelCaseToSymbolSeparated("myVar", null)); + assertEquals("myvar", Strings.camelCaseToSymbolSeparated("myVar", "")); + assertEquals("my.var", Strings.camelCaseToSymbolSeparated("myVar", ".")); + assertEquals("my-var", Strings.camelCaseToSymbolSeparated("MyVar", "-")); + assertEquals("my?var?name", Strings.camelCaseToSymbolSeparated("myVarName", "?")); + assertEquals("my___var___name", Strings.camelCaseToSymbolSeparated("myVarName", "___")); + } + + @Test + public void firstToUpper() { + assertNull(Strings.firstToUpper(null)); + assertEquals("", Strings.firstToUpper("")); + assertEquals("A", Strings.firstToUpper("a")); + assertEquals("A", Strings.firstToUpper("A")); + assertEquals("Ab", Strings.firstToUpper("Ab")); + assertEquals("AB", Strings.firstToUpper("AB")); + assertEquals("Ab", Strings.firstToUpper("ab")); + assertEquals("AB", Strings.firstToUpper("aB")); + } + + @Test + public void toStringWhenObjectIsNull() { + assertEquals("", Strings.toString(null)); + } + + @Test + public void classToString() throws SecurityException, NoSuchFieldException { + @SuppressWarnings("unused") + class Test { + + private String name = "myName"; + + private String lastname = "myLastname"; + + private String nullField = null; + + @Ignore + private String ignore = "ignoreMe"; + + } + + String result = Strings.toString(new Test()); + assertTrue(result.contains("Test [name=myName, lastname=myLastname, nullField=null, this")); + } + + private void testEqualsGetString(final String in, final String expected, final Object... params) { + String out = Strings.getString(in, params); + assertEquals(expected, out); + } + + @Test + public void removeBraces() { + assertNull(Strings.removeBraces(null)); + assertEquals("", Strings.removeBraces("")); + assertEquals(" ", Strings.removeBraces(" ")); + assertEquals(" {x} ", Strings.removeBraces(" {x} ")); + assertEquals("{x} ", Strings.removeBraces("{x} ")); + assertEquals(" {x}", Strings.removeBraces(" {x}")); + assertEquals("x", Strings.removeBraces("{x}")); + assertEquals("a b c", Strings.removeBraces("{a b c}")); + assertEquals("{}", Strings.removeBraces("{}")); + assertEquals("{}", Strings.removeBraces("{{}}")); + assertEquals("?", Strings.removeBraces("{?}")); + assertEquals("*", Strings.removeBraces("{*}")); + } + + @Test + public void insertBraces() { + assertNull(Strings.insertBraces(null)); + assertEquals("", Strings.insertBraces("")); + assertEquals(" ", Strings.insertBraces(" ")); + assertEquals("{ x }", Strings.insertBraces(" x ")); + assertEquals("{ {x} }", Strings.insertBraces(" {x} ")); + assertEquals("{{x}", Strings.insertBraces("{x")); + assertEquals("{*}", Strings.insertBraces("*")); + assertEquals("{?}", Strings.insertBraces("?")); + } + + @Test + public void removeCharsWhenStringIsNull() { + assertEquals(null, Strings.removeChars(null, 'a')); + } + + @Test + public void removeCharsWhenStringIsNotNull() { + String string = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus lobortis."; + string = Strings.removeChars(string, 'L', 'l'); + assertEquals(-1, string.indexOf('L')); + assertEquals(-1, string.indexOf('l')); + } + + @Test + public void insertZeros() { + String string = "Lorem ipsum"; + assertEquals("00000", Strings.insertZeros(null, 5)); + assertEquals(string, Strings.insertZeros(string, string.length() - 1)); + assertEquals(string, Strings.insertZeros(string, string.length())); + assertEquals("0" + string, Strings.insertZeros(string, string.length() + 1)); + assertEquals("00" + string, Strings.insertZeros(string, string.length() + 2)); + } +} -- libgit2 0.21.2