001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: *
017: */
018: package org.apache.tools.ant.taskdefs.optional;
019:
020: import org.apache.tools.ant.BuildFileTest;
021:
022: /**
023: * Test schema validation
024: */
025:
026: public class SchemaValidateTest extends BuildFileTest {
027:
028: /**
029: * where tasks run
030: */
031: private final static String TASKDEFS_DIR = "src/etc/testcases/taskdefs/optional/";
032:
033: /**
034: * Constructor
035: *
036: * @param name testname
037: */
038: public SchemaValidateTest(String name) {
039: super (name);
040: }
041:
042: /**
043: * The JUnit setup method
044: */
045: public void setUp() {
046: configureProject(TASKDEFS_DIR + "schemavalidate.xml");
047: }
048:
049: /**
050: * test with no namespace
051: */
052: public void testNoNamespace() throws Exception {
053: executeTarget("testNoNamespace");
054: }
055:
056: /**
057: * add namespace awareness.
058: */
059: public void testNSMapping() throws Exception {
060: executeTarget("testNSMapping");
061: }
062:
063: public void testNoEmptySchemaNamespace() throws Exception {
064: expectBuildExceptionContaining("testNoEmptySchemaNamespace",
065: "empty namespace URI",
066: SchemaValidate.SchemaLocation.ERROR_NO_URI);
067: }
068:
069: public void testNoEmptySchemaLocation() throws Exception {
070: expectBuildExceptionContaining("testNoEmptySchemaLocation",
071: "empty schema location",
072: SchemaValidate.SchemaLocation.ERROR_NO_LOCATION);
073: }
074:
075: public void testNoFile() throws Exception {
076: expectBuildExceptionContaining("testNoFile",
077: "no file at file attribute",
078: SchemaValidate.SchemaLocation.ERROR_NO_FILE);
079: }
080:
081: public void testNoDoubleSchemaLocation() throws Exception {
082: expectBuildExceptionContaining("testNoDoubleSchemaLocation",
083: "two locations for schemas",
084: SchemaValidate.SchemaLocation.ERROR_TWO_LOCATIONS);
085: }
086:
087: public void testNoDuplicateSchema() throws Exception {
088: expectBuildExceptionContaining("testNoDuplicateSchema",
089: "duplicate schemas with different values",
090: SchemaValidate.ERROR_DUPLICATE_SCHEMA);
091: }
092:
093: public void testEqualsSchemasOK() throws Exception {
094: executeTarget("testEqualsSchemasOK");
095: }
096:
097: public void testFileset() throws Exception {
098: executeTarget("testFileset");
099: }
100: }
|