diff --git a/impl/core/src/test/java/lifecycle/LifecycleClassWithPriority.java b/impl/core/src/test/java/lifecycle/LifecycleClassWithPriority.java deleted file mode 100644 index 8bff24b..0000000 --- a/impl/core/src/test/java/lifecycle/LifecycleClassWithPriority.java +++ /dev/null @@ -1,89 +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 lifecycle; - -import static br.gov.frameworkdemoiselle.annotation.Priority.MAX_PRIORITY; -import static br.gov.frameworkdemoiselle.annotation.Priority.MIN_PRIORITY; - -import java.util.ArrayList; -import java.util.List; - -import javax.enterprise.context.ApplicationScoped; - -import br.gov.frameworkdemoiselle.annotation.Priority; -import br.gov.frameworkdemoiselle.lifecycle.Shutdown; -import br.gov.frameworkdemoiselle.lifecycle.Startup; - -@ApplicationScoped -public class LifecycleClassWithPriority { - - private List priorityStartup = new ArrayList(); - - private List priorityShutdown = new ArrayList(); - - public List getPriorityStartup() { - return priorityStartup; - } - - public List getPriorityShutdown() { - return priorityShutdown; - } - - @Startup - @Priority(MIN_PRIORITY) - public void loadWithMinPriority() { - priorityStartup.add(2); - } - - @Startup - @Priority(MAX_PRIORITY) - public void loadWithMaxPriority() { - priorityStartup.add(1); - } - - @Shutdown - @Priority(MIN_PRIORITY) - public void unloadWithMinPriority() { - priorityShutdown.add(1); - } - - @Shutdown - @Priority(MAX_PRIORITY) - public void unloadWithMaxPriority() { - priorityShutdown.add(2); - } -} diff --git a/impl/core/src/test/java/lifecycle/LifecycleSimple.java b/impl/core/src/test/java/lifecycle/LifecycleSimple.java deleted file mode 100644 index 2eb4c8a..0000000 --- a/impl/core/src/test/java/lifecycle/LifecycleSimple.java +++ /dev/null @@ -1,68 +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 lifecycle; - -import javax.enterprise.context.ApplicationScoped; - -import br.gov.frameworkdemoiselle.lifecycle.Shutdown; -import br.gov.frameworkdemoiselle.lifecycle.Startup; - -@ApplicationScoped -public class LifecycleSimple { - - private boolean startup = false; - - private boolean shutdown = false; - - public boolean isStartup() { - return startup; - } - - public boolean isShutdown() { - return shutdown; - } - - @Startup - public void load() { - startup = true; - } - - @Shutdown - public void unload() { - shutdown = true; - } -} diff --git a/impl/core/src/test/java/lifecycle/LifecycleSimpleTest.java b/impl/core/src/test/java/lifecycle/LifecycleSimpleTest.java deleted file mode 100644 index f93819e..0000000 --- a/impl/core/src/test/java/lifecycle/LifecycleSimpleTest.java +++ /dev/null @@ -1,83 +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 lifecycle; - -import javax.inject.Inject; - -import junit.framework.Assert; - -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.lifecycle.AfterShutdownProccess; -import br.gov.frameworkdemoiselle.lifecycle.AfterStartupProccess; -import br.gov.frameworkdemoiselle.util.Beans; - -@RunWith(Arquillian.class) -public class LifecycleSimpleTest { - - @Inject - private LifecycleSimple simpleClass; - - @Deployment - public static JavaArchive createDeployment() { - JavaArchive deployment = Tests.createDeployment(LifecycleSimpleTest.class); - return deployment; - } - - @Test - public void testStartup() { - Beans.getBeanManager().fireEvent(new AfterStartupProccess() { - }); - - Assert.assertEquals(true, simpleClass.isStartup()); - } - - @Test - public void testShutdown() { - Beans.getBeanManager().fireEvent(new AfterShutdownProccess() { - }); - - Assert.assertEquals(true, simpleClass.isShutdown()); - } - -} - diff --git a/impl/core/src/test/java/lifecycle/LifecycleWithPriorityTest.java b/impl/core/src/test/java/lifecycle/LifecycleWithPriorityTest.java deleted file mode 100644 index c2d400d..0000000 --- a/impl/core/src/test/java/lifecycle/LifecycleWithPriorityTest.java +++ /dev/null @@ -1,91 +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 lifecycle; - -import java.util.ArrayList; -import java.util.List; - -import javax.inject.Inject; - -import junit.framework.Assert; - -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.lifecycle.AfterShutdownProccess; -import br.gov.frameworkdemoiselle.lifecycle.AfterStartupProccess; -import br.gov.frameworkdemoiselle.util.Beans; - -@RunWith(Arquillian.class) -public class LifecycleWithPriorityTest { - - @Inject - private LifecycleClassWithPriority lifecycleClassWithPriority; - - List expected = new ArrayList(); - - @Deployment - public static JavaArchive createDeployment() { - JavaArchive deployment = Tests.createDeployment(LifecycleWithPriorityTest.class); - return deployment; - } - - @Test - public void testStartup() { - Beans.getBeanManager().fireEvent(new AfterStartupProccess() { - }); - expected.add(1); - expected.add(2); - - Assert.assertEquals(expected, lifecycleClassWithPriority.getPriorityStartup()); - } - - @Test - public void testShutdown() { - Beans.getBeanManager().fireEvent(new AfterShutdownProccess() { - }); - expected.clear(); - expected.add(2); - expected.add(1); - - Assert.assertEquals(expected, lifecycleClassWithPriority.getPriorityShutdown()); - } -} diff --git a/impl/core/src/test/java/lifecycle/LifecycleWithoutPriority.java b/impl/core/src/test/java/lifecycle/LifecycleWithoutPriority.java deleted file mode 100644 index 55fc7b3..0000000 --- a/impl/core/src/test/java/lifecycle/LifecycleWithoutPriority.java +++ /dev/null @@ -1,92 +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 lifecycle; - -import java.util.ArrayList; -import java.util.List; - -import javax.enterprise.context.ApplicationScoped; - -import br.gov.frameworkdemoiselle.lifecycle.Shutdown; -import br.gov.frameworkdemoiselle.lifecycle.Startup; - -@ApplicationScoped -public class LifecycleWithoutPriority { - - private List priorityStartup = new ArrayList(); - - private List priorityShutdown = new ArrayList(); - - public List getPriorityStartup() { - return priorityStartup; - } - - public List getPriorityShutdown() { - return priorityShutdown; - } - - @Startup - public void loadWithoutPriorityFirst() { - priorityStartup.add(1); - } - - @Startup - public void loadWithoutPrioritySecond() { - priorityStartup.add(3); - } - - @Startup - public void loadWithoutPriorityThird() { - priorityStartup.add(2); - } - - @Shutdown - public void unloadWithoutPriorityFirst() { - priorityShutdown.add(3); - } - - @Shutdown - public void unloadWithoutPrioritySecond() { - priorityShutdown.add(2); - } - - @Shutdown - public void unloadWithoutPriorityThird() { - priorityShutdown.add(1); - } - -} diff --git a/impl/core/src/test/java/lifecycle/LifecycleWithoutPriorityTest.java b/impl/core/src/test/java/lifecycle/LifecycleWithoutPriorityTest.java deleted file mode 100644 index 58e56ce..0000000 --- a/impl/core/src/test/java/lifecycle/LifecycleWithoutPriorityTest.java +++ /dev/null @@ -1,94 +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 lifecycle; - -import java.util.ArrayList; -import java.util.List; - -import javax.inject.Inject; - -import junit.framework.Assert; - -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.lifecycle.AfterShutdownProccess; -import br.gov.frameworkdemoiselle.lifecycle.AfterStartupProccess; -import br.gov.frameworkdemoiselle.util.Beans; - -@RunWith(Arquillian.class) -public class LifecycleWithoutPriorityTest { - - @Inject - private LifecycleWithoutPriority lifecycleWithoutPriority; - - List expected = new ArrayList(); - - @Deployment - public static JavaArchive createDeployment() { - JavaArchive deployment = Tests.createDeployment(LifecycleWithoutPriorityTest.class); - return deployment; - } - - @Test - public void testStartup() { - Beans.getBeanManager().fireEvent(new AfterStartupProccess() { - }); - expected.add(1); - expected.add(3); - expected.add(2); - - Assert.assertEquals(expected, lifecycleWithoutPriority.getPriorityStartup()); - } - - @Test - public void testShutdown() { - Beans.getBeanManager().fireEvent(new AfterShutdownProccess() { - }); - expected.clear(); - expected.add(3); - expected.add(2); - expected.add(1); - - Assert.assertEquals(expected, lifecycleWithoutPriority.getPriorityShutdown()); - } - -} diff --git a/impl/core/src/test/java/lifecycle/shutdown/priority/ShutdownWithPriority.java b/impl/core/src/test/java/lifecycle/shutdown/priority/ShutdownWithPriority.java new file mode 100644 index 0000000..6b8e764 --- /dev/null +++ b/impl/core/src/test/java/lifecycle/shutdown/priority/ShutdownWithPriority.java @@ -0,0 +1,76 @@ +/* + * 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 lifecycle.shutdown.priority; + +import static br.gov.frameworkdemoiselle.annotation.Priority.MAX_PRIORITY; +import static br.gov.frameworkdemoiselle.annotation.Priority.MIN_PRIORITY; + +import java.util.ArrayList; +import java.util.List; + +import javax.enterprise.context.ApplicationScoped; + +import br.gov.frameworkdemoiselle.annotation.Priority; +import br.gov.frameworkdemoiselle.lifecycle.Shutdown; + +@ApplicationScoped +public class ShutdownWithPriority { + + private List listShutdown = new ArrayList(); + + public List getListShutdown() { + return listShutdown; + } + + @Shutdown + @Priority(MIN_PRIORITY) + public void unloadWithMinPriority() { + listShutdown.add(3); + } + + @Shutdown + @Priority(1) + public void unloadWithPriority1() { + listShutdown.add(2); + } + + @Shutdown + @Priority(MAX_PRIORITY) + public void unloadWithMaxPriority() { + listShutdown.add(1); + } +} diff --git a/impl/core/src/test/java/lifecycle/shutdown/priority/ShutdownWithPriorityTest.java b/impl/core/src/test/java/lifecycle/shutdown/priority/ShutdownWithPriorityTest.java new file mode 100644 index 0000000..f581f01 --- /dev/null +++ b/impl/core/src/test/java/lifecycle/shutdown/priority/ShutdownWithPriorityTest.java @@ -0,0 +1,85 @@ +/* + * 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 lifecycle.shutdown.priority; + +import java.util.ArrayList; +import java.util.List; + +import javax.inject.Inject; + +import junit.framework.Assert; + +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; + +import test.Tests; +import br.gov.frameworkdemoiselle.lifecycle.AfterShutdownProccess; +import br.gov.frameworkdemoiselle.util.Beans; + +@RunWith(Arquillian.class) +public class ShutdownWithPriorityTest { + + @Inject + private ShutdownWithPriority shutdownWithPriority; + + List expected = new ArrayList(); + + @Deployment + public static JavaArchive createDeployment() { + JavaArchive deployment = Tests.createDeployment(ShutdownWithPriorityTest.class); + return deployment; + } + + @Before + public void fireEvent() { + Beans.getBeanManager().fireEvent(new AfterShutdownProccess() { + }); + } + + @Test + public void shutdownWithPriority() { + expected.add(1); + expected.add(2); + expected.add(3); + + Assert.assertEquals(expected, shutdownWithPriority.getListShutdown()); + } +} diff --git a/impl/core/src/test/java/lifecycle/shutdown/simple/ShutdownSimple.java b/impl/core/src/test/java/lifecycle/shutdown/simple/ShutdownSimple.java new file mode 100644 index 0000000..b6a5359 --- /dev/null +++ b/impl/core/src/test/java/lifecycle/shutdown/simple/ShutdownSimple.java @@ -0,0 +1,69 @@ +/* + * 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 lifecycle.shutdown.simple; + +import java.util.ArrayList; +import java.util.List; + +import javax.enterprise.context.ApplicationScoped; + +import br.gov.frameworkdemoiselle.lifecycle.Shutdown; + +@ApplicationScoped +public class ShutdownSimple { + + private List listShutdown = new ArrayList(); + + public List getListShutdown() { + return listShutdown; + } + + @Shutdown + public void unloadWithoutPriorityFirst() { + listShutdown.add(3); + } + + @Shutdown + public void unloadWithoutPrioritySecond() { + listShutdown.add(2); + } + + @Shutdown + public void unloadWithoutPriorityThird() { + listShutdown.add(1); + } +} diff --git a/impl/core/src/test/java/lifecycle/shutdown/simple/ShutdownSimpleTest.java b/impl/core/src/test/java/lifecycle/shutdown/simple/ShutdownSimpleTest.java new file mode 100644 index 0000000..a50ab1b --- /dev/null +++ b/impl/core/src/test/java/lifecycle/shutdown/simple/ShutdownSimpleTest.java @@ -0,0 +1,85 @@ +/* + * 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 lifecycle.shutdown.simple; + +import java.util.ArrayList; +import java.util.List; + +import javax.inject.Inject; + +import junit.framework.Assert; + +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; + +import test.Tests; +import br.gov.frameworkdemoiselle.lifecycle.AfterShutdownProccess; +import br.gov.frameworkdemoiselle.util.Beans; + +@RunWith(Arquillian.class) +public class ShutdownSimpleTest { + + @Inject + private ShutdownSimple shutdownSimple; + + List expected = new ArrayList(); + + @Deployment + public static JavaArchive createDeployment() { + JavaArchive deployment = Tests.createDeployment(ShutdownSimpleTest.class); + return deployment; + } + + @Before + public void fireEvent() { + Beans.getBeanManager().fireEvent(new AfterShutdownProccess() { + }); + } + + @Test + public void testShutdown() { + expected.add(3); + expected.add(2); + expected.add(1); + + Assert.assertEquals(expected, shutdownSimple.getListShutdown()); + } +} diff --git a/impl/core/src/test/java/lifecycle/startup/priority/StartupWithPriority.java b/impl/core/src/test/java/lifecycle/startup/priority/StartupWithPriority.java new file mode 100644 index 0000000..e9c2fa3 --- /dev/null +++ b/impl/core/src/test/java/lifecycle/startup/priority/StartupWithPriority.java @@ -0,0 +1,76 @@ +/* + * 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 lifecycle.startup.priority; + +import static br.gov.frameworkdemoiselle.annotation.Priority.MAX_PRIORITY; +import static br.gov.frameworkdemoiselle.annotation.Priority.MIN_PRIORITY; + +import java.util.ArrayList; +import java.util.List; + +import javax.enterprise.context.ApplicationScoped; + +import br.gov.frameworkdemoiselle.annotation.Priority; +import br.gov.frameworkdemoiselle.lifecycle.Startup; + +@ApplicationScoped +public class StartupWithPriority { + + private List priorityStartup = new ArrayList(); + + public List getPriorityStartup() { + return priorityStartup; + } + + @Startup + @Priority(MIN_PRIORITY) + public void loadWithMinPriority() { + priorityStartup.add(3); + } + + @Startup + @Priority(1) + public void loadWithPriority1() { + priorityStartup.add(2); + } + + @Startup + @Priority(MAX_PRIORITY) + public void loadWithMaxPriority() { + priorityStartup.add(1); + } +} diff --git a/impl/core/src/test/java/lifecycle/startup/priority/StartupWithPriorityTest.java b/impl/core/src/test/java/lifecycle/startup/priority/StartupWithPriorityTest.java new file mode 100644 index 0000000..1ef19ef --- /dev/null +++ b/impl/core/src/test/java/lifecycle/startup/priority/StartupWithPriorityTest.java @@ -0,0 +1,85 @@ +/* + * 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 lifecycle.startup.priority; + +import java.util.ArrayList; +import java.util.List; + +import javax.inject.Inject; + +import junit.framework.Assert; + +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; + +import test.Tests; +import br.gov.frameworkdemoiselle.lifecycle.AfterStartupProccess; +import br.gov.frameworkdemoiselle.util.Beans; + +@RunWith(Arquillian.class) +public class StartupWithPriorityTest { + + @Inject + private StartupWithPriority stratupWithPriority; + + List expected = new ArrayList(); + + @Deployment + public static JavaArchive createDeployment() { + JavaArchive deployment = Tests.createDeployment(StartupWithPriorityTest.class); + return deployment; + } + + @Before + public void fireEvent() { + Beans.getBeanManager().fireEvent(new AfterStartupProccess() { + }); + } + + @Test + public void startupWithPriority() { + expected.add(1); + expected.add(2); + expected.add(3); + + Assert.assertEquals(expected, stratupWithPriority.getPriorityStartup()); + } +} diff --git a/impl/core/src/test/java/lifecycle/startup/simple/StartupSimple.java b/impl/core/src/test/java/lifecycle/startup/simple/StartupSimple.java new file mode 100644 index 0000000..bdcb821 --- /dev/null +++ b/impl/core/src/test/java/lifecycle/startup/simple/StartupSimple.java @@ -0,0 +1,69 @@ +/* + * 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 lifecycle.startup.simple; + +import java.util.ArrayList; +import java.util.List; + +import javax.enterprise.context.ApplicationScoped; + +import br.gov.frameworkdemoiselle.lifecycle.Startup; + +@ApplicationScoped +public class StartupSimple { + + private List listStartup = new ArrayList(); + + public List getListStartup() { + return listStartup; + } + + @Startup + public void loadWithoutPriorityFirst() { + listStartup.add(1); + } + + @Startup + public void loadWithoutPrioritySecond() { + listStartup.add(3); + } + + @Startup + public void loadWithoutPriorityThird() { + listStartup.add(2); + } +} diff --git a/impl/core/src/test/java/lifecycle/startup/simple/StartupSimpleTest.java b/impl/core/src/test/java/lifecycle/startup/simple/StartupSimpleTest.java new file mode 100644 index 0000000..007993e --- /dev/null +++ b/impl/core/src/test/java/lifecycle/startup/simple/StartupSimpleTest.java @@ -0,0 +1,86 @@ +/* + * 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 lifecycle.startup.simple; + +import java.util.ArrayList; +import java.util.List; + +import javax.inject.Inject; + +import junit.framework.Assert; + +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; + +import test.Tests; +import br.gov.frameworkdemoiselle.lifecycle.AfterStartupProccess; +import br.gov.frameworkdemoiselle.util.Beans; + +@RunWith(Arquillian.class) +public class StartupSimpleTest { + + @Inject + private StartupSimple startupSimple; + + List expected = new ArrayList(); + + @Deployment + public static JavaArchive createDeployment() { + JavaArchive deployment = Tests.createDeployment(StartupSimpleTest.class); + return deployment; + } + + @Before + public void fireEvent() { + Beans.getBeanManager().fireEvent(new AfterStartupProccess() { + }); + } + + @Test + public void startup() { + expected.add(1); + expected.add(3); + expected.add(2); + + Assert.assertEquals(expected, startupSimple.getListStartup()); + } +} + -- libgit2 0.21.2