blob: 2da9b05a370d0ee01b886379a76acb7dce2d0366 [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.netbeans.modules.xml.axi;
import javax.swing.text.Document;
import junit.framework.*;
import org.netbeans.modules.xml.schema.model.GlobalElement;
import org.netbeans.modules.xml.schema.model.SchemaModel;
import org.netbeans.modules.xml.xam.dom.AbstractDocumentModel;
/**
*
* @author Ayub Khan
*/
public class SchemaGeneratorDatatypesTest extends AbstractTestCase {
public static final String TEST_XSD = "resources/types.xsd";
public static final String GLOBAL_ELEMENT = "purchaseOrder";
private Document doc = null;
public SchemaGeneratorDatatypesTest(String testName) {
super(testName, TEST_XSD, GLOBAL_ELEMENT);
}
protected void setUp() throws Exception {
super.setUp();
}
public static Test suite() {
TestSuite suite = new TestSuite();
// Disabled as referenced XSD file were partly not donated by oracle to apache
// suite.addTestSuite(SchemaGeneratorDatatypesTest.class);
return suite;
}
/**
* Test of createElement method, of class org.netbeans.modules.xml.axi.XAMFactory.
*/
public void testGenerateSchema() throws Exception {
Element element = globalElement;
assertNotNull(element);
SchemaModel sm = getSchemaModel();
validateSchema(sm);
doc = ((AbstractDocumentModel)sm).getBaseDocument();
//global element name change (just to get the forward generation to work
axiModel.startTransaction();
for(Element e:axiModel.getRoot().getElements())
if(e.getName().equals(GLOBAL_ELEMENT))
e.setName(e.getName()+"_");
axiModel.endTransaction();
for(GlobalElement ge:sm.getSchema().getElements()) {
if(ge.getName().startsWith(GLOBAL_ELEMENT))
assertEquals("updated schemamodel", GLOBAL_ELEMENT+"_", ge.getName());
}
validateSchema(axiModel.getSchemaModel());
}
}