svn commit: r15113 - trunk/src/argouml-app/tests/org/argouml/uml/ui: behavior/collaborations foundation/core

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: tfmorris
Date: 2008-06-30 05:40:40-0700
New Revision: 15113

Modified:
   trunk/src/argouml-app/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLAssociationRoleBaseComboBoxModel.java
   trunk/src/argouml-app/tests/org/argouml/uml/ui/foundation/core/TestUMLStructuralFeatureTypeComboBoxModel.java

Log:
Fix tests that depend on side effects of UMLComboBoxModel2 behavior.

Modified: trunk/src/argouml-app/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLAssociationRoleBaseComboBoxModel.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLAssociationRoleBaseComboBoxModel.java?view=diff&rev=15113&p1=trunk/src/argouml-app/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLAssociationRoleBaseComboBoxModel.java&p2=trunk/src/argouml-app/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLAssociationRoleBaseComboBoxModel.java&r1=15112&r2=15113
==============================================================================
--- trunk/src/argouml-app/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLAssociationRoleBaseComboBoxModel.java	(original)
+++ trunk/src/argouml-app/tests/org/argouml/uml/ui/behavior/collaborations/TestUMLAssociationRoleBaseComboBoxModel.java	2008-06-30 05:40:40-0700
@@ -48,6 +48,8 @@
      * The element that we work on.
      */
     private Object elem;
+    
+    private Object dummy;
 
     /**
      * The model that we work on.
@@ -101,6 +103,8 @@
         Model.getCoreHelper().setNamespace(role2, col);
         elem =
 	    Model.getCollaborationsFactory().buildAssociationRole(role1, role2);
+        dummy =
+            Model.getCollaborationsFactory().buildAssociationRole(role1, role2);
         model.targetSet(new TargetEvent(this,
 					TargetEvent.TARGET_SET,
 					new Object[0],
@@ -182,16 +186,18 @@
         // One can only delete a assoc by changing target,
         // so let's simulate that:
         /* TODO: Get rid of this! */
-        model.targetSet(new TargetEvent(this,
-                TargetEvent.TARGET_SET,
-                new Object[0],
-                new Object[] {
-                    elem,
-                }));
+        changeTarget();
         // there is one extra element since removal of the base is allowed.
         Model.getPump().flushModelEvents();
         assertEquals(NO_ELEMENTS_IN_TEST + 1 - 1, model.getSize());
         assertTrue(!model.contains(bases[NO_ELEMENTS_IN_TEST - 1]));
     }
+    
+    private void changeTarget() {
+        model.targetSet(new TargetEvent(this, TargetEvent.TARGET_SET,
+                new Object[] {elem}, new Object[] {dummy}));
+        model.targetSet(new TargetEvent(this, TargetEvent.TARGET_SET,
+                new Object[] {dummy}, new Object[] {elem}));
+    }
 
 }

Modified: trunk/src/argouml-app/tests/org/argouml/uml/ui/foundation/core/TestUMLStructuralFeatureTypeComboBoxModel.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/tests/org/argouml/uml/ui/foundation/core/TestUMLStructuralFeatureTypeComboBoxModel.java?view=diff&rev=15113&p1=trunk/src/argouml-app/tests/org/argouml/uml/ui/foundation/core/TestUMLStructuralFeatureTypeComboBoxModel.java&p2=trunk/src/argouml-app/tests/org/argouml/uml/ui/foundation/core/TestUMLStructuralFeatureTypeComboBoxModel.java&r1=15112&r2=15113
==============================================================================
--- trunk/src/argouml-app/tests/org/argouml/uml/ui/foundation/core/TestUMLStructuralFeatureTypeComboBoxModel.java	(original)
+++ trunk/src/argouml-app/tests/org/argouml/uml/ui/foundation/core/TestUMLStructuralFeatureTypeComboBoxModel.java	2008-06-30 05:40:40-0700
@@ -1,5 +1,5 @@
 // $Id$
-// Copyright (c) 1996-2007 The Regents of the University of California. All
+// Copyright (c) 1996-2008 The Regents of the University of California. All
 // Rights Reserved. Permission to use, copy, modify, and distribute this
 // software and its documentation without fee, and without a written
 // agreement is hereby granted, provided that the above copyright notice
@@ -57,6 +57,8 @@
      * The element.
      */
     private Object elem;
+    
+    private Object dummy;
 
     /**
      * Constructor for TestUMLStructuralFeatureTypeComboBoxModel.
@@ -78,6 +80,7 @@
         Model.getCoreHelper().setName(mmodel, "untitledModel");
         Model.getModelManagementFactory().setRootModel(mmodel);
         elem = Model.getCoreFactory().createAttribute();
+        dummy = Model.getCoreFactory().createAttribute();
         model = new UMLStructuralFeatureTypeComboBoxModel();
         model.targetSet(new TargetEvent(this, "set", new Object[0],
                 new Object[] {elem}));
@@ -114,31 +117,27 @@
         Model.getPump().flushModelEvents();
         // One can only do this by changing target,
         // so let's simulate that:
-        model.targetSet(new TargetEvent(this,
-                TargetEvent.TARGET_SET,
-                new Object[0],
-                new Object[] {
-                    elem,
-                }));
+        changeTarget();
         assertTrue(model.contains(types[NO_OF_ELEMENTS / 2]));
         assertTrue(model.contains(types[0]));
         assertTrue(model.contains(types[NO_OF_ELEMENTS - 1]));
     }
 
+    
+    private void changeTarget() {
+        model.targetSet(new TargetEvent(this, TargetEvent.TARGET_SET,
+                new Object[] {elem}, new Object[] {dummy}));
+        model.targetSet(new TargetEvent(this, TargetEvent.TARGET_SET,
+                new Object[] {dummy}, new Object[] {elem}));
+    }
+
     /**
      * Test the setType function.
      */
     public void testSetType() {
         Model.getCoreHelper().setType(elem, types[0]);
         Model.getPump().flushModelEvents();
-        // One can only do this by changing target,
-        // so let's simulate that:
-        model.targetSet(new TargetEvent(this,
-                TargetEvent.TARGET_SET,
-                new Object[0],
-                new Object[] {
-                    elem,
-                }));
+        changeTarget();
         assertTrue(model.getSelectedItem() == types[0]);
     }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.