Lines 313-319
Link Here
|
313 |
FileObject fo = xfs.findResource ("TestModule/sample.txt"); |
313 |
FileObject fo = xfs.findResource ("TestModule/sample.txt"); |
314 |
assertNotNull(fo); |
314 |
assertNotNull(fo); |
315 |
|
315 |
|
316 |
Object clazz = fo.getAttribute("instanceClass"); |
316 |
Object clazz = fo.getAttribute("class:instanceCreate"); |
317 |
assertEquals("No instance of Count created", 0, Count.cnt); |
317 |
assertEquals("No instance of Count created", 0, Count.cnt); |
318 |
assertEquals("Yet right class guessed", Count.class, clazz); |
318 |
assertEquals("Yet right class guessed", Count.class, clazz); |
319 |
Object instance = fo.getAttribute("instanceCreate"); |
319 |
Object instance = fo.getAttribute("instanceCreate"); |
Lines 338-344
Link Here
|
338 |
FileObject fo = xfs.findResource ("TestModule/sample.txt"); |
338 |
FileObject fo = xfs.findResource ("TestModule/sample.txt"); |
339 |
assertNotNull(fo); |
339 |
assertNotNull(fo); |
340 |
|
340 |
|
341 |
Object clazz = fo.getAttribute("instanceClass"); |
341 |
Object clazz = fo.getAttribute("class:instanceCreate"); |
342 |
assertEquals("No instance of Count created", 0, Count.cnt); |
342 |
assertEquals("No instance of Count created", 0, Count.cnt); |
343 |
assertEquals("Yet right class guessed", Count.class, clazz); |
343 |
assertEquals("Yet right class guessed", Count.class, clazz); |
344 |
Object instance = fo.getAttribute("instanceCreate"); |
344 |
Object instance = fo.getAttribute("instanceCreate"); |
Lines 363-369
Link Here
|
363 |
FileObject fo = xfs.findResource ("TestModule/sample.txt"); |
363 |
FileObject fo = xfs.findResource ("TestModule/sample.txt"); |
364 |
assertNotNull(fo); |
364 |
assertNotNull(fo); |
365 |
|
365 |
|
366 |
Object clazz = fo.getAttribute("instanceClass"); |
366 |
Object clazz = fo.getAttribute("class:instanceCreate"); |
367 |
assertEquals("No instance of Count created", 0, Count.cnt); |
367 |
assertEquals("No instance of Count created", 0, Count.cnt); |
368 |
assertEquals("Only Runnable guessed as that is the return type of the method", Runnable.class, clazz); |
368 |
assertEquals("Only Runnable guessed as that is the return type of the method", Runnable.class, clazz); |
369 |
Object instance = fo.getAttribute("instanceCreate"); |
369 |
Object instance = fo.getAttribute("instanceCreate"); |
Lines 372-377
Link Here
|
372 |
assertEquals("Right class", Count.class, instance.getClass()); |
372 |
assertEquals("Right class", Count.class, instance.getClass()); |
373 |
} |
373 |
} |
374 |
|
374 |
|
|
|
375 |
public void testClassBoolean() throws Exception { |
376 |
doPrimitiveTypeTest("boolvalue='true'", Boolean.class); |
377 |
} |
378 |
|
379 |
public void testClassByte() throws Exception { |
380 |
doPrimitiveTypeTest("bytevalue='1'", Byte.class); |
381 |
} |
382 |
|
383 |
public void testClassInt() throws Exception { |
384 |
doPrimitiveTypeTest("intvalue='1'", Integer.class); |
385 |
} |
386 |
|
387 |
public void testClassShort() throws Exception { |
388 |
doPrimitiveTypeTest("shortvalue='1'", Short.class); |
389 |
} |
390 |
|
391 |
public void testClassLong() throws Exception { |
392 |
doPrimitiveTypeTest("longvalue='1'", Long.class); |
393 |
} |
394 |
public void testClassDouble() throws Exception { |
395 |
doPrimitiveTypeTest("doublevalue='1.0'", Double.class); |
396 |
} |
397 |
public void testClassFloat() throws Exception { |
398 |
doPrimitiveTypeTest("floatvalue='1.0'", Float.class); |
399 |
} |
400 |
public void testClassString() throws Exception { |
401 |
doPrimitiveTypeTest("stringvalue='1'", String.class); |
402 |
} |
403 |
public void testClassURL() throws Exception { |
404 |
doPrimitiveTypeTest("urlvalue='http://www.netbeans.org'", URL.class); |
405 |
} |
406 |
|
407 |
private void doPrimitiveTypeTest(String value, Class<?> expClass) throws Exception { |
408 |
File f = writeFile("layer.xml", |
409 |
"<filesystem>\n" + |
410 |
"<folder name='TestModule'>\n" + |
411 |
"<file name='sample.txt' >" + |
412 |
" <attr name='instanceCreate' " + value + "/>" + |
413 |
"</file>\n" + |
414 |
"</folder>\n" + |
415 |
"</filesystem>\n" |
416 |
); |
417 |
|
418 |
xfs = FileSystemFactoryHid.createXMLSystem(getName(), this, f.toURL()); |
419 |
FileObject fo = xfs.findResource ("TestModule/sample.txt"); |
420 |
assertNotNull(fo); |
421 |
|
422 |
Object clazz = fo.getAttribute("class:instanceCreate"); |
423 |
assertEquals("Only Runnable guessed as that is the return type of the method", expClass, clazz); |
424 |
Object instance = fo.getAttribute("instanceCreate"); |
425 |
assertNotNull("Returned", instance); |
426 |
assertEquals("Right class", expClass, instance.getClass()); |
427 |
} |
375 |
|
428 |
|
376 |
|
429 |
|
377 |
private File writeFile(String name, String content) throws IOException { |
430 |
private File writeFile(String name, String content) throws IOException { |