svn commit: r14348 - trunk/src/app/tests/org/argouml/kernel/TestProject.java

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: tfmorris
Date: 2008-04-14 16:07:05-0700
New Revision: 14348

Modified:
   trunk/src/app/tests/org/argouml/kernel/TestProject.java

Log:
Issue 4948 - Test from Bob to check for model elements not being completely deleted on project remove

Modified: trunk/src/app/tests/org/argouml/kernel/TestProject.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/app/tests/org/argouml/kernel/TestProject.java?view=diff&rev=14348&p1=trunk/src/app/tests/org/argouml/kernel/TestProject.java&p2=trunk/src/app/tests/org/argouml/kernel/TestProject.java&r1=14347&r2=14348
==============================================================================
--- trunk/src/app/tests/org/argouml/kernel/TestProject.java	(original)
+++ trunk/src/app/tests/org/argouml/kernel/TestProject.java	2008-04-14 16:07:05-0700
@@ -24,6 +24,8 @@
 
 package org.argouml.kernel;
 
+import java.io.File;
+import java.net.URL;
 import java.util.Collection;
 
 import junit.framework.TestCase;
@@ -31,11 +33,17 @@
 
 import org.argouml.i18n.Translator;
 import org.argouml.model.Model;
+import org.argouml.notation.InitNotation;
+import org.argouml.notation.providers.java.InitNotationJava;
+import org.argouml.notation.providers.uml.InitNotationUml;
+import org.argouml.persistence.AbstractFilePersister;
+import org.argouml.persistence.PersistenceManager;
 import org.argouml.profile.init.InitProfileSubsystem;
 import org.argouml.ui.targetmanager.TargetManager;
 import org.argouml.uml.diagram.activity.ui.UMLActivityDiagram;
 import org.argouml.uml.diagram.state.ui.UMLStateDiagram;
 import org.argouml.uml.diagram.static_structure.ui.UMLClassDiagram;
+import org.argouml.uml.diagram.ui.InitDiagramAppearanceUI;
 
 
 /**
@@ -66,6 +74,36 @@
     }
 
     /**
+     * Test remove() function. This is called when a new project is created to
+     * remove the old project. We confirm here that the users model has been
+     * emptied and that no none 'Model' model elements are at root.
+     * @throws Exception
+     */
+    public void testRemove() throws Exception {
+        String name = "/testmodels/uml14/Alittlebitofeverything.zargo";
+        URL url = TestProject.class.getResource(name);
+        AbstractFilePersister persister =
+            PersistenceManager.getInstance().getPersisterFromFileName(name);
+        String filename = url.getFile();
+        Project p = persister.doLoad(new File(filename));
+        
+        p.remove();
+        
+        for (Object root : Model.getFacade().getRootElements()) {
+            assertTrue(
+                    "All roots should be a Model",
+                    Model.getFacade().isAModel(root));
+            System.out.println(Model.getFacade().getName(root) + " "
+                    + Model.getFacade().getOwnedElements(root).size());
+            if (Model.getFacade().getName(root).equals("untitledModel")) {
+                assertEquals(
+                        "All root models should be empty", 0, 
+                        Model.getFacade().getOwnedElements(root).size());
+            }
+        }
+    }
+
+    /**
      * Test the moveToTrash function for package and content.
      */
     public void testTrashcanPackageContent() {
@@ -474,6 +512,10 @@
         super.setUp();
         InitializeModel.initializeDefault();
         ProjectManager.getManager().setCurrentProject(null);
-        new InitProfileSubsystem().init();
+        (new InitNotation()).init();
+        (new InitNotationUml()).init();
+        (new InitNotationJava()).init();
+        (new InitDiagramAppearanceUI()).init();
+        (new InitProfileSubsystem()).init();
     }
 }
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.