[jboss-svn-commits] JBL Code SVN: r20163 - in labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product: samples/quickstarts/bpm_orchestration2 and 10 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon May 26 07:42:26 EDT 2008


Author: beve
Date: 2008-05-26 07:42:26 -0400 (Mon, 26 May 2008)
New Revision: 20163

Added:
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/ant-task/test/
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/ant-task/test/org/
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/ant-task/test/org/jbpm/
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/ant-task/test/org/jbpm/ant/
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/ant-task/test/org/jbpm/ant/DeployProcessToServerTaskUnitTest.java
Modified:
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration1/build.xml
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration2/build.xml
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration3/build.xml
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration4/build.xml
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/conf/base-build.xml
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/conf/quickstarts.properties-example
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/ant-task/build.xml
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/ant-task/src/org/jbpm/ant/DeployProcessToServerTask.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/lib/ext/jbpm-ant.jar
Log:
Work for JBESB-1673 "SOA platform changed upload URL for jBPM"


Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration1/build.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration1/build.xml	2008-05-26 01:45:49 UTC (rev 20162)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration1/build.xml	2008-05-26 11:42:26 UTC (rev 20163)
@@ -41,11 +41,11 @@
 	
   <target name="deployProcess" description="deploys the process definition" depends="dependencies">
     <echo>Deploy the process definition</echo>
-	<taskdef name="deployToServer" classname="org.jbpm.ant.DeployProcessToServerTask">
-		<classpath refid="exec-classpath"/>
-	</taskdef>
-	<deployToServer>
-		<fileset dir="${basedir}/processDefinition" includes="*"/>
+	<taskdef name="deployToServer" classname="org.jbpm.ant.DeployProcessToServerTask">
+		<classpath refid="exec-classpath"/>
+	</taskdef>
+	<deployToServer username="${jbpm.console.username}" password="${jbpm.console.password}" serverDeployer="${org.jboss.esb.jbpm.console.upload.url}">
+		<fileset dir="${basedir}/processDefinition" includes="*"/>
 	</deployToServer>
   </target>
       

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration2/build.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration2/build.xml	2008-05-26 01:45:49 UTC (rev 20162)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration2/build.xml	2008-05-26 11:42:26 UTC (rev 20163)
@@ -36,7 +36,7 @@
 	<taskdef name="deployToServer" classname="org.jbpm.ant.DeployProcessToServerTask">
 		<classpath refid="exec-classpath"/>
 	</taskdef>
-	<deployToServer>
+	<deployToServer username="${jbpm.console.username}" password="${jbpm.console.password}" serverDeployer="${org.jboss.esb.jbpm.console.upload.url}">
 		<fileset dir="${basedir}/processDefinition" includes="*"/>
 	</deployToServer>
   </target>

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration3/build.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration3/build.xml	2008-05-26 01:45:49 UTC (rev 20162)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration3/build.xml	2008-05-26 11:42:26 UTC (rev 20163)
@@ -40,7 +40,7 @@
 	<taskdef name="deployToServer" classname="org.jbpm.ant.DeployProcessToServerTask">
 		<classpath refid="exec-classpath"/>
 	</taskdef>
-	<deployToServer>
+	<deployToServer username="${jbpm.console.username}" password="${jbpm.console.password}" serverDeployer="${org.jboss.esb.jbpm.console.upload.url}">
 		<fileset dir="${basedir}/processDefinition" includes="*"/>
 	</deployToServer>
   </target>

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration4/build.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration4/build.xml	2008-05-26 01:45:49 UTC (rev 20162)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/bpm_orchestration4/build.xml	2008-05-26 11:42:26 UTC (rev 20163)
@@ -34,7 +34,7 @@
 	<taskdef name="deployToServer" classname="org.jbpm.ant.DeployProcessToServerTask">
 		<classpath refid="exec-classpath"/>
 	</taskdef>
