public void testRefreshComplexType() throws ResourceException {
    MWXmlSchema schema = this.loadSchema("BasicComplexType");
    MWComplexTypeDefinition complexType = schema.complexType("complex-type");
    int originalTotalElementCount = complexType.totalElementCount();
    int originalAttributeCount = complexType.attributeCount();

    assertEquals(complexType.getBaseType().getName(), "anyType");
    assertTrue("The type is abstract.", !complexType.isAbstract());
    assertTrue("The number of total elements is zero.", originalTotalElementCount != 0);
    assertTrue("The number of attributes is zero.", originalAttributeCount != 0);

    schema.reload();

    assertTrue("The abstract flag changed.", !complexType.isAbstract());
    assertTrue(
        "The number of total elements changed.",
        complexType.totalElementCount() == originalTotalElementCount);
    assertTrue(
        "The number of attributes changed.",
        complexType.attributeCount() == originalAttributeCount);

    this.reloadSchema(schema, "BasicComplexTypeWithReferences");
    assertTrue(
        "The number of total elements changed.",
        complexType.totalElementCount() == originalTotalElementCount);
    assertTrue(
        "The number of attributes changed.",
        complexType.attributeCount() == originalAttributeCount);

    this.reloadSchema(schema, "BasicComplexTypeWithSimpleBaseType");

    assertNotNull(complexType.getBaseType());
    assertTrue("The number of total elements is not zero.", complexType.totalElementCount() == 0);

    this.reloadSchema(schema, "BasicComplexTypeWithComplexBaseType");

    assertNotNull(complexType.getBaseType());
    assertTrue(
        "The base type is not abstract.",
        ((MWComplexTypeDefinition) complexType.getBaseType()).isAbstract());
    assertTrue(
        "The number of total elements did not increase.",
        complexType.totalElementCount() > originalTotalElementCount);
    assertTrue(
        "The number of attributes did not increase.",
        complexType.attributeCount() > originalAttributeCount);

    this.reloadSchema(schema, "BasicComplexType");
    assertEquals(complexType.getBaseType().getName(), "anyType");
    assertTrue(
        "The number of total elements did not decrease.",
        complexType.totalElementCount() == originalTotalElementCount);
    assertTrue(
        "The number of attributes did not decrease.",
        complexType.attributeCount() == originalAttributeCount);
  }
  public void testRefreshType() throws ResourceException {
    MWXmlSchema schema = this.loadSchema("BasicType_Simple");
    assertNotNull(schema.simpleType("type"));

    this.reloadSchema(schema, "BasicType_Complex");
    assertNotNull(schema.complexType("type"));

    this.reloadSchema(schema, "BasicType_Simple");
    assertNotNull(schema.simpleType("type"));
  }
  public void testDefaultRootElementType() {
    String errorName = ProblemConstants.DESCRIPTOR_DEFAULT_ROOT_ELEMENT_TYPE;
    this.checkOXDescriptorsForFalseFailures(errorName);

    MWElementDeclaration defaultRootElement = getEmployeeEisDescriptor().getDefaultRootElement();
    MWXmlSchema empSchema = getEmployeeOXProject().getSchemaRepository().getSchema("employee.xsd");
    this.getEmployeeOXDescriptor().setDefaultRootElementType(empSchema.complexType("phone-type"));
    this.getEmployeeOXDescriptor().setDefaultRootElement(null);
    this.assertTrue(
        "default root element is null -- should have problem",
        this.hasProblem(errorName, this.getEmployeeOXDescriptor()));

    this.getEmployeeOXDescriptor().setDefaultRootElement(defaultRootElement);
    this.assertTrue(
        "default root element not null -- should have no problem",
        !this.hasProblem(errorName, this.getEmployeeOXDescriptor()));
  }