# HG changeset patch # Parent f5e2f605974717a825bac21f699250c6ffccaa8f # User Jesse Glick #207288: AntProjectHelper.createSharabilityQuery2. diff --git a/java.api.common/manifest.mf b/java.api.common/manifest.mf --- a/java.api.common/manifest.mf +++ b/java.api.common/manifest.mf @@ -1,4 +1,4 @@ Manifest-Version: 1.0 OpenIDE-Module: org.netbeans.modules.java.api.common/0 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/java/api/common/resources/Bundle.properties -OpenIDE-Module-Specification-Version: 1.34 +OpenIDE-Module-Specification-Version: 1.35 diff --git a/java.api.common/nbproject/project.xml b/java.api.common/nbproject/project.xml --- a/java.api.common/nbproject/project.xml +++ b/java.api.common/nbproject/project.xml @@ -99,7 +99,7 @@ 1 - 1.41 + 1.47 diff --git a/java.api.common/src/org/netbeans/modules/java/api/common/queries/QuerySupport.java b/java.api.common/src/org/netbeans/modules/java/api/common/queries/QuerySupport.java --- a/java.api.common/src/org/netbeans/modules/java/api/common/queries/QuerySupport.java +++ b/java.api.common/src/org/netbeans/modules/java/api/common/queries/QuerySupport.java @@ -42,12 +42,12 @@ package org.netbeans.modules.java.api.common.queries; +import java.io.File; import javax.swing.Icon; import org.netbeans.api.annotations.common.NonNull; import org.netbeans.api.annotations.common.NullAllowed; import org.netbeans.api.project.Sources; import org.netbeans.modules.java.api.common.SourceRoots; -import org.netbeans.api.java.queries.AnnotationProcessingQuery.Result; import org.netbeans.api.project.Project; import org.netbeans.api.project.ProjectInformation; import org.netbeans.modules.java.api.common.Roots; @@ -58,13 +58,13 @@ import org.netbeans.spi.java.queries.MultipleRootsUnitTestForSourceQueryImplementation; import org.netbeans.spi.java.queries.SourceForBinaryQueryImplementation; import org.netbeans.spi.java.queries.SourceLevelQueryImplementation2; -import org.netbeans.spi.project.SourceGroupModifierImplementation; import org.netbeans.spi.project.support.ant.AntProjectHelper; import org.netbeans.spi.project.support.ant.AntProjectListener; import org.netbeans.spi.project.support.ant.PropertyEvaluator; import org.netbeans.spi.queries.FileBuiltQueryImplementation; import org.netbeans.spi.queries.FileEncodingQueryImplementation; import org.netbeans.spi.queries.SharabilityQueryImplementation; +import org.netbeans.spi.queries.SharabilityQueryImplementation2; import org.openide.loaders.CreateFromTemplateAttributesProvider; import org.openide.util.Parameters; import org.openide.util.WeakListeners; @@ -180,9 +180,10 @@ * @param testRoots a list of test roots to treat as sharable, may be null if the project does not support tests * @param additionalSourceRoots additional paths to treat as sharable (just pure property names, do not * use ${ and } characters). Can be null. - * @return a {@link SharabilityQueryImplementation} to provide information about files sharability. + * @return a query to provide information about files sharability. + * @since 1.35 */ - public static SharabilityQueryImplementation createSharabilityQuery( + public static SharabilityQueryImplementation2 createSharabilityQuery2( final @NonNull AntProjectHelper helper, final @NonNull PropertyEvaluator evaluator, final @NonNull SourceRoots srcRoots, @@ -194,13 +195,27 @@ return new SharabilityQueryImpl(helper, evaluator, srcRoots, testRoots, additionalSourceRoots); } - /** - * Create a new query to provide information about files sharability without any additional source roots. See - * {@link #createSharabilityQuery(AntProjectHelper, PropertyEvaluator, SourceRoots, SourceRoots, String...) - * createSharabilityQuery()} - * for more information. + * @deprecated since 1.35 use {@link #createSharabilityQuery2} instead */ + @Deprecated + public static SharabilityQueryImplementation createSharabilityQuery( + final @NonNull AntProjectHelper helper, + final @NonNull PropertyEvaluator evaluator, + final @NonNull SourceRoots srcRoots, + final @NullAllowed SourceRoots testRoots, + final @NullAllowed String... additionalSourceRoots) { + final SharabilityQueryImplementation2 sq2 = createSharabilityQuery2(helper, evaluator, srcRoots, testRoots, additionalSourceRoots); + return new SharabilityQueryImplementation() { + @Override public int getSharability(File file) { + return sq2.getSharability(file.toURI()).ordinal(); + } + }; + } + /** + * @deprecated since 1.35 use {@link #createSharabilityQuery2} instead + */ + @Deprecated public static SharabilityQueryImplementation createSharabilityQuery(AntProjectHelper helper, PropertyEvaluator evaluator, SourceRoots srcRoots, SourceRoots testRoots) { diff --git a/java.api.common/src/org/netbeans/modules/java/api/common/queries/SharabilityQueryImpl.java b/java.api.common/src/org/netbeans/modules/java/api/common/queries/SharabilityQueryImpl.java --- a/java.api.common/src/org/netbeans/modules/java/api/common/queries/SharabilityQueryImpl.java +++ b/java.api.common/src/org/netbeans/modules/java/api/common/queries/SharabilityQueryImpl.java @@ -45,32 +45,34 @@ package org.netbeans.modules.java.api.common.queries; import org.netbeans.modules.java.api.common.SourceRoots; -import java.io.File; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; +import java.net.URI; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; import org.openide.util.Mutex; import org.netbeans.api.project.ProjectManager; +import org.netbeans.api.queries.SharabilityQuery; import org.netbeans.spi.queries.SharabilityQueryImplementation; import org.netbeans.spi.project.support.ant.AntProjectHelper; import org.netbeans.spi.project.support.ant.PropertyEvaluator; +import org.netbeans.spi.queries.SharabilityQueryImplementation2; /** * Default implementation of {@link SharabilityQueryImplementation} which is capable to take more sources. * It listens to the changes in particular property values. * @author Tomas Zezula, Tomas Mysik */ -class SharabilityQueryImpl implements SharabilityQueryImplementation, PropertyChangeListener { +class SharabilityQueryImpl implements SharabilityQueryImplementation2, PropertyChangeListener { private final AntProjectHelper helper; private final PropertyEvaluator evaluator; private final SourceRoots srcRoots; private final SourceRoots testRoots; private final List additionalSourceRoots; - private SharabilityQueryImplementation delegate; + private SharabilityQueryImplementation2 delegate; @SuppressWarnings("LeakingThisInConstructor") public SharabilityQueryImpl(AntProjectHelper helper, PropertyEvaluator evaluator, SourceRoots srcRoots, @@ -94,11 +96,9 @@ } } - @Override - public int getSharability(final File file) { - return ProjectManager.mutex().readAccess(new Mutex.Action() { - @Override - public Integer run() { + @Override public SharabilityQuery.Sharability getSharability(final URI file) { + return ProjectManager.mutex().readAccess(new Mutex.Action() { + @Override public SharabilityQuery.Sharability run() { synchronized (SharabilityQueryImpl.this) { if (delegate == null) { delegate = createDelegate(); @@ -118,7 +118,7 @@ } } - private SharabilityQueryImplementation createDelegate() { + private SharabilityQueryImplementation2 createDelegate() { String[] srcProps = srcRoots.getRootProperties(); String[] testProps = testRoots == null ? new String[0] : testRoots.getRootProperties(); String[] buildDirectories = new String[] {"${dist.dir}", "${build.dir}"}; // NOI18N @@ -136,6 +136,6 @@ } props.addAll(additionalSourceRoots); - return helper.createSharabilityQuery(evaluator, props.toArray(new String[props.size()]), buildDirectories); + return helper.createSharabilityQuery2(evaluator, props.toArray(new String[props.size()]), buildDirectories); } } diff --git a/java.j2seproject/nbproject/project.xml b/java.j2seproject/nbproject/project.xml --- a/java.j2seproject/nbproject/project.xml +++ b/java.j2seproject/nbproject/project.xml @@ -141,8 +141,8 @@ - 0-1 - 1.26 + 1 + 1.35 diff --git a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEProject.java b/java.j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEProject.java --- a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEProject.java +++ b/java.j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEProject.java @@ -72,7 +72,6 @@ import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; -import org.netbeans.api.annotations.common.NonNull; import org.netbeans.api.java.classpath.ClassPath; import org.netbeans.api.java.classpath.GlobalPathRegistry; import org.netbeans.api.java.project.JavaProjectConstants; @@ -373,7 +372,7 @@ QuerySupport.createUnitTestForSourceQuery(getSourceRoots(), getTestSourceRoots()), QuerySupport.createSourceLevelQuery2(evaluator()), QuerySupport.createSources(this, helper, evaluator(), getSourceRoots(), getTestSourceRoots(), Roots.nonSourceRoots(ProjectProperties.BUILD_DIR, J2SEProjectProperties.DIST_DIR)), - QuerySupport.createSharabilityQuery(helper, evaluator(), getSourceRoots(), getTestSourceRoots()), + QuerySupport.createSharabilityQuery2(helper, evaluator(), getSourceRoots(), getTestSourceRoots()), new CoSAwareFileBuiltQueryImpl(QuerySupport.createFileBuiltQuery(helper, evaluator(), getSourceRoots(), getTestSourceRoots()), this), new RecommendedTemplatesImpl (this.updateHelper), ProjectClassPathModifier.extenderForModifier(cpMod), diff --git a/project.ant/apichanges.xml b/project.ant/apichanges.xml --- a/project.ant/apichanges.xml +++ b/project.ant/apichanges.xml @@ -108,6 +108,27 @@ + + + Added AntProjectHelper.createSharabilityQuery2 + + + + +

