Lines 268-298
Link Here
|
268 |
FileObject d = FileUtil.toFileObject(getWorkDir()); |
268 |
FileObject d = FileUtil.toFileObject(getWorkDir()); |
269 |
FileObject p1 = d.getFileObject("project1"); |
269 |
FileObject p1 = d.getFileObject("project1"); |
270 |
assertNotNull(p1); |
270 |
assertNotNull(p1); |
271 |
assertNull("normal file addition", ProjectUtilities.canUseFileName(p1, null, "foo", "java", false)); |
271 |
assertNull("normal file addition", ProjectUtilities.canUseFileName(p1, null, "foo", "java", false, false)); |
272 |
assertNull("normal file addition with no extension is OK", ProjectUtilities.canUseFileName(p1, null, "foo", null, false)); |
272 |
assertNull("normal file addition with no extension is OK", ProjectUtilities.canUseFileName(p1, null, "foo", null, false, false)); |
273 |
assertNull("normal file addition in an existing subdir", ProjectUtilities.canUseFileName(d, "project1", "foo", "java", false)); |
273 |
assertNull("normal file addition in an existing subdir", ProjectUtilities.canUseFileName(d, "project1", "foo", "java", false, false)); |
274 |
assertNull("normal file addition in a new subdir", ProjectUtilities.canUseFileName(d, "dir", "foo", "java", false)); |
274 |
assertNull("normal file addition in a new subdir", ProjectUtilities.canUseFileName(d, "dir", "foo", "java", false, false)); |
275 |
//assertNotNull("no target name", ProjectUtilities.canUseFileName(d, "dir", null, "java")); |
275 |
//assertNotNull("no target name", ProjectUtilities.canUseFileName(d, "dir", null, "java")); |
276 |
assertNotNull("no target folder", ProjectUtilities.canUseFileName(null, "dir", "foo", "java", false)); |
276 |
assertNotNull("no target folder", ProjectUtilities.canUseFileName(null, "dir", "foo", "java", false, false)); |
277 |
assertNotNull("file already exists", ProjectUtilities.canUseFileName(p1, null, "f1_1", "java", false)); |
277 |
assertNotNull("file already exists", ProjectUtilities.canUseFileName(p1, null, "f1_1", "java", false, false)); |
278 |
assertNotNull("file already exists in subdir", ProjectUtilities.canUseFileName(d, "project1", "f1_1", "java", false)); |
278 |
assertNotNull("file already exists in subdir", ProjectUtilities.canUseFileName(d, "project1", "f1_1", "java", false, false)); |
279 |
assertNull("similar file already exists in subdir", ProjectUtilities.canUseFileName(d, "project1", "f1_1", "properties", false)); |
279 |
assertNull("similar file already exists in subdir", ProjectUtilities.canUseFileName(d, "project1", "f1_1", "properties", false, false)); |
280 |
assertNull("similar file already exists in subdir", ProjectUtilities.canUseFileName(d, "project1", "f1_1", null, false)); |
280 |
assertNull("similar file already exists in subdir", ProjectUtilities.canUseFileName(d, "project1", "f1_1", null, false, false)); |
281 |
d = new XMLFileSystem().getRoot(); |
281 |
d = new XMLFileSystem().getRoot(); |
282 |
assertNotNull("FS is r/o", ProjectUtilities.canUseFileName(d, null, "foo", "java", false)); |
282 |
assertNotNull("FS is r/o", ProjectUtilities.canUseFileName(d, null, "foo", "java", false, false)); |
283 |
// #59876: deal with non-disk-based filesystems sensibly |
283 |
// #59876: deal with non-disk-based filesystems sensibly |
284 |
d = FileUtil.createMemoryFileSystem().getRoot(); |
284 |
d = FileUtil.createMemoryFileSystem().getRoot(); |
285 |
d.createData("bar.java"); |
285 |
d.createData("bar.java"); |
286 |
FileUtil.createData(d, "sub/dir/foo.java"); |
286 |
FileUtil.createData(d, "sub/dir/foo.java"); |
287 |
assertNull("can create file in non-disk FS", ProjectUtilities.canUseFileName(d, null, "foo", "java", false)); |
287 |
assertNull("can create file in non-disk FS", ProjectUtilities.canUseFileName(d, null, "foo", "java", false, false)); |
288 |
assertNotNull("file already exists", ProjectUtilities.canUseFileName(d, null, "bar", "java", false)); |
288 |
assertNotNull("file already exists", ProjectUtilities.canUseFileName(d, null, "bar", "java", false, false)); |
289 |
assertNotNull("file already exists in subsubdir", ProjectUtilities.canUseFileName(d, "sub/dir", "foo", "java", false)); |
289 |
assertNotNull("file already exists in subsubdir", ProjectUtilities.canUseFileName(d, "sub/dir", "foo", "java", false, false)); |
290 |
assertNull("can otherwise create file in subsubdir", ProjectUtilities.canUseFileName(d, "sub/dir", "bar", "java", false)); |
290 |
assertNull("can otherwise create file in subsubdir", ProjectUtilities.canUseFileName(d, "sub/dir", "bar", "java", false, false)); |
291 |
//#66792: allow to create whole directory tree at once using Folder Template: |
291 |
//#66792: allow to create whole directory tree at once using Folder Template: |
292 |
assertNull("can create directory subtree", ProjectUtilities.canUseFileName(d, null, "a/b/c", null, true)); |
292 |
assertNull("can create directory subtree", ProjectUtilities.canUseFileName(d, null, "a/b/c", null, true, false)); |
293 |
//#59654: do not allow slash and backslash for common templates: |
293 |
//#59654: do not allow slash and backslash for common templates: |
294 |
assertNotNull("cannot create file with slashes", ProjectUtilities.canUseFileName(d, null, "a/b/c", "txt", false)); |
294 |
assertNotNull("cannot create file with slashes", ProjectUtilities.canUseFileName(d, null, "a/b/c", "txt", false, false)); |
295 |
assertNotNull("cannot create file with backslashes", ProjectUtilities.canUseFileName(d, null, "a\\b\\c", "txt", false)); |
295 |
assertNotNull("cannot create file with backslashes", ProjectUtilities.canUseFileName(d, null, "a\\b\\c", "txt", false, false)); |
|
|
296 |
// Check freeFileExtension mode: |
297 |
assertNull(ProjectUtilities.canUseFileName(d, null, "foo", "java", false, true)); |
298 |
assertNotNull(ProjectUtilities.canUseFileName(d, null, "bar", "java", false, true)); |
299 |
assertNotNull(ProjectUtilities.canUseFileName(d, null, "bar.java", "java", false, true)); |
300 |
assertNull(ProjectUtilities.canUseFileName(d, null, "bar.java", "java", false, false)); |
301 |
|
296 |
} |
302 |
} |
297 |
|
303 |
|
298 |
public void testNavigatorIsNotClosed() throws Exception { |
304 |
public void testNavigatorIsNotClosed() throws Exception { |