-	<deployToServer>
+	<deployToServer username="${jbpm.console.username}" password="${jbpm.console.password}" serverDeployer="${org.jboss.esb.jbpm.console.upload.url}">
 		<fileset dir="${basedir}/processDefinition" includes="*"/>
 	</deployToServer>
   </target>

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/conf/base-build.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/conf/base-build.xml	2008-05-26 01:45:49 UTC (rev 20162)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/conf/base-build.xml	2008-05-26 11:42:26 UTC (rev 20163)
@@ -251,8 +251,40 @@
 <!-- compile-classpath, exec-classpath                                    -->
 <!-- ==================================================================== -->
 
-	<target name="dependencies" depends="classpath-dependencies, quickstart-specific-checks"/>
+	<target name="dependencies" depends="classpath-dependencies, quickstart-specific-checks">
+	
+		<!-- jBPM Console properties -->
+		<condition property="jbpm.production.properties.set" value="true" else="false">
+            <and>
+                <equals arg1="${org.jboss.esb.server.config}" arg2="production"/>
+                <isset property="quickstart.jbpm.console.username"/>
+                <isset property="quickstart.jbpm.console.password"/>
+            </and>
+         </condition>
+        <fail message="Quickstart configuration error: ${line.separator}${line.separator} jBPM username and password must be set in ${pwd}/quickstarts.properties. ${line.separator} The jBPM web console is secured when running in production mode i.e when org.jboss.esb.server.config=production.">
+            <condition>
+                <and>
+                    <equals arg1="${org.jboss.esb.server.config}" arg2="production"/>
+                    <equals arg1="${jbpm.production.properties.set}" arg2="false"/>
+                </and>
+            </condition>
+        </fail>
 
+        <condition property="org.jboss.esb.jbpm.console.upload.url" value="/jbpm-console/app/upload/" else="/jbpm-console/upload/">
+            <equals arg1="${org.jboss.esb.server.config}" arg2="production"/>
+        </condition>
+
+        <condition property="jbpm.console.username" value="${quickstart.jbpm.console.username}" else="">
+            <equals arg1="${org.jboss.esb.server.config}" arg2="production"/>
+        </condition>
+
+        <condition property="jbpm.console.password" value="${quickstart.jbpm.console.password}" else="">
+            <equals arg1="${org.jboss.esb.server.config}" arg2="production"/>
+        </condition>
+
+		<!-- End jBPM Console properties -->
+	</target>
+
 	<target name="classpath-dependencies" depends="messaging-dependencies, jbossmq-dependencies, quickstart-specific-dependencies">
     	
 		<path id="compile-classpath">

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/conf/quickstarts.properties-example
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/conf/quickstarts.properties-example	2008-05-26 01:45:49 UTC (rev 20162)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/conf/quickstarts.properties-example	2008-05-26 11:42:26 UTC (rev 20163)
@@ -5,13 +5,17 @@
 ##############################################################################################
 # Location of your JBoss Application Server installation.
 # Will override the same property name from install/deployment.properties
-#org.jboss.esb.server.home=${product.dir}/build/jbossesb-server-4.2GA
+#org.jboss.esb.server.home=${product.dir}/build/jbossesb-server-4.2.1CP3
 
 # JBossAS server name. If not set defaults to 'default'
 # Will override the same property name from install/deployment.properties
 #org.jboss.esb.server.config=default
 
+# jBPM console security credentials (if org.jboss.esb.server.config=production)
+#jbpm.console.username=admin
+#jbpm.console.password=admin
 
+
 # If you are running the ftp tests then you must complete the following
 jbossesb.ftp.hostname=
 jbossesb.ftp.username=

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/ant-task/build.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/ant-task/build.xml	2008-05-26 01:45:49 UTC (rev 20162)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/ant-task/build.xml	2008-05-26 11:42:26 UTC (rev 20163)
@@ -1,20 +1,21 @@
 <project name="jbpm-ant-task" default="build-task" basedir=".">
 
-        <path id="classpath">
-            <pathelement location="src/test/resources"/>
-                <pathelement location="build/classes" />
-                <pathelement location="build/test/classes" />
-        </path>
+	<path id="classpath">
+		<pathelement location="src/test/resources"/>
+			<pathelement location="build/classes" />
+			<pathelement location="build/test/classes" />
+			<pathelement location="${basedir}/../../../lib/ext/commons-codec-1.3.jar" />
+			<pathelement location="${basedir}/../../../lib/ext/junit-4.1.jar" />
+			<pathelement location="${basedir}/../../../lib/ext/commons-httpclient.jar" />
+	</path>
+	
 
