[jboss-cvs] JBossAS SVN: r95051 - in branches/Branch_5_x/testsuite: imports and 17 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Oct 16 16:05:58 EDT 2009


Author: smcgowan at redhat.com
Date: 2009-10-16 16:05:58 -0400 (Fri, 16 Oct 2009)
New Revision: 95051

Added:
   branches/Branch_5_x/testsuite/imports/sections/weld.xml
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/numberguess/
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/numberguess/Game.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/numberguess/Generator.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/numberguess/MaxNumber.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/numberguess/Random.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/test/
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/test/WeldExampleTest.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/test/WeldNumberguessExampleUnitTestCase.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/test/WeldTranslatorExampleUnitTestCase.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/translator/
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/translator/ejb/
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/translator/ejb/.TextTranslator.java.swp
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/translator/ejb/SentenceParser.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/translator/ejb/SentenceTranslator.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/translator/ejb/TextTranslator.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/translator/ejb/Translator.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/translator/ejb/TranslatorController.java
   branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/translator/ejb/TranslatorControllerBean.java
   branches/Branch_5_x/testsuite/src/resources/deployers/weld/
   branches/Branch_5_x/testsuite/src/resources/deployers/weld/numberguess/
   branches/Branch_5_x/testsuite/src/resources/deployers/weld/numberguess/WEB-INF/
   branches/Branch_5_x/testsuite/src/resources/deployers/weld/numberguess/WEB-INF/beans.xml
   branches/Branch_5_x/testsuite/src/resources/deployers/weld/numberguess/WEB-INF/faces-config.xml
   branches/Branch_5_x/testsuite/src/resources/deployers/weld/numberguess/WEB-INF/web.xml
   branches/Branch_5_x/testsuite/src/resources/deployers/weld/numberguess/home.xhtml
   branches/Branch_5_x/testsuite/src/resources/deployers/weld/numberguess/index.html
   branches/Branch_5_x/testsuite/src/resources/deployers/weld/numberguess/template.xhtml
   branches/Branch_5_x/testsuite/src/resources/deployers/weld/translator/
   branches/Branch_5_x/testsuite/src/resources/deployers/weld/translator/ejb/
   branches/Branch_5_x/testsuite/src/resources/deployers/weld/translator/ejb/META-INF/
   branches/Branch_5_x/testsuite/src/resources/deployers/weld/translator/ejb/META-INF/beans.xml
   branches/Branch_5_x/testsuite/src/resources/deployers/weld/translator/war/
   branches/Branch_5_x/testsuite/src/resources/deployers/weld/translator/war/WEB-INF/
   branches/Branch_5_x/testsuite/src/resources/deployers/weld/translator/war/WEB-INF/faces-config.xml
   branches/Branch_5_x/testsuite/src/resources/deployers/weld/translator/war/WEB-INF/lib/
   branches/Branch_5_x/testsuite/src/resources/deployers/weld/translator/war/WEB-INF/lib/el-ri-1.2.jar
   branches/Branch_5_x/testsuite/src/resources/deployers/weld/translator/war/WEB-INF/lib/jsf-facelets-1.1.15.B1.jar
   branches/Branch_5_x/testsuite/src/resources/deployers/weld/translator/war/WEB-INF/web.xml
   branches/Branch_5_x/testsuite/src/resources/deployers/weld/translator/war/home.xhtml
   branches/Branch_5_x/testsuite/src/resources/deployers/weld/translator/war/index.html
   branches/Branch_5_x/testsuite/src/resources/deployers/weld/translator/war/template.xhtml
Modified:
   branches/Branch_5_x/testsuite/build.xml
   branches/Branch_5_x/testsuite/imports/test-jars.xml
Log:
JBAS-7266 - add WELD Integration Tests

Modified: branches/Branch_5_x/testsuite/build.xml
===================================================================
--- branches/Branch_5_x/testsuite/build.xml	2009-10-16 19:26:45 UTC (rev 95050)
+++ branches/Branch_5_x/testsuite/build.xml	2009-10-16 20:05:58 UTC (rev 95051)
@@ -124,6 +124,8 @@
       <path refid="rhino.rhino.classpath"/>
       <path refid="ibm.wsdl4j.classpath"/>
       <path refid="jacorb.jacorb.classpath"/>
+      <path refid="javax.enterprise.classpath"/>
+      <path refid="javax.inject.classpath"/>
       <path refid="jboss.cache.jbosscache.core.classpath"/>
       <path refid="jboss.cache.jbosscache.pojo.classpath"/>
       <path refid="jgroups.jgroups.classpath"/>
