01: /* Copyright 2004 The Apache Software Foundation
02: *
03: * Licensed under the Apache License, Version 2.0 (the "License");
04: * you may not use this file except in compliance with the License.
05: * You may obtain a copy of the License at
06: *
07: * http://www.apache.org/licenses/LICENSE-2.0
08: *
09: * Unless required by applicable law or agreed to in writing, software
10: * distributed under the License is distributed on an "AS IS" BASIS,
11: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: * See the License for the specific language governing permissions and
13: * limitations under the License.
14: */
15:
16: package org.apache.xmlbeans.samples.enumeration;
17:
18: import org.apache.xmlbeans.samples.enumeration.schemaenum.easypo.PurchaseOrderDocument;
19: import org.apache.xmlbeans.samples.enumeration.schemaenum.pricesummary.PriceSummaryDocument;
20:
21: /**
22: * A class to test the SchemaEnum sample.
23: */
24: public class SchemaEnumTest {
25: /**
26: * Tests the SchemaEnum sample.
27: *
28: * @param args An array in which the first item is a path to an XML file
29: * based on the schema in inventory.xsd.
30: */
31: public static void main(String[] args) {
32: SchemaEnum sample = new SchemaEnum();
33: PurchaseOrderDocument poDoc = sample.parseXml(args[0]);
34:
35: boolean exampleIsValid = sample.validateXml(poDoc);
36: assert exampleIsValid;
37:
38: // Create a new document that summarizes the PO doc.
39: PriceSummaryDocument summaryDoc = sample.summarizeItems(poDoc);
40:
41: boolean summaryIsValid = sample.validateXml(summaryDoc);
42: assert summaryIsValid;
43:
44: // Create a summary of the items based on price.
45: String sortedItems = sample.sortByThreshold(summaryDoc);
46:
47: boolean stringExists = (sortedItems != null);
48: assert stringExists;
49: }
50: }
|