-
-        <target name="build-task">
+	<target name="build-task">
 		<mkdir dir="build/classes"/>
-                <javac srcdir="src" destdir="build/classes"
-			debug="on" >
-                        <classpath refid="classpath" />
-                </javac>
-		<jar basedir="build/classes" destfile="build/jbpm-ant.jar"
-			includes="**/*.class"/>
+		<javac srcdir="src" destdir="build/classes" debug="on" >
+			<classpath refid="classpath" />
+		</javac>
+		<jar basedir="build/classes" destfile="build/jbpm-ant.jar" includes="**/*.class"/>
 	</target>
 
 </project>

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/ant-task/src/org/jbpm/ant/DeployProcessToServerTask.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/ant-task/src/org/jbpm/ant/DeployProcessToServerTask.java	2008-05-26 01:45:49 UTC (rev 20162)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/ant-task/src/org/jbpm/ant/DeployProcessToServerTask.java	2008-05-26 11:42:26 UTC (rev 20163)
@@ -29,6 +29,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.ConnectException;
+import java.net.HttpURLConnection;
 import java.net.URL;
 import java.net.URLConnection;
 import java.util.ArrayList;
@@ -37,6 +38,14 @@
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipOutputStream;
 
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.httpclient.Cookie;
+import org.apache.commons.httpclient.Header;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.HttpState;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.PostMethod;
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.DirectoryScanner;
 import org.apache.tools.ant.taskdefs.MatchingTask;
@@ -44,26 +53,51 @@
 
 /**
  * ant task for deploying process archives to the deployment servlet.
+ * </p>
+ * Usage:
+ * <pre>
+ * &lt;taskdef name="deployToServer" classname="org.jbpm.ant.DeployProcessToServerTask"&gt;
+ *     &lt;classpath refid="exec-classpath"/&gt;
+ * &lt;/taskdef&gt;
  * 
+ * &lt;deployToServer serverDeployer="jbpm-console/upload"&gt;
+ *     &lt;fileset dir="${basedir}/processDefinition" includes="*"/&gt;
+ * &lt;/deployToServer&gt;
+ * </pre>
+ * Optional attributes:
+ * <pre>
+ * serverName="localhost"
+ * serverPort="8080"
+ * serverDeployer="/jbpm-console/upload"
+ * process="processDefinitions/processdefinition.xml"
+ * username="username"
+ * password="password"
+ * </pre>
+ * 
  * @author kurt stam
+ * @author <a href="mailto:dbevenius at redhat.com">Daniel Bevenius</a>
  */
 public class DeployProcessToServerTask extends MatchingTask {
 
     private static final String boundary = "AaB03x";
     
-    String serverName = "localhost";
+    String servername = "localhost";
     String serverPort = "8080";
     String serverDeployer = "/jbpm-console/upload";
     String debug = null;
     File process = null;
     List fileSets = new ArrayList();
 
+	private String username;
+
+	private String password;
+
     public void setServerDeployer(String serverDeployer) {
         this.serverDeployer = serverDeployer;
     }
 
     public void setServerName(String serverName) {
-        this.serverName = serverName;
+        this.servername = serverName;
     }
 
     public void setServerPort(String serverPort) {
@@ -77,7 +111,17 @@
     public void setDebug(String debug) {
         this.debug = debug;
     }
+    
+	public void setUsername( final String userName )
+	{
+		this.username = userName;
+	}
 
+	public void setPassword( final String password )
+	{
+		this.password = password;
+	}
+
     public void execute() throws BuildException {
         try {
             if (pingServerOK()) {
@@ -95,7 +139,7 @@
                     if (debug!=null) {
                         saveParFile("debug.par", out.toByteArray());
                     }
-                    deployProcessWithServlet(serverName, serverPort, serverDeployer, out.toByteArray());
+                    deployProcessWithServlet(servername, serverPort, serverDeployer, out.toByteArray());
                     in.close();
                     log("deployment complete.");
                 }
@@ -127,12 +171,12 @@
                     if (debug!=null) {
                         saveParFile("debug.par", byteArrayOutputStream.toByteArray());
                     }
-                    deployProcessWithServlet(serverName, serverPort, serverDeployer, byteArrayOutputStream.toByteArray());
+                    deployProcessWithServlet(servername, serverPort, serverDeployer, byteArrayOutputStream.toByteArray());
                     log("deployment complete.");
                 }
             }
         } catch (Exception e) {
-            e.printStackTrace();
+        	log(e,1 );
             throw new BuildException( "couldn't deploy process archives : " + e.getMessage() );
         }
     }