@@ -876,7 +878,7 @@
   <patternset id="profileservice.includes">
     <include name="org/jboss/test/profileservice/test/*TestCase.class"/>
   	<include name="org/jboss/test/profileservice/override/test/*TestCase.class"/>
-    <!-- deployers + seam -->
+    <!-- deployers + seam + weld -->
   	<include name="org/jboss/test/deployers/test/*UnitTestCase.class"/>
     <include name="org/jboss/test/deployers/client/test/*UnitTestCase.class"/>
     <include name="org/jboss/test/deployers/ear/test/*UnitTestCase.class"/>
@@ -886,11 +888,12 @@
     <include name="org/jboss/test/deployers/web/test/*UnitTestCase.class"/>
     <include name="org/jboss/test/deployers/jbas2904/test/*UnitTestCase.class"/>
     <include name="org/jboss/test/deployers/seam/test/*UnitTestCase.class"/>
+    <include name="org/jboss/test/deployers/weld/test/*UnitTestCase.class"/>
   </patternset>
   <patternset id="profileservice.excludes">
     <exclude name="org/jboss/test/profileservice/test/*TestCase.class"/>
   	<exclude  name="org/jboss/test/profileservice/override/test/*TestCase.class"/>
-    <!-- deployers + seam -->
+    <!-- deployers + seam + weld -->
   	<exclude name="org/jboss/test/deployers/test/*UnitTestCase.class"/>
     <exclude name="org/jboss/test/deployers/client/test/*UnitTestCase.class"/>
     <exclude name="org/jboss/test/deployers/ear/test/*UnitTestCase.class"/>
@@ -900,6 +903,7 @@
     <exclude name="org/jboss/test/deployers/web/test/*UnitTestCase.class"/>
     <exclude name="org/jboss/test/deployers/jbas2904/test/*UnitTestCase.class"/>
     <exclude name="org/jboss/test/deployers/seam/test/*UnitTestCase.class"/>
+    <exclude name="org/jboss/test/deployers/weld/test/*UnitTestCase.class"/>
   </patternset>
   <patternset id="profileservice.restart.includes">
     <!-- include target for persisted admin changes -->

Added: branches/Branch_5_x/testsuite/imports/sections/weld.xml
===================================================================
--- branches/Branch_5_x/testsuite/imports/sections/weld.xml	                        (rev 0)
+++ branches/Branch_5_x/testsuite/imports/sections/weld.xml	2009-10-16 20:05:58 UTC (rev 95051)
@@ -0,0 +1,59 @@
+<project name="tests-weld-jars">
+
+   <target name="translator" depends="compile">
+      <mkdir dir="${build.lib}" />
+      
+      <jar destfile="${build.lib}/weld-translator.jar">
+         <fileset dir="${build.classes}">
+            <include name="org/jboss/test/deployers/weld/translator/ejb/**"/>
+         </fileset>
+      </jar>
+      
+      <war warfile="${build.lib}/weld-translator.war"
+         webxml="${source.resources}/deployers/weld/translator/war/WEB-INF/web.xml">
+         <webinf dir="${source.resources}/deployers/weld/translator/war/WEB-INF">
+            <include name="faces-config.xml"/>
+            <include name="beans.xml"/>
+            <include name="lib/**"/>
+         </webinf>
+         <fileset dir="${source.resources}/deployers/weld/translator/war/">
+            <include name="home.xhtml"/>
+            <include name="index.html"/>
+            <include name="template.xhtml"/>
+         </fileset>
+      </war>
+      
+      <jar destfile="${build.lib}/weld-translator.ear">
+         <fileset dir="${build.lib}">
+            <include name="weld-translator.jar"/>
+            <include name="weld-translator.war"/>
+         </fileset>
+      </jar>
+   </target>
+   
+   <target name="numberguess" depends="compile">
+      <mkdir dir="${build.lib}" />
+      
+      <war warfile="${build.lib}/weld-numberguess.war"
+         webxml="${source.resources}/deployers/weld/numberguess/WEB-INF/web.xml">
+         <webinf dir="${source.resources}/deployers/weld/numberguess/WEB-INF">
+            <include name="faces-config.xml"/>
+            <include name="beans.xml"/>
+         </webinf>
+         <classes dir="${build.classes}">
+            <include name="org/jboss/test/deployers/weld/numberguess/**"/>
+         </classes>
+         <fileset dir="${source.resources}/deployers/weld/numberguess/">
+            <include name="home.xhtml"/>
+            <include name="index.html"/>
+            <include name="template.xhtml"/>
+         </fileset>
+      </war>
+
+   </target>
+
+   <target name="_jars-weld" depends="numberguess, translator">
+      <mkdir dir="${build.lib}" />
+   </target>
+  
+</project>

