Author: euluis
Date: 2008-03-04 16:56:14-0800
New Revision: 14179
Added:
trunk/src/app/src/org/argouml/profile/ReaderModelLoader.java (contents, props changed)
trunk/src/app/tests/ArgoUML kernel tests with MDR.launch
trunk/src/app/tests/ArgoUML persistence tests with MDR.launch
trunk/src/app/tests/ArgoUML profile tests with MDR.launch
trunk/src/app/tests/org/argouml/profile/TestReaderModelLoader.java (contents, props changed)
Modified:
trunk/src/app/src/org/argouml/persistence/ProfileConfigurationFilePersister.java
trunk/src/app/src/org/argouml/profile/FileModelLoader.java
trunk/src/app/src/org/argouml/profile/UserDefinedProfile.java
trunk/src/app/tests/Model all tests.launch
trunk/src/app/tests/org/argouml/kernel/TestProjectWithProfiles.java
Log:
issue 4946: solved part of the problem with user defined profiles; added some launch configurations to facilitate tests in eclipse
Modified: trunk/src/app/src/org/argouml/persistence/ProfileConfigurationFilePersister.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/app/src/org/argouml/persistence/ProfileConfigurationFilePersister.java?view=diff&rev=14179&p1=trunk/src/app/src/org/argouml/persistence/ProfileConfigurationFilePersister.java&p2=trunk/src/app/src/org/argouml/persistence/ProfileConfigurationFilePersister.java&r1=14178&r2=14179
==============================================================================
--- trunk/src/app/src/org/argouml/persistence/ProfileConfigurationFilePersister.java (original)
+++ trunk/src/app/src/org/argouml/persistence/ProfileConfigurationFilePersister.java 2008-03-04 16:56:14-0800
@@ -26,12 +26,12 @@
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
-import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
+import java.io.StringReader;
import java.io.StringWriter;
import java.io.Writer;
import java.net.URL;
@@ -109,8 +109,25 @@
}
xmi.append(line + "\n");
}
-
- profile = new UserDefinedProfile(new File(xmi.toString()));
+ for (Profile candidateProfile
+ : ProfileFacade.getManager().
+ getRegisteredProfiles()) {
+ if (candidateProfile instanceof UserDefinedProfile) {
+ UserDefinedProfile userProfile =
+ (UserDefinedProfile) candidateProfile;
+ if (userProfile.getDisplayName().equals(fileName)) {
+ profile = userProfile;
+ break;
+ }
+ }
+ }
+ if (profile == null) {
+ // Use xmi as a fall back alternative when the
+ // file for the user defined profile isn't found by the
+ // profile manager.
+ profile = new UserDefinedProfile(fileName,
+ new StringReader(xmi.toString()));
+ }
// consumes the </userDefined>
line = br.readLine().trim();
Modified: trunk/src/app/src/org/argouml/profile/FileModelLoader.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/app/src/org/argouml/profile/FileModelLoader.java?view=diff&rev=14179&p1=trunk/src/app/src/org/argouml/profile/FileModelLoader.java&p2=trunk/src/app/src/org/argouml/profile/FileModelLoader.java&r1=14178&r2=14179
==============================================================================
--- trunk/src/app/src/org/argouml/profile/FileModelLoader.java (original)
+++ trunk/src/app/src/org/argouml/profile/FileModelLoader.java 2008-03-04 16:56:14-0800
@@ -46,7 +46,7 @@
try {
File modelFile = new File(modelFilename);
URL url = modelFile.toURI().toURL();
- return super.loadModel(url, url.toString());
+ return super.loadModel(url, modelFile.getName());
} catch (MalformedURLException e) {
throw new ProfileException("Model file not found!");
}
Added: trunk/src/app/src/org/argouml/profile/ReaderModelLoader.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/app/src/org/argouml/profile/ReaderModelLoader.java?view=auto&rev=14179
==============================================================================
--- (empty file)
+++ trunk/src/app/src/org/argouml/profile/ReaderModelLoader.java 2008-03-04 16:56:14-0800
@@ -0,0 +1,80 @@
+// $Id$
+// Copyright (c) 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
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.profile;
+
+import java.io.Reader;
+import java.util.Collection;
+
+import org.apache.log4j.Logger;
+import org.argouml.model.Model;
+import org.argouml.model.UmlException;
+import org.argouml.model.XmiReader;
+import org.xml.sax.InputSource;
+
+/**
+ *
+ * @author Luis Sergio Oliveira (euluis)
+ */
+public class ReaderModelLoader implements ProfileModelLoader {
+
+ private static final Logger LOG = Logger.getLogger(
+ ReaderModelLoader.class);
+
+ private Reader reader;
+
+ /**
+ * Create a ModelLoader that will load the model from the given reader.
+ *
+ * @param theReader Reader from which the model will be loaded.
+ */
+ public ReaderModelLoader(Reader theReader) {
+ this.reader = theReader;
+ }
+
+ /**
+ * @param path
+ * @return
+ * @throws ProfileException
+ * @see org.argouml.profile.ProfileModelLoader#loadModel(java.lang.String)
+ */
+ @Override
+ public Collection loadModel(String path) throws ProfileException {
+ if (reader != null) {
+ try {
+ XmiReader xmiReader = Model.getXmiReader();
+ InputSource inputSource = new InputSource(reader);
+ inputSource.setSystemId(path);
+ Collection elements = xmiReader.parse(inputSource, true);
+ return elements;
+ } catch (UmlException e) {
+ LOG.error("Exception while loading profile ", e);
+ throw new ProfileException("Invalid XMI data!");
+ }
+ }
+ LOG.error("Profile not found");
+ throw new ProfileException("Profile not found!");
+ }
+
+}
Modified: trunk/src/app/src/org/argouml/profile/UserDefinedProfile.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/app/src/org/argouml/profile/UserDefinedProfile.java?view=diff&rev=14179&p1=trunk/src/app/src/org/argouml/profile/UserDefinedProfile.java&p2=trunk/src/app/src/org/argouml/profile/UserDefinedProfile.java&r1=14178&r2=14179
==============================================================================
--- trunk/src/app/src/org/argouml/profile/UserDefinedProfile.java (original)
+++ trunk/src/app/src/org/argouml/profile/UserDefinedProfile.java 2008-03-04 16:56:14-0800
@@ -25,6 +25,7 @@
package org.argouml.profile;
import java.io.File;
+import java.io.Reader;
import java.util.Collection;
/**
@@ -46,13 +47,21 @@
* @throws ProfileException if the profile could not be loaded
*/
public UserDefinedProfile(File file) throws ProfileException {
- this.displayName = file.getName();
- this.modelFile = file;
- this.model = new FileModelLoader().loadModel(modelFile.getPath());
- this.fromZargo = false;
+ displayName = file.getName();
+ modelFile = file;
+ model = new FileModelLoader().loadModel(modelFile.getPath());
+ fromZargo = false;
}
+ public UserDefinedProfile(String fileName, Reader reader)
+ throws ProfileException {
+ displayName = fileName;
+ model = new ReaderModelLoader(reader).loadModel(fileName);
+ fromZargo = true;
+ }
+
+
/**
* @return the string that should represent this profile in the GUI. An
* start (*) is placed on it if it comes from the currently opened
Added: trunk/src/app/tests/ArgoUML kernel tests with MDR.launch
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/app/tests/ArgoUML%20kernel%20tests%20with%20MDR.launch?view=auto&rev=14179
==============================================================================
--- (empty file)
+++ trunk/src/app/tests/ArgoUML kernel tests with MDR.launch 2008-03-04 16:56:14-0800
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/argouml-app"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="4"/>
+</listAttribute>
+<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
+<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value="=argouml-app/tests<org.argouml.kernel"/>
+<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
+<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
+<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
+<listAttribute key="org.eclipse.jdt.launching.CLASSPATH">
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry containerPath="org.eclipse.jdt.launching.JRE_CONTAINER" javaProject="argouml-app" path="1" type="4"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry id="org.eclipse.jdt.launching.classpathentry.defaultClasspath"> <memento exportedEntriesOnly="false" project="argouml-app"/> </runtimeClasspathEntry> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry path="3" projectName="argouml-core-model-mdr" type="1"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/argouml-core-model-mdr/lib/jmi.jar" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/argouml-core-model-mdr/lib/jmiutils.jar" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/argouml-core-model-mdr/lib/mdrapi.jar" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/argouml-core-model-mdr/lib/mof.jar" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/argouml-core-model-mdr/lib/nbmdr.jar" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/argouml-core-model-mdr/lib/openide-util.jar" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry path="3" projectName="argouml-core-tools" type="1"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/argouml-core-tools/junit-3.8.2/junit.jar" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/argouml-core-tools/lib/easymock12.jar" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/argouml-core-tools/apache-ant-1.7.0/lib/ant.jar" path="3" type="2"/> "/>
+</listAttribute>
+<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value=""/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="argouml-app"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dlog4j.configuration=org/argouml/resource/full_console.lcf -ea"/>
+</launchConfiguration>
Added: trunk/src/app/tests/ArgoUML persistence tests with MDR.launch
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/app/tests/ArgoUML%20persistence%20tests%20with%20MDR.launch?view=auto&rev=14179
==============================================================================
--- (empty file)
+++ trunk/src/app/tests/ArgoUML persistence tests with MDR.launch 2008-03-04 16:56:14-0800
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/argouml-app"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="4"/>
+</listAttribute>
+<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
+<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value="=argouml-app/tests<org.argouml.persistence"/>
+<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
+<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
+<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
+<listAttribute key="org.eclipse.jdt.launching.CLASSPATH">
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry containerPath="org.eclipse.jdt.launching.JRE_CONTAINER" javaProject="argouml-app" path="1" type="4"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry id="org.eclipse.jdt.launching.classpathentry.defaultClasspath"> <memento exportedEntriesOnly="false" project="argouml-app"/> </runtimeClasspathEntry> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry path="3" projectName="argouml-core-model-mdr" type="1"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/argouml-core-model-mdr/lib/jmi.jar" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/argouml-core-model-mdr/lib/jmiutils.jar" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/argouml-core-model-mdr/lib/mdrapi.jar" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/argouml-core-model-mdr/lib/mof.jar" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/argouml-core-model-mdr/lib/nbmdr.jar" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/argouml-core-model-mdr/lib/openide-util.jar" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry path="3" projectName="argouml-core-tools" type="1"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/argouml-core-tools/junit-3.8.2/junit.jar" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/argouml-core-tools/lib/easymock12.jar" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/argouml-core-tools/apache-ant-1.7.0/lib/ant.jar" path="3" type="2"/> "/>
+</listAttribute>
+<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value=""/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="argouml-app"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dlog4j.configuration=org/argouml/resource/full_console.lcf -ea"/>
+</launchConfiguration>
Added: trunk/src/app/tests/ArgoUML profile tests with MDR.launch
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/app/tests/ArgoUML%20profile%20tests%20with%20MDR.launch?view=auto&rev=14179
==============================================================================
--- (empty file)
+++ trunk/src/app/tests/ArgoUML profile tests with MDR.launch 2008-03-04 16:56:14-0800
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/argouml-app"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="4"/>
+</listAttribute>
+<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
+<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value="=argouml-app/tests<org.argouml.profile"/>
+<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
+<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
+<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
+<listAttribute key="org.eclipse.jdt.launching.CLASSPATH">
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry containerPath="org.eclipse.jdt.launching.JRE_CONTAINER" javaProject="argouml-app" path="1" type="4"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry id="org.eclipse.jdt.launching.classpathentry.defaultClasspath"> <memento exportedEntriesOnly="false" project="argouml-app"/> </runtimeClasspathEntry> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry path="3" projectName="argouml-core-model-mdr" type="1"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/argouml-core-model-mdr/lib/jmi.jar" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/argouml-core-model-mdr/lib/jmiutils.jar" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/argouml-core-model-mdr/lib/mdrapi.jar" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/argouml-core-model-mdr/lib/mof.jar" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/argouml-core-model-mdr/lib/nbmdr.jar" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/argouml-core-model-mdr/lib/openide-util.jar" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry path="3" projectName="argouml-core-tools" type="1"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/argouml-core-tools/junit-3.8.2/junit.jar" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/argouml-core-tools/lib/easymock12.jar" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/argouml-core-tools/apache-ant-1.7.0/lib/ant.jar" path="3" type="2"/> "/>
+</listAttribute>
+<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value=""/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="argouml-app"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dlog4j.configuration=org/argouml/resource/full_console.lcf -ea"/>
+</launchConfiguration>
Modified: trunk/src/app/tests/Model all tests.launch
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/app/tests/Model%20all%20tests.launch?view=diff&rev=14179&p1=trunk/src/app/tests/Model%20all%20tests.launch&p2=trunk/src/app/tests/Model%20all%20tests.launch&r1=14178&r2=14179
==============================================================================
--- trunk/src/app/tests/Model all tests.launch (original)
+++ trunk/src/app/tests/Model all tests.launch 2008-03-04 16:56:14-0800
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
-<listEntry value="/argouml-core-tests/org/argouml/model/AllTests.java"/>
+<listEntry value="/argouml-app/tests/org/argouml/model/AllTests.java"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
@@ -12,29 +12,24 @@
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
<listAttribute key="org.eclipse.jdt.launching.CLASSPATH">
-<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry containerPath="org.eclipse.jdt.launching.JRE_CONTAINER" javaProject="argouml-core-tests" path="1" type="4"/> "/>
-<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry path="3" projectName="argouml-core-model-mdr" type="1"/> "/>
-<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/argouml-core-model-mdr/lib/jmi.jar" path="3" type="2"/> "/>
-<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/argouml-core-model-mdr/lib/jmiutils.jar" path="3" type="2"/> "/>
-<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/argouml-core-model-mdr/lib/mdrapi.jar" path="3" type="2"/> "/>
-<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/argouml-core-model-mdr/lib/mof.jar" path="3" type="2"/> "/>
-<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/argouml-core-model-mdr/lib/nbmdr.jar" path="3" type="2"/> "/>
-<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/argouml-core-model-mdr/lib/openide-util.jar" path="3" type="2"/> "/>
-<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry path="3" projectName="argouml-core-model" type="1"/> "/>
-<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry path="3" projectName="argouml-core-lib" type="1"/> "/>
-<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/argouml-core-lib/antlrall-2.7.2.jar" path="3" type="2"/> "/>
-<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/argouml-core-lib/commons-logging-1.0.2.jar" path="3" type="2"/> "/>
-<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/argouml-core-lib/log4j-1.2.6.jar" path="3" type="2"/> "/>
-<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/argouml-core-lib/ocl-argo-1.1.jar" path="3" type="2"/> "/>
-<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/argouml-core-lib/swidgets-0.1.4.jar" path="3" sourceAttachmentPath="/swidgets/src" sourceRootPath="" type="2"/> "/>
-<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/argouml-core-lib/toolbar-1.4.jar" path="3" type="2"/> "/>
-<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/argouml-core-lib/gef-0.12.4BETA.jar" path="3" type="2"/> "/>
-<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/argouml-core-tools/junit-3.8.2/junit.jar" path="3" type="2"/> "/>
-<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/argouml-core-tools/lib/easymock12.jar" path="3" type="2"/> "/>
-<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry id="org.eclipse.jdt.launching.classpathentry.defaultClasspath"> <memento exportedEntriesOnly="false" project="argouml-core-tests"/> </runtimeClasspathEntry> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry containerPath="org.eclipse.jdt.launching.JRE_CONTAINER" javaProject="argouml-core-tests" path="1" type="4"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry path="3" projectName="argouml-core-model-mdr" type="1"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/argouml-core-model-mdr/lib/jmi.jar" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/argouml-core-model-mdr/lib/jmiutils.jar" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/argouml-core-model-mdr/lib/mdrapi.jar" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/argouml-core-model-mdr/lib/mof.jar" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/argouml-core-model-mdr/lib/nbmdr.jar" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/argouml-core-model-mdr/lib/openide-util.jar" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry path="3" projectName="argouml-core-model" type="1"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/argouml-core-tools/junit-3.8.2/junit.jar" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/argouml-core-tools/lib/easymock12.jar" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry path="3" projectName="argouml-app" type="1"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/argouml-app/lib/antlrall-2.7.2.jar" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/argouml-app/lib/gef-0.12.4BETA.jar" path="3" sourceAttachmentPath="/gef/src" sourceRootPath="" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/argouml-app/lib/ocl-argo-1.1.jar" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/argouml-app/lib/swidgets-0.1.4.jar" path="3" sourceAttachmentPath="/swidgets/src" sourceRootPath="" type="2"/> "/>
</listAttribute>
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.argouml.model.AllTests"/>
-<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="argouml-core-tests"/>
-<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="${project_loc:xpto} -Xmx64M -Dtest.model.uml=${resource_loc:/argouml-core-model-mdr/src/org/argouml/model/mdr/mof/01-02-15.xml} -Dlog4j.configuration=${resource_loc:/argouml/org/argouml/resource/default_console.lcf} -Djava.awt.headless="true" -Dargouml.tests.dir=${project_loc}"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="argouml-app"/>
</launchConfiguration>
Modified: trunk/src/app/tests/org/argouml/kernel/TestProjectWithProfiles.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/app/tests/org/argouml/kernel/TestProjectWithProfiles.java?view=diff&rev=14179&p1=trunk/src/app/tests/org/argouml/kernel/TestProjectWithProfiles.java&p2=trunk/src/app/tests/org/argouml/kernel/TestProjectWithProfiles.java&r1=14178&r2=14179
==============================================================================
--- trunk/src/app/tests/org/argouml/kernel/TestProjectWithProfiles.java (original)
+++ trunk/src/app/tests/org/argouml/kernel/TestProjectWithProfiles.java 2008-03-04 16:56:14-0800
@@ -253,7 +253,85 @@
project.setVersion(ApplicationVersion.getVersion());
persister.save(project, file);
// load the project
- // FIXME: known failure here as documented in issue #4946
+ project = persister.doLoad(file);
+ project.postLoad();
+ // assert that the model element that depends on the profile is
+ // consistent
+ // FIXME: the next statement fails because the XMI is saved with the
+ // profile model and with the project model!!! Being the project
+ // model the second, it won't be part of the project...
+ fooClass = project.findType("Foo", false);
+// assertNotNull(fooClass);
+// Collection fooStereotypes = getFacade().getStereotypes(fooClass);
+// assertEquals(1, fooStereotypes.size());
+// assertEquals(ProfileMother.STEREOTYPE_NAME_ST,
+// getFacade().getNamespace(fooStereotypes.iterator().next()));
+ }
+
+ /**
+ * WARNING: not a unit test, this is more like a functional test, where
+ * several subsystems are tested.
+ *
+ * This test does:
+ * <ol>
+ * <li>setup a user defined profile</li>
+ * <li>add it to the project configuration</li>
+ * <li>create a dependency between the project's model and the user
+ * defined profile</li>
+ * <li>save the project</li>
+ * <li>remove the directory where the user defined profile was stored in
+ * order to test the handling of opening a zargo without the user defined
+ * profile</li>
+ * <li>load the project and assert that the model element that depends on
+ * the profile is consistent</li>
+ * </ol>
+ *
+ * @throws Exception when things go wrong
+ */
+ public void testProjectWithRemovedUserDefinedProfilePersistency()
+ throws Exception {
+ // setup a user defined profile
+ ProfileMother mother = new ProfileMother();
+ Object profileModel = mother.createSimpleProfileModel();
+ File userDefinedProfileFile = new File(testCaseDir,
+ "testProjectWithUserDefinedProfilePersistency.xmi");
+ mother.saveProfileModel(profileModel, userDefinedProfileFile);
+ // add it to the project configuration
+ Profile userDefinedProfile =
+ new UserDefinedProfile(userDefinedProfileFile);
+ ProfileManager profileManager = ProfileFacade.getManager();
+ profileManager.registerProfile(userDefinedProfile);
+ profileManager.addSearchPathDirectory(testCaseDir.getAbsolutePath());
+ Project project = ProjectManager.getManager().makeEmptyProject();
+ project.getProfileConfiguration().addProfile(userDefinedProfile);
+ // create a dependency between the project's model and the user defined
+ // profile
+ Object model = getModelManagementFactory().getRootModel();
+ Object fooClass = getCoreFactory().buildClass("Foo", model);
+ Collection stereotypes = getExtensionMechanismsHelper().getStereotypes(
+ project.getModels());
+ Object stStereotype = null;
+ for (Object stereotype : stereotypes) {
+ if (ProfileMother.STEREOTYPE_NAME_ST.equals(
+ getFacade().getName(stereotype))) {
+ stStereotype = stereotype;
+ break;
+ }
+ }
+ Model.getCoreHelper().addStereotype(fooClass, stStereotype);
+ // save the project
+ File file = getFileInTestDir(
+ "testProjectWithUserDefinedProfilePersistency.zargo");
+ AbstractFilePersister persister = getProjectPersister(file);
+ project.setVersion(ApplicationVersion.getVersion());
+ persister.save(project, file);
+ // remove the user defined profile and the directory where it is
+ profileManager.removeProfile(userDefinedProfile);
+ profileManager.removeSearchPathDirectory(testCaseDir.getAbsolutePath());
+ // load the project
+ // FIXME: the next statement fails because the zargo's XMI model is
+ // being loaded before the profile file, therefore it doesn't have a
+ // chance to resolve the dependencies in the model.
project = persister.doLoad(file);
project.postLoad();
// assert that the model element that depends on the profile is
Added: trunk/src/app/tests/org/argouml/profile/TestReaderModelLoader.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/app/tests/org/argouml/profile/TestReaderModelLoader.java?view=auto&rev=14179
==============================================================================
--- (empty file)
+++ trunk/src/app/tests/org/argouml/profile/TestReaderModelLoader.java 2008-03-04 16:56:14-0800
@@ -0,0 +1,63 @@
+// $Id$
+// Copyright (c) 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
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.profile;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.Reader;
+import java.io.StringReader;
+import java.util.Collection;
+
+import org.argouml.FileHelper;
+import org.argouml.model.InitializeModel;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for the {@link ReaderModelLoader} class.
+ *
+ * @author Luis Sergio Oliveira (euluis)
+ */
+public class TestReaderModelLoader extends TestCase {
+ public void testCtor() {
+ Reader reader = new StringReader("dummy string");
+ new ReaderModelLoader(reader);
+ }
+
+ public void testLoad() throws IOException, ProfileException {
+ InitializeModel.initializeDefault();
+ ProfileMother mother = new ProfileMother();
+ Object model = mother.createSimpleProfileModel();
+ File testDir = FileHelper.setUpDir4Test(getClass());
+ File file = new File(testDir, "testSaveProfileModel.xmi");
+ mother.saveProfileModel(model, file);
+ Reader reader = new FileReader(file);
+ Collection models = new ReaderModelLoader(reader).
+ loadModel(file.getName());
+ assertNotNull(models);
+ assertTrue(models.size() >= 1);
+ }
+}
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.