@TestTargetNew(
      level = TestLevel.COMPLETE,
      notes = "",
      method = "getPackage",
      args = {java.lang.String.class})
  @KnownFailure("PackageClassLoader.getPackage returns null.")
  public void test_getPackageLjava_lang_String() {
    PackageClassLoader pcl = new PackageClassLoader(getClass().getClassLoader());

    String[] packageProperties = {
      "test.package", "title", "1.0", "Vendor", "Title", "1.1", "implementation vendor"
    };

    URL url = null;
    try {
      url = new URL("file:");
    } catch (MalformedURLException e) {
      fail("MalformedURLException was thrown.");
    }
    pcl.definePackage(
        packageProperties[0],
        packageProperties[1],
        packageProperties[2],
        packageProperties[3],
        packageProperties[4],
        packageProperties[5],
        packageProperties[6],
        url);

    assertNotNull(pcl.getPackage(packageProperties[0]));

    assertEquals(
        "should define current package",
        getClass().getPackage(),
        pcl.getPackage(getClass().getPackage().getName()));

    assertNull(pcl.getPackage("not.found.package"));
  }
  @TestTargetNew(
      level = TestLevel.COMPLETE,
      notes = "",
      method = "definePackage",
      args = {
        java.lang.String.class, java.lang.String.class,
        java.lang.String.class, java.lang.String.class,
        java.lang.String.class, java.lang.String.class,
        java.lang.String.class, java.net.URL.class
      })
  public void test_definePackage() {

    PackageClassLoader pcl = new PackageClassLoader(getClass().getClassLoader());

    String[] packageProperties = {
      "test.package", "title", "1.0", "Vendor", "Title", "1.1", "implementation vendor"
    };

    URL url = null;
    try {
      url = new URL("file:");
    } catch (MalformedURLException e) {
      fail("MalformedURLException was thrown.");
    }
    pcl.definePackage(
        packageProperties[0],
        packageProperties[1],
        packageProperties[2],
        packageProperties[3],
        packageProperties[4],
        packageProperties[5],
        packageProperties[6],
        url);

    Package pack = pcl.getPackage(packageProperties[0]);
    assertEquals(packageProperties[1], pack.getSpecificationTitle());
    assertEquals(packageProperties[2], pack.getSpecificationVersion());
    assertEquals(packageProperties[3], pack.getSpecificationVendor());
    assertEquals(packageProperties[4], pack.getImplementationTitle());
    assertEquals(packageProperties[5], pack.getImplementationVersion());
    assertEquals(packageProperties[6], pack.getImplementationVendor());
    assertTrue(pack.isSealed(url));
    assertTrue(pack.isSealed());

    try {
      pcl.definePackage(
          packageProperties[0],
          packageProperties[1],
          packageProperties[2],
          packageProperties[3],
          packageProperties[4],
          packageProperties[5],
          packageProperties[6],
          null);
      fail("IllegalArgumentException was not thrown.");
    } catch (IllegalArgumentException iae) {
      // expected
    }

    pcl.definePackage("test.package.test", null, null, null, null, null, null, null);
    pack = pcl.getPackage("test.package.test");
    assertNull(pack.getSpecificationTitle());
    assertNull(pack.getSpecificationVersion());
    assertNull(pack.getSpecificationVendor());
    assertNull(pack.getImplementationTitle());
    assertNull(pack.getImplementationVersion());
    assertNull(pack.getImplementationVendor());
    assertFalse(pack.isSealed());
  }