This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 86423 - Cannot correctly rename a test
Summary: Cannot correctly rename a test
Status: VERIFIED FIXED
Alias: None
Product: soa
Classification: Unclassified
Component: JBI Test Driver (show other bugs)
Version: 5.x
Hardware: PC Windows XP
: P1 blocker (vote)
Assignee: Jun Qian
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-10-04 02:16 UTC by pchen
Modified: 2006-10-11 21:48 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
video showcasing the bug (586.00 KB, video/avi)
2006-10-04 02:17 UTC, pchen
Details

Note You need to log in before you can comment on or make changes to this bug.
Description pchen 2006-10-04 02:16:56 UTC
Steps to reproduce:

Set up: installed build 061002_2 on WindowXP having JDK 1.5.0_09

1. create and run a test which will give you a result.
2. rename the test to something else
3. the results will magically disappear
4. rename the test back to its original name
5. the results will magically reappear
Comment 1 pchen 2006-10-04 02:17:47 UTC
Created attachment 34846 [details]
video showcasing the bug
Comment 2 Jun Qian 2006-10-05 09:29:19 UTC
Fixed in release55_dev. Please let me know if this is a must-fix for release55.
Comment 3 _ rkubacki 2006-10-05 23:27:21 UTC
Patch attached to a mail sent to reviewers@netbeans.org is bad. FileLock needs
to be released in finally block. Especially if it seems to be likely that there
can be problem with performing I/O.

BTW: read http://www.netbeans.org/community/releases/55/high-resistance.html to
find that you should attach patch here.

Why are you asking for review if you are not sure if you want to commit your change.
Comment 4 Jun Qian 2006-10-06 06:50:19 UTC
Thanks a lot for the review. The problem has been corrected.

I think I missed the status whiteboard keyword when I checked the original fix
into release55_dev.

The following is the final cvs diff:

C:\nb_all\enterprise\compapp\projects\jbi\src\org\netbeans\modules\compapp\test\ui>cvs
diff -c -u -r 1.1.2.26 -r 1.1.2.26.2.2 TestcaseNode.java
Index: TestcaseNode.java
===================================================================
RCS file:
/cvs/enterprise/compapp/projects/jbi/src/org/netbeans/modules/compapp/test/ui/Attic/TestcaseNode.java,v
retrieving revision 1.1.2.26
retrieving revision 1.1.2.26.2.2
diff -c -u -r1.1.2.26 -r1.1.2.26.2.2
cvs server: conflicting specifications of output style
--- TestcaseNode.java   22 Sep 2006 04:48:19 -0000      1.1.2.26
+++ TestcaseNode.java   6 Oct 2006 01:49:31 -0000       1.1.2.26.2.2
@@ -45,6 +45,7 @@
 import org.openide.filesystems.FileChangeAdapter;
 import org.openide.filesystems.FileChangeListener;
 import org.openide.filesystems.FileEvent;
+import org.openide.filesystems.FileLock;
 import org.openide.filesystems.FileObject;
 import org.openide.filesystems.FileRenameEvent;
 import org.openide.filesystems.FileUtil;
@@ -244,6 +245,33 @@
         mChildren = (TestcaseChildren) getChildren();
     }

+    public void setName(String name) {
+        String oldName = getName();
+
+        super.setName(name);
+
+        if (getName().equals(name)) {
+            // if successful, we also need to update test case results
+            // directory name
+            FileLock fileLock = null;
+            try {
+                fileLock = mTestCaseResultsDir.lock();
+                mTestCaseResultsDir.rename(fileLock, name, null);
+            } catch (IOException ex) {
+                // revert back
+                super.setName(oldName);
+
+                NotifyDescriptor d1 = new NotifyDescriptor.Message(ex.getMessage(),
+                        NotifyDescriptor.WARNING_MESSAGE);
+                DialogDisplayer.getDefault().notify(d1);
+            } finally {
+                if (fileLock != null) {
+                    fileLock.releaseLock();
+                }
+            }
+        }
+    }
+
     private void registerPropertyFileChangeListener(final FileObject testcaseDir) {

         List specList = new ArrayList();
Comment 5 Jun Qian 2006-10-06 22:23:56 UTC
Fixed in release55_dev.
Comment 6 Jun Qian 2006-10-09 21:36:53 UTC
> I have updated http://www.netbeans.org/issues/show_bug.cgi?id=86423 
> with the new fix. Please let me know if you will be reviewing it again 
> or should I resent it the reviewer mailing list.
> 
I'd say it is not needed to resend it. Personally I do not have more 
comments.
-Radim
Comment 7 Jun Qian 2006-10-10 01:08:33 UTC
Fix checked into release55.
Comment 8 lchang 2006-10-11 19:04:14 UTC
This fix is not in milestone22, will wait for the next build.
Comment 9 lchang 2006-10-11 21:48:58 UTC
Verified that after I rename a testcase, the results still remain under the 
folder.

milestone22