Modified: branches/Branch_5_x/testsuite/imports/test-jars.xml
===================================================================
--- branches/Branch_5_x/testsuite/imports/test-jars.xml	2009-10-16 19:26:45 UTC (rev 95050)
+++ branches/Branch_5_x/testsuite/imports/test-jars.xml	2009-10-16 20:05:58 UTC (rev 95051)
@@ -78,6 +78,7 @@
    <import file="sections/tx.xml"/>
    <import file="sections/util.xml"/>
    <import file="sections/web.xml"/>
+   <import file="sections/weld.xml"/>
    <import file="sections/webservice.xml"/>
    <import file="sections/ws.xml"/>
    <import file="sections/xa.xml"/>
@@ -175,6 +176,7 @@
         _jars-txtimer,
         _jars-util,
         _jars-web,
+        _jars-weld,
         _jars-webservice,
         _jars-ws,
         _jars-xa,

Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/numberguess/Game.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/numberguess/Game.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/numberguess/Game.java	2009-10-16 20:05:58 UTC (rev 95051)
@@ -0,0 +1,114 @@
+package org.jboss.test.deployers.weld.numberguess;
+
+
+import java.io.Serializable;
+
+import javax.inject.Named;
+import javax.inject.Inject;
+import javax.annotation.PostConstruct;
+import javax.enterprise.context.SessionScoped;
+import javax.enterprise.inject.Instance;
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIInput;
+import javax.faces.context.FacesContext;
+
+ at Named
+ at SessionScoped
+public class Game implements Serializable
+{
+   private int number;
+   private int guess;
+   private int smallest;
+   
+   @MaxNumber @Inject
+   private int maxNumber;
+   
+   private int biggest;
+   private int remainingGuesses;
+   
+   @Random @Inject Instance<Integer> randomNumber;
+   
+   public Game()
+   {
+   }
+
+   public int getNumber()
+   {
+      return number;
+   }
+   
+   public int getGuess()
+   {
+      return guess;
+   }
+   
+   public void setGuess(int guess)
+   {
+      this.guess = guess;
+   }
+   
+   public int getSmallest()
+   {
+      return smallest;
+   }
+   
+   public int getBiggest()
+   {
+      return biggest;
+   }
+   
+   public int getRemainingGuesses()
+   {
+      return remainingGuesses;
+   }
+   
+   public String check() throws InterruptedException
+   {
+      if (guess>number)
+      {
+         biggest = guess - 1;
+      }
+      if (guess<number)
+      {
+         smallest = guess + 1;
+      }
+      if (guess == number)
+      {
+         FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Correct!"));
+      }
+      remainingGuesses--;
+      return null;
+   }
+   
+   @PostConstruct
+   public void reset()
+   {
+      this.smallest = 0;
+      this.guess = 0;
+      this.remainingGuesses = 10;
+      this.biggest = maxNumber;
+      this.number = randomNumber.get();
+   }
+   
+   public void validateNumberRange(FacesContext context,  UIComponent toValidate, Object value)
+   {
+      int input = (Integer) value;
+
+      if (remainingGuesses <= 0)
+      {
+     	FacesMessage message = new FacesMessage("No guesses left!");
+     	context.addMessage(toValidate.getClientId(context), message);
+     	((UIInput)toValidate).setValid(false);
+     	return;
+      }
+
+      if (input < smallest || input > biggest) 
+      {
+	((UIInput)toValidate).setValid(false);
+
+	FacesMessage message = new FacesMessage("Invalid guess");
+	context.addMessage(toValidate.getClientId(context), message);
+      }
+   }
+}

Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/numberguess/Generator.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/numberguess/Generator.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/numberguess/Generator.java	2009-10-16 20:05:58 UTC (rev 95051)
@@ -0,0 +1,33 @@
+package org.jboss.test.deployers.weld.numberguess;
+
+
+import java.io.Serializable;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Produces;
+
+ at ApplicationScoped
+public class Generator implements Serializable 
+{
+   
+   private static final long serialVersionUID = -7213673465118041882L;
+
+   private java.util.Random random = new java.util.Random( System.currentTimeMillis() );
+   
+   private int maxNumber = 100;
+   
+   java.util.Random getRandom()
+   {
+      return random;
+   }
+   
+   @Produces @Random int next() { 
+      return getRandom().nextInt(maxNumber); 
+   }
+   
+   @Produces @MaxNumber int getMaxNumber()
+   {
+      return maxNumber;
+   }
+
+} 

Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/numberguess/MaxNumber.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/numberguess/MaxNumber.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/numberguess/MaxNumber.java	2009-10-16 20:05:58 UTC (rev 95051)
@@ -0,0 +1,23 @@
+package org.jboss.test.deployers.weld.numberguess;
+
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+ at Target( { TYPE, METHOD, PARAMETER, FIELD })
+ at Retention(RUNTIME)
+ at Documented
+ at Qualifier
+public @interface MaxNumber
+{
+
+}

Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/numberguess/Random.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/numberguess/Random.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/numberguess/Random.java	2009-10-16 20:05:58 UTC (rev 95051)
@@ -0,0 +1,23 @@
+package org.jboss.test.deployers.weld.numberguess;
+
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+ at Target( { TYPE, METHOD, PARAMETER, FIELD })
+ at Retention(RUNTIME)
+ at Documented
+ at Qualifier
+public @interface Random
+{
+
+}

Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/test/WeldExampleTest.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/test/WeldExampleTest.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/test/WeldExampleTest.java	2009-10-16 20:05:58 UTC (rev 95051)
@@ -0,0 +1,199 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.test.deployers.weld.test;
+
+import java.net.URL;
+import java.util.HashSet;
+import java.util.Set;
+
+import junit.framework.Test;
+import org.jboss.test.deployers.AbstractDeploymentTest;
+import org.jboss.test.util.web.HttpUtils;
+
+/**
+ * Test WELD Examples
+*/
+
+public abstract class WeldExampleTest extends AbstractDeploymentTest
+{
+   // Example libs
+   public static final String WB = "weld-";
+   public static final String simpleName = "weld-%1$s";
+   public static final String exampleName = simpleName;
+   public static final String exampleEar = exampleName + ".ear";
+   public static final String exampleJar = exampleName + ".jar";
+   public static final String exampleWar = exampleName + ".war";
+   public static final String exampleDS = exampleName + "-ds.xml";
+
+
+   protected enum Type
+   {
+      EAR(exampleEar),
+      JAR(exampleJar),
+      WAR(exampleWar);
+
+      private String format;
+
+      Type(String format)
+      {
+         this.format = format;
+      }
+
+      public String getFormat()
+      {
+         return format;
+      }
+   }
+
+   private boolean testExpected;
+   private boolean useAuthentification;
+   private String username;
+   private String password;
+
+   protected WeldExampleTest(String test)
+   {
+      super(test);
+   }
+
+   protected static Test deploy(Class clazz) throws Exception
+   {
+      return deploy(clazz, true);
+   }
+
+   protected static Test deploy(Class clazz, boolean includeDS) throws Exception
+   {
+      return deploy(clazz, includeDS, Type.EAR);
+   }
+
+   protected static Test deploy(Class clazz, boolean includeDS, Type type) throws Exception
+   {
+      String name = getExampleName(clazz);
+      String deployments = String.format(type.getFormat(), name);
+      return getManagedDeployment(clazz, deployments);
+   }
+
+   protected static String getExampleName(Class clazz)
+  {
+      String className = clazz.getSimpleName();
+      int start = "Weld".length();
+      int end = "ExampleUnitTestCase".length();
+      int length = className.length();
+      return className.substring(start, length - end).toLowerCase();
+   }
+
+   /**
+    * Return type.
+    * Use EAR by default.
+    *
+    * @return
+    */
+   protected Type getType()
+   {
+      return Type.EAR;
+   }
+
+   protected String getExampleName()
+   {
+      return getExampleName(getClass());
+   }
+
+   protected String getTopLevelDeployment(String exampleName)
+   {
+      return String.format(getType().getFormat(), exampleName);
+   }
+
+   public void testExample() throws Exception
+   {
+      String exampleName = getExampleName();
+      log.info("Testing Weld " + exampleName + " example.");
+      String topLevelDeployment = getTopLevelDeployment(exampleName);
+   
+      assertTrue(isDeployed(topLevelDeployment));
+   
+      if (testExpected)
+      {
+         final Set<String> expected = getExpectedDeployments(topLevelDeployment, exampleName);
+         assertDeployed(topLevelDeployment, expected);
+      }
+
+      URL testURL = getBaseURL();
+      log.info("Accessing test URL: " + testURL);
+      HttpUtils.accessURL(testURL);
+   }
+
+   protected String getBaseURLString()
+   {
+      if (useAuthentification)
+      {
+         if (username != null && password != null)
+            return HttpUtils.getBaseURL(username, password);
+         else
+            return HttpUtils.getBaseURL();
+      }
+      return HttpUtils.getBaseURLNoAuth();
+   }
+
+   protected String getWebContextFormat()
+   {
+      return simpleName;
+   }
+
+   protected String getWebContextName()
+   {
+      return String.format(getWebContextFormat(), getExampleName());
+   }
+
+   protected URL getBaseURL() throws Exception
+   {
+      String example = getWebContextName();
+      return new URL(getBaseURLString() + example);
+   }
+
+   protected Set<String> getExpectedDeployments(String topLevelDeployment, String exampleName)
+   {
+      final Set<String> expected = new HashSet<String>();
+      expected.add(topLevelDeployment);
+      expected.add(String.format(exampleJar, exampleName));
+      expected.add(String.format(exampleWar, exampleName));
+      return expected;
+   }
+
+   public void setTestExpected(boolean testExpected)
+   {
+      this.testExpected = testExpected;
+   }
+
+   public void setUseAuthentification(boolean useAuthentification)
+   {
+      this.useAuthentification = useAuthentification;
+   }
+
+   public void setUsername(String username)
+   {
+      this.username = username;
+   }
+
+   public void setPassword(String password)
+   {
+      this.password = password;
+   }
+}

Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/test/WeldNumberguessExampleUnitTestCase.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/test/WeldNumberguessExampleUnitTestCase.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/test/WeldNumberguessExampleUnitTestCase.java	2009-10-16 20:05:58 UTC (rev 95051)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.test.deployers.weld.test;
+
+import junit.framework.Test;
+
+/**
+ * Test WELD Numberguess example.
+ *
+ */
+public class WeldNumberguessExampleUnitTestCase extends WeldExampleTest
+{
+   public WeldNumberguessExampleUnitTestCase(String test)
+   {
+      super(test);
+   }
+
+   public static Test suite() throws Exception
+   {
+      return deploy(WeldNumberguessExampleUnitTestCase.class, false, Type.WAR);
+   }
+
+   protected Type getType()
+   {
+      return Type.WAR;
+   }
+
+   protected String getWebContextFormat()
+   {
+      return exampleName;
+   }
+
+}
+

Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/test/WeldTranslatorExampleUnitTestCase.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/test/WeldTranslatorExampleUnitTestCase.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/test/WeldTranslatorExampleUnitTestCase.java	2009-10-16 20:05:58 UTC (rev 95051)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.test.deployers.weld.test;
+
+import junit.framework.Test;
+
+/**
+ * Test WELD Translator example.
+ *
+ */
+public class WeldTranslatorExampleUnitTestCase extends WeldExampleTest
+{
+   public WeldTranslatorExampleUnitTestCase(String test)
+   {
+      super(test);
+      setTestExpected(true);
+   }
+
+   public static Test suite() throws Exception
+   {
+      return deploy(WeldTranslatorExampleUnitTestCase.class, false);
+   }
+}
+

Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/translator/ejb/.TextTranslator.java.swp
===================================================================
(Binary files differ)


