Lines 564-569
Link Here
|
564 |
assertNotNull ("Has cookie", ic); |
564 |
assertNotNull ("Has cookie", ic); |
565 |
assertEquals ("And its value is x", x, ic.instanceCreate ()); |
565 |
assertEquals ("And its value is x", x, ic.instanceCreate ()); |
566 |
} |
566 |
} |
|
|
567 |
|
568 |
|
569 |
public void testWeAreAbleToResetSharedClassObjectByCallingResetOnItIssue20962 () throws Exception { |
570 |
FileObject lookupFO; |
571 |
{ |
572 |
Object x = Setting.findObject (Setting.class, true); |
573 |
lookupFO = lfs.findResource("/system/Services/lookupTest"); |
574 |
DataFolder folderTest = DataFolder.findFolder(lookupFO); |
575 |
InstanceDataObject ido = InstanceDataObject.create (folderTest, "testLookupRefresh", x, null); |
576 |
lookupFO = ido.getPrimaryFile (); |
577 |
WeakReference ref = new WeakReference (ido); |
578 |
Setting.resetCalled = 0; |
579 |
} |
580 |
|
581 |
InstanceDataObject ido = (InstanceDataObject)DataObject.find (lookupFO); |
582 |
InstanceCookie ic = (InstanceCookie)ido.getCookie (InstanceCookie.class); |
583 |
assertNotNull ("Has cookie", ic); |
584 |
Object obj = ic.instanceCreate (); |
585 |
assertNotNull ("Not null", obj); |
586 |
assertEquals ("It is settings", Setting.class, obj.getClass ()); |
587 |
|
588 |
|
589 |
FileLock lock = lookupFO.lock (); |
590 |
OutputStream os = lookupFO.getOutputStream (lock); |
591 |
|
592 |
PrintWriter pw = new PrintWriter (os); |
593 |
pw.println ("<?xml version=\"1.0\"?>"); |
594 |
pw.println ("<!DOCTYPE settings PUBLIC \"-//NetBeans//DTD Session settings 1.0//EN\" \"http://www.netbeans.org/dtds/sessionsettings-1_0.dtd\">"); |
595 |
pw.println ("<settings version=\"1.0\">"); |
596 |
pw.println (" <module name=\"org.openide/1\" spec=\"1.13\"/>"); |
597 |
pw.println (" <instanceof class=\"org.openide.options.SystemOption\"/>"); |
598 |
pw.println (" <instance class=\"" + Setting.class.getName () + "\"/>"); |
599 |
pw.println ("</settings>"); |
600 |
pw.close (); |
601 |
lock.releaseLock (); |
602 |
|
603 |
ic = (InstanceCookie)ido.getCookie (InstanceCookie.class); |
604 |
assertNotNull ("Has cookie", ic); |
605 |
assertNotNull ("Not null", obj); |
606 |
assertEquals ("It is settings", Setting.class, obj.getClass ()); |
607 |
Setting s = (Setting)Setting.findObject (Setting.class, true); |
608 |
assertEquals ("Refresh has been called", 1, s.resetCalled); |
609 |
} |
567 |
|
610 |
|
568 |
/** Checks whether the instance is not saved multiple times. |
611 |
/** Checks whether the instance is not saved multiple times. |
569 |
* |
612 |
* |
Lines 920-923
Link Here
|
920 |
} |
963 |
} |
921 |
} |
964 |
} |
922 |
|
965 |
|
|
|
966 |
public static final class Setting extends org.openide.options.SystemOption { |
967 |
private static int resetCalled; |
968 |
|
969 |
protected void reset () { |
970 |
resetCalled++; |
971 |
} |
972 |
|
973 |
public String displayName () { |
974 |
return "My Setting"; |
975 |
} |
976 |
} |
923 |
} |
977 |
} |