[jboss-cvs] JBossAS SVN: r86290 - in projects/ejb3/examples/trunk: firstejb and 3 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Mar 25 03:47:14 EDT 2009
Author: ALRubinger
Date: 2009-03-25 03:47:14 -0400 (Wed, 25 Mar 2009)
New Revision: 86290
Added:
projects/ejb3/examples/trunk/firstejb/src/test/java/org/jboss/ejb3/examples/ch04/firstejb/CalculatorUnitTestCase.java
projects/ejb3/examples/trunk/firstejb/src/test/resources/jndi.properties
projects/ejb3/examples/trunk/firstejb/src/test/resources/log4j.xml
Removed:
projects/ejb3/examples/trunk/firstejb/src/test/java/org/jboss/ejb3/examples/ch04/firstejb/CalculatorTestCase.java
Modified:
projects/ejb3/examples/trunk/build/
projects/ejb3/examples/trunk/build/pom.xml
projects/ejb3/examples/trunk/firstejb/pom.xml
projects/ejb3/examples/trunk/firstejb/src/main/java/org/jboss/ejb3/examples/ch04/firstejb/CalculatorBeanBase.java
projects/ejb3/examples/trunk/firstejb/src/main/java/org/jboss/ejb3/examples/ch04/firstejb/CalculatorLocalHome.java
Log:
Created firstejb Integration Tests, tied into M2 lifecycle
Property changes on: projects/ejb3/examples/trunk/build
___________________________________________________________________
Name: svn:ignore
- target
.settings
.classpath
.project
+ target
.settings
.classpath
.project
bin
Modified: projects/ejb3/examples/trunk/build/pom.xml
===================================================================
--- projects/ejb3/examples/trunk/build/pom.xml 2009-03-25 07:16:55 UTC (rev 86289)
+++ projects/ejb3/examples/trunk/build/pom.xml 2009-03-25 07:47:14 UTC (rev 86290)
@@ -16,8 +16,11 @@
<properties>
<!-- Versioning -->
+
+ <version.junit_junit>4.5</version.junit_junit>
<version.org.jboss.ejb3_jboss-ejb3-api>3.1.0-Alpha1</version.org.jboss.ejb3_jboss-ejb3-api>
- <version.junit_junit>4.5</version.junit_junit>
+ <version.org.jboss.logging_jboss.logging.log4j>2.0.6.GA</version.org.jboss.logging_jboss.logging.log4j>
+ <version.org.jboss.logging_jboss.logging.spi>2.0.5.GA</version.org.jboss.logging_jboss.logging.spi>
</properties>
@@ -56,8 +59,7 @@
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<printSummary>true</printSummary>
<includes>
- <include>**/*TestCase.java</include>
- <include>**/*TestSuite.java</include>
+ <include>**/*UnitTestCase.java</include>
</includes>
<forkMode>always</forkMode>
<argLine>-ea</argLine>
@@ -97,17 +99,31 @@
<dependencies>
<dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${version.junit_junit}</version>
+ </dependency>
+
+ <dependency>
<groupId>org.jboss.ejb3</groupId>
<artifactId>jboss-ejb3-api</artifactId>
<version>${version.org.jboss.ejb3_jboss-ejb3-api}</version>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>${version.junit_junit}</version>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-log4j</artifactId>
+ <version>${version.org.jboss.logging_jboss.logging.log4j}</version>
+ <optional>true</optional>
</dependency>
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-spi</artifactId>
+ <version>${version.org.jboss.logging_jboss.logging.spi}</version>
+ <optional>true</optional>
+ </dependency>
+
</dependencies>
</dependencyManagement>
Modified: projects/ejb3/examples/trunk/firstejb/pom.xml
===================================================================
--- projects/ejb3/examples/trunk/firstejb/pom.xml 2009-03-25 07:16:55 UTC (rev 86289)
+++ projects/ejb3/examples/trunk/firstejb/pom.xml 2009-03-25 07:47:14 UTC (rev 86290)
@@ -13,8 +13,8 @@
<modelVersion>4.0.0</modelVersion>
<!-- Artifact Information -->
- <artifactId>jboss-ejb3-examples-firstejb</artifactId>
- <name>JBoss EJB 3.x Examples - My First EJB</name>
+ <artifactId>jboss-ejb3-examples-ch04-firstejb</artifactId>
+ <name>JBoss EJB 3.x Examples - Chapter 4: Calculator Service EJBs</name>
<description>Example to accompany O'Reilly "Enterprise Java Beans 6th Edition" Chapter 4</description>
<!-- Dependencies -->
@@ -30,6 +30,136 @@
<artifactId>junit</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-log4j</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-spi</artifactId>
+ </dependency>
+
</dependencies>
+ <profiles>
+
+ <profile>
+
+ <!-- Declare the "Integration Test" Profile -->
+ <id>it</id>
+
+ <build>
+
+ <plugins>
+
+ <!--
+
+ Configure Surefire to run in integration-test phase
+ -->
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>surefire-it</id>
+ <phase>integration-test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <skip>false</skip>
+ <!-- Include jbossall-client.jar on the CP -->
+ <additionalClasspathElements>
+ <additionalClasspathElement>${env.JBOSS_HOME}/client/jbossall-client.jar</additionalClasspathElement>
+ </additionalClasspathElements>
+ <redirectTestOutputToFile>true</redirectTestOutputToFile>
+ <printSummary>true</printSummary>
+ <forkMode>always</forkMode>
+ <includes>
+ <include>**/*IntegrationTestCase.java</include>
+ </includes>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!--
+
+ Define the JBossAS Maven Control Plugin
+ -->
+ <plugin>
+
+ <groupId>org.jboss.maven.plugins.jbossas</groupId>
+ <artifactId>maven-jboss-as-control-plugin</artifactId>
+ <version>0.1.0</version>
+
+ <!-- Executions -->
+ <executions>
+
+ <!--
+
+ Start JBossAS with our new configuration
+ -->
+ <execution>
+ <id>start-jbossas</id>
+ <goals>
+ <goal>start</goal>
+ </goals>
+ <phase>pre-integration-test</phase>
+ <configuration>
+ <jvmArgs>
+ <jvmArg>-Xmx512M</jvmArg>
+ </jvmArgs>
+ <serverConfigName>default</serverConfigName>
+ <jboss.test.run>true</jboss.test.run>
+ </configuration>
+ </execution>
+
+ <!--
+
+ Deploy into our custom JBossAS Configuration
+ -->
+ <execution>
+ <id>deploy-test-slsb</id>
+ <goals>
+ <goal>deploy</goal>
+ </goals>
+ <phase>pre-integration-test</phase>
+ <configuration>
+ <serverConfigName>default</serverConfigName>
+ <files>
+ ${project.build.directory}/${project.build.finalName}.${project.packaging}
+ </files>
+ <jboss.test.run>true</jboss.test.run>
+ </configuration>
+ </execution>
+
+ <!--
+
+ Stop JBossAS
+ -->
+ <execution>
+ <id>stop-jbossas</id>
+ <goals>
+ <goal>stop</goal>
+ </goals>
+ <phase>post-integration-test</phase>
+ <configuration>
+ <serverConfigName>default</serverConfigName>
+ <jboss.test.run>true</jboss.test.run>
+ </configuration>
+ </execution>
+
+ </executions>
+
+ </plugin>
+
+ </plugins>
+
+ </build>
+
+ </profile>
+
+ </profiles>
+
</project>
\ No newline at end of file
Modified: projects/ejb3/examples/trunk/firstejb/src/main/java/org/jboss/ejb3/examples/ch04/firstejb/CalculatorBeanBase.java
===================================================================
--- projects/ejb3/examples/trunk/firstejb/src/main/java/org/jboss/ejb3/examples/ch04/firstejb/CalculatorBeanBase.java 2009-03-25 07:16:55 UTC (rev 86289)
+++ projects/ejb3/examples/trunk/firstejb/src/main/java/org/jboss/ejb3/examples/ch04/firstejb/CalculatorBeanBase.java 2009-03-25 07:47:14 UTC (rev 86290)
@@ -22,6 +22,8 @@
package org.jboss.ejb3.examples.ch04.firstejb;
+import org.jboss.logging.Logger;
+
/**
* CalculatorBeanBase
*
@@ -34,27 +36,40 @@
public class CalculatorBeanBase implements CalculatorCommonBusiness
{
// ---------------------------------------------------------------------------||
+ // Class Members -------------------------------------------------------------||
+ // ---------------------------------------------------------------------------||
+
+ /**
+ * Logger
+ */
+ private static final Logger log = Logger.getLogger(CalculatorBeanBase.class);
+
+ // ---------------------------------------------------------------------------||
// Required Implementations --------------------------------------------------||
// ---------------------------------------------------------------------------||
/**
- * Adds all arguments
- *
- * @return The sum of all arguments
+ * {@link CalculatorCommonBusiness#add(int...)}
*/
@Override
public int add(final int... arguments)
{
// Initialize
+ StringBuffer sb = new StringBuffer();
+ sb.append("Adding arguments: ");
int result = 0;
// Add all arguments
for (final int arg : arguments)
{
result += arg;
+ sb.append(arg);
+ sb.append(" ");
}
// Return
+ log.info(sb.toString());
+ log.info("Result: " + result);
return result;
}
Modified: projects/ejb3/examples/trunk/firstejb/src/main/java/org/jboss/ejb3/examples/ch04/firstejb/CalculatorLocalHome.java
===================================================================
--- projects/ejb3/examples/trunk/firstejb/src/main/java/org/jboss/ejb3/examples/ch04/firstejb/CalculatorLocalHome.java 2009-03-25 07:16:55 UTC (rev 86289)
+++ projects/ejb3/examples/trunk/firstejb/src/main/java/org/jboss/ejb3/examples/ch04/firstejb/CalculatorLocalHome.java 2009-03-25 07:47:14 UTC (rev 86290)
@@ -40,7 +40,7 @@
// ---------------------------------------------------------------------------||
/**
- * Returns a reference to a remote component view of the CalculatorEJB
+ * Returns a reference to a local component view of the CalculatorEJB
*/
CalculatorLocal create() throws CreateException;
Deleted: projects/ejb3/examples/trunk/firstejb/src/test/java/org/jboss/ejb3/examples/ch04/firstejb/CalculatorTestCase.java
===================================================================
--- projects/ejb3/examples/trunk/firstejb/src/test/java/org/jboss/ejb3/examples/ch04/firstejb/CalculatorTestCase.java 2009-03-25 07:16:55 UTC (rev 86289)
+++ projects/ejb3/examples/trunk/firstejb/src/test/java/org/jboss/ejb3/examples/ch04/firstejb/CalculatorTestCase.java 2009-03-25 07:47:14 UTC (rev 86290)
@@ -1,76 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.ejb3.examples.ch04.firstejb;
-
-import junit.framework.TestCase;
-
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- * CalculatorTestCase
- *
- * Tests to ensure that the business methods of the CalculatorEJB
- * are working as expected
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-public class CalculatorTestCase
-{
- // ---------------------------------------------------------------------------||
- // Required Implementations --------------------------------------------------||
- // ---------------------------------------------------------------------------||
-
- private static SimpleCalculatorBean calc;
-
- // ---------------------------------------------------------------------------||
- // Lifecycle Methods ---------------------------------------------------------||
- // ---------------------------------------------------------------------------||
-
- @BeforeClass
- public static void beforeClass()
- {
- calc = new SimpleCalculatorBean();
- }
-
- // ---------------------------------------------------------------------------||
- // Tests ---------------------------------------------------------------------||
- // ---------------------------------------------------------------------------||
-
- /**
- * Ensures that the CalculatorEJB adds as expected
- */
- @Test
- public void testAddition()
- {
- // Initialize
- int expectedSum = 10;
-
- // Add
- int actualSum = calc.add(2, 3, 5);
-
- // Test
- TestCase.assertEquals("Addition did not return the expected result", expectedSum, actualSum);
- }
-}
Copied: projects/ejb3/examples/trunk/firstejb/src/test/java/org/jboss/ejb3/examples/ch04/firstejb/CalculatorUnitTestCase.java (from rev 86274, projects/ejb3/examples/trunk/firstejb/src/test/java/org/jboss/ejb3/examples/ch04/firstejb/CalculatorTestCase.java)
===================================================================
--- projects/ejb3/examples/trunk/firstejb/src/test/java/org/jboss/ejb3/examples/ch04/firstejb/CalculatorUnitTestCase.java (rev 0)
+++ projects/ejb3/examples/trunk/firstejb/src/test/java/org/jboss/ejb3/examples/ch04/firstejb/CalculatorUnitTestCase.java 2009-03-25 07:47:14 UTC (rev 86290)
@@ -0,0 +1,103 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.ejb3.examples.ch04.firstejb;
+
+import junit.framework.TestCase;
+
+import org.jboss.logging.Logger;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * CalculatorTestCase
+ *
+ * Tests to ensure that the business methods of the CalculatorEJB
+ * are working as expected
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class CalculatorUnitTestCase
+{
+ // ---------------------------------------------------------------------------||
+ // Class Members -------------------------------------------------------------||
+ // ---------------------------------------------------------------------------||
+
+ /**
+ * Logger
+ */
+ private static final Logger log = Logger.getLogger(CalculatorUnitTestCase.class);
+
+ /**
+ * The POJO instance to test
+ */
+ private static CalculatorCommonBusiness calc;
+
+ // ---------------------------------------------------------------------------||
+ // Lifecycle Methods ---------------------------------------------------------||
+ // ---------------------------------------------------------------------------||
+
+ @BeforeClass
+ public static void beforeClass()
+ {
+ // Make a POJO instance adhering to the
+ // CalculatorCommonBusiness contract
+ calc = new SimpleCalculatorBean();
+ }
+
+ // ---------------------------------------------------------------------------||
+ // Tests ---------------------------------------------------------------------||
+ // ---------------------------------------------------------------------------||
+
+ /**
+ * Ensures that the business logic behind the
+ * CalculatorEJB adds as expected when used
+ * as a pure POJO
+ */
+ @Test
+ public void testAddition()
+ {
+ // Initialize
+ final int[] arguments = new int[]
+ {3, 7, 2};
+ final int expectedSum = 12;
+
+ // Add
+ final int actualSum = calc.add(arguments);
+
+ // Test
+ TestCase.assertEquals("Addition did not return the expected result", expectedSum, actualSum);
+
+ // Log
+ final StringBuffer sb = new StringBuffer();
+ sb.append("Obtained expected result, ");
+ sb.append(actualSum);
+ sb.append(", from arguments: ");
+ for (final int arg : arguments)
+ {
+ sb.append(arg);
+ sb.append(" ");
+ }
+ log.info(sb.toString());
+ }
+}
Property changes on: projects/ejb3/examples/trunk/firstejb/src/test/java/org/jboss/ejb3/examples/ch04/firstejb/CalculatorUnitTestCase.java
___________________________________________________________________
Name: svn:mergeinfo
+
Added: projects/ejb3/examples/trunk/firstejb/src/test/resources/jndi.properties
===================================================================
--- projects/ejb3/examples/trunk/firstejb/src/test/resources/jndi.properties (rev 0)
+++ projects/ejb3/examples/trunk/firstejb/src/test/resources/jndi.properties 2009-03-25 07:47:14 UTC (rev 86290)
@@ -0,0 +1,4 @@
+# JNDI Properties for Remote interaction with JBoss Application Server Naming Service
+java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
+java.naming.provider.url=jnp://localhost:1099
\ No newline at end of file
Added: projects/ejb3/examples/trunk/firstejb/src/test/resources/log4j.xml
===================================================================
--- projects/ejb3/examples/trunk/firstejb/src/test/resources/log4j.xml (rev 0)
+++ projects/ejb3/examples/trunk/firstejb/src/test/resources/log4j.xml 2009-03-25 07:47:14 UTC (rev 86290)
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- Log4j Configuration -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<!-- $Id: log4j.xml 68671 2008-01-08 10:04:25Z wolfc $ -->
+
+<!--
+ | For more configuration infromation and examples see the Jakarta Log4j
+ | website: http://jakarta.apache.org/log4j
+ -->
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+ <!-- ============================== -->
+ <!-- Append messages to the console -->
+ <!-- ============================== -->
+
+ <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out"/>
+ <param name="Threshold" value="INFO"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
+ </layout>
+ </appender>
+
+
+ <!-- ================ -->
+ <!-- Limit categories -->
+ <!-- ================ -->
+
+ <category name="org.jboss.ejb3.examples">
+ <priority value="ALL"/>
+ </category>
+
+ <!-- ======================= -->
+ <!-- Setup the Root category -->
+ <!-- ======================= -->
+
+ <root>
+ <appender-ref ref="CONSOLE"/>
+ </root>
+
+</log4j:configuration>
More information about the jboss-cvs-commits
mailing list