[jboss-cvs] JBossAS SVN: r103923 - in projects/embedded: examples and 11 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Apr 13 12:45:59 EDT 2010
Author: ALRubinger
Date: 2010-04-13 12:45:57 -0400 (Tue, 13 Apr 2010)
New Revision: 103923
Added:
projects/embedded/examples/
projects/embedded/examples/trunk/
projects/embedded/examples/trunk/pom.xml
projects/embedded/examples/trunk/src/
projects/embedded/examples/trunk/src/main/
projects/embedded/examples/trunk/src/main/java/
projects/embedded/examples/trunk/src/main/java/org/
projects/embedded/examples/trunk/src/main/java/org/jboss/
projects/embedded/examples/trunk/src/main/java/org/jboss/embedded/
projects/embedded/examples/trunk/src/main/java/org/jboss/embedded/examples/
projects/embedded/examples/trunk/src/main/java/org/jboss/embedded/examples/slsb/
projects/embedded/examples/trunk/src/main/java/org/jboss/embedded/examples/slsb/EchoBean.java
projects/embedded/examples/trunk/src/main/java/org/jboss/embedded/examples/slsb/EchoLocalBusiness.java
projects/embedded/examples/trunk/src/main/resources/
projects/embedded/examples/trunk/src/test/
projects/embedded/examples/trunk/src/test/java/
projects/embedded/examples/trunk/src/test/java/EchoBeanIntegrationTest.java
projects/embedded/examples/trunk/src/test/resources/
Log:
[EMB-89] Start a standalone example for EmbeddedAS
Property changes on: projects/embedded/examples/trunk
___________________________________________________________________
Name: svn:ignore
+ target
.classpath
.project
.settings
eclipse-target
target-eclipse
bin
Added: projects/embedded/examples/trunk/pom.xml
===================================================================
--- projects/embedded/examples/trunk/pom.xml (rev 0)
+++ projects/embedded/examples/trunk/pom.xml 2010-04-13 16:45:57 UTC (rev 103923)
@@ -0,0 +1,186 @@
+<?xml version="1.0" encoding="UTF-8"?>
+ <!--
+ vi:ts=2:sw=2:expandtab:
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <!-- Parent -->
+ <parent>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-parent</artifactId>
+ <version>4</version>
+ </parent>
+
+ <!-- Model Version -->
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- Artifact Configuration -->
+ <groupId>org.jboss.eembedded.examples</groupId>
+ <artifactId>examples-slsb</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <name>JBoss Embedded AS Examples - SLSB</name>
+ <description>Example for EmbeddedAS for testing EJB 3.x Stateless Session Beans</description>
+
+ <!-- Properties -->
+ <properties>
+
+ <version.org.jboss.jbossas>6.0.0-SNAPSHOT</version.org.jboss.jbossas>
+ <JBOSS_HOME>${project.build.directory}/jboss-${version.org.jboss.jbossas}</JBOSS_HOME>
+ <version.junit>4.7</version.junit>
+
+ </properties>
+
+ <build>
+ <plugins>
+ <!-- Compiler -->
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <inherited>true</inherited>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ <showDeprecation>false</showDeprecation>
+ <showWarnings>true</showWarnings>
+ <optimize>true</optimize>
+ <compilerVersion>1.6</compilerVersion>
+ <fork>true</fork>
+ <argLine>-Xmx512M</argLine>
+ <executable>${JAVA_HOME}/bin/javac</executable>
+ </configuration>
+ </plugin>
+
+ <!-- Surefire -->
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <redirectTestOutputToFile>true</redirectTestOutputToFile>
+ <trimStackTrace>false</trimStackTrace>
+ <printSummary>true</printSummary>
+ <includes>
+ <include>**/*UnitTest.java</include>
+ </includes>
+ <forkMode>always</forkMode>
+ </configuration>
+ </plugin>
+ </plugins>
+
+ </build>
+
+ <!-- Dependencies -->
+ <dependencies>
+
+ <!-- org.jboss.jbossas -->
+ <dependency>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-as-depchain</artifactId>
+ <version>${version.org.jboss.jbossas}</version>
+ <type>pom</type>
+ </dependency>
+
+ <!-- JUnit -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${version.junit}</version>
+ </dependency>
+
+ </dependencies>
+
+ <dependencyManagement>
+ <dependencies>
+
+ <!-- org.jboss.jbossas -->
+ <dependency>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-as-depchain</artifactId>
+ <version>${version.org.jboss.jbossas}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+
+ </dependencies>
+
+ </dependencyManagement>
+
+ <profiles>
+ <profile>
+ <id>embedded</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>integration-test</id>
+ <phase>integration-test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+
+ <configuration>
+ <additionalClasspathElements>
+ <additionalClasspathElement>${JBOSS_HOME}/client/jbossws-native-client.jar</additionalClasspathElement>
+ <!--
+ Because jbossweb.sar contains shared web.xml,
+ which must be visible from same CL as
+ TomcatDeployer.class.getClassLoader
+ -->
+ <additionalClasspathElement>${JBOSS_HOME}/server/default/deploy/jbossweb.sar</additionalClasspathElement>
+ </additionalClasspathElements>
+
+ <redirectTestOutputToFile>true</redirectTestOutputToFile>
+ <trimStackTrace>false</trimStackTrace>
+ <printSummary>true</printSummary>
+ <includes>
+ <include>**/*IntegrationTest.java</include>
+ </includes>
+ <forkMode>always</forkMode>
+
+ <!--
+ MaxPermSize Required to bump the space for relective
+ data like classes, methods, etc. EMB-41. Endorsed
+ required for things like WS support (EMB-61)
+ -->
+ <argLine>-Xmx512m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Djava.util.logging.manager=org.jboss.logmanager.LogManager -Djava.endorsed.dirs=${JBOSS_HOME}/lib/endorsed -Djboss.home=${JBOSS_HOME}</argLine>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!-- Get AS and put into "target" -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>unpack</id>
+ <phase>pre-integration-test</phase> <!-- So run before testing -->
+ <goals>
+ <goal>unpack</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-as-distribution</artifactId>
+ <version>${version.org.jboss.jbossas}</version>
+ <type>zip</type>
+ <overWrite>false</overWrite>
+ <outputDirectory>${project.build.directory}</outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+</project>
Added: projects/embedded/examples/trunk/src/main/java/org/jboss/embedded/examples/slsb/EchoBean.java
===================================================================
--- projects/embedded/examples/trunk/src/main/java/org/jboss/embedded/examples/slsb/EchoBean.java (rev 0)
+++ projects/embedded/examples/trunk/src/main/java/org/jboss/embedded/examples/slsb/EchoBean.java 2010-04-13 16:45:57 UTC (rev 103923)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.embedded.examples.slsb;
+
+import javax.ejb.Local;
+import javax.ejb.Stateless;
+
+import org.jboss.ejb3.annotation.LocalBinding;
+
+/**
+ * Stateless Session implementation of {@link EchoLocalBusiness},
+ * an EJB which echos messages from the caller
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+ at Stateless
+ at Local(EchoLocalBusiness.class)
+ at LocalBinding(jndiBinding = EchoLocalBusiness.JNDI_NAME)
+public class EchoBean implements EchoLocalBusiness
+{
+ //-------------------------------------------------------------------------------------||
+ // Required Implementations -----------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * {@inheritDoc}
+ * @see org.jboss.embedded.examples.slsb.EchoLocalBusiness#echo(java.lang.String)
+ */
+ public String echo(final String message)
+ {
+ // Return
+ return message;
+ }
+
+}
Added: projects/embedded/examples/trunk/src/main/java/org/jboss/embedded/examples/slsb/EchoLocalBusiness.java
===================================================================
--- projects/embedded/examples/trunk/src/main/java/org/jboss/embedded/examples/slsb/EchoLocalBusiness.java (rev 0)
+++ projects/embedded/examples/trunk/src/main/java/org/jboss/embedded/examples/slsb/EchoLocalBusiness.java 2010-04-13 16:45:57 UTC (rev 103923)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.embedded.examples.slsb;
+
+/**
+ * Local business interface of an EJB capable of
+ * echoing a specified message
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface EchoLocalBusiness
+{
+ //-------------------------------------------------------------------------------------||
+ // Constants --------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ String JNDI_NAME = "EchoLocalBusiness";
+
+ //-------------------------------------------------------------------------------------||
+ // Contracts --------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Echos back the specified message
+ *
+ * @param The message to return to the caller
+ */
+ String echo(String message);
+}
Added: projects/embedded/examples/trunk/src/test/java/EchoBeanIntegrationTest.java
===================================================================
--- projects/embedded/examples/trunk/src/test/java/EchoBeanIntegrationTest.java (rev 0)
+++ projects/embedded/examples/trunk/src/test/java/EchoBeanIntegrationTest.java 2010-04-13 16:45:57 UTC (rev 103923)
@@ -0,0 +1,154 @@
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import org.jboss.bootstrap.api.lifecycle.LifecycleState;
+import org.jboss.embedded.api.server.JBossASEmbeddedServer;
+import org.jboss.embedded.api.server.JBossASEmbeddedServerFactory;
+import org.jboss.embedded.examples.slsb.EchoBean;
+import org.jboss.embedded.examples.slsb.EchoLocalBusiness;
+import org.jboss.logging.Logger;
+import org.jboss.shrinkwrap.api.Archives;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.
+ */
+
+/**
+ * Test to ensure that the {@link EchoBean}
+ * is working as contracted
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class EchoBeanIntegrationTest
+{
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Logger
+ */
+ private static final Logger log = Logger.getLogger(EchoBeanIntegrationTest.class);
+
+ /**
+ * AS instance
+ */
+ private static JBossASEmbeddedServer server;
+
+ /**
+ * JNDI Context
+ */
+ private static Context jndiContext;
+
+ //-------------------------------------------------------------------------------------||
+ // Instance Members -------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ private JavaArchive deployment;
+
+ //-------------------------------------------------------------------------------------||
+ // Lifecycle --------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Creates and starts the server, setting the JNDI Context
+ */
+ @BeforeClass
+ public static void createAndStartServer() throws Exception
+ {
+ // Will pick up configuration of $JBOSS_HOME from sysprops
+ server = JBossASEmbeddedServerFactory.createServer();
+
+ // Start
+ server.start();
+
+ // Set JNDI Context
+ jndiContext = new InitialContext();
+ }
+
+ /**
+ * Creates and deploys the EJB JAR
+ */
+ @Before
+ public void deploy() throws Exception
+ {
+ deployment = Archives.create("slsb.jar", JavaArchive.class).addClasses(EchoBean.class, EchoLocalBusiness.class);
+ log.info(deployment.toString(true));
+ server.deploy(deployment);
+ }
+
+ /**
+ * Undeploys the EJB
+ * @throws Exception
+ */
+ @After
+ public void undeploy() throws Exception
+ {
+ if (server != null && server.getState().equals(LifecycleState.STARTED))
+ {
+ server.undeploy(deployment);
+ }
+ }
+
+ /**
+ * Brings down the server
+ * @throws Exception
+ */
+ @AfterClass
+ public static void stopServer() throws Exception
+ {
+ if (server != null && server.getState().equals(LifecycleState.STARTED))
+ {
+ server.shutdown();
+ }
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Tests ------------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Ensures the EJB is working as expected
+ */
+ @Test
+ public void testSlsb() throws Exception
+ {
+ // Get a proxy
+ final EchoLocalBusiness slsb = (EchoLocalBusiness) jndiContext.lookup(EchoLocalBusiness.JNDI_NAME);
+
+ // Invoke
+ final String expected = "Testing EmbeddedAS";
+ final String received = slsb.echo(expected);
+
+ // Ensure equal
+ Assert.assertEquals("Expected result was not as received", expected, received);
+ Assert.assertTrue("Expected result was not the same reference as received", expected == received);
+ }
+
+}
More information about the jboss-cvs-commits
mailing list