/* Ensures that the read() method parses data source types properly,
   * assuming getDataSourceType() works.
   */
  public void testReadDataSourceType() throws IOException {
    testRead();

    JDBCDataSourceType dst = target.getDataSourceType("my db type");
    assertNotNull(dst);
    assertEquals(dst.getProperty("silly property"), "diddle");

    JDBCDataSourceType dst2 = target.getDataSourceType("my other db type");
    assertNotNull(dst2);
    assertEquals(dst2.getProperty("silly property"), "fiddle");
    assertSame(dst, dst2.getParentType());
  }
  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
    }
  }