/* * Test method for 'ca.sqlpower.architect.PlDotIni.write(OutputStream)' */ public void testWriteOutputStream() throws IOException { String orig = makePlIniString(); InputStream in = makeInputStream(orig); target.read(in); ByteArrayOutputStream out = new ByteArrayOutputStream(); target.write(out); assertEquals(orig, out.toString()); }
/** * Tests that any items coming before the first section get written out when we re-save the file. */ public void testNotLoseItemsWithoutSection() throws Exception { testRead(); File tmp2 = File.createTempFile("pl.out", null); target.write(tmp2); PlDotIni reread = new PlDotIni(); reread.read(tmp2); Object sect = reread.getSection(0); assertEquals(PlDotIni.Section.class, sect.getClass()); assertNull(((PlDotIni.Section) sect).getName()); }
public void testDatabaseTypeParentDoesntExist() throws Exception { testRead(); JDBCDataSourceType dbType = target.getDataSourceType("my other db type"); dbType.putProperty(JDBCDataSourceType.PARENT_TYPE_NAME, "non existant parent"); ByteArrayOutputStream out = new ByteArrayOutputStream(); target.write(out); ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); try { target.read(in); fail("Parent type didn't exist but no exception was thrown."); } catch (IllegalStateException ex) { // test passed } }