new File("bin/test-tmp").mkdirs();
}
public void testLoadSaveFromDisk() throws Exception
{
final ResourceKey key = createImageKey();
final Element element = new Element();
element.setElementType(new ContentType());
element.setAttribute(AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, key);
// .. save it.
final MasterReport report = new MasterReport();
report.getReportHeader().addElement(element);
saveReport(report, new File("bin/test-tmp/prd-3319-load-save-disk-1.prpt"));
// load it to establish the context in all resource-keys ..
final ResourceManager mgr = new ResourceManager();
mgr.registerDefaults();
final Resource resource = mgr.createDirectly(new File("bin/test-tmp/prd-3319-load-save-disk-1.prpt"), MasterReport.class);
// save it once, that changes the bundle ...
final MasterReport report2 = (MasterReport) resource.getResource();
saveReport(report2, new File("bin/test-tmp/prd-3319-load-save-disk-2.prpt"));
// save it twice, that triggers the crash...
saveReport(report2, new File("bin/test-tmp/prd-3319-load-save-disk-2.prpt"));
final ProcessingContext processingContext = new DefaultProcessingContext();
final DebugExpressionRuntime runtime = new DebugExpressionRuntime(new DefaultTableModel(), 0, processingContext);
final Element reportElement = report2.getReportHeader().getElement(0);
Object attribute = reportElement.getAttribute(AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE);
assertTrue(attribute instanceof ResourceKey);
ResourceKey atKey = (ResourceKey) attribute;
assertEquals("http://127.0.0.1:65535/image.jpg", atKey.getIdentifierAsString());
}