Property changes on: branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/translator/ejb/.TextTranslator.java.swp
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/translator/ejb/SentenceParser.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/translator/ejb/SentenceParser.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/translator/ejb/SentenceParser.java	2009-10-16 20:05:58 UTC (rev 95051)
@@ -0,0 +1,14 @@
+package org.jboss.test.deployers.weld.translator.ejb;
+
+import java.util.Arrays;
+import java.util.List;
+
+public class SentenceParser  
+{ 
+   
+   public List<String> parse(String text) 
+   {
+      return Arrays.asList( text.split("[.?]") );
+   }
+   
+} 

Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/translator/ejb/SentenceTranslator.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/translator/ejb/SentenceTranslator.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/translator/ejb/SentenceTranslator.java	2009-10-16 20:05:58 UTC (rev 95051)
@@ -0,0 +1,15 @@
+package org.jboss.test.deployers.weld.translator.ejb;
+
+
+import javax.ejb.Stateless;
+
+ at Stateless
+public class SentenceTranslator implements Translator 
+{ 
+   
+   public String translate(String sentence) 
+   { 
+      return "Lorem ipsum dolor sit amet"; 
+   }
+   
+}

Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/translator/ejb/TextTranslator.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/translator/ejb/TextTranslator.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/translator/ejb/TextTranslator.java	2009-10-16 20:05:58 UTC (rev 95051)
@@ -0,0 +1,31 @@
+package org.jboss.test.deployers.weld.translator.ejb;
+
+
+import java.io.Serializable;
+
+import javax.ejb.EJB;
+import javax.inject.Inject;
+
+public class TextTranslator implements Serializable
+{ 
+   private SentenceParser sentenceParser; 
+   
+   @EJB Translator translator;
+   
+   @Inject
+   TextTranslator(SentenceParser sentenceParser) 
+   { 
+      this.sentenceParser = sentenceParser;  
+   }
+   
+   public String translate(String text) 
+   { 
+      StringBuilder sb = new StringBuilder(); 
+      for (String sentence: sentenceParser.parse(text)) 
+      { 
+         sb.append(translator.translate(sentence)).append(". "); 
+      } 
+      return sb.toString().trim(); 
+   }
+   
+}

Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/translator/ejb/Translator.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/translator/ejb/Translator.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/translator/ejb/Translator.java	2009-10-16 20:05:58 UTC (rev 95051)
@@ -0,0 +1,12 @@
+package org.jboss.test.deployers.weld.translator.ejb;
+
+
+import javax.ejb.Local;
+
+ at Local 
+public interface Translator 
+{ 
+
+   public String translate(String sentence);
+   
+}

Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/translator/ejb/TranslatorController.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/translator/ejb/TranslatorController.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/translator/ejb/TranslatorController.java	2009-10-16 20:05:58 UTC (rev 95051)
@@ -0,0 +1,17 @@
+package org.jboss.test.deployers.weld.translator.ejb;
+
+
+public interface TranslatorController
+{
+   
+   public String getText();
+   
+   public void setText(String text);
+   
+   public void translate();
+   
+   public String getTranslatedText();
+   
+   public void remove();
+   
+}

Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/translator/ejb/TranslatorControllerBean.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/translator/ejb/TranslatorControllerBean.java	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/weld/translator/ejb/TranslatorControllerBean.java	2009-10-16 20:05:58 UTC (rev 95051)
@@ -0,0 +1,47 @@
+package org.jboss.test.deployers.weld.translator.ejb;
+
+import javax.inject.Named;
+import javax.enterprise.context.RequestScoped;
+import javax.ejb.Remove;
+import javax.ejb.Stateful;
+import javax.inject.Inject;
+
+ at Stateful
+ at RequestScoped
+ at Named("translator")
+public class TranslatorControllerBean implements TranslatorController
+{
+   
+   @Inject TextTranslator translator;
+   
+   private String inputText;
+   
+   private String translatedText;
+   
+   public String getText()
+   {
+      return inputText;
+   }
+   
+   public void setText(String text)
+   {
+      this.inputText = text;
+   }
+   
+   public void translate()
+   {
+      translatedText = translator.translate(inputText);
+   }
+   
+   public String getTranslatedText()
+   {
+      return translatedText;
+   }
+   
+   @Remove
+   public void remove()
+   {
+      
+   }
+   
+}

