private static String plIniToString(PlDotIni plini) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < plini.getSectionCount(); i++) { Object o = plini.getSection(i); if (o instanceof PlDotIni.Section) { sb.append(((PlDotIni.Section) o).getPropertiesMap().toString()); } else if (o instanceof SPDataSource) { sb.append(((SPDataSource) o).getPropertiesMap().toString()); } else if (o instanceof JDBCDataSourceType) { sb.append(((JDBCDataSourceType) o).getProperties().toString()); } else if (o instanceof UserDefinedSQLType) { sb.append(plini.createSQLTypePropertiesMap(((UserDefinedSQLType) o)).toString()); } else { throw new IllegalArgumentException("Unknown pl.ini section type: " + o); } sb.append("\n"); } return sb.toString(); }
/* ensures we read all sections in the correct order */ public void testReadSections() throws Exception { testRead(); assertEquals(6, target.getSectionCount()); // the nameless first section Object s = target.getSection(0); assertEquals(PlDotIni.Section.class, s.getClass()); assertEquals(null, ((PlDotIni.Section) s).getName()); s = target.getSection(1); assertEquals(JDBCDataSourceType.class, s.getClass()); s = target.getSection(2); assertEquals(JDBCDataSourceType.class, s.getClass()); s = target.getSection(3); assertEquals(PlDotIni.Section.class, s.getClass()); s = target.getSection(4); assertEquals(JDBCDataSource.class, s.getClass()); s = target.getSection(5); assertEquals(UserDefinedSQLType.class, s.getClass()); }