Added tests for bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=324531
diff --git a/tests/bundles/org.eclipse.ecf.tests.sharedobject/src/org/eclipse/ecf/tests/sharedobject/TestTransactionSharedObject.java b/tests/bundles/org.eclipse.ecf.tests.sharedobject/src/org/eclipse/ecf/tests/sharedobject/TestTransactionSharedObject.java
new file mode 100644
index 0000000..2cf632a
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.sharedobject/src/org/eclipse/ecf/tests/sharedobject/TestTransactionSharedObject.java
@@ -0,0 +1,79 @@
+/****************************************************************************
+ * Copyright (c) 2007 Composent, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Composent, Inc. - initial API and implementation
+ *****************************************************************************/
+
+package org.eclipse.ecf.tests.sharedobject;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.ecf.core.identity.ID;
+import org.eclipse.ecf.core.sharedobject.ReplicaSharedObjectDescription;
+import org.eclipse.ecf.core.sharedobject.SharedObjectInitException;
+import org.eclipse.ecf.core.sharedobject.SharedObjectMsg;
+import org.eclipse.ecf.core.sharedobject.TransactionSharedObject;
+
+/**
+ *
+ */
+public class TestTransactionSharedObject extends TransactionSharedObject {
+
+ public static final String NAME_PROPERTY = "name";
+
+ String name;
+ /**
+ * Primary constructor
+ * @param name the name to say hello to
+ */
+ public TestTransactionSharedObject(String name, IMessageReceiver receiver) {
+ this.name = name;
+ }
+
+ /**
+ * Replica constructor (null constructor)
+ */
+ public TestTransactionSharedObject() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.core.sharedobject.BaseSharedObject#initialize()
+ */
+ protected void initialize() throws SharedObjectInitException {
+ super.initialize();
+ if (isPrimary()) {
+ System.out.println("Primary(" + getContext().getLocalContainerID() + ") says Hello " + name);
+ } else {
+ // This is a replica, so initialize the name from property
+ name = (String) getConfig().getProperties().get(NAME_PROPERTY);
+ System.out.println("Replica(" + getContext().getLocalContainerID() + ") says Hello " + name);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.core.sharedobject.BaseSharedObject#getReplicaDescription(org.eclipse.ecf.core.identity.ID)
+ */
+ protected ReplicaSharedObjectDescription getReplicaDescription(ID receiver) {
+ // Put primary state into properties and include in replica description
+ final Map properties = new HashMap();
+ properties.put(NAME_PROPERTY, name);
+ return new ReplicaSharedObjectDescription(this.getClass(), getConfig().getSharedObjectID(), getConfig().getHomeContainerID(), properties);
+ }
+
+ protected boolean handleSharedObjectMsg(SharedObjectMsg msg) {
+ try {
+ msg.invoke(this);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return true;
+ }
+
+}
diff --git a/tests/bundles/org.eclipse.ecf.tests.sharedobject/src/org/eclipse/ecf/tests/sharedobject/TransactionSharedObjectTest.java b/tests/bundles/org.eclipse.ecf.tests.sharedobject/src/org/eclipse/ecf/tests/sharedobject/TransactionSharedObjectTest.java
new file mode 100644
index 0000000..7e22a93
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.sharedobject/src/org/eclipse/ecf/tests/sharedobject/TransactionSharedObjectTest.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+* Copyright (c) 2009 EclipseSource and others. All rights reserved. This
+* program and the accompanying materials are made available under the terms of
+* the Eclipse Public License v1.0 which accompanies this distribution, and is
+* available at http://www.eclipse.org/legal/epl-v10.html
+*
+* Contributors:
+* EclipseSource - initial API and implementation
+******************************************************************************/
+package org.eclipse.ecf.tests.sharedobject;
+
+import org.eclipse.ecf.core.identity.ID;
+import org.eclipse.ecf.core.identity.IDFactory;
+
+public class TransactionSharedObjectTest extends AbstractSharedObjectTest {
+
+ public static final String SERVER_NAME = "ecftcp://localhost:5889/server";
+
+ public static final String TEST_USERNAME0 = "slewis";
+
+ ID sharedObjectID;
+ TestTransactionSharedObject sharedObject;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.tests.ContainerAbstractTestCase#getClientCount()
+ */
+ protected int getClientCount() {
+ return 1;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ecf.tests.ContainerAbstractTestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ createServerAndClients();
+ connectClients();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ cleanUpServerAndClients();
+ sharedObjectID = null;
+ sharedObject = null;
+ }
+
+ public void testAddTransactionSharedObject() throws Exception {
+ // Add test messaging shared object
+ sharedObjectID = addClientSharedObject(0,IDFactory.getDefault()
+ .createStringID("foo0"),new TestTransactionSharedObject(TEST_USERNAME0,new IMessageReceiver() {
+ public void handleMessage(ID fromID, Object message) {
+ System.out.println("received fromId="+fromID+" message="+message);
+ }}),null);
+ sharedObject = (TestTransactionSharedObject) getClientSOManager(0).getSharedObject(sharedObjectID);
+ sleep(2000);
+ }
+
+}