Author: rob.stryker(a)jboss.com
Date: 2008-06-30 17:59:04 -0400 (Mon, 30 Jun 2008)
New Revision: 9034
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspaceVariables.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/ModelUtil.java
trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/model/ModelUtilTest.java
Log:
Unit test regressions fixed
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspaceVariables.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspaceVariables.java 2008-06-30
19:37:26 UTC (rev 9033)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/model/other/internal/WorkspaceVariables.java 2008-06-30
21:59:04 UTC (rev 9034)
@@ -5,6 +5,7 @@
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.variables.VariablesPlugin;
import org.jboss.ide.eclipse.archives.core.model.IArchivesVFS;
@@ -60,8 +61,14 @@
public IPath workspacePathToAbsolutePath(IPath path) {
IResource r = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
+ IPath append = new Path("");
+ while( r == null && path.segmentCount() > 0) {
+ append = new Path(path.lastSegment()).append(append);
+ path = path.removeLastSegments(1);
+ r = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
+ }
if( r != null )
- return r.getLocation();
+ return r.getLocation().append(append);
return null;
}
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/ModelUtil.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/ModelUtil.java 2008-06-30
19:37:26 UTC (rev 9033)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/ModelUtil.java 2008-06-30
21:59:04 UTC (rev 9034)
@@ -136,35 +136,29 @@
}
- public static boolean otherFilesetMatchesPathAndOutputLocation(IArchiveFileSet fileset,
FileWrapper file) {
- return otherFilesetMatchesPathAndOutputLocation(fileset, file, null);
- }
-
/**
* Do any filesets other than the parameter match this path?
- * @param fileset
- * @param path
- * @param root a node to start with, or null if the entire model
- * @return
*/
- public static boolean otherFilesetMatchesPathAndOutputLocation(IArchiveFileSet fileset,
FileWrapper file, IArchiveNode root) {
- return otherFilesetMatchesPathAndOutputLocation(fileset, new
Path(file.getAbsolutePath()), file.getFilesetRelative(), root);
+ public static boolean otherFilesetMatchesPathAndOutputLocation(IArchiveFileSet fileset,
FileWrapper file) {
+ return otherFilesetMatchesPathAndOutputLocation(fileset, new
Path(file.getAbsolutePath()),
+ file.getFilesetRelative(), file.getRootArchiveRelative().toString(), null);
}
- public static boolean otherFilesetMatchesPathAndOutputLocation(IArchiveFileSet fileset,
IPath absolute, IArchiveNode root) {
- return otherFilesetMatchesPathAndOutputLocation(fileset, absolute, null, root);
- }
- public static boolean otherFilesetMatchesPathAndOutputLocation(IArchiveFileSet fileset,
IPath absolute, String fsRelative, IArchiveNode root) {
+ public static boolean otherFilesetMatchesPathAndOutputLocation(IArchiveFileSet fileset,
IPath absolute,
+ String fsRelative, String rootArchiveRelative, IArchiveNode root) {
IArchiveFileSet[] filesets = ModelUtil.getMatchingFilesets(root, absolute);
if( filesets.length == 0 || (filesets.length == 1 &&
Arrays.asList(filesets).contains(fileset))) {
return false;
} else {
// other filesets DO match... but are they at the same location in the archive?
- boolean relativePathsMatch;
- boolean destinationsMatch;
+ boolean relativePathsMatch = false;
+ boolean destinationsMatch = false;
+ FileWrapper[] matches;
for( int i = 0; i < filesets.length; i++ ) {
if( fileset.equals(filesets[i])) continue;
- relativePathsMatch = filesets[i].matchesPath(absolute, fsRelative);
+ matches = filesets[i].getMatches(absolute);
+ for( int j = 0; j < matches.length; j++ )
+ relativePathsMatch |=
matches[j].getRootArchiveRelative().toString().equals(rootArchiveRelative);
destinationsMatch =
fileset.getRootArchive().getArchiveFilePath().equals(filesets[i].getRootArchive().getArchiveFilePath());
if( relativePathsMatch && destinationsMatch ) {
Modified:
trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/model/ModelUtilTest.java
===================================================================
---
trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/model/ModelUtilTest.java 2008-06-30
19:37:26 UTC (rev 9033)
+++
trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/model/ModelUtilTest.java 2008-06-30
21:59:04 UTC (rev 9034)
@@ -14,6 +14,7 @@
import org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet;
import org.jboss.ide.eclipse.archives.core.model.IArchiveFolder;
import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
+import
org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory.DirectoryScannerExtension.FileWrapper;
import org.jboss.ide.eclipse.archives.core.model.internal.ArchiveNodeImpl;
import org.jboss.ide.eclipse.archives.core.util.ModelUtil;
import org.jboss.ide.eclipse.archives.test.ArchivesTest;
@@ -127,13 +128,13 @@
IPath xml =
inputs.append("fileTrees").append("misc").append("rug.xml");
IArchiveFileSet[] xmlFS = ModelUtil.getMatchingFilesets(rootArchive, xml);
assertTrue(xmlFS.length == 2);
- assertFalse(ModelUtil.otherFilesetMatchesPathAndOutputLocation(xmlFS[0], xml,
rootArchive));
- assertFalse(ModelUtil.otherFilesetMatchesPathAndOutputLocation(xmlFS[1], xml,
rootArchive));
+ assertFalse(testMatches(xmlFS[0], xml, rootArchive));
+ assertFalse(testMatches(xmlFS[1], xml, rootArchive));
IPath html =
inputs.append("fileTrees").append("misc").append("someHtml.html");
IArchiveFileSet[] htmlFS = ModelUtil.getMatchingFilesets(rootArchive, html);
assertTrue(htmlFS.length == 1);
- assertFalse(ModelUtil.otherFilesetMatchesPathAndOutputLocation(htmlFS[0], html,
rootArchive));
+ assertFalse(testMatches(htmlFS[0], html, rootArchive));
// add a temporary fileset that will match exactly
IArchiveFileSet otherFS = ArchiveNodeFactory.createFileset();
@@ -142,6 +143,13 @@
otherFS.setSourcePath(xmlFS[0].getSourcePath());
xmlFS[0].getParent().addChild(otherFS);
- assertTrue(ModelUtil.otherFilesetMatchesPathAndOutputLocation(xmlFS[0], xml,
rootArchive));
+ assertTrue(testMatches(xmlFS[0], xml, rootArchive));
}
+
+ private boolean testMatches(IArchiveFileSet fs, IPath absoluteFile, IArchiveNode node)
{
+ FileWrapper[] wrappers = fs.getMatches(absoluteFile);
+ return ModelUtil.otherFilesetMatchesPathAndOutputLocation(fs, absoluteFile,
wrappers[0].getFilesetRelative(), wrappers[0].getRootArchiveRelative().toString(), node);
+
+ }
+
}