Author: marco.rietveld
Date: 2011-06-14 08:01:19 -0400 (Tue, 14 Jun 2011)
New Revision: 6954
Added:
jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/jbpm3234/
jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/jbpm3234/JBPM3234Test.java
Modified:
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/job/executor/JobExecutor.java
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/mail/Mail.java
Log:
SOA-3083, JBPM-3234: Repaired public api to conform to legacy applicaiton expectations.
Modified:
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/job/executor/JobExecutor.java
===================================================================
---
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/job/executor/JobExecutor.java 2011-06-14
07:12:16 UTC (rev 6953)
+++
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/job/executor/JobExecutor.java 2011-06-14
12:01:19 UTC (rev 6954)
@@ -7,11 +7,13 @@
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -253,8 +255,8 @@
}
}
- public Collection getMonitoredJobIds() {
- return monitoredJobIds.values();
+ public Set getMonitoredJobIds() {
+ return new HashSet(monitoredJobIds.values());
}
public void addMonitoredJobId(String threadName, long jobId) {
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/mail/Mail.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/mail/Mail.java 2011-06-14
07:12:16 UTC (rev 6953)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/mail/Mail.java 2011-06-14
12:01:19 UTC (rev 6954)
@@ -74,21 +74,36 @@
send();
}
- public Collection getRecipients() {
- return collectRecipients(actors, to);
+
+ public List getRecipients() {
+ Collection recipientsCollection = collectRecipients(actors, to);
+ List recipientsList = null;
+ if( recipientsCollection != null ) {
+ recipientsList = new ArrayList(recipientsCollection);
+ }
+ return recipientsList;
}
- public Collection getCcRecipients() {
- return collectRecipients(ccActors, cc);
+ public List getCcRecipients() {
+ Collection ccRecipientsCollection = collectRecipients(ccActors, cc);
+ List ccRecipientsList = null;
+ if( ccRecipientsCollection != null ) {
+ ccRecipientsList = new ArrayList(ccRecipientsCollection);
+ }
+ return ccRecipientsList;
}
- public Collection getBccRecipients() {
+ public List getBccRecipients() {
Collection recipients = collectRecipients(bccActors, bcc);
if (Configs.hasObject("jbpm.mail.bcc.address")) {
if (!(recipients instanceof ArrayList)) recipients = new ArrayList(recipients);
recipients.addAll(tokenize(Configs.getString("jbpm.mail.bcc.address")));
}
- return recipients;
+ List bccRecipientsList = null;
+ if( recipients != null ) {
+ bccRecipientsList = new ArrayList(recipients);
+ }
+ return bccRecipientsList;
}
private Collection collectRecipients(String actors, String addresses) {
@@ -231,13 +246,27 @@
}
}
- public static void send(Properties serverProperties, String sender, Collection
recipients,
- String subject, String text) {
+ /**
+ * Kept for backwards compatibility
+ * @deprecated
+ */
+ public static void send(Properties serverProperties, String sender, List recipients,
String subject, String text) {
+ send(serverProperties,sender,(Collection) recipients,subject,text);
+ }
+
+ public static void send(Properties serverProperties, String sender, Collection
recipients, String subject, String text) {
send(serverProperties, sender, recipients, null, subject, text);
}
- public static void send(Properties serverProperties, String sender, Collection
recipients,
- Collection bccRecipients, String subject, String text) {
+ /**
+ * Kept for backwards compatibility
+ * @deprecated
+ */
+ public static void send(Properties serverProperties, String sender, List recipients,
List bccRecipients, String subject, String text) {
+ send(serverProperties,sender,(Collection) recipients, (Collection) bccRecipients,
subject,text);
+ }
+
+ public static void send(Properties serverProperties, String sender, Collection
recipients, Collection bccRecipients, String subject, String text) {
if (nullOrEmpty(recipients) && nullOrEmpty(bccRecipients)) return;
if (log.isDebugEnabled()) {
Added: jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/jbpm3234/JBPM3234Test.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/jbpm3234/JBPM3234Test.java
(rev 0)
+++
jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/jbpm3234/JBPM3234Test.java 2011-06-14
12:01:19 UTC (rev 6954)
@@ -0,0 +1,155 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, 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.jbpm3234;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+
+import javax.sound.midi.VoiceStatus;
+
+import junit.framework.TestCase;
+
+import org.jbpm.JbpmConfiguration.Configs;
+import org.jbpm.JbpmContext;
+import org.jbpm.command.CommandService;
+import org.jbpm.command.ExecuteJobsCommand;
+import org.jbpm.command.impl.CommandServiceImpl;
+import org.jbpm.db.AbstractDbTestCase;
+import org.jbpm.graph.def.ProcessDefinition;
+import org.jbpm.graph.exe.ProcessInstance;
+import org.jbpm.job.Timer;
+import org.jbpm.mail.Mail;
+
+/**
+ * ExecuteJobsCommand uses a hardcoded number of retries (instead of injected
jbpm.job.retries value)
+ *
+ * @see <a
href="https://jira.jboss.org/jira/browse/JBPM-3218">JBPM-321...
+ */
+public class JBPM3234Test extends TestCase {
+
+ protected void setUp() throws Exception {
+ }
+
+ private static String SEND_METHOD_NAME = "send";
+ private static String GET_RECIPIENTS_METHOD_NAME = "getRecipients";
+ private static String GET_CC_RECIPIENTS_METHOD_NAME = "getCcRecipients";
+ private static String GET_BCC_RECIPIENTS_METHOD_NAME = "getBccRecipients";
+
+ public void testMailRecipientMethods() {
+ Method [] methods = Mail.class.getDeclaredMethods();
+
+ HashMap nameMethodMap = new HashMap();
+ nameMethodMap.put(GET_RECIPIENTS_METHOD_NAME, null);
+ nameMethodMap.put(GET_CC_RECIPIENTS_METHOD_NAME, null);
+ nameMethodMap.put(GET_BCC_RECIPIENTS_METHOD_NAME, null);
+
+ Class [] classes = null;
+
+ for( int i = 0; i < methods.length; ++i ) {
+ if( nameMethodMap.containsKey(methods[i].getName()) ) {
+ classes = methods[i].getParameterTypes();
+ assertTrue("Unexpected parameters for [" + methods[i].getName() +
"] :" + classes.length + " parameters.",
+ classes == null || classes.length == 0);
+ Class returnTypeClass = methods[i].getReturnType();
+ assertTrue("Unexpected return type for [" + methods[i].getName() +
"] :" + returnTypeClass.getName() + ", etc.",
+ returnTypeClass != null && List.class.equals(returnTypeClass));
+ nameMethodMap.put(methods[i].getName(), methods[i]);
+ }
+ }
+
+ Iterator iter = nameMethodMap.keySet().iterator();
+ while(iter.hasNext()) {
+ String methodName = (String) iter.next();
+ assertTrue("Method [" + methodName + "] not found in class" +
Mail.class.getName(), nameMethodMap.get(methodName) != null);
+ }
+
+ }
+
+ public void testMailSendMethods() {
+ Method [] methods = Mail.class.getDeclaredMethods();
+
+ HashSet sendMethods = new HashSet();
+ for( int i = 0; i < methods.length; ++i ) {
+ if( SEND_METHOD_NAME.equals(methods[i].getName()) ) {
+ sendMethods.add(methods[i]);
+ }
+ }
+
+ // The following are the correct parameter signatures for the expected send()
methods.
+ HashSet sendMethodParameters = new HashSet();
+
+ Class [] methodParams =
{Properties.class,String.class,List.class,String.class,String.class};
+ sendMethodParameters.add(methodParams);
+ Class [] methodParams2 =
{Properties.class,String.class,List.class,List.class,String.class,String.class};
+ sendMethodParameters.add(methodParams2);
+
+ HashSet correctMethods = new HashSet();
+ Iterator iter = sendMethods.iterator();
+ int countCorrectSendMethods = 0;
+ while( iter.hasNext()) {
+ Method sendMethod = (Method) iter.next();
+ Class [] methodParamClasses = sendMethod.getParameterTypes();
+
+ Iterator smpIter = sendMethodParameters.iterator();
+ while(smpIter.hasNext()) {
+ Object og = smpIter.next();
+ Class [] correctParamClasses = (Class []) og;
+ if( Arrays.equals(correctParamClasses, methodParamClasses) ) {
+ countCorrectSendMethods++;
+ smpIter.remove();
+ correctMethods.add(sendMethod);
+ }
+ }
+ }
+
+ assertTrue(countCorrectSendMethods + " correct send methods found, instead of
2", countCorrectSendMethods == 2);
+
+
+ iter = correctMethods.iterator();
+ while(iter.hasNext()) {
+ Method sendMethod = (Method) iter.next();
+ int methodModifiers = sendMethod.getModifiers();
+ assertTrue("Method is not static.", Modifier.isStatic(methodModifiers));
+ assertTrue("Method is not public.", Modifier.isPublic(methodModifiers));
+ Class returnTypeClass = sendMethod.getReturnType();
+
+ // Java bug!!
+ String voidClassname = returnTypeClass.getName();
+ if( voidClassname.lastIndexOf('.') >= 0 ) {
+ voidClassname = voidClassname.substring(voidClassname.lastIndexOf('.'));
+ }
+ assertTrue("Method does not return void.",
"Void".equalsIgnoreCase(voidClassname));
+ }
+ }
+
+
+}
\ No newline at end of file
Property changes on:
jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/jbpm3234/JBPM3234Test.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native