From 0633a0ce5c206b83a7a4eb5b4c7e306ede2d69ba Mon Sep 17 00:00:00 2001 From: Cleverson Sacramento Date: Wed, 5 Sep 2012 05:55:32 -0300 Subject: [PATCH] Inclusão do primeiro projeto de exemple para o usuário --- example/.gitignore | 5 +++++ example/initializer/.gitignore | 5 +++++ example/initializer/pom.xml | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ example/initializer/src/main/java/example/Hello.java | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ example/initializer/src/main/resources/META-INF/beans.xml | 40 ++++++++++++++++++++++++++++++++++++++++ example/initializer/src/main/resources/demoiselle.properties | 34 ++++++++++++++++++++++++++++++++++ example/initializer/src/test/java/example/InitializerAdvancedTest.java | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ example/initializer/src/test/java/example/InitializerSimpleTest.java | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ example/initializer/src/test/resources/META-INF/beans.xml | 47 +++++++++++++++++++++++++++++++++++++++++++++++ example/initializer/src/test/resources/log4j.properties | 39 +++++++++++++++++++++++++++++++++++++++ example/pom.xml | 101 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ pom.xml | 1 + 12 files changed, 591 insertions(+), 0 deletions(-) create mode 100755 example/.gitignore create mode 100755 example/initializer/.gitignore create mode 100755 example/initializer/pom.xml create mode 100755 example/initializer/src/main/java/example/Hello.java create mode 100755 example/initializer/src/main/resources/META-INF/beans.xml create mode 100755 example/initializer/src/main/resources/demoiselle.properties create mode 100755 example/initializer/src/test/java/example/InitializerAdvancedTest.java create mode 100755 example/initializer/src/test/java/example/InitializerSimpleTest.java create mode 100755 example/initializer/src/test/resources/META-INF/beans.xml create mode 100755 example/initializer/src/test/resources/log4j.properties create mode 100755 example/pom.xml diff --git a/example/.gitignore b/example/.gitignore new file mode 100755 index 0000000..221c8fc --- /dev/null +++ b/example/.gitignore @@ -0,0 +1,5 @@ +/target +/.project +/.classpath +/.settings +/.externalToolBuilders diff --git a/example/initializer/.gitignore b/example/initializer/.gitignore new file mode 100755 index 0000000..221c8fc --- /dev/null +++ b/example/initializer/.gitignore @@ -0,0 +1,5 @@ +/target +/.project +/.classpath +/.settings +/.externalToolBuilders diff --git a/example/initializer/pom.xml b/example/initializer/pom.xml new file mode 100755 index 0000000..a6d5e93 --- /dev/null +++ b/example/initializer/pom.xml @@ -0,0 +1,74 @@ + + + + 4.0.0 + + demoiselle-framework-initializer-example + jar + + + + + + + br.gov.frameworkdemoiselle + demoiselle-minimal-parent + 2.3.0-RC1-SNAPSHOT + ../../parent/minimal/pom.xml + + + + + org.slf4j + slf4j-log4j12 + test + + + + + + demoiselle.sourceforge.net-release + http://demoiselle.sourceforge.net/repository/release + + + + + 2.3.0-RC1-SNAPSHOT + + diff --git a/example/initializer/src/main/java/example/Hello.java b/example/initializer/src/main/java/example/Hello.java new file mode 100755 index 0000000..80e493a --- /dev/null +++ b/example/initializer/src/main/java/example/Hello.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 example; + +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; +import br.gov.frameworkdemoiselle.lifecycle.Shutdown; + +@ApplicationScoped +public class Hello { + + private List list = new ArrayList(); + + public List getList() { + return list; + } + + public void say() { + list.add("Hello World"); + } + + @Startup + public void load() { + list.add("Startup: Priority Not Defined"); + } + + @Startup + @Priority(MIN_PRIORITY) + public void loadWithMinPriority() { + list.add("Startup: Min Priority"); + } + + @Shutdown + @Priority(1) + public void unload() { + list.add("Shutdown: Priority 1"); + } + + @Shutdown + @Priority(MAX_PRIORITY) + public void unloadWithMaxPriority() { + list.add("Shutdown: Max Priority"); + } +} diff --git a/example/initializer/src/main/resources/META-INF/beans.xml b/example/initializer/src/main/resources/META-INF/beans.xml new file mode 100755 index 0000000..b131cc9 --- /dev/null +++ b/example/initializer/src/main/resources/META-INF/beans.xml @@ -0,0 +1,40 @@ + + + + diff --git a/example/initializer/src/main/resources/demoiselle.properties b/example/initializer/src/main/resources/demoiselle.properties new file mode 100755 index 0000000..2df6d7f --- /dev/null +++ b/example/initializer/src/main/resources/demoiselle.properties @@ -0,0 +1,34 @@ +# 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. \ No newline at end of file diff --git a/example/initializer/src/test/java/example/InitializerAdvancedTest.java b/example/initializer/src/test/java/example/InitializerAdvancedTest.java new file mode 100755 index 0000000..d301120 --- /dev/null +++ b/example/initializer/src/test/java/example/InitializerAdvancedTest.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 example; + +import static junit.framework.Assert.assertEquals; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; + +import br.gov.frameworkdemoiselle.junit.DemoiselleRunner; +import br.gov.frameworkdemoiselle.util.Beans; + +@RunWith(DemoiselleRunner.class) +public class InitializerAdvancedTest { + + private static Hello hello = Beans.getReference(Hello.class); + + private static List expected = new ArrayList(); + + @BeforeClass + public static void beforeClass() { + expected.add("Startup: Priority Not Defined"); + expected.add("Startup: Min Priority"); + + assertEquals(expected, hello.getList()); + } + + @Test + public void enqueueingAfterStartup() { + hello.say(); + expected.add("Hello World"); + + assertEquals(expected, hello.getList()); + } + + @Test + public void enqueueingAfterStartupAgain() { + hello.say(); + expected.add("Hello World"); + + assertEquals(expected, hello.getList()); + } + + @AfterClass + public static void afterClass() { + expected.add("Shutdown: Max Priority"); + expected.add("Shutdown: Priority 1"); + + assertEquals(expected, hello.getList()); + } +} diff --git a/example/initializer/src/test/java/example/InitializerSimpleTest.java b/example/initializer/src/test/java/example/InitializerSimpleTest.java new file mode 100755 index 0000000..cc4126c --- /dev/null +++ b/example/initializer/src/test/java/example/InitializerSimpleTest.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 example; + +import static junit.framework.Assert.assertEquals; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; + +import br.gov.frameworkdemoiselle.junit.DemoiselleRunner; +import br.gov.frameworkdemoiselle.util.Beans; + +@RunWith(DemoiselleRunner.class) +public class InitializerSimpleTest { + + private static Hello hello = Beans.getReference(Hello.class); + + @BeforeClass + public static void beforeClass() { + assertEquals(2, hello.getList().size()); + } + + @Test + public void enqueueingAfterStartup() { + hello.say(); + assertEquals(3, hello.getList().size()); + } + + @AfterClass + public static void afterClass() { + assertEquals(5, hello.getList().size()); + } +} diff --git a/example/initializer/src/test/resources/META-INF/beans.xml b/example/initializer/src/test/resources/META-INF/beans.xml new file mode 100755 index 0000000..b042a89 --- /dev/null +++ b/example/initializer/src/test/resources/META-INF/beans.xml @@ -0,0 +1,47 @@ + + + + + br.gov.frameworkdemoiselle.internal.interceptor.ExceptionHandlerInterceptor + br.gov.frameworkdemoiselle.internal.interceptor.RequiredPermissionInterceptor + br.gov.frameworkdemoiselle.internal.interceptor.RequiredRoleInterceptor + br.gov.frameworkdemoiselle.internal.interceptor.TransactionalInterceptor + br.gov.frameworkdemoiselle.internal.interceptor.ConfigurationInterceptor + + + \ No newline at end of file diff --git a/example/initializer/src/test/resources/log4j.properties b/example/initializer/src/test/resources/log4j.properties new file mode 100755 index 0000000..4505013 --- /dev/null +++ b/example/initializer/src/test/resources/log4j.properties @@ -0,0 +1,39 @@ +# 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. + +log4j.rootLogger=INFO, A1 +log4j.appender.A1=org.apache.log4j.ConsoleAppender +log4j.appender.A1.layout=org.apache.log4j.PatternLayout +log4j.appender.A1.layout.ConversionPattern=%-4r %-5p %c - %m%n diff --git a/example/pom.xml b/example/pom.xml new file mode 100755 index 0000000..b23c47d --- /dev/null +++ b/example/pom.xml @@ -0,0 +1,101 @@ + + + + 4.0.0 + + br.gov.frameworkdemoiselle + demoiselle-framework-example-build + 2.3.0-RC1-SNAPSHOT + pom + + Examples Build Aggregator + Demoiselle Examples Build Aggregator + + + initializer + + + + + + + org.codehaus.mojo + wagon-maven-plugin + + . + true + + + + org.apache.maven.plugins + maven-deploy-plugin + + true + + + + + + + + + + + + + + + + + file://${project.build.directory}/tmp + + + diff --git a/pom.xml b/pom.xml index 0a8a3d5..253874b 100755 --- a/pom.xml +++ b/pom.xml @@ -59,6 +59,7 @@ impl parent archetype + example documentation -- libgit2 0.21.2