public void testType() throws Exception {
    ICompilationUnit cu = createPackageInfoWithSchemaTypeAndType();
    JavaResourcePackage resourcePackage = buildJavaResourcePackage(cu);

    XmlSchemaTypeAnnotation annotation =
        (XmlSchemaTypeAnnotation) resourcePackage.getAnnotation(0, JAXB.XML_SCHEMA_TYPE);
    assertTrue(annotation != null);
    assertEquals(TEST_CLASS, annotation.getType());
    assertEquals(FQ_TEST_CLASS, annotation.getFullyQualifiedType());
    assertSourceContains("@XmlSchemaType(type = " + TEST_CLASS + ".class)", cu);

    annotation.setType(TEST_CLASS_2);
    assertEquals(TEST_CLASS_2, annotation.getType());
    assertEquals(FQ_TEST_CLASS_2, annotation.getFullyQualifiedType());
    assertSourceContains("@XmlSchemaType(type = " + TEST_CLASS_2 + ".class)", cu);

    annotation.setType(null);
    assertEquals(null, annotation.getType());
    assertEquals(null, annotation.getFullyQualifiedType());
    assertSourceContains("@XmlSchemaType", cu);

    annotation.setType(TEST_CLASS);
    assertEquals(TEST_CLASS, annotation.getType());
    assertEquals(FQ_TEST_CLASS, annotation.getFullyQualifiedType());
    assertSourceContains("@XmlSchemaType(type = " + TEST_CLASS + ".class)", cu);
  }
  public void testContainedWithType() throws Exception {
    // test contained annotation type setting/updating

    ICompilationUnit cu = createPackageInfoWithSchemaTypes();
    JavaResourcePackage resourcePackage = buildJavaResourcePackage(cu);

    XmlSchemaTypeAnnotation containedAnnotation =
        (XmlSchemaTypeAnnotation) resourcePackage.getAnnotation(1, JAXB.XML_SCHEMA_TYPE);

    containedAnnotation.setType(TEST_CLASS);
    assertEquals(TEST_CLASS, containedAnnotation.getType());
    assertEquals(FQ_TEST_CLASS, containedAnnotation.getFullyQualifiedType());
    assertSourceContains(
        "@XmlSchemaTypes({@XmlSchemaType,@XmlSchemaType(type = " + TEST_CLASS + ".class)})", cu);

    containedAnnotation.setType(null);
    assertNull(containedAnnotation.getType());
    assertNull(FQ_TEST_CLASS, containedAnnotation.getFullyQualifiedType());
    assertSourceContains("@XmlSchemaTypes({@XmlSchemaType,@XmlSchemaType})", cu);
  }