();
+
+ ClusterBuilder clusterBuilder = new ClusterBuilder();
+
+ for (int i = 1; i <= memberCount; i++)
+ {
+ ClusterMemberSchema schema =
+ new ClusterMemberSchema().setEnvironmentInherited(true).setPreferIPv4(true)
+ .setClusterPort(clusterPort)
+ .setSystemProperty("test.unicast.port",
+ String.valueOf(clusterPort)).setSystemProperty("proxy.port",
+ Container.getAvailablePorts().next())
+ .setCacheConfigURI(sCachConfig)
+ .setSingleServerMode()
+ .setStorageEnabled(fStorageEnabled)
+ .setJMXPort(Container.getAvailablePorts())
+ .setRemoteJMXManagement(true)
+ .setJMXManagementMode(ClusterMemberSchema
+ .JMXManagementMode
+ .ALL).setJMXSupport(true)
+ .addOption("-ea");
+
+ if (sPofConfig != null)
+ {
+ schema.setPofConfigURI(sPofConfig);
+ schema.setPofEnabled(true);
+ }
+
+ System.out.println("Adding builder " + i);
+ clusterBuilder.addBuilder(bldrApp, schema, "processing-pattern-" + i, 1);
+ }
+
+ cluster = clusterBuilder.realize(new SystemApplicationConsole());
+
+ while (cluster.getClusterSize() < memberCount)
+ {
+ System.out.println("Cluster size is " + cluster.getClusterSize());
+ Base.sleep(4000);
+ }
+
+ DeferredAssert.assertThat(eventually(invoking(cluster).getClusterSize()), is(memberCount));
+
+ return cluster;
+
+ }
+ catch (Exception e)
+ {
+ throw Base.ensureRuntimeException(e);
+ }
+ }
+
+
+ /**
+ * Shutdown the cluster.
+ */
+ public void shutdownTestCluster(Cluster cluster)
+ {
+ CacheFactory.shutdown();
+
+ if (cluster != null)
+ {
+ cluster.destroy();
+ }
+
+ // wait until cluster has been shut down
+ DeferredAssert.assertThat(eventually(invoking(cluster).getClusterSize()), is(0));
+ }
+
+}
diff --git a/coherence-processingpattern-tests/src/test/java/com/oracle/coherence/patterns/processing/runnable/CancelSubmissionTests.java b/coherence-processingpattern-tests/src/test/java/com/oracle/coherence/patterns/processing/runnable/CancelSubmissionTests.java
new file mode 100644
index 00000000..b19066aa
--- /dev/null
+++ b/coherence-processingpattern-tests/src/test/java/com/oracle/coherence/patterns/processing/runnable/CancelSubmissionTests.java
@@ -0,0 +1,112 @@
+/*
+ * File: CancelSubmissionTests.java
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * The contents of this file are subject to the terms and conditions of
+ * the Common Development and Distribution License 1.0 (the "License").
+ *
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the License by consulting the LICENSE.txt file
+ * distributed with this file, or by consulting
+ * or https://oss.oracle.com/licenses/CDDL
+ *
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file LICENSE.txt.
+ *
+ * MODIFICATIONS:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ */
+
+package com.oracle.coherence.patterns.processing.runnable;
+
+import com.oracle.coherence.common.identifiers.StringBasedIdentifier;
+
+import com.oracle.coherence.patterns.processing.ProcessingSession;
+import com.oracle.coherence.patterns.processing.SubmissionOutcome;
+import com.oracle.coherence.patterns.processing.SubmissionRetentionPolicy;
+import com.oracle.coherence.patterns.processing.SubmissionState;
+import com.oracle.coherence.patterns.processing.internal.DefaultProcessingSession;
+import com.oracle.coherence.patterns.processing.internal.DefaultSubmissionConfiguration;
+import com.oracle.coherence.patterns.processing.misc.AbstractClusterTests;
+
+import com.oracle.tools.runtime.coherence.Cluster;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+/**
+ * This is a test that exercises the ability to control
+ * the lifecycle of a Submission directly.
+ */
+public class CancelSubmissionTests extends AbstractClusterTests
+{
+ /**
+ * {@inheritDoc}
+ */
+ public Cluster startCluster()
+ {
+ return startTestCluster(gridCacheConfig, pofConfig, 0, 1, true);
+ }
+
+
+ /**
+ * A test that checks that a Runnable can be canceled after submission.
+ */
+ @Test
+ public void testCancelSubmission() throws Throwable
+ {
+ extendClientInit(pofConfig, extendClientCacheConfig);
+
+ ProcessingSession session = null;
+
+ try
+ {
+ session = new DefaultProcessingSession(StringBasedIdentifier.newInstance("RunnableLifecycleTestSession"));
+
+ System.out.println("Testing CANCELLING SUBMISSIONS");
+
+ String taskName = "RunnableToCancel";
+ SubmissionOutcome outcome = session.submit(new DoNothingRunnable(15000),
+ new DefaultSubmissionConfiguration(null),
+ StringBasedIdentifier.newInstance(taskName),
+ SubmissionRetentionPolicy.ExplicitRemove,
+ null);
+
+ System.out.println("Wait a second before CANCELLING submission");
+
+ Thread.currentThread();
+ Thread.sleep(1000);
+ session.cancelSubmission(outcome.getIdentifier());
+ outcome.get();
+ System.out.println("After get:" + outcome.getSubmissionState());
+ assertTrue(outcome.getSubmissionState() == SubmissionState.CANCELLED);
+ System.out.println("Waiting 3 seconds to complete cancelling of job");
+ Thread.currentThread();
+ Thread.sleep(3000);
+
+ }
+ catch (Throwable t)
+ {
+ System.out.println("Unexpected Exception in " + getClass().getName());
+ t.printStackTrace(System.out);
+ fail();
+ }
+ finally
+ {
+ if (session != null)
+ {
+ System.out.println("Finally - shutting down cluster");
+ session.shutdown();
+ }
+ }
+ }
+}
diff --git a/coherence-processingpattern-tests/src/test/java/com/oracle/coherence/patterns/processing/runnable/DoNothingRunnable.java b/coherence-processingpattern-tests/src/test/java/com/oracle/coherence/patterns/processing/runnable/DoNothingRunnable.java
new file mode 100644
index 00000000..e001d098
--- /dev/null
+++ b/coherence-processingpattern-tests/src/test/java/com/oracle/coherence/patterns/processing/runnable/DoNothingRunnable.java
@@ -0,0 +1,141 @@
+/*
+ * File: DoNothingRunnable.java
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * The contents of this file are subject to the terms and conditions of
+ * the Common Development and Distribution License 1.0 (the "License").
+ *
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the License by consulting the LICENSE.txt file
+ * distributed with this file, or by consulting
+ * or https://oss.oracle.com/licenses/CDDL
+ *
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file LICENSE.txt.
+ *
+ * MODIFICATIONS:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ */
+
+package com.oracle.coherence.patterns.processing.runnable;
+
+import com.tangosol.io.ExternalizableLite;
+
+import com.tangosol.io.pof.PofReader;
+import com.tangosol.io.pof.PofWriter;
+import com.tangosol.io.pof.PortableObject;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+
+/**
+ * A {@link DoNothingRunnable} just prints out that it is running.
+ *
+ * @author Christer Fahlgren
+ */
+@SuppressWarnings("serial")
+public class DoNothingRunnable implements Runnable, ExternalizableLite, PortableObject
+{
+ /**
+ * A long indicating how long to sleep in milliseconds.
+ */
+ private long milliSecsToSleep;
+
+
+ /**
+ * Constructs ...
+ *
+ */
+ public DoNothingRunnable()
+ {
+ }
+
+
+ /**
+ * Constructs ...
+ *
+ *
+ * @param milliSecsToSleep
+ */
+ public DoNothingRunnable(long milliSecsToSleep)
+ {
+ this.milliSecsToSleep = milliSecsToSleep;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void run()
+ {
+ System.out.println("Executing the DONOTHINGRUNNABLE sleeping " + milliSecsToSleep);
+
+ if (milliSecsToSleep > 0)
+ {
+ try
+ {
+ Thread.currentThread();
+ Thread.sleep(milliSecsToSleep);
+ System.out.println("FINISHED SLEEPING");
+
+ }
+ catch (InterruptedException e)
+ {
+ System.out.println("RUNNABLE INTERRUPTED");
+ Thread.currentThread().interrupt(); // preserve interruption status
+ e.printStackTrace();
+ }
+ catch (Throwable t)
+ {
+ System.out.println("RUNNABLE INTERRUPTED THROWABLE:" + t);
+ Thread.currentThread().interrupt(); // preserve interruption status
+ t.printStackTrace();
+ }
+ }
+
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void readExternal(DataInput in) throws IOException
+ {
+ milliSecsToSleep = in.readLong();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void writeExternal(DataOutput out) throws IOException
+ {
+ out.writeLong(milliSecsToSleep);
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void readExternal(PofReader reader) throws IOException
+ {
+ milliSecsToSleep = reader.readLong(0);
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void writeExternal(PofWriter writer) throws IOException
+ {
+ writer.writeLong(0, milliSecsToSleep);
+ }
+}
diff --git a/coherence-processingpattern-tests/src/test/java/com/oracle/coherence/patterns/processing/runnable/RunnableLifecycleTests.java b/coherence-processingpattern-tests/src/test/java/com/oracle/coherence/patterns/processing/runnable/RunnableLifecycleTests.java
new file mode 100644
index 00000000..495e4633
--- /dev/null
+++ b/coherence-processingpattern-tests/src/test/java/com/oracle/coherence/patterns/processing/runnable/RunnableLifecycleTests.java
@@ -0,0 +1,190 @@
+/*
+ * File: RunnableLifecycleTests.java
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * The contents of this file are subject to the terms and conditions of
+ * the Common Development and Distribution License 1.0 (the "License").
+ *
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the License by consulting the LICENSE.txt file
+ * distributed with this file, or by consulting
+ * or https://oss.oracle.com/licenses/CDDL
+ *
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file LICENSE.txt.
+ *
+ * MODIFICATIONS:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ */
+
+package com.oracle.coherence.patterns.processing.runnable;
+
+import com.oracle.coherence.common.identifiers.StringBasedIdentifier;
+
+import com.oracle.coherence.patterns.processing.ProcessingSession;
+import com.oracle.coherence.patterns.processing.SubmissionOutcome;
+import com.oracle.coherence.patterns.processing.SubmissionRetentionPolicy;
+import com.oracle.coherence.patterns.processing.SubmissionState;
+import com.oracle.coherence.patterns.processing.internal.DefaultProcessingSession;
+import com.oracle.coherence.patterns.processing.internal.DefaultSubmissionConfiguration;
+import com.oracle.coherence.patterns.processing.misc.AbstractClusterTests;
+
+import com.oracle.tools.runtime.coherence.Cluster;
+
+import com.tangosol.io.pof.PortableException;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+/**
+ * This is a test that exercises the ability to control
+ * the lifecycle of a Submission directly.
+ *
+ * @author David Rowlands
+ */
+public class RunnableLifecycleTests extends AbstractClusterTests
+{
+ /**
+ * {@inheritDoc}
+ */
+ public Cluster startCluster()
+ {
+ return startTestCluster(gridCacheConfig, pofConfig, 0, 1, true);
+ }
+
+
+ /**
+ * A test that checks that runnables with no result are removed with RemoveOnFinalState policy.
+ */
+ @Test
+ public void testRunnableNoResultLifecycle() throws Throwable
+ {
+ extendClientInit(pofConfig, extendClientCacheConfig);
+
+ ProcessingSession session = null;
+
+ try
+ {
+ session = new DefaultProcessingSession(StringBasedIdentifier.newInstance("RunnableLifecycleTestSession"));
+
+ String taskName = "RunnableLifecycle";
+ SubmissionOutcome outcome = session.submit(new DoNothingRunnable(2000),
+ new DefaultSubmissionConfiguration(null),
+ StringBasedIdentifier.newInstance(taskName),
+ SubmissionRetentionPolicy.RemoveOnFinalState,
+ null);
+
+ assertTrue(session.submissionExists(outcome.getIdentifier()));
+ Thread.currentThread();
+ Thread.sleep(5000);
+
+ // After having waited for one second, the runnable should have run and have been removed.
+ // Now we submit a second identically named runnable
+ session.submit(new DoNothingRunnable(),
+ new DefaultSubmissionConfiguration(null),
+ StringBasedIdentifier.newInstance(taskName),
+ SubmissionRetentionPolicy.RemoveOnFinalState,
+ null);
+
+ Thread.currentThread();
+ Thread.sleep(1000);
+
+ // And after having waited another second, the second one should have run and have been deleted
+
+ // We verify that the submission is gone
+ assertFalse(session.submissionExists(StringBasedIdentifier.newInstance(taskName)));
+
+ }
+ catch (Throwable t)
+ {
+ System.out.println("Unexpected Exception in " + getClass().getName());
+ t.printStackTrace(System.out);
+ fail();
+ }
+ finally
+ {
+ if (session != null)
+ {
+ System.out.println("Finally - shutting down cluster");
+ session.shutdown();
+ }
+ }
+ }
+
+
+ /**
+ * A test that checks that runnables with no result are not removed with ExplicitRemove policy.
+ */
+ @Test
+ public void testRunnableNoResultLifecycleExplicitRemove() throws Throwable
+ {
+ extendClientInit(pofConfig, extendClientCacheConfig);
+
+ ProcessingSession session = null;
+
+ try
+ {
+ session = new DefaultProcessingSession(StringBasedIdentifier.newInstance("RunnableLifecycleTestSession"));
+
+ System.out.println("Cluster started - now running testRunnableNoResultLifecycleExplicitRemove");
+
+ String taskName = "RunnableLifecycle";
+ SubmissionOutcome outcome = session.submit(new DoNothingRunnable(),
+ new DefaultSubmissionConfiguration(null),
+ StringBasedIdentifier.newInstance(taskName),
+ SubmissionRetentionPolicy.ExplicitRemove,
+ null);
+
+ Thread.currentThread();
+ Thread.sleep(1000);
+
+ assertTrue(outcome.getSubmissionState() == SubmissionState.DONE);
+
+ try
+ {
+ // After having waited for one second, the runnable should have run and still be there
+ // Now we submit a second identically named runnable
+ session.submit(new DoNothingRunnable(),
+ new DefaultSubmissionConfiguration(null),
+ StringBasedIdentifier.newInstance(taskName),
+ SubmissionRetentionPolicy.RemoveOnFinalState,
+ null);
+ }
+ catch (PortableException e)
+ {
+ if (e.getName().equals("Portable(java.lang.IllegalStateException)"))
+ {
+ // The above should throw an exception because the submission still exists
+ System.out.println("An expected IllegalStateException testRunnableNoResultLifecycleExplicitRemove");
+ }
+ else
+ {
+ throw e;
+ }
+ }
+
+ }
+ catch (Exception t)
+ {
+ System.out.println("Unexpected Exception in testRunnableNoResultLifecycleExplicitRemove");
+ System.out.println("caught exception:" + t);
+ }
+ finally
+ {
+ if (session != null)
+ {
+ session.shutdown();
+ }
+ }
+ }
+}
diff --git a/coherence-processingpattern-tests/src/test/java/com/oracle/coherence/patterns/processing/task/CancelTaskTests.java b/coherence-processingpattern-tests/src/test/java/com/oracle/coherence/patterns/processing/task/CancelTaskTests.java
new file mode 100644
index 00000000..8fca9ddc
--- /dev/null
+++ b/coherence-processingpattern-tests/src/test/java/com/oracle/coherence/patterns/processing/task/CancelTaskTests.java
@@ -0,0 +1,111 @@
+/*
+ * File: CancelTaskTests.java
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * The contents of this file are subject to the terms and conditions of
+ * the Common Development and Distribution License 1.0 (the "License").
+ *
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the License by consulting the LICENSE.txt file
+ * distributed with this file, or by consulting
+ * or https://oss.oracle.com/licenses/CDDL
+ *
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file LICENSE.txt.
+ *
+ * MODIFICATIONS:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ */
+
+package com.oracle.coherence.patterns.processing.task;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.junit.Test;
+
+import com.oracle.coherence.common.identifiers.StringBasedIdentifier;
+import com.oracle.coherence.patterns.processing.ProcessingSession;
+import com.oracle.coherence.patterns.processing.SubmissionOutcome;
+import com.oracle.coherence.patterns.processing.SubmissionRetentionPolicy;
+import com.oracle.coherence.patterns.processing.SubmissionState;
+import com.oracle.coherence.patterns.processing.internal.DefaultProcessingSession;
+import com.oracle.coherence.patterns.processing.internal.DefaultSubmissionConfiguration;
+import com.oracle.coherence.patterns.processing.misc.AbstractClusterTests;
+import com.oracle.tools.runtime.coherence.Cluster;
+
+/**
+ * This is a test that exercises canceling of a task
+ *
+ * @author Christer Fahlgren
+ */
+public class CancelTaskTests extends AbstractClusterTests
+{
+ /**
+ * {@inheritDoc}
+ */
+ public Cluster startCluster()
+ {
+ return startTestCluster(gridCacheConfig, pofConfig, 0, 1, true);
+ }
+
+
+ /**
+ * A test that checks that a Runnable can be canceled after submission.
+ */
+ @Test
+ public void testCancelTask() throws Throwable
+ {
+ extendClientInit(pofConfig, extendClientCacheConfig);
+
+ ProcessingSession session = null;
+
+ try
+ {
+ session =
+ new DefaultProcessingSession(StringBasedIdentifier.newInstance("RunnableLifecycleTestSession"));
+
+ System.out.println("Testing CANCELLING TASK");
+ String taskName = "TaskToCancel";
+ SubmissionOutcome outcome = session.submit(new CancelableTask(6000),
+ new DefaultSubmissionConfiguration(null),
+ StringBasedIdentifier.newInstance(taskName),
+ SubmissionRetentionPolicy.ExplicitRemove,
+ null);
+
+ System.out.println("Wait a second before CANCELLING Task");
+ assertTrue(session.submissionExists(outcome.getIdentifier()));
+ Thread.currentThread();
+ Thread.sleep(500);
+ session.cancelSubmission(outcome.getIdentifier());
+ outcome.get();
+ System.out.println("After get:" + outcome.getSubmissionState());
+ assertTrue(outcome.getSubmissionState() == SubmissionState.CANCELLED);
+ System.out.println("Waiting 3 seconds to complete cancelling of task");
+ Thread.currentThread();
+ Thread.sleep(3000);
+
+ }
+ catch (Throwable t)
+ {
+ System.out.println("Unexpected Exception in " + getClass().getName());
+ t.printStackTrace(System.out);
+ fail();
+ }
+ finally
+ {
+ if (session != null)
+ {
+ System.out.println("Finally - shutting down cluster");
+ session.shutdown();
+ }
+ }
+ }
+}
diff --git a/coherence-processingpattern-tests/src/test/java/com/oracle/coherence/patterns/processing/task/CancelableTask.java b/coherence-processingpattern-tests/src/test/java/com/oracle/coherence/patterns/processing/task/CancelableTask.java
new file mode 100644
index 00000000..636e8193
--- /dev/null
+++ b/coherence-processingpattern-tests/src/test/java/com/oracle/coherence/patterns/processing/task/CancelableTask.java
@@ -0,0 +1,157 @@
+/*
+ * File: CancelableTask.java
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * The contents of this file are subject to the terms and conditions of
+ * the Common Development and Distribution License 1.0 (the "License").
+ *
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the License by consulting the LICENSE.txt file
+ * distributed with this file, or by consulting
+ * or https://oss.oracle.com/licenses/CDDL
+ *
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file LICENSE.txt.
+ *
+ * MODIFICATIONS:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ */
+
+package com.oracle.coherence.patterns.processing.task;
+
+import com.tangosol.io.ExternalizableLite;
+
+import com.tangosol.io.pof.PofReader;
+import com.tangosol.io.pof.PofWriter;
+import com.tangosol.io.pof.PortableObject;
+
+import com.tangosol.util.ExternalizableHelper;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+
+/**
+ * Taks that is used in Cancellation testing.
+ *
+ * @author David Rowlands
+ */
+public class CancelableTask implements ResumableTask, ExternalizableLite, PortableObject
+{
+ private long sleepDuration;
+
+
+ /**
+ * Constructs ...
+ *
+ */
+ public CancelableTask()
+ {
+ }
+
+
+ /**
+ * Constructs ...
+ *
+ *
+ * @param sleepDuration
+ */
+ public CancelableTask(int sleepDuration)
+ {
+ this.sleepDuration = sleepDuration;
+ }
+
+
+ /**
+ * Method description
+ *
+ * @param in
+ *
+ * @throws IOException
+ */
+ public void readExternal(DataInput in) throws IOException
+ {
+ sleepDuration = ExternalizableHelper.readLong(in);
+ }
+
+
+ /**
+ * Method description
+ *
+ * @param out
+ *
+ * @throws IOException
+ */
+ public void writeExternal(DataOutput out) throws IOException
+ {
+ ExternalizableHelper.writeLong(out, sleepDuration);
+ }
+
+
+ /**
+ * Method description
+ *
+ * @param reader
+ *
+ * @throws IOException
+ */
+ public void readExternal(PofReader reader) throws IOException
+ {
+ sleepDuration = reader.readLong(10);
+ }
+
+
+ /**
+ * Method description
+ *
+ * @param writer
+ *
+ * @throws IOException
+ */
+ public void writeExternal(PofWriter writer) throws IOException
+ {
+ writer.writeLong(10, sleepDuration);
+ }
+
+
+ /**
+ * Method description
+ *
+ * @param environment
+ *
+ * @return
+ */
+ public Object run(TaskExecutionEnvironment environment)
+ {
+ try
+ {
+ Thread.sleep(sleepDuration);
+ }
+ catch (InterruptedException e)
+ {
+ System.out.println("Thread was interrupted during sleep - stack trace as follows:");
+ e.printStackTrace();
+ }
+
+ return null;
+ }
+
+
+ /**
+ * Method description
+ *
+ * @return
+ */
+ @Override
+ public String toString()
+ {
+ return "CancelableTask [sleepDuration=" + sleepDuration + "]";
+ }
+}
diff --git a/coherence-processingpattern-tests/src/test/java/com/oracle/coherence/patterns/processing/task/DuplicateIdentifierTests.java b/coherence-processingpattern-tests/src/test/java/com/oracle/coherence/patterns/processing/task/DuplicateIdentifierTests.java
new file mode 100644
index 00000000..74f8ec0f
--- /dev/null
+++ b/coherence-processingpattern-tests/src/test/java/com/oracle/coherence/patterns/processing/task/DuplicateIdentifierTests.java
@@ -0,0 +1,116 @@
+/*
+ * File: DuplicateIdentifierTests.java
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * The contents of this file are subject to the terms and conditions of
+ * the Common Development and Distribution License 1.0 (the "License").
+ *
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the License by consulting the LICENSE.txt file
+ * distributed with this file, or by consulting
+ * or https://oss.oracle.com/licenses/CDDL
+ *
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file LICENSE.txt.
+ *
+ * MODIFICATIONS:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ */
+
+package com.oracle.coherence.patterns.processing.task;
+
+import com.oracle.coherence.common.identifiers.StringBasedIdentifier;
+
+import com.oracle.coherence.patterns.processing.ProcessingSession;
+import com.oracle.coherence.patterns.processing.SubmissionOutcome;
+import com.oracle.coherence.patterns.processing.SubmissionRetentionPolicy;
+import com.oracle.coherence.patterns.processing.internal.DefaultProcessingSession;
+import com.oracle.coherence.patterns.processing.internal.DefaultSubmissionConfiguration;
+import com.oracle.coherence.patterns.processing.misc.AbstractClusterTests;
+
+import com.tangosol.net.CacheFactory;
+import com.tangosol.net.NamedCache;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+/**
+ * Test multiple task using the same indentifiers.
+ *
+ * @author Christer Fahlgren
+ */
+public class DuplicateIdentifierTests extends AbstractClusterTests
+{
+ /**
+ * A test that checks that an exception is thrown for duplicate identifiers.
+ */
+ @Test
+ public void testDuplicateIdentifier() throws Throwable
+ {
+ extendClientInit(pofConfig, extendClientCacheConfig);
+
+ ProcessingSession session = null;
+
+ try
+ {
+ session = new DefaultProcessingSession(StringBasedIdentifier.newInstance("DuplicateIdentifierSession"));
+
+ String taskName = "DuplicateIdentifier";
+
+ System.out.println("Submitting first task");
+
+ SubmissionOutcome outcome = session.submit(new TestTask(taskName),
+ new DefaultSubmissionConfiguration(null),
+ StringBasedIdentifier.newInstance(taskName),
+ SubmissionRetentionPolicy.ExplicitRemove,
+ null);
+
+ try
+ {
+ System.out.println("Submitting second task");
+ session.submit(new TestTask(taskName),
+ new DefaultSubmissionConfiguration(null),
+ StringBasedIdentifier.newInstance(taskName),
+ SubmissionRetentionPolicy.ExplicitRemove,
+ null);
+ }
+ catch (IllegalStateException e)
+ {
+ System.out.println("Expected IllegalStateException thrown during submit of second task:" + e);
+ }
+
+ NamedCache cache = CacheFactory.getCache("coherence.patterns.processing.submissions");
+
+ assertEquals(cache.size(), 1);
+ System.out.println("Now lets wait for the completion of first outcome.");
+ System.out.print(outcome.get());
+ System.out.println("\n");
+ System.out.println("========================================");
+ System.out.println("TEST COMPLETED.");
+
+ }
+ catch (Throwable t)
+ {
+ System.out.println("Unexpected Exception in " + getClass().getName());
+ t.printStackTrace(System.out);
+ fail();
+ }
+ finally
+ {
+ if (session != null)
+ {
+ System.out.println("Finally - shutting down cluster");
+ session.shutdown();
+ }
+ }
+ }
+}
diff --git a/coherence-processingpattern-tests/src/test/java/com/oracle/coherence/patterns/processing/task/GetIdentifiersTests.java b/coherence-processingpattern-tests/src/test/java/com/oracle/coherence/patterns/processing/task/GetIdentifiersTests.java
new file mode 100644
index 00000000..899ce64e
--- /dev/null
+++ b/coherence-processingpattern-tests/src/test/java/com/oracle/coherence/patterns/processing/task/GetIdentifiersTests.java
@@ -0,0 +1,127 @@
+/*
+ * File: GetIdentifiersTests.java
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * The contents of this file are subject to the terms and conditions of
+ * the Common Development and Distribution License 1.0 (the "License").
+ *
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the License by consulting the LICENSE.txt file
+ * distributed with this file, or by consulting
+ * or https://oss.oracle.com/licenses/CDDL
+ *
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file LICENSE.txt.
+ *
+ * MODIFICATIONS:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ */
+
+package com.oracle.coherence.patterns.processing.task;
+
+import com.oracle.coherence.common.identifiers.Identifier;
+import com.oracle.coherence.common.identifiers.StringBasedIdentifier;
+
+import com.oracle.coherence.patterns.processing.ProcessingSession;
+import com.oracle.coherence.patterns.processing.SubmissionOutcome;
+import com.oracle.coherence.patterns.processing.SubmissionRetentionPolicy;
+import com.oracle.coherence.patterns.processing.internal.DefaultProcessingSession;
+import com.oracle.coherence.patterns.processing.internal.DefaultSubmissionConfiguration;
+import com.oracle.coherence.patterns.processing.misc.AbstractClusterTests;
+
+import com.oracle.tools.runtime.coherence.Cluster;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+/**
+ * Test to ensure test identifiers are created and handled correctly.
+ *
+ * @author Christer Fahlgren
+ */
+public class GetIdentifiersTests extends AbstractClusterTests
+{
+ /**
+ * {@inheritDoc}
+ */
+ public Cluster startCluster()
+ {
+ return startTestCluster(gridCacheConfig, pofConfig, 0, 1, true);
+ }
+
+
+ /**
+ * A test that creates tasks with specific identifiers and then tests for their existence.
+ */
+ @Test
+ public void testGetIdentifiers() throws Throwable
+ {
+ extendClientInit(pofConfig, extendClientCacheConfig);
+
+ ProcessingSession session = null;
+
+ try
+ {
+ session = new DefaultProcessingSession(StringBasedIdentifier.newInstance("GetIdentifiersSession"));
+
+ String taskName = "firstIdentifier";
+ SubmissionOutcome outcome = session.submit(new TestTask(taskName),
+ new DefaultSubmissionConfiguration(null),
+ StringBasedIdentifier.newInstance(taskName),
+ SubmissionRetentionPolicy.ExplicitRemove,
+ new SubmissionCallback(taskName));
+
+ String taskName2 = "secondIdentifier";
+ SubmissionOutcome secondoutcome = session.submit(new TestTask(taskName2),
+ new DefaultSubmissionConfiguration(null),
+ StringBasedIdentifier.newInstance(taskName2),
+ SubmissionRetentionPolicy.ExplicitRemove,
+ new SubmissionCallback(taskName2));
+
+ assertTrue(session.submissionExists(StringBasedIdentifier.newInstance(taskName)));
+ assertTrue(session.submissionExists(StringBasedIdentifier.newInstance(taskName2)));
+ assertFalse(session.submissionExists(StringBasedIdentifier.newInstance("doesn't exist")));
+
+ Iterator iter = session.getIdentifierIterator();
+ ArrayList ids = new ArrayList();
+
+ while (iter.hasNext())
+ {
+ Identifier id = iter.next();
+
+ ids.add(id);
+ System.out.println("Id in list:" + id);
+ }
+
+ assertTrue(ids.contains(StringBasedIdentifier.newInstance(taskName)));
+ assertTrue(ids.contains(StringBasedIdentifier.newInstance(taskName2)));
+ }
+ catch (Throwable t)
+ {
+ System.out.println("Unexpected Exception in " + getClass().getName());
+ t.printStackTrace(System.out);
+ fail();
+ }
+ finally
+ {
+ if (session != null)
+ {
+ System.out.println("Finally - shutting down cluster");
+ session.shutdown();
+ }
+ }
+ }
+}
diff --git a/coherence-processingpattern-tests/src/test/java/com/oracle/coherence/patterns/processing/task/NoRemoveTaskTests.java b/coherence-processingpattern-tests/src/test/java/com/oracle/coherence/patterns/processing/task/NoRemoveTaskTests.java
new file mode 100644
index 00000000..eecac480
--- /dev/null
+++ b/coherence-processingpattern-tests/src/test/java/com/oracle/coherence/patterns/processing/task/NoRemoveTaskTests.java
@@ -0,0 +1,170 @@
+/*
+ * File: NoRemoveTaskTests.java
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * The contents of this file are subject to the terms and conditions of
+ * the Common Development and Distribution License 1.0 (the "License").
+ *
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the License by consulting the LICENSE.txt file
+ * distributed with this file, or by consulting
+ * or https://oss.oracle.com/licenses/CDDL
+ *
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file LICENSE.txt.
+ *
+ * MODIFICATIONS:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ */
+
+package com.oracle.coherence.patterns.processing.task;
+
+import com.oracle.coherence.common.identifiers.StringBasedIdentifier;
+
+import com.oracle.coherence.patterns.processing.ProcessingSession;
+import com.oracle.coherence.patterns.processing.SubmissionOutcome;
+import com.oracle.coherence.patterns.processing.SubmissionRetentionPolicy;
+import com.oracle.coherence.patterns.processing.internal.DefaultProcessingSession;
+import com.oracle.coherence.patterns.processing.internal.DefaultSubmissionConfiguration;
+import com.oracle.coherence.patterns.processing.misc.AbstractClusterTests;
+
+import com.oracle.tools.runtime.coherence.Cluster;
+
+import com.tangosol.net.CacheFactory;
+import com.tangosol.net.NamedCache;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.text.DateFormat;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Verify submission retention policy.
+ *
+ * @author Christer Fahlgren
+ */
+public class NoRemoveTaskTests extends AbstractClusterTests
+{
+ /**
+ * {@inheritDoc}
+ */
+ public Cluster startCluster()
+ {
+ return startTestCluster(gridCacheConfig, pofConfig, 0, 1, true);
+ }
+
+
+ /**
+ * A test that creates tasks, and controls the lifecycle directly.
+ */
+ @Test
+ public void testNoRemoveTask() throws Throwable
+ {
+ extendClientInit(pofConfig, extendClientCacheConfig);
+
+ ProcessingSession session = null;
+
+ try
+ {
+ session =
+ new DefaultProcessingSession(StringBasedIdentifier
+ .newInstance("TaskExecutionSample"
+ + DateFormat.getDateTimeInstance().format(System.currentTimeMillis())));
+
+ ArrayList tasklist = new ArrayList();
+
+ for (int i = 0; i < 5; i++)
+ {
+ String taskName = "TestTask:" + Integer.toString(i);
+ Map attrMap = new HashMap();
+
+ attrMap.put("type", "grid");
+ System.out.println("Submitting test tasks " + i);
+
+ SubmissionOutcome outcome = session.submit(new TestTask(taskName),
+ new DefaultSubmissionConfiguration(attrMap),
+ StringBasedIdentifier.newInstance(taskName),
+ SubmissionRetentionPolicy.ExplicitRemove,
+ new SubmissionCallback(taskName));
+
+ tasklist.add(outcome);
+ }
+
+ NamedCache cache = CacheFactory.getCache("coherence.patterns.processing.submissions");
+
+ System.out.println("Cache size: " + cache.size());
+
+ for (int i = 0; i < tasklist.size(); i++)
+ {
+ System.out.println("Waiting for: " + i);
+
+ System.out.println("Result:" + Integer.toString(i) + ":" + tasklist.get(i).get().toString());
+ System.out.println("Took:" + Integer.toString(i) + ":" + tasklist.get(i).getExecutionDuration() + " L:"
+ + tasklist.get(i).getWaitDuration());
+ }
+
+ // Verifying that the submissions didn't get deleted.
+ assertEquals(cache.size(), tasklist.size());
+
+ ProcessingSession newsession = new DefaultProcessingSession(StringBasedIdentifier.newInstance("NewOwner"));
+ ArrayList newtasklist = new ArrayList();
+
+ for (int i = 0; i < tasklist.size(); i++)
+ {
+ System.out.println("Changing owner: " + i);
+ newtasklist.add(newsession.acquireSubmission(tasklist.get(i).getIdentifier(),
+ SubmissionRetentionPolicy.ExplicitRemove, null));
+ }
+
+ System.out.println("After changing owner Cache size: " + cache.size());
+
+ // Now since we changed owner for the Submissions, we shall not be able to remove
+ // them using the original session.
+ for (int i = 0; i < tasklist.size(); i++)
+ {
+ assertFalse(session.discardSubmission(tasklist.get(i).getIdentifier()));
+ }
+
+ // But we should be able to remove them using the new session.
+ for (int i = 0; i < newtasklist.size(); i++)
+ {
+ assertTrue(newsession.discardSubmission(newtasklist.get(i).getIdentifier()));
+ }
+
+ System.out.println("after remove Cache size: " + cache.size());
+
+ System.out.println("Cache size: " + cache.size());
+ assertEquals(cache.size(), 0);
+ System.out.println("Finished");
+ }
+ catch (Throwable t)
+ {
+ System.out.println("Unexpected Exception in " + getClass().getName());
+ t.printStackTrace(System.out);
+ fail();
+ }
+ finally
+ {
+ if (session != null)
+ {
+ System.out.println("Finally - shutting down cluster");
+ session.shutdown();
+ }
+ }
+ }
+}
diff --git a/coherence-processingpattern-tests/src/test/java/com/oracle/coherence/patterns/processing/task/SimpleTaskTests.java b/coherence-processingpattern-tests/src/test/java/com/oracle/coherence/patterns/processing/task/SimpleTaskTests.java
new file mode 100644
index 00000000..05ac8ae2
--- /dev/null
+++ b/coherence-processingpattern-tests/src/test/java/com/oracle/coherence/patterns/processing/task/SimpleTaskTests.java
@@ -0,0 +1,142 @@
+/*
+ * File: SimpleTaskTests.java
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * The contents of this file are subject to the terms and conditions of
+ * the Common Development and Distribution License 1.0 (the "License").
+ *
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the License by consulting the LICENSE.txt file
+ * distributed with this file, or by consulting
+ * or https://oss.oracle.com/licenses/CDDL
+ *
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file LICENSE.txt.
+ *
+ * MODIFICATIONS:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ */
+
+package com.oracle.coherence.patterns.processing.task;
+
+import static org.junit.Assert.fail;
+
+import java.text.DateFormat;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Test;
+
+import com.oracle.coherence.common.identifiers.StringBasedIdentifier;
+import com.oracle.coherence.patterns.processing.ProcessingSession;
+import com.oracle.coherence.patterns.processing.SubmissionOutcome;
+import com.oracle.coherence.patterns.processing.SubmissionRetentionPolicy;
+import com.oracle.coherence.patterns.processing.internal.DefaultProcessingSession;
+import com.oracle.coherence.patterns.processing.internal.DefaultSubmissionConfiguration;
+import com.oracle.coherence.patterns.processing.misc.AbstractClusterTests;
+import com.oracle.tools.runtime.coherence.Cluster;
+import com.tangosol.net.CacheFactory;
+import com.tangosol.net.NamedCache;
+
+/**
+ * Test submit of several task given a random server failure.
+ *
+ * @author Christer Fahlgren
+ */
+public class SimpleTaskTests extends AbstractClusterTests
+{
+ /**
+ * {@inheritDoc}
+ */
+ public Cluster startCluster()
+ {
+ return startTestCluster(gridCacheConfig, pofConfig, 0, 2, true);
+ }
+
+
+ // ----- test methods ---------------------------------------------------
+
+ /**
+ * Test of ResumableTask.
+ *
+ * @throws Throwable if something fails
+ */
+ @Test
+ public void testSimpleTask() throws Throwable
+ {
+ extendClientInit(pofConfig, extendClientCacheConfig);
+ ProcessingSession session = null;
+
+ try
+ {
+ session =
+ new DefaultProcessingSession(StringBasedIdentifier
+ .newInstance("TaskExecutionSample"
+ + DateFormat.getDateTimeInstance().format(System.currentTimeMillis())));
+
+ ArrayList tasklist = new ArrayList();
+
+ for (int i = 0; i < 6; i++)
+ {
+ String taskName = "TestTask:" + Integer.toString(i);
+ Map attrMap = new HashMap();
+
+ attrMap.put("type", "grid");
+ System.out.println("Submitting test tasks " + i);
+
+ SubmissionOutcome outcome = session.submit(new TestTask(taskName),
+ new DefaultSubmissionConfiguration(attrMap),
+ StringBasedIdentifier.newInstance(taskName),
+ SubmissionRetentionPolicy.RemoveOnFinalState,
+ new SubmissionCallback(taskName));
+
+ tasklist.add(outcome);
+ }
+
+ NamedCache cache = CacheFactory.getCache("coherence.patterns.processing.submissions");
+
+ System.out.println("Cache size: " + cache.size());
+
+ for (int i = 0; i < tasklist.size(); i++)
+ {
+ if (i == (tasklist.size() / 2))
+ {
+ System.out.println("-----------------------------------");
+ System.out.println("- STOPPING ONE SERVER -");
+ //shutdownServer();
+ System.out.println("-----------------------------------");
+ }
+
+ System.out.println("Waiting for: " + i);
+ System.out.println("Result:" + Integer.toString(i) + ":" + tasklist.get(i).get().toString());
+ System.out.println("Took:" + Integer.toString(i) + ":" + tasklist.get(i).getExecutionDuration() + " L:"
+ + tasklist.get(i).getWaitDuration());
+ }
+
+ System.out.println("Cache size: " + cache.size());
+ System.out.println("Finished");
+ }
+ catch (Throwable t)
+ {
+ System.out.println("Unexpected Exception in " + getClass().getName());
+ t.printStackTrace(System.out);
+ fail();
+ }
+ finally
+ {
+ if (session != null)
+ {
+ System.out.println("Finally - shutting down cluster");
+ session.shutdown();
+ }
+ }
+ }
+}
diff --git a/coherence-processingpattern-tests/src/test/java/com/oracle/coherence/patterns/processing/task/SubmissionCallback.java b/coherence-processingpattern-tests/src/test/java/com/oracle/coherence/patterns/processing/task/SubmissionCallback.java
new file mode 100644
index 00000000..cee61486
--- /dev/null
+++ b/coherence-processingpattern-tests/src/test/java/com/oracle/coherence/patterns/processing/task/SubmissionCallback.java
@@ -0,0 +1,96 @@
+/*
+ * File: SubmissionCallback.java
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * The contents of this file are subject to the terms and conditions of
+ * the Common Development and Distribution License 1.0 (the "License").
+ *
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the License by consulting the LICENSE.txt file
+ * distributed with this file, or by consulting
+ * or https://oss.oracle.com/licenses/CDDL
+ *
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file LICENSE.txt.
+ *
+ * MODIFICATIONS:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ */
+
+package com.oracle.coherence.patterns.processing.task;
+
+import com.oracle.coherence.patterns.processing.SubmissionOutcomeListener;
+
+/**
+ * Callback class reporting on the results of a Task.
+ *
+ * @author Christer Fahlgren
+ */
+public class SubmissionCallback implements SubmissionOutcomeListener
+{
+ private String m_sTaskName;
+
+
+ /**
+ * Constructs ...
+ *
+ *
+ * @param sTaskName
+ */
+ public SubmissionCallback(String sTaskName)
+ {
+ m_sTaskName = sTaskName;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void onDone(Object oResult)
+ {
+ System.out.println(m_sTaskName + ":Submission done");
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void onFailed(Object oResult)
+ {
+ System.out.println(m_sTaskName + ":Submission failed");
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void onProgress(Object oProgress)
+ {
+ System.out.println(m_sTaskName + ":Submission progress:" + oProgress.toString());
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void onStarted()
+ {
+ System.out.println(m_sTaskName + ":Submission started");
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void onSuspended()
+ {
+ System.out.println(m_sTaskName + ":Submission suspended");
+ }
+}
diff --git a/coherence-processingpattern-tests/src/test/java/com/oracle/coherence/patterns/processing/task/TestTask.java b/coherence-processingpattern-tests/src/test/java/com/oracle/coherence/patterns/processing/task/TestTask.java
new file mode 100644
index 00000000..1b1716bc
--- /dev/null
+++ b/coherence-processingpattern-tests/src/test/java/com/oracle/coherence/patterns/processing/task/TestTask.java
@@ -0,0 +1,155 @@
+/*
+ * File: TestTask.java
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * The contents of this file are subject to the terms and conditions of
+ * the Common Development and Distribution License 1.0 (the "License").
+ *
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the License by consulting the LICENSE.txt file
+ * distributed with this file, or by consulting
+ * or https://oss.oracle.com/licenses/CDDL
+ *
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file LICENSE.txt.
+ *
+ * MODIFICATIONS:
+ * If applicable, add the following below the License Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyright [year] [name of copyright owner]"
+ */
+
+package com.oracle.coherence.patterns.processing.task;
+
+import com.tangosol.io.ExternalizableLite;
+
+import com.tangosol.io.pof.PofReader;
+import com.tangosol.io.pof.PofWriter;
+import com.tangosol.io.pof.PortableObject;
+
+import com.tangosol.net.CacheFactory;
+import com.tangosol.net.Cluster;
+
+import com.tangosol.util.ExternalizableHelper;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+
+/**
+ * A {@link TestTask} used by the {@link SimpleTaskTest}.
+ *
+ * @author Christer Fahlgren
+ */
+public class TestTask implements ResumableTask, ExternalizableLite, PortableObject
+{
+ /**
+ * A message.
+ */
+ private String m_sMessage;
+
+
+ /**
+ * Default constructor.
+ */
+ public TestTask()
+ {
+ super();
+ }
+
+
+ /**
+ * Standard constructor.
+ * @param message the message for this task
+ */
+ public TestTask(String message)
+ {
+ m_sMessage = message;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void readExternal(DataInput in) throws IOException
+ {
+ m_sMessage = ExternalizableHelper.readSafeUTF(in);
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void writeExternal(DataOutput out) throws IOException
+ {
+ ExternalizableHelper.writeSafeUTF(out, m_sMessage);
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void readExternal(PofReader reader) throws IOException
+ {
+ m_sMessage = reader.readString(10);
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void writeExternal(PofWriter writer) throws IOException
+ {
+ writer.writeString(10, m_sMessage);
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object run(TaskExecutionEnvironment environment)
+ {
+ if (!environment.isResuming())
+ {
+ Cluster cluster = CacheFactory.getCluster();
+ String MemberID = "Member ID:" + cluster.getLocalMember().getId() + " Cluster name:"
+ + cluster.getClusterName();
+
+ System.out.println(MemberID);
+ environment.reportProgress(50);
+
+ return new Yield(MemberID, 1000);
+ }
+ else
+ {
+ String messageToReturn = (String) environment.loadCheckpoint();
+
+ environment.reportProgress(100);
+
+ return messageToReturn;
+ }
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ return "TestTask:" + getType() + ": " + m_sMessage;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getType()
+ {
+ return "";
+ }
+}
diff --git a/coherence-processingpattern-tests/src/test/resources/coherence-processingpattern-test-extend-taskprocessing-cache-config.xml b/coherence-processingpattern-tests/src/test/resources/coherence-processingpattern-test-extend-taskprocessing-cache-config.xml
new file mode 100755
index 00000000..32ea3ad2
--- /dev/null
+++ b/coherence-processingpattern-tests/src/test/resources/coherence-processingpattern-test-extend-taskprocessing-cache-config.xml
@@ -0,0 +1,67 @@
+
+
+
+
+
+
+ coherence.patterns.processing.*
+ extend-dist
+
+
+
+
+
+ extend-dist
+
+
+ com.tangosol.io.pof.ConfigurablePofContext
+
+
+
+
+ localhost
+ 20020
+
+
+ 10s
+
+
+
+
+
+
+ single
+
+
+
+
+
\ No newline at end of file
diff --git a/coherence-processingpattern-tests/src/test/resources/coherence-processingpattern-test-extendclient-cache-config.xml b/coherence-processingpattern-tests/src/test/resources/coherence-processingpattern-test-extendclient-cache-config.xml
new file mode 100755
index 00000000..0fcc9f46
--- /dev/null
+++ b/coherence-processingpattern-tests/src/test/resources/coherence-processingpattern-test-extendclient-cache-config.xml
@@ -0,0 +1,63 @@
+
+
+
+
+
+ pof
+
+
+
+
+
+ coherence.patterns.processing.*
+ extend-dist
+
+
+
+
+
+ extend-dist
+
+
+
+
+ localhost
+ 10000
+
+
+
+ 10s
+
+
+
+
+
diff --git a/coherence-processingpattern-tests/src/test/resources/coherence-processingpattern-test-grid-server-cache-config.xml b/coherence-processingpattern-tests/src/test/resources/coherence-processingpattern-test-grid-server-cache-config.xml
new file mode 100755
index 00000000..e935b611
--- /dev/null
+++ b/coherence-processingpattern-tests/src/test/resources/coherence-processingpattern-test-grid-server-cache-config.xml
@@ -0,0 +1,67 @@
+
+
+>
+
+
+
+ ExtendTcpProxyService
+
+
+
+ localhost
+ 10000
+
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ grid
+
+
+
+
\ No newline at end of file
diff --git a/coherence-processingpattern-tests/src/test/resources/coherence-processingpattern-test-pof-config.xml b/coherence-processingpattern-tests/src/test/resources/coherence-processingpattern-test-pof-config.xml
new file mode 100755
index 00000000..c93567f3
--- /dev/null
+++ b/coherence-processingpattern-tests/src/test/resources/coherence-processingpattern-test-pof-config.xml
@@ -0,0 +1,63 @@
+
+
+
+
+
+ coherence-pof-config.xml
+ coherence-common-pof-config.xml
+ coherence-processingpattern-pof-config.xml
+
+
+
+ 16500
+ com.oracle.coherence.patterns.processing.task.TestTask
+
+
+
+
+ 16501
+ com.oracle.coherence.patterns.processing.callable.SimpleCallable
+
+
+
+
+ 16502
+ com.oracle.coherence.patterns.processing.runnable.DoNothingRunnable
+
+
+
+
+ 16503
+ com.oracle.coherence.patterns.processing.task.CancelableTask
+
+
+
+
+
+
+
diff --git a/coherence-processingpattern-tests/src/test/resources/coherence-processingpattern-test-proxy-cache-config.xml b/coherence-processingpattern-tests/src/test/resources/coherence-processingpattern-test-proxy-cache-config.xml
new file mode 100755
index 00000000..a4d437a3
--- /dev/null
+++ b/coherence-processingpattern-tests/src/test/resources/coherence-processingpattern-test-proxy-cache-config.xml
@@ -0,0 +1,59 @@
+
+
+>
+
+
+
+ ExtendTcpProxyService
+
+
+
+ localhost
+ 10000
+
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/coherence-processingpattern-tests/src/test/resources/coherence-processingpattern-test-single-server-cache-config.xml b/coherence-processingpattern-tests/src/test/resources/coherence-processingpattern-test-single-server-cache-config.xml
new file mode 100755
index 00000000..68b43d8e
--- /dev/null
+++ b/coherence-processingpattern-tests/src/test/resources/coherence-processingpattern-test-single-server-cache-config.xml
@@ -0,0 +1,73 @@
+
+
+>
+
+
+
+ ExtendTcpProxyService
+
+
+
+ localhost
+ 10000
+
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ com.oracle.coherence.patterns.processing.taskprocessor.DefaultTaskProcessor
+
+ String Task Processor
+ 10
+
+
+ single
+
+
+
+
\ No newline at end of file