Added: branches/Branch_5_x/testsuite/src/resources/deployers/weld/numberguess/WEB-INF/beans.xml
===================================================================

Added: branches/Branch_5_x/testsuite/src/resources/deployers/weld/numberguess/WEB-INF/faces-config.xml
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/deployers/weld/numberguess/WEB-INF/faces-config.xml	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/resources/deployers/weld/numberguess/WEB-INF/faces-config.xml	2009-10-16 20:05:58 UTC (rev 95051)
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<faces-config version="2.0" 
+              xmlns="http://java.sun.com/xml/ns/javaee"
+              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
+              xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2.0.xsd">
+     
+</faces-config>
\ No newline at end of file

Added: branches/Branch_5_x/testsuite/src/resources/deployers/weld/numberguess/WEB-INF/web.xml
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/deployers/weld/numberguess/WEB-INF/web.xml	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/resources/deployers/weld/numberguess/WEB-INF/web.xml	2009-10-16 20:05:58 UTC (rev 95051)
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<web-app version="2.5"
+    xmlns="http://java.sun.com/xml/ns/javaee"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+   
+   <display-name>Web Beans Numberguess example</display-name>
+
+   <!-- JSF -->
+
+   <servlet>
+      <servlet-name>Faces Servlet</servlet-name>
+      <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+   </servlet>
+
+   <servlet-mapping>
+      <servlet-name>Faces Servlet</servlet-name>
+      <url-pattern>*.jsf</url-pattern>
+   </servlet-mapping>
+
+   <session-config>
+      <session-timeout>10</session-timeout>
+   </session-config>
+
+</web-app>

