Example usage for org.apache.wicket.util.file File write

List of usage examples for org.apache.wicket.util.file File write

Introduction

In this page you can find the example usage for org.apache.wicket.util.file File write.

Prototype

public void write(final String string) throws IOException 

Source Link

Document

Write the given string to this file

Usage

From source file:eu.uqasar.util.io.importer.QModelParserTest.java

License:Apache License

@Test
public void testParseFileQModelEmptyNameXML() {
    logger.info("testParseFileQModelEmptyNameXML start");
    try {//from ww w .  ja va 2s  .  com

        String xmlToImport = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><qModel><name></name><description> Importpre-loaded quality model</description><nodeKey>Importedqm</nodeKey><edition>1.0</edition><companyId>175</companyId></qModel>";
        File fl = new File("xmlToImport.xml");
        fl.createNewFile();
        fl.setWritable(true);
        fl.write(xmlToImport);

        qm = QModelXmlDomParser.parseFile(fl);
        Assert.assertNotNull(qm);
        Assert.assertNotNull(qm.getName());
        Assert.assertTrue(qm.getName().contains("Quality Model Imported"));

        fl.delete();
    } catch (IOException e) {
        e.printStackTrace();
        Assert.assertTrue(false);
    } catch (JAXBException e) {
        e.printStackTrace();
        Assert.assertTrue(false);
    }
}

From source file:eu.uqasar.util.io.importer.QModelParserTest.java

License:Apache License

@Test
public void testParseFileQModelEmptyNameJSON() {
    logger.info("testParseFileQModelEmptyNameJSON start");
    try {/*from w w  w .  j  ava2 s .com*/

        String jsonToImport = "{\"@class\" : \"eu.uqasar.model.qmtree.QModel\",\"companyId\" : 173, \"description\" : \"Quality Model pre-loaded\", \"name\" : \"\", \"nodeKey\" : \"Quality Model A, U-QASAR\"}";

        File fl = new File("xmlToImport.json");
        fl.createNewFile();
        fl.setWritable(true);
        fl.write(jsonToImport);

        qm = QModelJsonParser.parseFile(fl);
        Assert.assertNotNull(qm);
        Assert.assertNotNull(qm.getName());
        Assert.assertTrue(qm.getName().contains("Quality Model Imported"));
        fl.delete();
    } catch (IOException e) {
        e.printStackTrace();
        Assert.assertTrue(false);
    }
}