+ Project types using AntProjectHelper.createSharabilityQuery should switch to the new method. +

+
+ +

+ AntProjectHelper.createSharabilityQuery2 was introduced + to avoid the deprecated SharabilityQueryImplementation. +

+
+ + +
+ Added getLibraryChooserImportHandler method into ReferenceHelper accepting URL diff --git a/project.ant/manifest.mf b/project.ant/manifest.mf --- a/project.ant/manifest.mf +++ b/project.ant/manifest.mf @@ -1,6 +1,6 @@ Manifest-Version: 1.0 OpenIDE-Module: org.netbeans.modules.project.ant/1 -OpenIDE-Module-Specification-Version: 1.46 +OpenIDE-Module-Specification-Version: 1.47 OpenIDE-Module-Layer: org/netbeans/modules/project/ant/resources/mf-layer.xml OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/project/ant/Bundle.properties OpenIDE-Module-Install: org/netbeans/modules/project/ant/AntProjectModule.class diff --git a/project.ant/src/org/netbeans/spi/project/support/ant/AntProjectHelper.java b/project.ant/src/org/netbeans/spi/project/support/ant/AntProjectHelper.java --- a/project.ant/src/org/netbeans/spi/project/support/ant/AntProjectHelper.java +++ b/project.ant/src/org/netbeans/spi/project/support/ant/AntProjectHelper.java @@ -74,6 +74,7 @@ import org.netbeans.spi.project.ProjectState; import org.netbeans.spi.queries.FileBuiltQueryImplementation; import org.netbeans.spi.queries.SharabilityQueryImplementation; +import org.netbeans.spi.queries.SharabilityQueryImplementation2; import org.openide.ErrorManager; import org.openide.filesystems.FileAlreadyLockedException; import org.openide.filesystems.FileAttributeEvent; @@ -1153,9 +1154,9 @@ * Typical usage would be: *