Added: branches/Branch_5_x/testsuite/src/resources/deployers/weld/numberguess/home.xhtml
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/deployers/weld/numberguess/home.xhtml	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/resources/deployers/weld/numberguess/home.xhtml	2009-10-16 20:05:58 UTC (rev 95051)
@@ -0,0 +1,34 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+    xmlns:ui="http://java.sun.com/jsf/facelets"
+    xmlns:h="http://java.sun.com/jsf/html"
+    xmlns:f="http://java.sun.com/jsf/core">
+
+  <ui:composition template="template.xhtml">
+    <ui:define name="content">
+       <h1>Guess a number...</h1>
+       <h:form id="NumberGuessMain">
+          <div style="color: red">
+             <h:messages id="messages" globalOnly="false"/>
+             <h:outputText id="Higher" value="Higher!" rendered="#{game.number gt game.guess and game.guess ne 0}"/>
+             <h:outputText id="Lower" value="Lower!" rendered="#{game.number lt game.guess and game.guess ne 0}"/>
+          </div>
+   
+          <div>
+             I'm thinking of a number between #{game.smallest} and #{game.biggest}. You have #{game.remainingGuesses} guesses.
+          </div>
+     
+          <div>
+             Your guess: 
+             <h:inputText id="inputGuess" value="#{game.guess}" required="true" size="3" disabled="#{game.number eq game.guess}" 
+			              validator="#{game.validateNumberRange}">
+			 </h:inputText>
+            <h:commandButton id="GuessButton" value="Guess" action="#{game.check}" disabled="#{game.number eq game.guess}"/>
+          </div>
+          <div>
+            <h:commandButton id="RestartButton" value="Reset" action="#{game.reset}" immediate="true" />
+          </div>
+       </h:form>
+    </ui:define>
+  </ui:composition>
+</html>

