| 1 |
import java.util.regex.Pattern |
| 2 |
|
| 3 |
/* |
| 4 |
* Licensed to the Apache Software Foundation (ASF) under one |
| 5 |
* or more contributor license agreements. See the NOTICE file |
| 6 |
* distributed with this work for additional information |
| 7 |
* regarding copyright ownership. The ASF licenses this file |
| 8 |
* to you under the Apache License, Version 2.0 (the |
| 9 |
* "License"); you may not use this file except in compliance |
| 10 |
* with the License. You may obtain a copy of the License at |
| 11 |
* |
| 12 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 13 |
* |
| 14 |
* Unless required by applicable law or agreed to in writing, |
| 15 |
* software distributed under the License is distributed on an |
| 16 |
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 17 |
* KIND, either express or implied. See the License for the |
| 18 |
* specific language governing permissions and limitations |
| 19 |
* under the License. |
| 20 |
*/ |
| 21 |
|
| 22 |
|
| 23 |
// Assemble |
| 24 |
File buildLog = new File(basedir, 'build.log') |
| 25 |
List<String> lines = buildLog.readLines(); |
| 26 |
|
| 27 |
String pathToLeafPackage = "target/generated-sources/jaxb/com/example/myschema/"; |
| 28 |
File expectedAddressTypeFile = new File(basedir, pathToLeafPackage + "AddressType.java"); |
| 29 |
File expectedObjectFactoryFile = new File(basedir, pathToLeafPackage + "ObjectFactory.java"); |
| 30 |
|
| 31 |
/* |
| 32 |
+=================== [11 XJC Arguments] (Mac/Linux version) |
| 33 |
| |
| 34 |
| [0]: -xmlschema |
| 35 |
| [1]: -encoding |
| 36 |
| [2]: UTF-8 |
| 37 |
| [3]: -d |
| 38 |
| [4]: /Users/lj/Development/Projects/Codehaus/lennartj-jaxb2-maven-plugin/target/it/xjc-handles-spaces-in-filenames/target/generated-sources/jaxb |
| 39 |
| [5]: -extension |
| 40 |
| [6]: -episode |
| 41 |
| [7]: /Users/lj/Development/Projects/Codehaus/lennartj-jaxb2-maven-plugin/target/it/xjc-handles-spaces-in-filenames/target/generated-sources/jaxb/META-INF/sun-jaxb.episode |
| 42 |
| [8]: -b |
| 43 |
| [9]: /Users/lj/Development/Projects/Codehaus/lennartj-jaxb2-maven-plugin/target/it/xjc-handles-spaces-in-filenames/src/main/xjb/spaced filename.xjb |
| 44 |
| [10]: /Users/lj/Development/Projects/Codehaus/lennartj-jaxb2-maven-plugin/target/it/xjc-handles-spaces-in-filenames/src/main/xsd/address.xsd |
| 45 |
| |
| 46 |
+=================== [End 11 XJC Arguments] |
| 47 |
|
| 48 |
+=================== [11 XJC Arguments] (Windows version) |
| 49 |
| |
| 50 |
| [0]: -xmlschema |
| 51 |
| [1]: -encoding |
| 52 |
| [2]: UTF-8 |
| 53 |
| [3]: -d |
| 54 |
| [4]: E:\Mojohaus\jaxb2-maven-plugin\target\it\xjc-handles-spaces-in-filenames\target\generated-sources\jaxb |
| 55 |
| [5]: -extension |
| 56 |
| [6]: -episode |
| 57 |
| [7]: E:\Mojohaus\jaxb2-maven-plugin\target\it\xjc-handles-spaces-in-filenames\target\generated-sources\jaxb\META-INF\sun-jaxb.episode |
| 58 |
| [8]: -b |
| 59 |
| [9]: E:\Mojohaus\jaxb2-maven-plugin\target\it\xjc-handles-spaces-in-filenames\src\main\xjb\spaced filename.xjb |
| 60 |
| [10]: /E:/Mojohaus/jaxb2-maven-plugin/target/it/xjc-handles-spaces-in-filenames/src/main/xsd/address.xsd |
| 61 |
| |
| 62 |
+=================== [End 11 XJC Arguments] |
| 63 |
*/ |
| 64 |
def sep = Pattern.quote(System.getProperty("file.separator")); |
| 65 |
def xjcArgumentPatternPrefix = "\\| \\[\\p{Digit}+\\]: "; |
| 66 |
Pattern expectedBArgumentPattern = Pattern.compile(xjcArgumentPatternPrefix + "\\-b"); |
| 67 |
Pattern expectedXjbArgumentPattern = Pattern.compile(xjcArgumentPatternPrefix |
| 68 |
+ ".*src/main/xjb/spaced filename.xjb".replace("/", sep)); |
| 69 |
Pattern expectedSourceArgumentPattern = Pattern.compile(xjcArgumentPatternPrefix + ".*src/main/xsd/address.xsd"); |
| 70 |
|
| 71 |
boolean foundBArgument = false; |
| 72 |
boolean foundXjbArgument = false; |
| 73 |
boolean foundSourceArgument = false; |
| 74 |
|
| 75 |
// Act |
| 76 |
for (line in lines) { |
| 77 |
|
| 78 |
String trimmedLine = line.trim() |
| 79 |
if (trimmedLine.isEmpty()) { |
| 80 |
continue |
| 81 |
}; |
| 82 |
|
| 83 |
if(!foundBArgument && expectedBArgumentPattern.matcher(trimmedLine).matches()) { |
| 84 |
foundBArgument = true; |
| 85 |
} |
| 86 |
|
| 87 |
if(!foundXjbArgument && expectedXjbArgumentPattern.matcher(trimmedLine).matches()) { |
| 88 |
foundXjbArgument = true; |
| 89 |
} |
| 90 |
|
| 91 |
if(!foundSourceArgument && expectedSourceArgumentPattern.matcher(trimmedLine).matches()) { |
| 92 |
foundSourceArgument = true; |
| 93 |
} |
| 94 |
} |
| 95 |
|
| 96 |
// Assert |
| 97 |
def missingRequired(Pattern pattern) { |
| 98 |
return "Missing required pattern: [" + pattern.pattern() + "]" ; |
| 99 |
} |
| 100 |
|
| 101 |
assert foundBArgument, missingRequired(expectedBArgumentPattern); |
| 102 |
assert foundXjbArgument, missingRequired(expectedXjbArgumentPattern); |
| 103 |
assert foundSourceArgument, missingRequired(expectedSourceArgumentPattern); |
| 104 |
|
| 105 |
assert expectedAddressTypeFile.exists() && expectedAddressTypeFile.isFile(), "Missing required file: [" + |
| 106 |
expectedAddressTypeFile.getPath() + "]" ; |
| 107 |
assert expectedObjectFactoryFile.exists() && expectedObjectFactoryFile.isFile(), "Missing required file: [" + |
| 108 |
expectedObjectFactoryFile.getPath() + "]" ; |