*
-     * helper.createSharabilityQuery(helper.getStandardPropertyEvaluator(),
-     *                               new String[] {"${src.dir}", "${test.src.dir}"},
-     *                               new String[] {"${build.dir}", "${dist.dir}"})
+     * helper.createSharabilityQuery2(helper.getStandardPropertyEvaluator(),
+     *                                new String[] {"${src.dir}", "${test.src.dir}"},
+     *                                new String[] {"${build.dir}", "${dist.dir}"})
      * 
*

* A quick rule of thumb is that the include list should contain any @@ -1180,8 +1181,9 @@ * @param buildDirectories a list of paths to treat as not sharable * @return a sharability query implementation suitable for the project lookup * @see Project#getLookup + * @since 1.47 */ - public SharabilityQueryImplementation createSharabilityQuery(PropertyEvaluator eval, String[] sourceRoots, String[] buildDirectories) { + public SharabilityQueryImplementation2 createSharabilityQuery2(PropertyEvaluator eval, String[] sourceRoots, String[] buildDirectories) { String[] includes = new String[sourceRoots.length + 1]; System.arraycopy(sourceRoots, 0, includes, 0, sourceRoots.length); includes[sourceRoots.length] = ""; // NOI18N @@ -1190,6 +1192,18 @@ excludes[buildDirectories.length] = "nbproject/private"; // NOI18N return new SharabilityQueryImpl(this, eval, includes, excludes); } + /** + * @deprecated since 1.47 use {@link #createSharabilityQuery2} instead + */ + @Deprecated + public SharabilityQueryImplementation createSharabilityQuery(PropertyEvaluator eval, String[] sourceRoots, String[] buildDirectories) { + final SharabilityQueryImplementation2 sq2 = createSharabilityQuery2(eval, sourceRoots, buildDirectories); + return new SharabilityQueryImplementation() { + @Override public int getSharability(File file) { + return sq2.getSharability(file.toURI()).ordinal(); + } + }; + } /** * Get a property provider which defines basedir according to diff --git a/project.ant/src/org/netbeans/spi/project/support/ant/SharabilityQueryImpl.java b/project.ant/src/org/netbeans/spi/project/support/ant/SharabilityQueryImpl.java --- a/project.ant/src/org/netbeans/spi/project/support/ant/SharabilityQueryImpl.java +++ b/project.ant/src/org/netbeans/spi/project/support/ant/SharabilityQueryImpl.java @@ -47,18 +47,19 @@ import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.File; +import java.net.URI; import java.util.ArrayList; import java.util.List; import org.netbeans.api.queries.SharabilityQuery; import org.netbeans.modules.project.ant.ProjectLibraryProvider; -import org.netbeans.spi.queries.SharabilityQueryImplementation; +import org.netbeans.spi.queries.SharabilityQueryImplementation2; import org.openide.util.WeakListeners; /** - * Standard impl of {@link SharabilityQueryImplementation}. + * Standard impl of {@link SharabilityQueryImplementation2}. * @author Jesse Glick */ -final class SharabilityQueryImpl implements SharabilityQueryImplementation, PropertyChangeListener, AntProjectListener { +final class SharabilityQueryImpl implements SharabilityQueryImplementation2, PropertyChangeListener, AntProjectListener { private final AntProjectHelper h; private final PropertyEvaluator eval; @@ -105,15 +106,16 @@ // XXX should remove overlaps somehow return result.toArray(new String[result.size()]); } - - public synchronized int getSharability(File file) { - String path = file.getAbsolutePath(); + + @Override public SharabilityQuery.Sharability getSharability(URI uri) { + // XXX might be more efficient to precompute URIs for includePaths and excludePaths + String path = new File(uri).getAbsolutePath(); if (contains(path, excludePaths, false)) { - return SharabilityQuery.NOT_SHARABLE; + return SharabilityQuery.Sharability.NOT_SHARABLE; } return contains(path, includePaths, false) ? - (contains(path, excludePaths, true) ? SharabilityQuery.MIXED : SharabilityQuery.SHARABLE) : - SharabilityQuery.UNKNOWN; + (contains(path, excludePaths, true) ? SharabilityQuery.Sharability.MIXED : SharabilityQuery.Sharability.SHARABLE) : + SharabilityQuery.Sharability.UNKNOWN; } /** diff --git a/project.ant/test/unit/src/org/netbeans/spi/project/support/ant/AntBasedTestUtil.java b/project.ant/test/unit/src/org/netbeans/spi/project/support/ant/AntBasedTestUtil.java --- a/project.ant/test/unit/src/org/netbeans/spi/project/support/ant/AntBasedTestUtil.java +++ b/project.ant/test/unit/src/org/netbeans/spi/project/support/ant/AntBasedTestUtil.java @@ -189,7 +189,7 @@ genFilesHelper, aux, helper.createCacheDirectoryProvider(), - helper.createSharabilityQuery(helper.getStandardPropertyEvaluator(), new String[0], new String[0]), + helper.createSharabilityQuery2(helper.getStandardPropertyEvaluator(), new String[0], new String[0]), refHelper.createSubprojectProvider(), new TestAntArtifactProvider(), new ProjectXmlSavedHook() { diff --git a/project.ant/test/unit/src/org/netbeans/spi/project/support/ant/SharabilityQueryImplTest.java b/project.ant/test/unit/src/org/netbeans/spi/project/support/ant/SharabilityQueryImplTest.java --- a/project.ant/test/unit/src/org/netbeans/spi/project/support/ant/SharabilityQueryImplTest.java +++ b/project.ant/test/unit/src/org/netbeans/spi/project/support/ant/SharabilityQueryImplTest.java @@ -45,11 +45,12 @@ package org.netbeans.spi.project.support.ant; import java.io.File; +import java.net.URI; import org.netbeans.api.project.ProjectManager; import org.netbeans.api.project.TestUtil; import org.netbeans.api.queries.SharabilityQuery; import org.netbeans.junit.NbTestCase; -import org.netbeans.spi.queries.SharabilityQueryImplementation; +import org.netbeans.spi.queries.SharabilityQueryImplementation2; import org.openide.filesystems.FileObject; import org.openide.filesystems.FileUtil; import org.openide.util.test.MockLookup; @@ -67,7 +68,7 @@ /** Location of top of testing dir (contains projdir and external). */ private File scratchF; /** Tested impl. */ - private SharabilityQueryImplementation sqi; + private SharabilityQueryImplementation2 sqi; protected void setUp() throws Exception { super.setUp(); @@ -88,65 +89,65 @@ props.setProperty("build3.dir", new File(externalF, "build").getAbsolutePath()); h.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, props); ProjectManager.getDefault().saveProject(ProjectManager.getDefault().findProject(projdir)); - sqi = h.createSharabilityQuery(h.getStandardPropertyEvaluator(), new String[] {"${src.dir}", "${src2.dir}"}, + sqi = h.createSharabilityQuery2(h.getStandardPropertyEvaluator(), new String[] {"${src.dir}", "${src2.dir}"}, new String[] {"${build.dir}", "${build2.dir}", "${build3.dir}", "${dist.dir}"}); } - private File file(String path) { - return new File(scratchF, path.replace('/', File.separatorChar)); + private URI file(String path) { + return new File(scratchF, path.replace('/', File.separatorChar)).toURI(); } public void testBasicIncludesExcludes() throws Exception { - assertEquals("project directory is mixed", SharabilityQuery.MIXED, sqi.getSharability(file("projdir"))); - assertEquals("build.xml is sharable", SharabilityQuery.SHARABLE, sqi.getSharability(file("projdir/build.xml"))); - assertEquals("src/ is sharable", SharabilityQuery.SHARABLE, sqi.getSharability(file("projdir/src"))); - assertEquals("src/org/foo/ is sharable", SharabilityQuery.SHARABLE, sqi.getSharability(file("projdir/src/org/foo"))); - assertEquals("src/org/foo/Foo.java is sharable", SharabilityQuery.SHARABLE, sqi.getSharability(file("projdir/src/org/foo/Foo.java"))); - assertEquals("nbproject/ is mixed", SharabilityQuery.MIXED, sqi.getSharability(file("projdir/nbproject"))); - assertEquals("nbproject/project.xml is sharable", SharabilityQuery.SHARABLE, sqi.getSharability(file("projdir/nbproject/project.xml"))); - assertEquals("nbproject/private/ is not sharable", SharabilityQuery.NOT_SHARABLE, sqi.getSharability(file("projdir/nbproject/private"))); - assertEquals("nbproject/private/private.properties is not sharable", SharabilityQuery.NOT_SHARABLE, sqi.getSharability(file("projdir/nbproject/private/private.properties"))); - assertEquals("build/ is not sharable", SharabilityQuery.NOT_SHARABLE, sqi.getSharability(file("projdir/build"))); - assertEquals("build/classes/org/foo/Foo.class is not sharable", SharabilityQuery.NOT_SHARABLE, sqi.getSharability(file("projdir/build/classes/org/foo/Foo.class"))); - assertEquals("dist/ is not sharable", SharabilityQuery.NOT_SHARABLE, sqi.getSharability(file("projdir/dist"))); + assertEquals("project directory is mixed", SharabilityQuery.Sharability.MIXED, sqi.getSharability(file("projdir"))); + assertEquals("build.xml is sharable", SharabilityQuery.Sharability.SHARABLE, sqi.getSharability(file("projdir/build.xml"))); + assertEquals("src/ is sharable", SharabilityQuery.Sharability.SHARABLE, sqi.getSharability(file("projdir/src"))); + assertEquals("src/org/foo/ is sharable", SharabilityQuery.Sharability.SHARABLE, sqi.getSharability(file("projdir/src/org/foo"))); + assertEquals("src/org/foo/Foo.java is sharable", SharabilityQuery.Sharability.SHARABLE, sqi.getSharability(file("projdir/src/org/foo/Foo.java"))); + assertEquals("nbproject/ is mixed", SharabilityQuery.Sharability.MIXED, sqi.getSharability(file("projdir/nbproject"))); + assertEquals("nbproject/project.xml is sharable", SharabilityQuery.Sharability.SHARABLE, sqi.getSharability(file("projdir/nbproject/project.xml"))); + assertEquals("nbproject/private/ is not sharable", SharabilityQuery.Sharability.NOT_SHARABLE, sqi.getSharability(file("projdir/nbproject/private"))); + assertEquals("nbproject/private/private.properties is not sharable", SharabilityQuery.Sharability.NOT_SHARABLE, sqi.getSharability(file("projdir/nbproject/private/private.properties"))); + assertEquals("build/ is not sharable", SharabilityQuery.Sharability.NOT_SHARABLE, sqi.getSharability(file("projdir/build"))); + assertEquals("build/classes/org/foo/Foo.class is not sharable", SharabilityQuery.Sharability.NOT_SHARABLE, sqi.getSharability(file("projdir/build/classes/org/foo/Foo.class"))); + assertEquals("dist/ is not sharable", SharabilityQuery.Sharability.NOT_SHARABLE, sqi.getSharability(file("projdir/dist"))); } public void testOverlaps() throws Exception { - assertEquals("build/2/ is not sharable", SharabilityQuery.NOT_SHARABLE, sqi.getSharability(file("projdir/build/2"))); - assertEquals("build/2/whatever is not sharable", SharabilityQuery.NOT_SHARABLE, sqi.getSharability(file("projdir/build/2/whatever"))); + assertEquals("build/2/ is not sharable", SharabilityQuery.Sharability.NOT_SHARABLE, sqi.getSharability(file("projdir/build/2"))); + assertEquals("build/2/whatever is not sharable", SharabilityQuery.Sharability.NOT_SHARABLE, sqi.getSharability(file("projdir/build/2/whatever"))); // overlaps in includePaths tested in basicIncludesExcludes: src is inside projdir } public void testExternalFiles() throws Exception { - assertEquals("external/src is sharable", SharabilityQuery.SHARABLE, sqi.getSharability(file("external/src"))); - assertEquals("external/src/org/foo/Foo.java is sharable", SharabilityQuery.SHARABLE, sqi.getSharability(file("external/src/org/foo/Foo.java"))); - assertEquals("external/build is not sharable", SharabilityQuery.NOT_SHARABLE, sqi.getSharability(file("external/build"))); - assertEquals("external/build/classes/org/foo/Foo.class is not sharable", SharabilityQuery.NOT_SHARABLE, sqi.getSharability(file("external/build/classes/org/foo/Foo.class"))); + assertEquals("external/src is sharable", SharabilityQuery.Sharability.SHARABLE, sqi.getSharability(file("external/src"))); + assertEquals("external/src/org/foo/Foo.java is sharable", SharabilityQuery.Sharability.SHARABLE, sqi.getSharability(file("external/src/org/foo/Foo.java"))); + assertEquals("external/build is not sharable", SharabilityQuery.Sharability.NOT_SHARABLE, sqi.getSharability(file("external/build"))); + assertEquals("external/build/classes/org/foo/Foo.class is not sharable", SharabilityQuery.Sharability.NOT_SHARABLE, sqi.getSharability(file("external/build/classes/org/foo/Foo.class"))); } public void testUnknownFiles() throws Exception { - assertEquals("some other dir is unknown", SharabilityQuery.UNKNOWN, sqi.getSharability(file("something"))); - assertEquals("some other file is unknown", SharabilityQuery.UNKNOWN, sqi.getSharability(file("something/else"))); - assertEquals("external itself is unknown", SharabilityQuery.UNKNOWN, sqi.getSharability(file("external"))); + assertEquals("some other dir is unknown", SharabilityQuery.Sharability.UNKNOWN, sqi.getSharability(file("something"))); + assertEquals("some other file is unknown", SharabilityQuery.Sharability.UNKNOWN, sqi.getSharability(file("something/else"))); + assertEquals("external itself is unknown", SharabilityQuery.Sharability.UNKNOWN, sqi.getSharability(file("external"))); } public void testDirNamesEndingInSlash() throws Exception { - assertEquals("project directory is mixed", SharabilityQuery.MIXED, sqi.getSharability(file("projdir/"))); - assertEquals("src/ is sharable", SharabilityQuery.SHARABLE, sqi.getSharability(file("projdir/src/"))); - assertEquals("src/org/foo/ is sharable", SharabilityQuery.SHARABLE, sqi.getSharability(file("projdir/src/org/foo/"))); - assertEquals("nbproject/ is mixed", SharabilityQuery.MIXED, sqi.getSharability(file("projdir/nbproject/"))); - assertEquals("nbproject/private/ is not sharable", SharabilityQuery.NOT_SHARABLE, sqi.getSharability(file("projdir/nbproject/private/"))); - assertEquals("build/ is not sharable", SharabilityQuery.NOT_SHARABLE, sqi.getSharability(file("projdir/build/"))); - assertEquals("dist/ is not sharable", SharabilityQuery.NOT_SHARABLE, sqi.getSharability(file("projdir/dist/"))); - assertEquals("build/2/ is not sharable", SharabilityQuery.NOT_SHARABLE, sqi.getSharability(file("projdir/build/2/"))); - assertEquals("some other dir is unknown", SharabilityQuery.UNKNOWN, sqi.getSharability(file("something/"))); - assertEquals("external itself is unknown", SharabilityQuery.UNKNOWN, sqi.getSharability(file("external/"))); - assertEquals("external/src is sharable", SharabilityQuery.SHARABLE, sqi.getSharability(file("external/src/"))); - assertEquals("external/build is not sharable", SharabilityQuery.NOT_SHARABLE, sqi.getSharability(file("external/build/"))); + assertEquals("project directory is mixed", SharabilityQuery.Sharability.MIXED, sqi.getSharability(file("projdir/"))); + assertEquals("src/ is sharable", SharabilityQuery.Sharability.SHARABLE, sqi.getSharability(file("projdir/src/"))); + assertEquals("src/org/foo/ is sharable", SharabilityQuery.Sharability.SHARABLE, sqi.getSharability(file("projdir/src/org/foo/"))); + assertEquals("nbproject/ is mixed", SharabilityQuery.Sharability.MIXED, sqi.getSharability(file("projdir/nbproject/"))); + assertEquals("nbproject/private/ is not sharable", SharabilityQuery.Sharability.NOT_SHARABLE, sqi.getSharability(file("projdir/nbproject/private/"))); + assertEquals("build/ is not sharable", SharabilityQuery.Sharability.NOT_SHARABLE, sqi.getSharability(file("projdir/build/"))); + assertEquals("dist/ is not sharable", SharabilityQuery.Sharability.NOT_SHARABLE, sqi.getSharability(file("projdir/dist/"))); + assertEquals("build/2/ is not sharable", SharabilityQuery.Sharability.NOT_SHARABLE, sqi.getSharability(file("projdir/build/2/"))); + assertEquals("some other dir is unknown", SharabilityQuery.Sharability.UNKNOWN, sqi.getSharability(file("something/"))); + assertEquals("external itself is unknown", SharabilityQuery.Sharability.UNKNOWN, sqi.getSharability(file("external/"))); + assertEquals("external/src is sharable", SharabilityQuery.Sharability.SHARABLE, sqi.getSharability(file("external/src/"))); + assertEquals("external/build is not sharable", SharabilityQuery.Sharability.NOT_SHARABLE, sqi.getSharability(file("external/build/"))); } public void testSubprojectFiles() throws Exception { - assertEquals("nbproject/private from a subproject is sharable as far as this impl is concerned", SharabilityQuery.SHARABLE, sqi.getSharability(file("projdir/subproj/nbproject/private"))); + assertEquals("nbproject/private from a subproject is sharable as far as this impl is concerned", SharabilityQuery.Sharability.SHARABLE, sqi.getSharability(file("projdir/subproj/nbproject/private"))); } // XXX testChangedProperties