Added: branches/Branch_5_x/testsuite/src/resources/deployers/weld/numberguess/index.html
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/deployers/weld/numberguess/index.html	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/resources/deployers/weld/numberguess/index.html	2009-10-16 20:05:58 UTC (rev 95051)
@@ -0,0 +1,5 @@
+<html>
+<head>
+  <meta http-equiv="Refresh" content="0; URL=home.jsf">
+</head>
+</html>
\ No newline at end of file

Added: branches/Branch_5_x/testsuite/src/resources/deployers/weld/numberguess/template.xhtml
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/deployers/weld/numberguess/template.xhtml	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/resources/deployers/weld/numberguess/template.xhtml	2009-10-16 20:05:58 UTC (rev 95051)
@@ -0,0 +1,34 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+    xmlns:ui="http://java.sun.com/jsf/facelets"
+    xmlns:h="http://java.sun.com/jsf/html"
+    xmlns:f="http://java.sun.com/jsf/core">
+
+<head>
+  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+  <title>Numberguess</title>
+  <link href="style/main.css" rel="stylesheet" type="text/css"/>
+  <ui:insert name="head"/>
+</head>
+
+<body>
+  
+  <div id="container">
+    <div id="header">
+  
+    </div>
+
+    <div id="sidebar">
+    
+    </div>
+  
+    <div id="content">
+      <ui:insert name="content"/>
+    </div>
+    
+    <br style="clear:both"/>
+  </div>
+   
+</body>
+</html>
+

Added: branches/Branch_5_x/testsuite/src/resources/deployers/weld/translator/ejb/META-INF/beans.xml
===================================================================

Added: branches/Branch_5_x/testsuite/src/resources/deployers/weld/translator/war/WEB-INF/faces-config.xml
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/deployers/weld/translator/war/WEB-INF/faces-config.xml	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/resources/deployers/weld/translator/war/WEB-INF/faces-config.xml	2009-10-16 20:05:58 UTC (rev 95051)
@@ -0,0 +1,11 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<faces-config version="1.2"
+              xmlns="http://java.sun.com/xml/ns/javaee"
+              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+              xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
+    
+    <application>
+        <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
+    </application>
+
+</faces-config>

Added: branches/Branch_5_x/testsuite/src/resources/deployers/weld/translator/war/WEB-INF/lib/el-ri-1.2.jar
===================================================================
(Binary files differ)


Property changes on: branches/Branch_5_x/testsuite/src/resources/deployers/weld/translator/war/WEB-INF/lib/el-ri-1.2.jar
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: branches/Branch_5_x/testsuite/src/resources/deployers/weld/translator/war/WEB-INF/lib/jsf-facelets-1.1.15.B1.jar
===================================================================
(Binary files differ)


