Lines 45-55
Link Here
|
45 |
package org.netbeans.spi.project.support.ant; |
45 |
package org.netbeans.spi.project.support.ant; |
46 |
|
46 |
|
47 |
import java.io.File; |
47 |
import java.io.File; |
|
|
48 |
import java.net.URI; |
48 |
import org.netbeans.api.project.ProjectManager; |
49 |
import org.netbeans.api.project.ProjectManager; |
49 |
import org.netbeans.api.project.TestUtil; |
50 |
import org.netbeans.api.project.TestUtil; |
50 |
import org.netbeans.api.queries.SharabilityQuery; |
51 |
import org.netbeans.api.queries.SharabilityQuery; |
51 |
import org.netbeans.junit.NbTestCase; |
52 |
import org.netbeans.junit.NbTestCase; |
52 |
import org.netbeans.spi.queries.SharabilityQueryImplementation; |
53 |
import org.netbeans.spi.queries.SharabilityQueryImplementation2; |
53 |
import org.openide.filesystems.FileObject; |
54 |
import org.openide.filesystems.FileObject; |
54 |
import org.openide.filesystems.FileUtil; |
55 |
import org.openide.filesystems.FileUtil; |
55 |
import org.openide.util.test.MockLookup; |
56 |
import org.openide.util.test.MockLookup; |
Lines 67-73
Link Here
|
67 |
/** Location of top of testing dir (contains projdir and external). */ |
68 |
/** Location of top of testing dir (contains projdir and external). */ |
68 |
private File scratchF; |
69 |
private File scratchF; |
69 |
/** Tested impl. */ |
70 |
/** Tested impl. */ |
70 |
private SharabilityQueryImplementation sqi; |
71 |
private SharabilityQueryImplementation2 sqi; |
71 |
|
72 |
|
72 |
protected void setUp() throws Exception { |
73 |
protected void setUp() throws Exception { |
73 |
super.setUp(); |
74 |
super.setUp(); |
Lines 88-152
Link Here
|
88 |
props.setProperty("build3.dir", new File(externalF, "build").getAbsolutePath()); |
89 |
props.setProperty("build3.dir", new File(externalF, "build").getAbsolutePath()); |
89 |
h.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, props); |
90 |
h.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, props); |
90 |
ProjectManager.getDefault().saveProject(ProjectManager.getDefault().findProject(projdir)); |
91 |
ProjectManager.getDefault().saveProject(ProjectManager.getDefault().findProject(projdir)); |
91 |
sqi = h.createSharabilityQuery(h.getStandardPropertyEvaluator(), new String[] {"${src.dir}", "${src2.dir}"}, |
92 |
sqi = h.createSharabilityQuery2(h.getStandardPropertyEvaluator(), new String[] {"${src.dir}", "${src2.dir}"}, |
92 |
new String[] {"${build.dir}", "${build2.dir}", "${build3.dir}", "${dist.dir}"}); |
93 |
new String[] {"${build.dir}", "${build2.dir}", "${build3.dir}", "${dist.dir}"}); |
93 |
} |
94 |
} |
94 |
|
95 |
|
95 |
private File file(String path) { |
96 |
private URI file(String path) { |
96 |
return new File(scratchF, path.replace('/', File.separatorChar)); |
97 |
return new File(scratchF, path.replace('/', File.separatorChar)).toURI(); |
97 |
} |
98 |
} |
98 |
|
99 |
|
99 |
public void testBasicIncludesExcludes() throws Exception { |
100 |
public void testBasicIncludesExcludes() throws Exception { |
100 |
assertEquals("project directory is mixed", SharabilityQuery.MIXED, sqi.getSharability(file("projdir"))); |
101 |
assertEquals("project directory is mixed", SharabilityQuery.Sharability.MIXED, sqi.getSharability(file("projdir"))); |
101 |
assertEquals("build.xml is sharable", SharabilityQuery.SHARABLE, sqi.getSharability(file("projdir/build.xml"))); |
102 |
assertEquals("build.xml is sharable", SharabilityQuery.Sharability.SHARABLE, sqi.getSharability(file("projdir/build.xml"))); |
102 |
assertEquals("src/ is sharable", SharabilityQuery.SHARABLE, sqi.getSharability(file("projdir/src"))); |
103 |
assertEquals("src/ is sharable", SharabilityQuery.Sharability.SHARABLE, sqi.getSharability(file("projdir/src"))); |
103 |
assertEquals("src/org/foo/ is sharable", SharabilityQuery.SHARABLE, sqi.getSharability(file("projdir/src/org/foo"))); |
104 |
assertEquals("src/org/foo/ is sharable", SharabilityQuery.Sharability.SHARABLE, sqi.getSharability(file("projdir/src/org/foo"))); |
104 |
assertEquals("src/org/foo/Foo.java is sharable", SharabilityQuery.SHARABLE, sqi.getSharability(file("projdir/src/org/foo/Foo.java"))); |
105 |
assertEquals("src/org/foo/Foo.java is sharable", SharabilityQuery.Sharability.SHARABLE, sqi.getSharability(file("projdir/src/org/foo/Foo.java"))); |
105 |
assertEquals("nbproject/ is mixed", SharabilityQuery.MIXED, sqi.getSharability(file("projdir/nbproject"))); |
106 |
assertEquals("nbproject/ is mixed", SharabilityQuery.Sharability.MIXED, sqi.getSharability(file("projdir/nbproject"))); |
106 |
assertEquals("nbproject/project.xml is sharable", SharabilityQuery.SHARABLE, sqi.getSharability(file("projdir/nbproject/project.xml"))); |
107 |
assertEquals("nbproject/project.xml is sharable", SharabilityQuery.Sharability.SHARABLE, sqi.getSharability(file("projdir/nbproject/project.xml"))); |
107 |
assertEquals("nbproject/private/ is not sharable", SharabilityQuery.NOT_SHARABLE, sqi.getSharability(file("projdir/nbproject/private"))); |
108 |
assertEquals("nbproject/private/ is not sharable", SharabilityQuery.Sharability.NOT_SHARABLE, sqi.getSharability(file("projdir/nbproject/private"))); |
108 |
assertEquals("nbproject/private/private.properties is not sharable", SharabilityQuery.NOT_SHARABLE, sqi.getSharability(file("projdir/nbproject/private/private.properties"))); |
109 |
assertEquals("nbproject/private/private.properties is not sharable", SharabilityQuery.Sharability.NOT_SHARABLE, sqi.getSharability(file("projdir/nbproject/private/private.properties"))); |
109 |
assertEquals("build/ is not sharable", SharabilityQuery.NOT_SHARABLE, sqi.getSharability(file("projdir/build"))); |
110 |
assertEquals("build/ is not sharable", SharabilityQuery.Sharability.NOT_SHARABLE, sqi.getSharability(file("projdir/build"))); |
110 |
assertEquals("build/classes/org/foo/Foo.class is not sharable", SharabilityQuery.NOT_SHARABLE, sqi.getSharability(file("projdir/build/classes/org/foo/Foo.class"))); |
111 |
assertEquals("build/classes/org/foo/Foo.class is not sharable", SharabilityQuery.Sharability.NOT_SHARABLE, sqi.getSharability(file("projdir/build/classes/org/foo/Foo.class"))); |
111 |
assertEquals("dist/ is not sharable", SharabilityQuery.NOT_SHARABLE, sqi.getSharability(file("projdir/dist"))); |
112 |
assertEquals("dist/ is not sharable", SharabilityQuery.Sharability.NOT_SHARABLE, sqi.getSharability(file("projdir/dist"))); |
112 |
} |
113 |
} |
113 |
|
114 |
|
114 |
public void testOverlaps() throws Exception { |
115 |
public void testOverlaps() throws Exception { |
115 |
assertEquals("build/2/ is not sharable", SharabilityQuery.NOT_SHARABLE, sqi.getSharability(file("projdir/build/2"))); |
116 |
assertEquals("build/2/ is not sharable", SharabilityQuery.Sharability.NOT_SHARABLE, sqi.getSharability(file("projdir/build/2"))); |
116 |
assertEquals("build/2/whatever is not sharable", SharabilityQuery.NOT_SHARABLE, sqi.getSharability(file("projdir/build/2/whatever"))); |
117 |
assertEquals("build/2/whatever is not sharable", SharabilityQuery.Sharability.NOT_SHARABLE, sqi.getSharability(file("projdir/build/2/whatever"))); |
117 |
// overlaps in includePaths tested in basicIncludesExcludes: src is inside projdir |
118 |
// overlaps in includePaths tested in basicIncludesExcludes: src is inside projdir |
118 |
} |
119 |
} |
119 |
|
120 |
|
120 |
public void testExternalFiles() throws Exception { |
121 |
public void testExternalFiles() throws Exception { |
121 |
assertEquals("external/src is sharable", SharabilityQuery.SHARABLE, sqi.getSharability(file("external/src"))); |
122 |
assertEquals("external/src is sharable", SharabilityQuery.Sharability.SHARABLE, sqi.getSharability(file("external/src"))); |
122 |
assertEquals("external/src/org/foo/Foo.java is sharable", SharabilityQuery.SHARABLE, sqi.getSharability(file("external/src/org/foo/Foo.java"))); |
123 |
assertEquals("external/src/org/foo/Foo.java is sharable", SharabilityQuery.Sharability.SHARABLE, sqi.getSharability(file("external/src/org/foo/Foo.java"))); |
123 |
assertEquals("external/build is not sharable", SharabilityQuery.NOT_SHARABLE, sqi.getSharability(file("external/build"))); |
124 |
assertEquals("external/build is not sharable", SharabilityQuery.Sharability.NOT_SHARABLE, sqi.getSharability(file("external/build"))); |
124 |
assertEquals("external/build/classes/org/foo/Foo.class is not sharable", SharabilityQuery.NOT_SHARABLE, sqi.getSharability(file("external/build/classes/org/foo/Foo.class"))); |
125 |
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"))); |
125 |
} |
126 |
} |
126 |
|
127 |
|
127 |
public void testUnknownFiles() throws Exception { |
128 |
public void testUnknownFiles() throws Exception { |
128 |
assertEquals("some other dir is unknown", SharabilityQuery.UNKNOWN, sqi.getSharability(file("something"))); |
129 |
assertEquals("some other dir is unknown", SharabilityQuery.Sharability.UNKNOWN, sqi.getSharability(file("something"))); |
129 |
assertEquals("some other file is unknown", SharabilityQuery.UNKNOWN, sqi.getSharability(file("something/else"))); |
130 |
assertEquals("some other file is unknown", SharabilityQuery.Sharability.UNKNOWN, sqi.getSharability(file("something/else"))); |
130 |
assertEquals("external itself is unknown", SharabilityQuery.UNKNOWN, sqi.getSharability(file("external"))); |
131 |
assertEquals("external itself is unknown", SharabilityQuery.Sharability.UNKNOWN, sqi.getSharability(file("external"))); |
131 |
} |
132 |
} |
132 |
|
133 |
|
133 |
public void testDirNamesEndingInSlash() throws Exception { |
134 |
public void testDirNamesEndingInSlash() throws Exception { |
134 |
assertEquals("project directory is mixed", SharabilityQuery.MIXED, sqi.getSharability(file("projdir/"))); |
135 |
assertEquals("project directory is mixed", SharabilityQuery.Sharability.MIXED, sqi.getSharability(file("projdir/"))); |
135 |
assertEquals("src/ is sharable", SharabilityQuery.SHARABLE, sqi.getSharability(file("projdir/src/"))); |
136 |
assertEquals("src/ is sharable", SharabilityQuery.Sharability.SHARABLE, sqi.getSharability(file("projdir/src/"))); |
136 |
assertEquals("src/org/foo/ is sharable", SharabilityQuery.SHARABLE, sqi.getSharability(file("projdir/src/org/foo/"))); |
137 |
assertEquals("src/org/foo/ is sharable", SharabilityQuery.Sharability.SHARABLE, sqi.getSharability(file("projdir/src/org/foo/"))); |
137 |
assertEquals("nbproject/ is mixed", SharabilityQuery.MIXED, sqi.getSharability(file("projdir/nbproject/"))); |
138 |
assertEquals("nbproject/ is mixed", SharabilityQuery.Sharability.MIXED, sqi.getSharability(file("projdir/nbproject/"))); |
138 |
assertEquals("nbproject/private/ is not sharable", SharabilityQuery.NOT_SHARABLE, sqi.getSharability(file("projdir/nbproject/private/"))); |
139 |
assertEquals("nbproject/private/ is not sharable", SharabilityQuery.Sharability.NOT_SHARABLE, sqi.getSharability(file("projdir/nbproject/private/"))); |
139 |
assertEquals("build/ is not sharable", SharabilityQuery.NOT_SHARABLE, sqi.getSharability(file("projdir/build/"))); |
140 |
assertEquals("build/ is not sharable", SharabilityQuery.Sharability.NOT_SHARABLE, sqi.getSharability(file("projdir/build/"))); |
140 |
assertEquals("dist/ is not sharable", SharabilityQuery.NOT_SHARABLE, sqi.getSharability(file("projdir/dist/"))); |
141 |
assertEquals("dist/ is not sharable", SharabilityQuery.Sharability.NOT_SHARABLE, sqi.getSharability(file("projdir/dist/"))); |
141 |
assertEquals("build/2/ is not sharable", SharabilityQuery.NOT_SHARABLE, sqi.getSharability(file("projdir/build/2/"))); |
142 |
assertEquals("build/2/ is not sharable", SharabilityQuery.Sharability.NOT_SHARABLE, sqi.getSharability(file("projdir/build/2/"))); |
142 |
assertEquals("some other dir is unknown", SharabilityQuery.UNKNOWN, sqi.getSharability(file("something/"))); |
143 |
assertEquals("some other dir is unknown", SharabilityQuery.Sharability.UNKNOWN, sqi.getSharability(file("something/"))); |
143 |
assertEquals("external itself is unknown", SharabilityQuery.UNKNOWN, sqi.getSharability(file("external/"))); |
144 |
assertEquals("external itself is unknown", SharabilityQuery.Sharability.UNKNOWN, sqi.getSharability(file("external/"))); |
144 |
assertEquals("external/src is sharable", SharabilityQuery.SHARABLE, sqi.getSharability(file("external/src/"))); |
145 |
assertEquals("external/src is sharable", SharabilityQuery.Sharability.SHARABLE, sqi.getSharability(file("external/src/"))); |
145 |
assertEquals("external/build is not sharable", SharabilityQuery.NOT_SHARABLE, sqi.getSharability(file("external/build/"))); |
146 |
assertEquals("external/build is not sharable", SharabilityQuery.Sharability.NOT_SHARABLE, sqi.getSharability(file("external/build/"))); |
146 |
} |
147 |
} |
147 |
|
148 |
|
148 |
public void testSubprojectFiles() throws Exception { |
149 |
public void testSubprojectFiles() throws Exception { |
149 |
assertEquals("nbproject/private from a subproject is sharable as far as this impl is concerned", SharabilityQuery.SHARABLE, sqi.getSharability(file("projdir/subproj/nbproject/private"))); |
150 |
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"))); |
150 |
} |
151 |
} |
151 |
|
152 |
|
152 |
// XXX testChangedProperties |
153 |
// XXX testChangedProperties |