1.1 --- a/masterfs/src/org/netbeans/modules/masterfs/filebasedfs/naming/FileName.java Tue Jun 15 15:35:23 2010 +0200
1.2 +++ b/masterfs/src/org/netbeans/modules/masterfs/filebasedfs/naming/FileName.java Mon Jun 21 20:56:25 2010 +0200
1.3 @@ -58,11 +58,13 @@
1.4 private final CharSequence name;
1.5 private final FileNaming parent;
1.6 private final Integer id;
1.7 + private CharSequence currentName;
1.8
1.9 protected FileName(final FileNaming parent, final File file) {
1.10 this.parent = parent;
1.11 this.name = CharSequences.create(parseName(parent, file));
1.12 id = NamingFactory.createID(file);
1.13 + this.currentName = name;
1.14 }
1.15
1.16 private static String parseName(final FileNaming parent, final File file) {
1.17 @@ -102,7 +104,7 @@
1.18
1.19
1.20 public final String getName() {
1.21 - return name.toString();
1.22 + return currentName.toString();
1.23 }
1.24
1.25 public FileNaming getParent() {
1.26 @@ -146,4 +148,9 @@
1.27 public boolean isDirectory() {
1.28 return !isFile();
1.29 }
1.30 +
1.31 + void updateCase(String name) {
1.32 + assert String.CASE_INSENSITIVE_ORDER.compare(name, this.name.toString()) == 0: "Only case can be changed. Was: " + this.name + " name: " + name;
1.33 + this.currentName = CharSequences.create(name);
1.34 + }
1.35 }
2.1 --- a/masterfs/src/org/netbeans/modules/masterfs/filebasedfs/naming/NamingFactory.java Tue Jun 15 15:35:23 2010 +0200
2.2 +++ b/masterfs/src/org/netbeans/modules/masterfs/filebasedfs/naming/NamingFactory.java Mon Jun 21 20:56:25 2010 +0200
2.3 @@ -93,10 +93,8 @@
2.4 if (!childName.getFile().getName().equals(f.getName())) {
2.5 boolean isCaseSensitive = !new File(f,"a").equals(new File(f,"A"));//NOI18N
2.6 if (!isCaseSensitive) {
2.7 - FileNaming[] ret = NamingFactory.rename(childName,f.getName(), null);
2.8 - if (ret != null) {
2.9 - return ret[0];
2.10 - }
2.11 + FileName fn = (FileName)childName;
2.12 + fn.updateCase(f.getName());
2.13 }
2.14 }
2.15 return childName;
3.1 --- a/masterfs/test/unit/src/org/netbeans/modules/masterfs/filebasedfs/fileobjects/FileObjTest.java Tue Jun 15 15:35:23 2010 +0200
3.2 +++ b/masterfs/test/unit/src/org/netbeans/modules/masterfs/filebasedfs/fileobjects/FileObjTest.java Mon Jun 21 20:56:25 2010 +0200
3.3 @@ -67,6 +67,11 @@
3.4 super(testName);
3.5 }
3.6
3.7 + @Override
3.8 + protected int timeOut() {
3.9 + return 60000;
3.10 + }
3.11 +
3.12 /** Tests it is not possible to create duplicate FileObject for the same path.
3.13 * - create FO1
3.14 * - create FO2
4.1 --- a/masterfs/test/unit/src/org/netbeans/modules/masterfs/filebasedfs/naming/FileNameTest.java Tue Jun 15 15:35:23 2010 +0200
4.2 +++ b/masterfs/test/unit/src/org/netbeans/modules/masterfs/filebasedfs/naming/FileNameTest.java Mon Jun 21 20:56:25 2010 +0200
4.3 @@ -197,6 +197,34 @@
4.4 }
4.5 }
4.6
4.7 + public void testNamingIsCaseInsensitive() throws Exception {
4.8 + File f1 = new File(getWorkDir(), "Ahoj");
4.9 + File f2 = new File(getWorkDir(), "ahoJ");
4.10 +
4.11 + FileNaming root = NamingFactory.fromFile(getWorkDir());
4.12 + FileNaming fn1 = NamingFactory.fromFile(root, f1, false);
4.13 + FileNaming fn2 = NamingFactory.fromFile(root, f2, false);
4.14 +
4.15 + boolean equalF = f1.equals(f2);
4.16 +
4.17 + f2.createNewFile();
4.18 + NamingFactory.checkCaseSensitivity(fn2, f2);
4.19 + assertEquals("Name equals file name f2", f2.getName(), fn2.getName());
4.20 +
4.21 + if (equalF) {
4.22 + assertEquals("File has code", f1.hashCode(), f2.hashCode());
4.23 + assertEquals("FileNaming hash code", fn1.hashCode(), fn2.hashCode());
4.24 + assertSame("namings are equal", fn1, fn2);
4.25 + } else {
4.26 + assertFalse("FileNaming shall be different", fn1.equals(fn2));
4.27 + }
4.28 +
4.29 + f2.delete();
4.30 + f1.createNewFile();
4.31 + NamingFactory.checkCaseSensitivity(fn1, f1);
4.32 + assertEquals("Name equals file name f1", f1.getName(), fn1.getName());
4.33 + }
4.34 +
4.35
4.36 /**
4.37 * Test of rename method, of class org.netbeans.modules.masterfs.naming.PathItem.