Property changes on: branches/Branch_5_x/testsuite/src/resources/deployers/weld/translator/war/WEB-INF/lib/jsf-facelets-1.1.15.B1.jar
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: branches/Branch_5_x/testsuite/src/resources/deployers/weld/translator/war/WEB-INF/web.xml
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/deployers/weld/translator/war/WEB-INF/web.xml	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/resources/deployers/weld/translator/war/WEB-INF/web.xml	2009-10-16 20:05:58 UTC (rev 95051)
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<web-app version="2.5"
+    xmlns="http://java.sun.com/xml/ns/javaee"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+   
+   <display-name>WELD Numberguess example</display-name>
+
+   <!-- JSF -->
+
+   <servlet>
+      <servlet-name>Faces Servlet</servlet-name>
+      <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+      <load-on-startup>1</load-on-startup>
+   </servlet>
+
+   <servlet-mapping>
+      <servlet-name>Faces Servlet</servlet-name>
+      <url-pattern>*.jsf</url-pattern>
+   </servlet-mapping>
+   
+   <context-param>
+      <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
+      <param-value>.xhtml</param-value>
+   </context-param>
+
+   <session-config>
+      <session-timeout>10</session-timeout>
+   </session-config>
+
+</web-app>

Added: branches/Branch_5_x/testsuite/src/resources/deployers/weld/translator/war/home.xhtml
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/deployers/weld/translator/war/home.xhtml	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/resources/deployers/weld/translator/war/home.xhtml	2009-10-16 20:05:58 UTC (rev 95051)
@@ -0,0 +1,39 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+    xmlns:ui="http://java.sun.com/jsf/facelets"
+    xmlns:h="http://java.sun.com/jsf/html"
+    xmlns:f="http://java.sun.com/jsf/core"
+    xmlns:s="http://jboss.com/products/seam/taglib">
+
+  <ui:composition template="template.xhtml">
+    <ui:define name="content">
+       <h1>Translate your text into Latin!</h1>
+       <h:form id="NumberGuessMain">
+            
+          <table>
+             <tr align="center" style="font-weight: bold" >
+               <td>
+                  Your text
+               </td>
+               <td>
+                  Translation
+               </td>
+            </tr>
+            <tr>
+               <td>
+                  <h:inputTextarea id="text" value="#{translator.text}" required="true" rows="5" cols="80" />
+               </td>
+               <td>
+                  <h:outputText value="#{translator.translatedText}" />
+               </td>
+            </tr>
+          </table>
+          <div>
+            <h:commandButton id="button" value="Translate" action="#{translator.translate}"/>
+          </div>
+   
+
+       </h:form>
+    </ui:define>
+  </ui:composition>
+</html>

Added: branches/Branch_5_x/testsuite/src/resources/deployers/weld/translator/war/index.html
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/deployers/weld/translator/war/index.html	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/resources/deployers/weld/translator/war/index.html	2009-10-16 20:05:58 UTC (rev 95051)
@@ -0,0 +1,5 @@
+<html>
+<head>
+  <meta http-equiv="Refresh" content="0; URL=home.jsf">
+</head>
+</html>
\ No newline at end of file

Added: branches/Branch_5_x/testsuite/src/resources/deployers/weld/translator/war/template.xhtml
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/deployers/weld/translator/war/template.xhtml	                        (rev 0)
+++ branches/Branch_5_x/testsuite/src/resources/deployers/weld/translator/war/template.xhtml	2009-10-16 20:05:58 UTC (rev 95051)
@@ -0,0 +1,35 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+    xmlns:ui="http://java.sun.com/jsf/facelets"
+    xmlns:s="http://jboss.com/products/seam/taglib"
+    xmlns:h="http://java.sun.com/jsf/html"
+    xmlns:f="http://java.sun.com/jsf/core">
+
+<head>
+  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+  <title>Translator</title>
+  <link href="style/main.css" rel="stylesheet" type="text/css"/>
+  <ui:insert name="head"/>
+</head>
+
+<body>
+  
+  <div id="container">
+    <div id="header">
+  
+    </div>
+
+    <div id="sidebar">
+    
+    </div>
+  
+    <div id="content">
+      <ui:insert name="content"/>
+    </div>
+    
+    <br style="clear:both"/>
+  </div>
+   
+</body>
+</html>
+




More information about the jboss-cvs-commits mailing list