svn commit: r18043 - trunk/src/argouml-core-model-mdr: src/org/argouml/model/mdr tests/org/argouml/model/mdr tests/testmodels/AndroMDA-3.3
Luis Sergio Oliveira <[email protected]>
| Newsgroups | gmane.comp.lang.uml.argouml.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: euluis
Date: 2010-02-27 13:41:48-0800
New Revision: 18043
Modified:
trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/XmiReferenceResolverImpl.java
trunk/src/argouml-core-model-mdr/tests/org/argouml/model/mdr/TestReadCompressedFilesAndHref.java
trunk/src/argouml-core-model-mdr/tests/testmodels/AndroMDA-3.3/timetracker.xmi
Log:
issue 5946: resolves profiles recursively in search paths. Approved by Linus.
Modified: trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/XmiReferenceResolverImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/XmiReferenceResolverImpl.java?view=diff&pathrev=18043&r1=18042&r2=18043
==============================================================================
--- trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/XmiReferenceResolverImpl.java (original)
+++ trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/XmiReferenceResolverImpl.java 2010-02-27 13:41:48-0800
@@ -46,6 +46,7 @@
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -370,26 +371,27 @@
if (modulesPath == null) {
return null;
}
-
if (LOG.isDebugEnabled()) {
LOG.debug("findModuleURL: modulesPath.size() = "
+ modulesPath.size());
}
for (String moduleDirectory : modulesPath) {
- File candidate = new File(moduleDirectory, moduleName);
- if (LOG.isDebugEnabled()) {
- LOG.debug("candidate '" + candidate.toString() + "' exists="
- + candidate.exists());
- }
- if (candidate.exists()) {
- String urlString;
- try {
- urlString = candidate.toURI().toURL().toExternalForm();
- } catch (MalformedURLException e) {
- return null;
+ Collection<File> candidates = findAllCandidateModulePaths(
+ moduleDirectory, moduleName);
+ for (File candidate : candidates) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("candidate '" + candidate.toString()
+ + "' exists=" + candidate.exists());
+ }
+ if (candidate.exists()) {
+ String urlString;
+ try {
+ urlString = candidate.toURI().toURL().toExternalForm();
+ } catch (MalformedURLException e) {
+ return null;
+ }
+ return fixupURL(urlString);
}
-
- return fixupURL(urlString);
}
}
if (public2SystemIds.containsKey(moduleName)) {
@@ -403,8 +405,36 @@
return null;
}
+ private static Collection<File> findAllCandidateModulePaths(
+ String basePath, String fileName) {
+ Collection<File> candidates = new ArrayList<File>();
+ if (basePath != null && basePath.length() > 0) {
+ Collection<File> dirs = new ArrayList<File>();
+ dirs = findAllInternalDirectories(new File(basePath));
+ for (File dir : dirs) {
+ candidates.add(new File(dir, fileName));
+ }
+ } else {
+ candidates.add(new File(fileName));
+ }
+ return candidates;
+ }
+
+ private static Collection<File> findAllInternalDirectories(File baseDir) {
+ List<File> dirs = new ArrayList<File>();
+ if (baseDir.exists() && baseDir.isDirectory()) {
+ dirs.add(baseDir);
+ File[] files = baseDir.listFiles();
+ for (File file : files) {
+ if (file.isDirectory()) {
+ dirs.add(file);
+ dirs.addAll(findAllInternalDirectories(file));
+ }
+ }
+ }
+ return dirs;
+ }
-
/**
* Gets the suffix of the <code>systemId</code>.
* <p>
Modified: trunk/src/argouml-core-model-mdr/tests/org/argouml/model/mdr/TestReadCompressedFilesAndHref.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-model-mdr/tests/org/argouml/model/mdr/TestReadCompressedFilesAndHref.java?view=diff&pathrev=18043&r1=18042&r2=18043
==============================================================================
--- trunk/src/argouml-core-model-mdr/tests/org/argouml/model/mdr/TestReadCompressedFilesAndHref.java (original)
+++ trunk/src/argouml-core-model-mdr/tests/org/argouml/model/mdr/TestReadCompressedFilesAndHref.java 2010-02-27 13:41:48-0800
@@ -40,49 +40,22 @@
package org.argouml.model.mdr;
import java.io.File;
-import java.io.FileInputStream;
import org.apache.log4j.Logger;
import org.xml.sax.InputSource;
/**
- * Test read models.
+ * Test read compressed models, mainly to verify the correct reading of
+ * AndroMDA profiles.
* TODO: Move this test into argouml base when we will want to read also zip
* file.
*
* @author lmaitre
- *
*/
public class TestReadCompressedFilesAndHref extends
AbstractMDRModelImplementationTestCase {
private Logger LOG = Logger.getLogger(TestReadCompressedFilesAndHref.class);
-
- /**
- * TODO: either the AndroMDA profiles are added to the repository or this
- * should be deleted [euluis on 2010-01-18].
- */
- public void testReadCompressedFileAndHref() {
- String testModel = "tests/testmodels/MDASampleModel.xmi";
- //notice that i must replace and hardcode user.home on my Mac OS X computer
- //[since this always give "/tmp" (at least under Eclipe)]
- final String ANDROMDA_HOME = System.getProperty("user.home")
- + "/andromda-bin-3.1-RC1";
- File mdaIsHere = new File(ANDROMDA_HOME);
- if (mdaIsHere.exists()) {
- LOG.info("Begin testReadCompressedFileAndHref()");
- XmiReaderImpl reader = new XmiReaderImpl(modelImplementation);
- reader.addSearchPath(ANDROMDA_HOME + "/andromda/xml.zips");
- try {
- reader.parse(
- new InputSource(new FileInputStream(testModel)), false);
- } catch (Exception e) {
- e.printStackTrace();
- fail("Exception while loading model");
- }
- assertTrue("model is loaded", true);
- }
- }
private final String ISSUE5946_BASE_DIR = "/testmodels/AndroMDA-3.3/";
@@ -114,10 +87,9 @@
* </ul>
*/
public void testReadCompressedFileAndHrefIssue5946() {
- // TODO: uncomment the following to get the failure.
-// assertLoadModel(ISSUE5946_BASE_DIR + "timetracker.xmi",
-// ISSUE5946_BASE_DIR + "zipped-uml14/",
-// "testReadFileAndHrefIssue5946");
+ assertLoadModel(ISSUE5946_BASE_DIR + "timetracker.xmi",
+ ISSUE5946_BASE_DIR + "zipped-uml14/",
+ "testCompressedReadFileAndHrefIssue5946");
}
void assertLoadModel(String modelPath, String profilesPath,
@@ -125,17 +97,18 @@
LOG.info("Begin " + testName + "()");
XmiReaderImpl reader = new XmiReaderImpl(modelImplementation);
if (profilesPath != null) {
- reader.addSearchPath(
- getClass().getResource(profilesPath).getFile());
+ String file = getClass().getResource(profilesPath).getFile();
+ reader.addSearchPath(file);
}
try {
- reader.parse(new InputSource(getClass().getResourceAsStream(
- modelPath)), false);
+ InputSource inputSource = new InputSource(
+ getClass().getResource(modelPath).toExternalForm());
+ inputSource.setPublicId(new File(modelPath).getName());
+ reader.parse(inputSource, false);
} catch (Exception e) {
e.printStackTrace();
- fail("Exception while loading model");
+ fail("Exception while loading model: " + e.getMessage());
}
assertTrue(modelPath + " model is loaded", true);
-
}
}
Modified: trunk/src/argouml-core-model-mdr/tests/testmodels/AndroMDA-3.3/timetracker.xmi
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-model-mdr/tests/testmodels/AndroMDA-3.3/timetracker.xmi?view=diff&pathrev=18043&r1=18042&r2=18043
==============================================================================
--- trunk/src/argouml-core-model-mdr/tests/testmodels/AndroMDA-3.3/timetracker.xmi (original)
+++ trunk/src/argouml-core-model-mdr/tests/testmodels/AndroMDA-3.3/timetracker.xmi 2010-02-27 13:41:48-0800
@@ -21,7 +21,7 @@
</XMI.extension>
<UML:Namespace.ownedElement>
<UML:Package xmi.id='eee_1045467100313_365297_7' name='Component View'/>
- <UML:Package href='andromda-profile-3.3.xml|_8a70287_1078771814628_224704_589'>
+ <UML:Package href='andromda-profile-3.3.xml.zip|_8a70287_1078771814628_224704_589'>
<XMI.extension xmi.extender='MagicDraw UML 9.5' xmi.extenderID='MagicDraw UML 9.5'>
<referentPath xmi.value='::org.andromda.profile'/>
</XMI.extension>
@@ -167,7 +167,7 @@
<UML:Comment xmi.id='_9_0_2_8980277_1149642394454_972306_376' name='This class enumerates the three states a timecard can be in.'/>
</UML:ModelElement.comment>
<UML:ModelElement.stereotype>
- <UML:Stereotype href='andromda-profile-3.3.xml|_9_0_1fe00f9_1119373197267_700962_14'>
+ <UML:Stereotype href='andromda-profile-3.3.xml.zip|_9_0_1fe00f9_1119373197267_700962_14'>
<XMI.extension xmi.extender='MagicDraw UML 9.5' xmi.extenderID='MagicDraw UML 9.5'>
<referentPath xmi.value='org.andromda.profile::Enumeration'/>
</XMI.extension>
@@ -508,7 +508,7 @@
</UML:Association>
<UML:Class xmi.id='_9_0_2_8980277_1156394472130_552212_164' name='Role'>
<UML:ModelElement.stereotype>
- <UML:Stereotype href='andromda-profile-3.3.xml|_9_0_1fe00f9_1119373197267_700962_14'>
+ <UML:Stereotype href='andromda-profile-3.3.xml.zip|_9_0_1fe00f9_1119373197267_700962_14'>
<XMI.extension xmi.extender='MagicDraw UML 9.5' xmi.extenderID='MagicDraw UML 9.5'>
<referentPath xmi.value='org.andromda.profile::Enumeration'/>
</XMI.extension>
@@ -617,7 +617,7 @@
<UML:Class xmi.id='_9_0_2_8980277_1148170347964_451862_237' name='UserVO[]'/>
<UML:Class xmi.id='_9_0_2_8980277_1148170347974_962254_242' name='UserVO'>
<UML:ModelElement.stereotype>
- <UML:Stereotype href='andromda-profile-3.3.xml|_9_0_1fe00f9_1119373197267_59537_10'>
+ <UML:Stereotype href='andromda-profile-3.3.xml.zip|_9_0_1fe00f9_1119373197267_59537_10'>
<XMI.extension xmi.extender='MagicDraw UML 9.5' xmi.extenderID='MagicDraw UML 9.5'>
<referentPath xmi.value='org.andromda.profile::ValueObject'/>
</XMI.extension>
@@ -673,7 +673,7 @@
<UML:Class xmi.id='_9_0_2_8980277_1149642611356_750576_500' name='TaskVO[]'/>
<UML:Class xmi.id='_9_0_2_8980277_1149642611356_405034_505' name='TimePeriodVO'>
<UML:ModelElement.stereotype>
- <UML:Stereotype href='andromda-profile-3.3.xml|_9_0_1fe00f9_1119373197267_59537_10'>
+ <UML:Stereotype href='andromda-profile-3.3.xml.zip|_9_0_1fe00f9_1119373197267_59537_10'>
<XMI.extension xmi.extender='MagicDraw UML 9.5' xmi.extenderID='MagicDraw UML 9.5'>
<referentPath xmi.value='org.andromda.profile::ValueObject'/>
</XMI.extension>
@@ -702,7 +702,7 @@
</UML:Class>
<UML:Class xmi.id='_9_0_2_8980277_1149642611356_560722_508' name='TaskVO'>
<UML:ModelElement.stereotype>
- <UML:Stereotype href='andromda-profile-3.3.xml|_9_0_1fe00f9_1119373197267_59537_10'>
+ <UML:Stereotype href='andromda-profile-3.3.xml.zip|_9_0_1fe00f9_1119373197267_59537_10'>
<XMI.extension xmi.extender='MagicDraw UML 9.5' xmi.extenderID='MagicDraw UML 9.5'>
<referentPath xmi.value='org.andromda.profile::ValueObject'/>
</XMI.extension>
@@ -740,7 +740,7 @@
<UML:Class xmi.id='_9_0_2_8980277_1149642611356_915381_513' name='TimecardSummaryVO[]'/>
<UML:Class xmi.id='_9_0_2_8980277_1149642611356_360927_520' name='TimecardSummaryVO'>
<UML:ModelElement.stereotype>
- <UML:Stereotype href='andromda-profile-3.3.xml|_9_0_1fe00f9_1119373197267_59537_10'>
+ <UML:Stereotype href='andromda-profile-3.3.xml.zip|_9_0_1fe00f9_1119373197267_59537_10'>
<XMI.extension xmi.extender='MagicDraw UML 9.5' xmi.extenderID='MagicDraw UML 9.5'>
<referentPath xmi.value='org.andromda.profile::ValueObject'/>
</XMI.extension>
@@ -804,7 +804,7 @@
</UML:Class>
<UML:Class xmi.id='_9_0_2_8980277_1149642611356_414295_533' name='TimeAllocationVO'>
<UML:ModelElement.stereotype>
- <UML:Stereotype href='andromda-profile-3.3.xml|_9_0_1fe00f9_1119373197267_59537_10'>
+ <UML:Stereotype href='andromda-profile-3.3.xml.zip|_9_0_1fe00f9_1119373197267_59537_10'>
<XMI.extension xmi.extender='MagicDraw UML 9.5' xmi.extenderID='MagicDraw UML 9.5'>
<referentPath xmi.value='org.andromda.profile::ValueObject'/>
</XMI.extension>
@@ -841,7 +841,7 @@
</UML:Class>
<UML:Class xmi.id='_9_0_2_8980277_1149642611356_904176_535' name='TimecardVO'>
<UML:ModelElement.stereotype>
- <UML:Stereotype href='andromda-profile-3.3.xml|_9_0_1fe00f9_1119373197267_59537_10'>
+ <UML:Stereotype href='andromda-profile-3.3.xml.zip|_9_0_1fe00f9_1119373197267_59537_10'>
<XMI.extension xmi.extender='MagicDraw UML 9.5' xmi.extenderID='MagicDraw UML 9.5'>
<referentPath xmi.value='org.andromda.profile::ValueObject'/>
</XMI.extension>
@@ -853,7 +853,7 @@
</UML:Class>
<UML:Class xmi.id='_9_0_2_8980277_1149644056824_230589_1219' name='TimecardSearchCriteriaVO'>
<UML:ModelElement.stereotype>
- <UML:Stereotype href='andromda-profile-3.3.xml|_9_0_1fe00f9_1119373197267_59537_10'>
+ <UML:Stereotype href='andromda-profile-3.3.xml.zip|_9_0_1fe00f9_1119373197267_59537_10'>
<XMI.extension xmi.extender='MagicDraw UML 9.5' xmi.extenderID='MagicDraw UML 9.5'>
<referentPath xmi.value='org.andromda.profile::ValueObject'/>
</XMI.extension>
@@ -938,7 +938,7 @@
<UML:Class xmi.id='_9_0_2_8980277_1156396215447_781061_342' name='UserRoleVO[]'/>
<UML:Class xmi.id='_9_0_2_8980277_1156396244188_824032_358' name='UserRoleVO'>
<UML:ModelElement.stereotype>
- <UML:Stereotype href='andromda-profile-3.3.xml|_9_0_1fe00f9_1119373197267_59537_10'>
+ <UML:Stereotype href='andromda-profile-3.3.xml.zip|_9_0_1fe00f9_1119373197267_59537_10'>
<XMI.extension xmi.extender='MagicDraw UML 9.5' xmi.extenderID='MagicDraw UML 9.5'>
<referentPath xmi.value='org.andromda.profile::ValueObject'/>
</XMI.extension>
@@ -966,7 +966,7 @@
</UML:Class>
<UML:Class xmi.id='_9_0_2_8980277_1156396447130_332684_387' name='UserDetailsVO'>
<UML:ModelElement.stereotype>
- <UML:Stereotype href='andromda-profile-3.3.xml|_9_0_1fe00f9_1119373197267_59537_10'>
+ <UML:Stereotype href='andromda-profile-3.3.xml.zip|_9_0_1fe00f9_1119373197267_59537_10'>
<XMI.extension xmi.extender='MagicDraw UML 9.5' xmi.extenderID='MagicDraw UML 9.5'>
<referentPath xmi.value='org.andromda.profile::ValueObject'/>
</XMI.extension>
------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=2452966
To unsubscribe from this discussion, e-mail: [[email protected]].