@@ -141,16 +185,30 @@
         this.fileSets.add(fileSet);
     }
 
-    public void deployProcessWithServlet(String serverName, String serverPort, String serverDeployer, byte[] parBytes) throws Exception {
+    public void deployProcessWithServlet(final String serverName, final String serverPort, final String serverDeployer, final byte[] parBytes) throws Exception {
+        
+        String sessionID = null; 
+        //	pass security credentials if specified.
+        boolean security = verifySecurityProperties();
+        if ( security )
+        	sessionID = tryFormBasedAuthentication();
+        
         URL url = new URL("http://" + serverName + ":" + serverPort + serverDeployer);
-        URLConnection urlConnection = url.openConnection();
+        HttpURLConnection urlConnection = (HttpURLConnection)url.openConnection();
+        urlConnection.setRequestMethod( "POST" );
         urlConnection.setDoInput(true);
         urlConnection.setDoOutput(true);
+        urlConnection.setAllowUserInteraction(false);
         urlConnection.setUseCaches(false);
-        urlConnection.setRequestProperty("Content-Type",
-        "multipart/form-data; boundary=AaB03x");
-        DataOutputStream dataOutputStream = new DataOutputStream(urlConnection
-                .getOutputStream());
+        
+        if ( sessionID != null ) // FORM based authentication
+        	urlConnection.setRequestProperty( "Cookie", sessionID  );
+        else // fall back to BASIC authentication
+            urlConnection.setRequestProperty( "Authorization", "Basic " + encode(username + ":" + password ) );
+        	
+        urlConnection.setRequestProperty("Content-Type", "multipart/form-data; boundary=AaB03x");
+        
+        DataOutputStream dataOutputStream = new DataOutputStream(urlConnection.getOutputStream());
         dataOutputStream.writeBytes("--" + boundary + "\r\n");
         dataOutputStream.writeBytes("Content-Disposition: form-data; name=\"definition\"; filename=\"dummy.par\"\r\n");
         dataOutputStream.writeBytes("Content-Type: application/x-zip-compressed\r\n\r\n");
@@ -160,14 +218,66 @@
         dataOutputStream.writeBytes("\r\n--" + boundary + "--\r\n");
         dataOutputStream.flush();
         dataOutputStream.close();
+        
         InputStream inputStream = urlConnection.getInputStream();
         StringBuffer result = new StringBuffer();
         int read;
         while ((read = inputStream.read()) != -1) {
             result.append((char)read);
         }
+        log(result.toString());
     }
+    
+    /**
+     * Adds BASIC Authentication properties to the passed-in urlConnection.
+     * 
+     * @param urlConnection
+     */
+    void addBasicSecurityCredentials( final URLConnection urlConnection )
+    {
+        urlConnection.setRequestProperty("Authorization", "Basic " + encode(username + ":" + password));
+    }
+    
+    /**
+     * Try to authenticate using FORM based Authentication. 
+     * If succuessful the returned String will contain the JSESSIONID.
+     * 
+     * @return String	The session id from the serlvet. 
+     */
+    private String tryFormBasedAuthentication() throws HttpException, IOException
+    {
+    	final String path ="http://" + servername + ":" + serverPort + serverDeployer;
+        String sessionId = null;
+        
+    	final HttpClient httpClient = new HttpClient();
+        GetMethod indexGet = new GetMethod( path );
+        
+        if ( httpClient.executeMethod(indexGet) == 200 )
+        {
+        
+            HttpState state = httpClient.getState();
+            Cookie[] cookies = state.getCookies();
+        	for (Cookie cookie : cookies)
+			{
+                if( cookie.getName().equalsIgnoreCase("JSESSIONID") )
+                {
+                    sessionId = "JSESSIONID=" + cookie.getValue();
+                }
+            }
+        
+            PostMethod loginFormPost = new PostMethod( path + "/j_security_check");
+            loginFormPost.addParameter("j_username", username);
+            loginFormPost.addParameter("j_password", password);
+            httpClient.executeMethod(loginFormPost.getHostConfiguration(), loginFormPost, state);
 
+            Header location = loginFormPost.getResponseHeader("Location");
+            String indexURI = location.getValue();
+            GetMethod war1Index = new GetMethod(indexURI);
+            httpClient.executeMethod(war1Index.getHostConfiguration(), war1Index, state);
+        }
+        return sessionId;
+    }
+    
     public void addFile(ZipOutputStream zos, File file)
     throws IOException 
     {
@@ -194,9 +304,12 @@
     public boolean pingServerOK() {
         URL url = null;
         try {
-            url = new URL("http://" + serverName + ":" + serverPort + serverDeployer);
+            url = new URL("http://" + servername + ":" + serverPort + serverDeployer);
             URLConnection urlConnection = url.openConnection();
             urlConnection.setDoOutput(true);
+            //	pass security credentials is specified.
+            if ( verifySecurityProperties() )
+                addBasicSecurityCredentials( urlConnection );
             InputStream inputStream = urlConnection.getInputStream();
             StringBuffer result = new StringBuffer();
             int read;
@@ -210,8 +323,27 @@
             return false;
         }
         catch (Exception e) {
+        	e.printStackTrace();
             log("An unexpected exception happened while testing the server (" + url + ") connection.");
             return false;
         }
     }
+
+	boolean verifySecurityProperties() throws BuildException
+	{
+		if ( username == null && password == null || "".equals( username ) && "".equals( password ) )
+			return false;
+		
+		if ( username != null && password == null )
+			throw new BuildException( "'userName' must be accompanied with 'password'");
+		else if ( password != null && username == null )
+			throw new BuildException( "'password' must be accompanied with 'userName'");
+		
+		return true;
+	}
+	
+    public static String encode (String source) {
+        return new String( new Base64().encode( source.getBytes() ));
+    }
+
 }
\ No newline at end of file

Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/ant-task/test/org/jbpm/ant/DeployProcessToServerTaskUnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/ant-task/test/org/jbpm/ant/DeployProcessToServerTaskUnitTest.java	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/ant-task/test/org/jbpm/ant/DeployProcessToServerTaskUnitTest.java	2008-05-26 11:42:26 UTC (rev 20163)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2006, JBoss Inc., and
+ * individual contributors as indicated by the @authors tag. See the
+ * copyright.txt 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.jbpm.ant;
+
+import static org.junit.Assert.*;
+
+import org.apache.tools.ant.BuildException;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Unit test for {@link DeployProcessToServerTask}
+ * <p/>
+ * @author <a href="mailto:dbevenius at redhat.com">Daniel Bevenius</a>
+ * 
+ */
+public class DeployProcessToServerTaskUnitTest
+{
+	private DeployProcessToServerTask task;
+	
+	private final String userName = "testuser";
+	private final String password = "testpasswd";
+	
+	@Test ( expected = BuildException.class )
+	public void showThrowIfPasswordIsNotSet()
+	{
+		task.setUsername( userName );
+		task.verifySecurityProperties();
+		
+	}
+	
+	@Test ( expected = BuildException.class )
+	public void showThrowIfUserNameIsNotSet()
+	{
+		task.setPassword( password );
+		task.verifySecurityProperties();
+	}
+	
+	@Test
+	public void noSecurityPropeties()
+	{
+		boolean useSecurity = task.verifySecurityProperties();
+		assertFalse ( useSecurity );
+	}
+	
+	@Test
+	public void emptyStringsSecurityPropeties()
+	{
+		task.setUsername( "" );
+		task.setPassword( "" );
+		boolean useSecurity = task.verifySecurityProperties();
+		assertFalse ( useSecurity );
+	}
+	
+	//	lifecycle 
+	
+	@Before
+	public void setup()
+	{
+		task = new DeployProcessToServerTask();
+	}
+		
+}

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/lib/ext/jbpm-ant.jar
===================================================================
(Binary files differ)




More information about the jboss-svn-commits mailing list