Lines 91-98
Link Here
|
91 |
|
91 |
|
92 |
// test reading |
92 |
// test reading |
93 |
FileObject fo = dobj.getPrimaryFile().copy(fs.getRoot(), dobj.getPrimaryFile().getName() + "_copy", "settings"); |
93 |
FileObject fo = dobj.getPrimaryFile().copy(fs.getRoot(), dobj.getPrimaryFile().getName() + "_copy", "settings"); |
94 |
org.openide.cookies.InstanceCookie ic = (org.openide.cookies.InstanceCookie) |
94 |
org.openide.cookies.InstanceCookie ic = DataObject.find(fo).getCookie(org.openide.cookies.InstanceCookie.class); |
95 |
DataObject.find(fo).getCookie(org.openide.cookies.InstanceCookie.class); |
|
|
96 |
assertNotNull("missing InstanceCookie", ic); |
95 |
assertNotNull("missing InstanceCookie", ic); |
97 |
assertEquals(cs.getClass(), ic.instanceClass()); |
96 |
assertEquals(cs.getClass(), ic.instanceClass()); |
98 |
|
97 |
|
Lines 110-115
Link Here
|
110 |
} |
109 |
} |
111 |
} |
110 |
} |
112 |
|
111 |
|
|
|
112 |
public void testCreateSetting_XML() throws Exception { |
113 |
try { |
114 |
org.openide.filesystems.FileUtil.createFolder(fs.getRoot(), "testCreateSetting"); |
115 |
DataFolder folder = DataFolder.findFolder(fs.findResource("testCreateSetting")); |
116 |
|
117 |
ComposedSetting cs = new ComposedSetting(); |
118 |
cs.b1 = new java.awt.Button(); |
119 |
cs.b2 = cs.b1; |
120 |
cs.cs = new ComposedSetting(); |
121 |
cs.cs.b1 = new java.awt.Button(); |
122 |
DataObject dobj = InstanceDataObject.create(folder, "testCreateSetting", cs, null); |
123 |
|
124 |
// test reading |
125 |
FileObject fo = dobj.getPrimaryFile().copy(fs.getRoot(), dobj.getPrimaryFile().getName() + "_copy", "xml"); |
126 |
fo.getParent().setAttribute("recognizeXML", Boolean.TRUE); |
127 |
org.openide.cookies.InstanceCookie ic = DataObject.find(fo).getCookie(org.openide.cookies.InstanceCookie.class); |
128 |
assertNotNull("missing InstanceCookie", ic); |
129 |
assertEquals(cs.getClass(), ic.instanceClass()); |
130 |
|
131 |
try { |
132 |
ComposedSetting cs2 = (ComposedSetting) ic.instanceCreate(); |
133 |
assertEquals(cs2.b1, cs2.b2); |
134 |
} catch (IOException e) { |
135 |
System.err.println("File contents:\n"); |
136 |
FileUtil.copy(fo.getInputStream(), System.err); |
137 |
throw e; |
138 |
} |
139 |
} catch (Exception ex) { |
140 |
Logger.global.log(Level.WARNING, null, ex); |
141 |
throw ex; |
142 |
} |
143 |
} |
144 |
|
113 |
public static class ComposedSetting { |
145 |
public static class ComposedSetting { |
114 |
java.awt.Button b1; |
146 |
java.awt.Button b1; |
115 |
java.awt.Button b2; |
147 |
java.awt.Button b2; |