Author: penyaskito Date: 2008-10-08 03:17:14-0700 New Revision: 15904 Modified: branches/BRANCH_0_26_x/src/argouml-app/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLAssociationRoleBaseComboBoxModel.java branches/BRANCH_0_26_x/src/argouml-app/tests/org/argouml/uml/ui/behavior/common_behavior/TestUMLReceptionSignalComboBoxModel.java
Log: Applying patch from trunk r15886, fixes the tests that could fail because of a race condition after the fixes in Issue 5416. Modified: branches/BRANCH_0_26_x/src/argouml-app/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLAssociationRoleBaseComboBoxModel.java Url: http://argouml.tigris.org/source/browse/argouml/branches/BRANCH_0_26_x/src/argouml-app/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLAssociationRoleBaseComboBoxModel.java?view=diff&rev=15904&p1=branches/BRANCH_0_26_x/src/argouml-app/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLAssociationRoleBaseComboBoxModel.java&p2=branches/BRANCH_0_26_x/src/argouml-app/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLAssociationRoleBaseComboBoxModel.java&r1=15903&r2=15904 ============================================================================== --- branches/BRANCH_0_26_x/src/argouml-app/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLAssociationRoleBaseComboBoxModel.java (original) +++ branches/BRANCH_0_26_x/src/argouml-app/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLAssociationRoleBaseComboBoxModel.java 2008-10-08 03:17:14-0700 @@ -24,14 +24,19 @@ package org.argouml.uml.ui.behavior.collaborations; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.Collection; + import junit.framework.TestCase; -import org.argouml.model.InitializeModel; import org.argouml.kernel.Project; import org.argouml.kernel.ProjectManager; +import org.argouml.model.InitializeModel; import org.argouml.model.Model; import org.argouml.profile.init.InitProfileSubsystem; import org.argouml.ui.targetmanager.TargetEvent; +import org.argouml.util.ThreadHelper; /** * @since Oct 30, 2002 @@ -83,7 +88,9 @@ Object class1 = Model.getCoreFactory().createClass(); Object class2 = Model.getCoreFactory().createClass(); Object m = Model.getModelManagementFactory().createModel(); - p.setRoot(m); + Collection roots = new ArrayList(); + roots.add(m); + p.setRoots(roots); Model.getCoreHelper().setNamespace(class1, m); Model.getCoreHelper().setNamespace(class2, m); bases = new Object[NO_ELEMENTS_IN_TEST]; @@ -111,12 +118,13 @@ new Object[] { elem, })); - Model.getPump().flushModelEvents(); + ThreadHelper.synchronize(); } /* * @see junit.framework.TestCase#tearDown() */ + @Override protected void tearDown() throws Exception { super.tearDown(); Model.getUmlFactory().delete(elem); @@ -140,55 +148,83 @@ /** * Test setting the Base. - */ - public void testSetBase() { + * + * @throws InterruptedException if interrupted while synchronizing + * @throws InvocationTargetException should never happen indicates a problem + * with the test itself + */ + public void testSetBase() throws InterruptedException, + InvocationTargetException { + Model.getCollaborationsHelper().setBase(elem, bases[0]); - Model.getPump().flushModelEvents(); + ThreadHelper.synchronize(); assertTrue(model.getSelectedItem() == bases[0]); } /** * Test setting the Base. - */ - public void testChangeBase() { + * + * @throws InterruptedException if interrupted while synchronizing + * @throws InvocationTargetException should never happen indicates a problem + * with the test itself + */ + public void testChangeBase() throws InterruptedException, + InvocationTargetException { + Model.getCollaborationsHelper().setBase(elem, bases[0]); - Model.getPump().flushModelEvents(); + ThreadHelper.synchronize(); Model.getCollaborationsHelper().setBase(elem, bases[1]); - Model.getPump().flushModelEvents(); + ThreadHelper.synchronize(); assertTrue(model.getSelectedItem() == bases[1]); } /** * Test deleting selected Base. - */ - public void testDeleteBase() { + * + * @throws InterruptedException if interrupted while synchronizing + * @throws InvocationTargetException should never happen indicates a problem + * with the test itself + */ + public void testDeleteBase() throws InterruptedException, + InvocationTargetException { + Model.getCollaborationsHelper().setBase(elem, bases[1]); Model.getUmlFactory().delete(bases[1]); - Model.getPump().flushModelEvents(); + ThreadHelper.synchronize(); assertNull(model.getSelectedItem()); } /** * Test setting the Base to null. - */ - public void testSetBaseToNull() { + * + * @throws InterruptedException if interrupted while synchronizing + * @throws InvocationTargetException should never happen indicates a problem + * with the test itself + */ + public void testSetBaseToNull() throws InterruptedException, + InvocationTargetException { + Model.getCollaborationsHelper().setBase(elem, bases[0]); Model.getCollaborationsHelper().setBase(elem, null); - Model.getPump().flushModelEvents(); + ThreadHelper.synchronize(); assertNull(model.getSelectedItem()); } /** * Test removing the Base. + * + * @throws InterruptedException if interrupted while synchronizing + * @throws InvocationTargetException should never happen indicates a problem + * with the test itself */ - public void testRemoveBase() { + public void testRemoveBase() throws InterruptedException, + InvocationTargetException { Model.getUmlFactory().delete(bases[NO_ELEMENTS_IN_TEST - 1]); // One can only delete a assoc by changing target, // so let's simulate that: /* TODO: Get rid of this! */ changeTarget(); - // there is one extra element since removal of the base is allowed. - Model.getPump().flushModelEvents(); + ThreadHelper.synchronize(); assertEquals(NO_ELEMENTS_IN_TEST + 1 - 1, model.getSize()); assertTrue(!model.contains(bases[NO_ELEMENTS_IN_TEST - 1])); } @@ -199,5 +235,6 @@ model.targetSet(new TargetEvent(this, TargetEvent.TARGET_SET, new Object[] {dummy}, new Object[] {elem})); } + } Modified: branches/BRANCH_0_26_x/src/argouml-app/tests/org/argouml/uml/ui/behavior/common_behavior/TestUMLReceptionSignalComboBoxModel.java Url: http://argouml.tigris.org/source/browse/argouml/branches/BRANCH_0_26_x/src/argouml-app/tests/org/argouml/uml/ui/behavior/common_behavior/TestUMLReceptionSignalComboBoxModel.java?view=diff&rev=15904&p1=branches/BRANCH_0_26_x/src/argouml-app/tests/org/argouml/uml/ui/behavior/common_behavior/TestUMLReceptionSignalComboBoxModel.java&p2=branches/BRANCH_0_26_x/src/argouml-app/tests/org/argouml/uml/ui/behavior/common_behavior/TestUMLReceptionSignalComboBoxModel.java&r1=15903&r2=15904 ============================================================================== --- branches/BRANCH_0_26_x/src/argouml-app/tests/org/argouml/uml/ui/behavior/common_behavior/TestUMLReceptionSignalComboBoxModel.java (original) +++ branches/BRANCH_0_26_x/src/argouml-app/tests/org/argouml/uml/ui/behavior/common_behavior/TestUMLReceptionSignalComboBoxModel.java 2008-10-08 03:17:14-0700 @@ -24,14 +24,19 @@ package org.argouml.uml.ui.behavior.common_behavior; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.Collection; + import junit.framework.TestCase; -import org.argouml.model.InitializeModel; import org.argouml.kernel.Project; import org.argouml.kernel.ProjectManager; +import org.argouml.model.InitializeModel; import org.argouml.model.Model; import org.argouml.profile.init.InitProfileSubsystem; import org.argouml.ui.targetmanager.TargetEvent; +import org.argouml.util.ThreadHelper; /** * @since Nov 2, 2002 @@ -72,6 +77,7 @@ /* * @see junit.framework.TestCase#setUp() */ + @Override protected void setUp() throws Exception { super.setUp(); InitializeModel.initializeDefault(); @@ -80,7 +86,9 @@ elem = Model.getCommonBehaviorFactory().createReception(); signals = new Object[NO_OF_ELEMENTS]; Object m = Model.getModelManagementFactory().createModel(); - p.setRoot(m); + Collection roots = new ArrayList(); + roots.add(m); + p.setRoots(roots); Model.getCoreHelper().setNamespace(elem, m); for (int i = 0; i < NO_OF_ELEMENTS; i++) { signals[i] = Model.getCommonBehaviorFactory().createSignal(); @@ -89,12 +97,13 @@ model = new UMLReceptionSignalComboBoxModel(); model.targetSet(new TargetEvent(this, "set", new Object[0], new Object[] {elem})); - Model.getPump().flushModelEvents(); + ThreadHelper.synchronize(); } /* * @see junit.framework.TestCase#tearDown() */ + @Override protected void tearDown() throws Exception { super.tearDown(); Model.getUmlFactory().delete(elem); @@ -116,27 +125,42 @@ /** * Test setSignal(). + * + * @throws InvocationTargetException test failure + * @throws InterruptedException test failure */ - public void testSetSignal() { + public void testSetSignal() throws InterruptedException, + InvocationTargetException { + Model.getCommonBehaviorHelper().setSignal(elem, signals[0]); - Model.getPump().flushModelEvents(); + ThreadHelper.synchronize(); // One can only do this by changing target, // so let's simulate that: + Object dummy = Model.getCommonBehaviorFactory().createReception(); model.targetSet(new TargetEvent(this, TargetEvent.TARGET_SET, - new Object[0], - new Object[] { - elem, - })); + new Object[] {elem}, + new Object[] {dummy}) + ); + model.targetSet(new TargetEvent(this, + TargetEvent.TARGET_SET, + new Object[] {dummy}, + new Object[] {elem})); + ThreadHelper.synchronize(); assertTrue(model.getSelectedItem() == signals[0]); } /** * Test removing signals. - */ - public void testRemoveSignal() { + * + * @throws InvocationTargetException test failure + * @throws InterruptedException test failure + */ + public void testRemoveSignal() throws InterruptedException, + InvocationTargetException { + Model.getUmlFactory().delete(signals[NO_OF_ELEMENTS - 1]); - Model.getPump().flushModelEvents(); + ThreadHelper.synchronize(); assertEquals(NO_OF_ELEMENTS - 1, model.getSize()); assertTrue(!model.contains(signals[NO_OF_ELEMENTS - 1])); } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
