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: import org.apache.tools.ant.taskdefs.optional.dotnet.WsdlToDotnet;
022:
023: /**
024: * Tests the WsdlToDotnet task.
025: *
026: * @since Ant 1.5
027: */
028: public class WsdlToDotnetTest extends BuildFileTest {
029:
030: /**
031: * dir for taskdefs
032: */
033: private final static String TASKDEFS_DIR = "src/etc/testcases/taskdefs/optional/";
034:
035: /**
036: * message from exec
037: */
038: private static final String WSDL_FAILED = "WSDL returned:";
039:
040: /**
041: * Constructor
042: *
043: * @param name testname
044: */
045: public WsdlToDotnetTest(String name) {
046: super (name);
047: }
048:
049: /**
050: * The JUnit setup method
051: */
052: public void setUp() {
053: configureProject(TASKDEFS_DIR + "WsdlToDotnet.xml");
054: }
055:
056: /**
057: * The teardown method for JUnit
058: */
059: public void tearDown() {
060: executeTarget("teardown");
061: }
062:
063: /**
064: * A unit test for JUnit
065: */
066: public void testNoParams() throws Exception {
067: expectBuildExceptionContaining("testNoParams",
068: "expected failure", WsdlToDotnet.ERROR_NO_DEST_FILE);
069: }
070:
071: /**
072: * A unit test for JUnit
073: */
074: public void testNoSrc() throws Exception {
075: expectBuildExceptionContaining("testNoSrc", "expected failure",
076: WsdlToDotnet.Schema.ERROR_NONE_DECLARED);
077: }
078:
079: /**
080: * A unit test for JUnit
081: */
082: public void testDestIsDir() throws Exception {
083: expectBuildExceptionContaining("testDestIsDir",
084: "expected failure", WsdlToDotnet.ERROR_DEST_FILE_IS_DIR);
085: }
086:
087: /**
088: * A unit test for JUnit
089: */
090: public void testBothSrc() throws Exception {
091: expectBuildExceptionContaining("testBothSrc",
092: "expected failure",
093: WsdlToDotnet.Schema.ERROR_BOTH_DECLARED);
094: }
095:
096: /**
097: * A unit test for JUnit
098: */
099: public void testSrcIsDir() throws Exception {
100: expectBuildExceptionContaining("testSrcIsDir",
101: "expected failure",
102: WsdlToDotnet.Schema.ERROR_FILE_IS_DIR);
103: }
104:
105: /**
106: * A unit test for JUnit
107: */
108: public void testSrcIsMissing() throws Exception {
109: expectBuildExceptionContaining("testSrcIsMissing",
110: "expected failure",
111: WsdlToDotnet.Schema.ERROR_FILE_NOT_FOUND);
112: }
113:
114: /**
115: * A unit test for JUnit
116: */
117: public void testLocalWsdl() throws Exception {
118: executeTarget("testLocalWsdl");
119: }
120:
121: /**
122: * A unit test for JUnit
123: */
124: public void testLocalWsdlServer() throws Exception {
125: executeTarget("testLocalWsdlServer");
126: }
127:
128: /**
129: * A unit test for JUnit
130: */
131: public void testInvalidExtraOps() throws Exception {
132: expectBuildExceptionContaining("testInvalidExtraOps",
133: "expected failure", WSDL_FAILED);
134: }
135:
136: /**
137: * A unit test for JUnit
138: */
139: public void testLocalWsdlVB() throws Exception {
140: executeTarget("testLocalWsdlVB");
141: }
142:
143: /**
144: * A unit test for JUnit
145: */
146: public void testLocalWsdlServerVB() throws Exception {
147: executeTarget("testLocalWsdlServerVB");
148: }
149:
150: /**
151: * A unit test for JUnit
152: */
153: public void testInvalidExtraOpsVB() throws Exception {
154: expectBuildExceptionContaining("testInvalidExtraOpsVB",
155: "expected failure", WSDL_FAILED);
156: }
157:
158: /**
159: * as if parseable errors were not ignored, mono and WSE1.0 would
160: * crash and burn. So here we verify the property exists,
161: * and that it is not passed to the app when false
162: */
163: public void testParseableErrorsIgnoredWhenFalse() throws Exception {
164: executeTarget("testLocalWsdl");
165: }
166:
167: /**
168: * A unit test for JUnit
169: */
170: public void testSchemaFileMustExist() throws Exception {
171: expectBuildExceptionContaining("testSchemaFileMustExist",
172: "expected failure",
173: WsdlToDotnet.Schema.ERROR_FILE_NOT_FOUND);
174: }
175:
176: /**
177: * A unit test for JUnit
178: */
179: public void testSchemaFileMustHaveOneOptionOnly() throws Exception {
180: expectBuildExceptionContaining(
181: "testSchemaFileMustHaveOneOptionOnly",
182: "expected failure",
183: WsdlToDotnet.Schema.ERROR_BOTH_DECLARED);
184: }
185:
186: /**
187: * A unit test for JUnit
188: */
189: public void testSchemaMustBeSet() throws Exception {
190: expectBuildExceptionContaining("testSchemaMustBeSet",
191: "expected failure",
192: WsdlToDotnet.Schema.ERROR_NONE_DECLARED);
193: }
194:
195: }
|