fix some lineends
Project: http://git-wip-us.apache.org/repos/asf/ant/repo Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/1ae68097 Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/1ae68097 Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/1ae68097 Branch: refs/heads/master Commit: 1ae68097893838e1c0d217a82c5ee037f3380e48 Parents: 28cfaa4 Author: YOUR NAME <[email protected]> Authored: Sat Apr 18 22:13:48 2015 +0200 Committer: YOUR NAME <[email protected]> Committed: Sat Apr 18 22:13:48 2015 +0200 ---------------------------------------------------------------------- .../tools/ant/taskdefs/email/MessageTest.java | 124 +- .../tools/ant/taskdefs/optional/ANTLRTest.java | 432 ++-- .../optional/AbstractXSLTLiaisonTest.java | 208 +- .../taskdefs/optional/BeanShellScriptTest.java | 96 +- .../taskdefs/optional/EchoPropertiesTest.java | 532 ++--- .../tools/ant/taskdefs/optional/JavahTest.java | 120 +- .../tools/ant/taskdefs/optional/JspcTest.java | 400 ++-- .../ant/taskdefs/optional/Native2AsciiTest.java | 114 +- .../ant/taskdefs/optional/PropertyFileTest.java | 470 ++-- .../tools/ant/taskdefs/optional/PvcsTest.java | 158 +- .../taskdefs/optional/ReplaceRegExpTest.java | 264 +-- .../taskdefs/optional/RhinoReferenceTest.java | 90 +- .../ant/taskdefs/optional/RhinoScriptTest.java | 134 +- .../tools/ant/taskdefs/optional/RpmTest.java | 142 +- .../taskdefs/optional/SchemaValidateTest.java | 256 +-- .../ant/taskdefs/optional/TraXLiaisonTest.java | 258 +-- .../optional/XmlValidateCatalogTest.java | 142 +- .../ant/taskdefs/optional/XmlValidateTest.java | 386 ++-- .../tools/ant/taskdefs/optional/XsltTest.java | 172 +- .../taskdefs/optional/depend/DependTest.java | 426 ++-- .../taskdefs/optional/i18n/TranslateTest.java | 174 +- .../ant/taskdefs/optional/image/ImageTest.java | 266 +-- .../taskdefs/optional/jdepend/JDependTest.java | 198 +- .../taskdefs/optional/junit/BatchTestTest.java | 242 +- .../taskdefs/optional/junit/DOMUtilTest.java | 106 +- .../optional/junit/JUnitClassLoaderTest.java | 74 +- .../optional/junit/JUnitReportTest.java | 422 ++-- .../taskdefs/optional/junit/JUnitTaskTest.java | 796 +++---- .../optional/junit/JUnitTestListenerTest.java | 222 +- .../optional/junit/JUnitTestRunnerTest.java | 434 ++-- .../optional/junit/JUnitVersionHelperTest.java | 204 +- .../ant/taskdefs/optional/junit/NoVmCrash.java | 60 +- .../ant/taskdefs/optional/junit/Printer.java | 84 +- .../ant/taskdefs/optional/junit/Sleeper.java | 60 +- .../optional/junit/SuiteMethodTest.java | 84 +- .../optional/junit/TearDownOnVmCrashTest.java | 104 +- .../taskdefs/optional/junit/TestFormatter.java | 224 +- .../ant/taskdefs/optional/junit/VmCrash.java | 62 +- .../junit/XMLFormatterWithCDATAOnSystemOut.java | 166 +- .../optional/junit/XMLResultAggregatorTest.java | 186 +- .../ant/taskdefs/optional/net/FTPTest.java | 1758 +++++++-------- .../taskdefs/optional/script/ScriptDefTest.java | 292 +-- .../ant/taskdefs/optional/sos/SOSTest.java | 702 +++--- .../optional/splash/SplashScreenTest.java | 100 +- .../ant/taskdefs/optional/ssh/ScpTest.java | 412 ++-- .../ant/taskdefs/optional/unix/SymlinkTest.java | 594 ++--- .../ant/taskdefs/optional/vss/MSVSSTest.java | 950 ++++---- .../tools/ant/types/AbstractFileSetTest.java | 496 ++-- .../org/apache/tools/ant/types/AddTypeTest.java | 446 ++-- .../apache/tools/ant/types/AssertionsTest.java | 250 +-- .../tools/ant/types/CommandlineJavaTest.java | 382 ++-- .../apache/tools/ant/types/CommandlineTest.java | 360 +-- .../apache/tools/ant/types/DescriptionTest.java | 118 +- .../org/apache/tools/ant/types/DirSetTest.java | 188 +- .../ant/types/EnumeratedAttributeTest.java | 212 +- .../apache/tools/ant/types/FileListTest.java | 326 +-- .../org/apache/tools/ant/types/FileSetTest.java | 72 +- .../apache/tools/ant/types/FilterSetTest.java | 478 ++-- .../apache/tools/ant/types/FlexIntegerTest.java | 148 +- .../org/apache/tools/ant/types/MapperTest.java | 470 ++-- .../org/apache/tools/ant/types/PathTest.java | 1158 +++++----- .../apache/tools/ant/types/PatternSetTest.java | 412 ++-- .../apache/tools/ant/types/PermissionsTest.java | 316 +-- .../org/apache/tools/ant/types/PolyTest.java | 158 +- .../tools/ant/types/RedirectorElementTest.java | 172 +- .../tools/ant/types/ResourceOutputTest.java | 320 +-- .../apache/tools/ant/types/TarFileSetTest.java | 238 +- .../ant/types/XMLCatalogBuildFileTest.java | 196 +- .../apache/tools/ant/types/XMLCatalogTest.java | 784 +++---- .../apache/tools/ant/types/ZipFileSetTest.java | 236 +- .../tools/ant/types/mappers/GlobMapperTest.java | 98 +- .../tools/ant/types/mappers/MapperResult.java | 206 +- .../types/mappers/RegexpPatternMapperTest.java | 102 +- .../ant/types/optional/ScriptMapperTest.java | 106 +- .../ant/types/optional/ScriptSelectorTest.java | 166 +- .../types/optional/depend/ClassFileSetTest.java | 372 +-- .../ant/types/resources/FileResourceTest.java | 244 +- .../ant/types/resources/JavaResourceTest.java | 124 +- .../resources/LazyResourceCollectionTest.java | 372 +-- .../types/resources/MultiRootFileSetTest.java | 262 +-- .../ant/types/resources/ResourceListTest.java | 268 +-- .../ant/types/resources/TarResourceTest.java | 108 +- .../ant/types/selectors/BaseSelectorRule.java | 250 +-- .../ant/types/selectors/BaseSelectorTest.java | 590 ++--- .../ant/types/selectors/ContainsRegexpTest.java | 112 +- .../types/selectors/ContainsSelectorTest.java | 228 +- .../ant/types/selectors/DateSelectorTest.java | 458 ++-- .../ant/types/selectors/DependSelectorTest.java | 370 +-- .../ant/types/selectors/DepthSelectorTest.java | 294 +-- .../types/selectors/FilenameSelectorTest.java | 230 +- .../ant/types/selectors/MockAlgorithm.java | 74 +- .../tools/ant/types/selectors/MockCache.java | 136 +- .../ant/types/selectors/MockComparator.java | 64 +- .../types/selectors/ModifiedSelectorTest.java | 2124 +++++++++--------- .../types/selectors/PresentSelectorTest.java | 274 +-- .../org/apache/tools/ant/types/selectors/README | 192 +- .../ant/types/selectors/SignedSelectorTest.java | 108 +- .../ant/types/selectors/SizeSelectorTest.java | 474 ++-- .../types/selectors/TokenizedPatternTest.java | 128 +- .../ant/types/selectors/TypeSelectorTest.java | 162 +- .../tools/ant/util/Base64ConverterTest.java | 86 +- .../tools/ant/util/ClasspathUtilsTest.java | 134 +- .../tools/ant/util/CollectionUtilsTest.java | 204 +- .../tools/ant/util/DOMElementWriterTest.java | 610 ++--- .../apache/tools/ant/util/DateUtilsTest.java | 212 +- .../apache/tools/ant/util/DeweyDecimalTest.java | 140 +- .../apache/tools/ant/util/FileUtilsTest.java | 1250 +++++------ .../tools/ant/util/GlobPatternMapperTest.java | 204 +- .../apache/tools/ant/util/JAXPUtilsTest.java | 86 +- .../apache/tools/ant/util/JavaEnvUtilsTest.java | 288 +-- .../util/LayoutPreservingPropertiesTest.java | 632 +++--- .../ant/util/LazyFileOutputStreamTest.java | 150 +- .../ant/util/LineOrientedOutputStreamTest.java | 306 +-- .../tools/ant/util/LinkedHashtableTest.java | 330 +-- .../apache/tools/ant/util/LoaderUtilsTest.java | 86 +- .../tools/ant/util/PackageNameMapperTest.java | 86 +- .../tools/ant/util/ReaderInputStreamTest.java | 284 +-- .../tools/ant/util/ResourceUtilsTest.java | 126 +- .../apache/tools/ant/util/StringUtilsTest.java | 340 +-- .../apache/tools/ant/util/SymlinkUtilsTest.java | 80 +- .../tools/ant/util/UnPackageNameMapperTest.java | 84 +- .../apache/tools/ant/util/VectorSetTest.java | 590 ++--- .../apache/tools/ant/util/XMLFragmentTest.java | 182 +- .../ant/util/facade/FacadeTaskHelperTest.java | 128 +- .../ImplementationSpecificArgumentTest.java | 118 +- .../ant/util/regexp/JakartaOroMatcherTest.java | 70 +- .../ant/util/regexp/JakartaOroRegexpTest.java | 70 +- .../util/regexp/JakartaRegexpMatcherTest.java | 126 +- .../util/regexp/JakartaRegexpRegexpTest.java | 124 +- .../ant/util/regexp/Jdk14RegexpMatcherTest.java | 140 +- .../ant/util/regexp/Jdk14RegexpRegexpTest.java | 142 +- .../ant/util/regexp/RegexpMatcherTest.java | 408 ++-- .../tools/ant/util/regexp/RegexpTest.java | 126 +- .../org/apache/tools/bzip2/BlockSortTest.java | 340 +-- .../apache/tools/bzip2/CBZip2StreamTest.java | 94 +- .../org/apache/tools/mail/MailMessageTest.java | 1414 ++++++------ .../org/apache/tools/tar/TarEntryTest.java | 70 +- .../apache/tools/tar/TarOutputStreamTest.java | 70 +- .../org/apache/tools/tar/TarRoundTripTest.java | 148 +- .../org/apache/tools/zip/AsiExtraFieldTest.java | 326 +-- .../apache/tools/zip/ExtraFieldUtilsTest.java | 420 ++-- .../org/apache/tools/zip/UTF8ZipFilesTest.java | 520 ++--- .../org/apache/tools/zip/ZipEncodingTest.java | 304 +-- .../org/apache/tools/zip/ZipEntryTest.java | 456 ++-- .../junit/org/apache/tools/zip/ZipLongTest.java | 188 +- .../apache/tools/zip/ZipOutputStreamTest.java | 146 +- .../org/apache/tools/zip/ZipShortTest.java | 184 +- .../org/example/junit/JUnit4Skippable.java | 148 +- .../org/example/junit/MultilineAsserts.java | 54 +- src/tests/junit/org/example/junit/Output.java | 74 +- .../junit/org/example/junit/ThreadedOutput.java | 86 +- src/tests/junit/org/example/junit/Timeout.java | 64 +- .../junit/org/example/junit/XmlParserTest.java | 116 +- .../example/tasks/TaskdefTestContainerTask.java | 50 +- .../example/tasks/TaskdefTestSimpleTask.java | 90 +- src/tests/junit/org/example/tasks/antlib.xml | 52 +- src/tests/junit/org/example/tasks/antlib2.xml | 52 +- .../org/example/types/TypedefTestType.java | 50 +- 158 files changed, 21995 insertions(+), 21995 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ant/blob/1ae68097/src/tests/junit/org/apache/tools/ant/taskdefs/email/MessageTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/email/MessageTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/email/MessageTest.java index df75067..505decd 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/email/MessageTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/email/MessageTest.java @@ -1,62 +1,62 @@ -/* - * 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.apache.tools.ant.taskdefs.email; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.PrintStream; - -import org.apache.tools.ant.Project; -import org.apache.tools.ant.util.FileUtils; -import org.junit.After; -import org.junit.Test; - -public class MessageTest { - private static final File f = new File(System.getProperty("java.io.tmpdir"), - "message.txt"); - /** - * test for bugzilla 48932 - */ - @Test - public void testPrintStreamDoesNotGetClosed() throws IOException { - Message ms = new Message(); - Project p = new Project(); - ms.setProject(p); - ms.addText("hi, this is an email"); - FileOutputStream fis = null; - try { - fis = new FileOutputStream(f); - ms.print(new PrintStream(fis)); - fis.write(120); - } finally { - FileUtils.close(fis); - } - - } - - @After - public void tearDown() { - if (f.exists()) { - FileUtils fu = FileUtils.getFileUtils(); - fu.tryHardToDelete(f); - } - } - -} +/* + * 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.apache.tools.ant.taskdefs.email; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.PrintStream; + +import org.apache.tools.ant.Project; +import org.apache.tools.ant.util.FileUtils; +import org.junit.After; +import org.junit.Test; + +public class MessageTest { + private static final File f = new File(System.getProperty("java.io.tmpdir"), + "message.txt"); + /** + * test for bugzilla 48932 + */ + @Test + public void testPrintStreamDoesNotGetClosed() throws IOException { + Message ms = new Message(); + Project p = new Project(); + ms.setProject(p); + ms.addText("hi, this is an email"); + FileOutputStream fis = null; + try { + fis = new FileOutputStream(f); + ms.print(new PrintStream(fis)); + fis.write(120); + } finally { + FileUtils.close(fis); + } + + } + + @After + public void tearDown() { + if (f.exists()) { + FileUtils fu = FileUtils.getFileUtils(); + fu.tryHardToDelete(f); + } + } + +} http://git-wip-us.apache.org/repos/asf/ant/blob/1ae68097/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ANTLRTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ANTLRTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ANTLRTest.java index 9258448..47abcfe 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ANTLRTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ANTLRTest.java @@ -1,216 +1,216 @@ -/* - * 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.apache.tools.ant.taskdefs.optional; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.BuildFileRule; -import org.apache.tools.ant.FileUtilities; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; - -import java.io.File; -import java.io.FilenameFilter; - -import static org.apache.tools.ant.AntAssert.assertContains; -import static org.apache.tools.ant.AntAssert.assertNotContains; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -/** - * If you want to run tests, it is highly recommended - * to download ANTLR (www.antlr.org), build the 'antlrall.jar' jar - * with <code>make antlr-all.jar</code> and drop the jar (about 300KB) into - * Ant lib. - * - Running w/ the default antlr.jar (70KB) does not work (missing class) - * - * Unless of course you specify the ANTLR classpath in your - * system classpath. (see ANTLR install.html) - * - */ -public class ANTLRTest { - - private final static String TASKDEFS_DIR = "src/etc/testcases/taskdefs/optional/antlr/"; - - @Rule - public BuildFileRule buildRule = new BuildFileRule(); - - @Before - public void setUp() { - buildRule.configureProject(TASKDEFS_DIR + "antlr.xml"); - } - - @Test - public void test1() { - try { - buildRule.executeTarget("test1"); - fail("required argument, target, missing"); - } catch (BuildException ex) { - //TODO should check exception message - } - } - - @Test - public void test2() { - try { - buildRule.executeTarget("test2"); - fail("Invalid output directory"); - } catch (BuildException ex) { - //TODO should check exception message - } - } - - @Test - public void test3() { - buildRule.executeTarget("test3"); - } - - @Test - public void test4() { - buildRule.executeTarget("test4"); - } - - @Test - public void test5() { - // should print "panic: Cannot find importVocab file 'JavaTokenTypes.txt'" - // since it needs to run java.g first before java.tree.g - try { - buildRule.executeTarget("test5"); - fail("ANTLR returned: 1"); - } catch (BuildException ex) { - //TODO should check exception message - } - } - - @Test - public void test6() { - buildRule.executeTarget("test6"); - } - - @Test - public void test7() { - try { - buildRule.executeTarget("test7"); - fail("Unable to determine generated class"); - } catch (BuildException ex) { - //TODO should check exception message - } - } - - /** - * This is a negative test for the super grammar (glib) option. - */ - @Test - public void test8() { - try { - buildRule.executeTarget("test8"); - fail("Invalid super grammar file"); - } catch (BuildException ex) { - //TODO should check exception message - } - } - - /** - * This is a positive test for the super grammar (glib) option. ANTLR - * will throw an error if everything is not correct. - */ - @Test - public void test9() { - buildRule.executeTarget("test9"); - } - - /** - * This test creates an html-ized version of the calculator grammar. - * The sanity check is simply whether or not an html file was generated. - */ - @Test - public void test10() { - buildRule.executeTarget("test10"); - File outputDirectory = new File(buildRule.getProject().getProperty("output")); - String[] calcFiles = outputDirectory.list(new HTMLFilter()); - assertTrue(calcFiles.length > 0); - } - - /** - * This is just a quick sanity check to run the diagnostic option and - * make sure that it doesn't throw any funny exceptions. - */ - @Test - public void test11() { - buildRule.executeTarget("test11"); - } - - /** - * This is just a quick sanity check to run the trace option and - * make sure that it doesn't throw any funny exceptions. - */ - @Test - public void test12() { - buildRule.executeTarget("test12"); - } - - /** - * This is just a quick sanity check to run all the rest of the - * trace options (traceLexer, traceParser, and traceTreeWalker) to - * make sure that they don't throw any funny exceptions. - */ - @Test - public void test13() { - buildRule.executeTarget("test13"); - } - - @Test - public void testNoRecompile() { - buildRule.executeTarget("test9"); - assertNotContains("Skipped grammar file.", buildRule.getFullLog()); - buildRule.executeTarget("noRecompile"); - assertContains("Skipped grammar file.", buildRule.getFullLog()); - } - - @Test - public void testNormalRecompile() { - buildRule.executeTarget("test9"); - assertNotContains("Skipped grammar file.", buildRule.getFullLog()); - - FileUtilities.rollbackTimetamps(buildRule.getOutputDir(), 5); - - buildRule.executeTarget("normalRecompile"); - assertNotContains("Skipped grammar file.", buildRule.getFullLog()); - } - - @Test - // Bugzilla Report 12961 - public void testSupergrammarChangeRecompile() { - buildRule.executeTarget("test9"); - assertNotContains("Skipped grammar file.", buildRule.getFullLog()); - - FileUtilities.rollbackTimetamps(buildRule.getOutputDir(), 5); - - buildRule.executeTarget("supergrammarChangeRecompile"); - assertNotContains("Skipped grammar file.", buildRule.getFullLog()); - - } - -} - -class HTMLFilter implements FilenameFilter { - public boolean accept(File dir, String name) { - return name.endsWith("html"); - } -} +/* + * 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.apache.tools.ant.taskdefs.optional; + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.BuildFileRule; +import org.apache.tools.ant.FileUtilities; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; + +import java.io.File; +import java.io.FilenameFilter; + +import static org.apache.tools.ant.AntAssert.assertContains; +import static org.apache.tools.ant.AntAssert.assertNotContains; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +/** + * If you want to run tests, it is highly recommended + * to download ANTLR (www.antlr.org), build the 'antlrall.jar' jar + * with <code>make antlr-all.jar</code> and drop the jar (about 300KB) into + * Ant lib. + * - Running w/ the default antlr.jar (70KB) does not work (missing class) + * + * Unless of course you specify the ANTLR classpath in your + * system classpath. (see ANTLR install.html) + * + */ +public class ANTLRTest { + + private final static String TASKDEFS_DIR = "src/etc/testcases/taskdefs/optional/antlr/"; + + @Rule + public BuildFileRule buildRule = new BuildFileRule(); + + @Before + public void setUp() { + buildRule.configureProject(TASKDEFS_DIR + "antlr.xml"); + } + + @Test + public void test1() { + try { + buildRule.executeTarget("test1"); + fail("required argument, target, missing"); + } catch (BuildException ex) { + //TODO should check exception message + } + } + + @Test + public void test2() { + try { + buildRule.executeTarget("test2"); + fail("Invalid output directory"); + } catch (BuildException ex) { + //TODO should check exception message + } + } + + @Test + public void test3() { + buildRule.executeTarget("test3"); + } + + @Test + public void test4() { + buildRule.executeTarget("test4"); + } + + @Test + public void test5() { + // should print "panic: Cannot find importVocab file 'JavaTokenTypes.txt'" + // since it needs to run java.g first before java.tree.g + try { + buildRule.executeTarget("test5"); + fail("ANTLR returned: 1"); + } catch (BuildException ex) { + //TODO should check exception message + } + } + + @Test + public void test6() { + buildRule.executeTarget("test6"); + } + + @Test + public void test7() { + try { + buildRule.executeTarget("test7"); + fail("Unable to determine generated class"); + } catch (BuildException ex) { + //TODO should check exception message + } + } + + /** + * This is a negative test for the super grammar (glib) option. + */ + @Test + public void test8() { + try { + buildRule.executeTarget("test8"); + fail("Invalid super grammar file"); + } catch (BuildException ex) { + //TODO should check exception message + } + } + + /** + * This is a positive test for the super grammar (glib) option. ANTLR + * will throw an error if everything is not correct. + */ + @Test + public void test9() { + buildRule.executeTarget("test9"); + } + + /** + * This test creates an html-ized version of the calculator grammar. + * The sanity check is simply whether or not an html file was generated. + */ + @Test + public void test10() { + buildRule.executeTarget("test10"); + File outputDirectory = new File(buildRule.getProject().getProperty("output")); + String[] calcFiles = outputDirectory.list(new HTMLFilter()); + assertTrue(calcFiles.length > 0); + } + + /** + * This is just a quick sanity check to run the diagnostic option and + * make sure that it doesn't throw any funny exceptions. + */ + @Test + public void test11() { + buildRule.executeTarget("test11"); + } + + /** + * This is just a quick sanity check to run the trace option and + * make sure that it doesn't throw any funny exceptions. + */ + @Test + public void test12() { + buildRule.executeTarget("test12"); + } + + /** + * This is just a quick sanity check to run all the rest of the + * trace options (traceLexer, traceParser, and traceTreeWalker) to + * make sure that they don't throw any funny exceptions. + */ + @Test + public void test13() { + buildRule.executeTarget("test13"); + } + + @Test + public void testNoRecompile() { + buildRule.executeTarget("test9"); + assertNotContains("Skipped grammar file.", buildRule.getFullLog()); + buildRule.executeTarget("noRecompile"); + assertContains("Skipped grammar file.", buildRule.getFullLog()); + } + + @Test + public void testNormalRecompile() { + buildRule.executeTarget("test9"); + assertNotContains("Skipped grammar file.", buildRule.getFullLog()); + + FileUtilities.rollbackTimetamps(buildRule.getOutputDir(), 5); + + buildRule.executeTarget("normalRecompile"); + assertNotContains("Skipped grammar file.", buildRule.getFullLog()); + } + + @Test + // Bugzilla Report 12961 + public void testSupergrammarChangeRecompile() { + buildRule.executeTarget("test9"); + assertNotContains("Skipped grammar file.", buildRule.getFullLog()); + + FileUtilities.rollbackTimetamps(buildRule.getOutputDir(), 5); + + buildRule.executeTarget("supergrammarChangeRecompile"); + assertNotContains("Skipped grammar file.", buildRule.getFullLog()); + + } + +} + +class HTMLFilter implements FilenameFilter { + public boolean accept(File dir, String name) { + return name.endsWith("html"); + } +} http://git-wip-us.apache.org/repos/asf/ant/blob/1ae68097/src/tests/junit/org/apache/tools/ant/taskdefs/optional/AbstractXSLTLiaisonTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/AbstractXSLTLiaisonTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/AbstractXSLTLiaisonTest.java index 434e81f..8f2f494 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/AbstractXSLTLiaisonTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/AbstractXSLTLiaisonTest.java @@ -1,104 +1,104 @@ -/* - * 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.apache.tools.ant.taskdefs.optional; - -import static org.junit.Assert.assertEquals; - -import java.io.File; -import java.io.FileNotFoundException; -import java.net.URL; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; - -import org.apache.tools.ant.taskdefs.XSLTLiaison; -import org.apache.tools.ant.util.FileUtils; -import org.junit.Before; -import org.junit.Test; -import org.w3c.dom.Document; - -/** - * Abtract testcase for XSLTLiaison. - * Override createLiaison for each XSLTLiaison. - * - * <a href="[email protected]">Stephane Bailliez</a> - */ -public abstract class AbstractXSLTLiaisonTest { - - private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); - - protected XSLTLiaison liaison; - - @Before - public void setUp() throws Exception { - liaison = createLiaison(); - } - - // to override - protected abstract XSLTLiaison createLiaison() throws Exception ; - - /** load the file from the caller classloader that loaded this class */ - protected File getFile(String name) throws FileNotFoundException { - URL url = getClass().getResource(name); - if (url == null){ - throw new FileNotFoundException("Unable to load '" + name + "' from classpath"); - } - return new File(FILE_UTILS.fromURI(url.toExternalForm())); - } - - /** keep it simple stupid */ - @Test - public void testTransform() throws Exception { - File xsl = getFile("/taskdefs/optional/xsltliaison-in.xsl"); - liaison.setStylesheet(xsl); - liaison.addParam("param", "value"); - File in = getFile("/taskdefs/optional/xsltliaison-in.xml"); - File out = new File("xsltliaison.tmp"); - out.deleteOnExit(); // just to be sure - try { - liaison.transform(in, out); - } finally { - out.delete(); - } - } - - @Test - public void testEncoding() throws Exception { - File xsl = getFile("/taskdefs/optional/xsltliaison-encoding-in.xsl"); - liaison.setStylesheet(xsl); - File in = getFile("/taskdefs/optional/xsltliaison-encoding-in.xml"); - File out = new File("xsltliaison-encoding.tmp"); - out.deleteOnExit(); // just to be sure - try { - liaison.transform(in, out); - Document doc = parseXML(out); - assertEquals("root",doc.getDocumentElement().getNodeName()); - assertEquals("message",doc.getDocumentElement().getFirstChild().getNodeName()); - assertEquals("\u00E9\u00E0\u00E8\u00EF\u00F9",doc.getDocumentElement().getFirstChild().getFirstChild().getNodeValue()); - } finally { - out.delete(); - } - } - - public Document parseXML(File file) throws Exception { - DocumentBuilderFactory dbfactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder dbuilder = dbfactory.newDocumentBuilder(); - return dbuilder.parse(file); - } -} +/* + * 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.apache.tools.ant.taskdefs.optional; + +import static org.junit.Assert.assertEquals; + +import java.io.File; +import java.io.FileNotFoundException; +import java.net.URL; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; + +import org.apache.tools.ant.taskdefs.XSLTLiaison; +import org.apache.tools.ant.util.FileUtils; +import org.junit.Before; +import org.junit.Test; +import org.w3c.dom.Document; + +/** + * Abtract testcase for XSLTLiaison. + * Override createLiaison for each XSLTLiaison. + * + * <a href="[email protected]">Stephane Bailliez</a> + */ +public abstract class AbstractXSLTLiaisonTest { + + private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); + + protected XSLTLiaison liaison; + + @Before + public void setUp() throws Exception { + liaison = createLiaison(); + } + + // to override + protected abstract XSLTLiaison createLiaison() throws Exception ; + + /** load the file from the caller classloader that loaded this class */ + protected File getFile(String name) throws FileNotFoundException { + URL url = getClass().getResource(name); + if (url == null){ + throw new FileNotFoundException("Unable to load '" + name + "' from classpath"); + } + return new File(FILE_UTILS.fromURI(url.toExternalForm())); + } + + /** keep it simple stupid */ + @Test + public void testTransform() throws Exception { + File xsl = getFile("/taskdefs/optional/xsltliaison-in.xsl"); + liaison.setStylesheet(xsl); + liaison.addParam("param", "value"); + File in = getFile("/taskdefs/optional/xsltliaison-in.xml"); + File out = new File("xsltliaison.tmp"); + out.deleteOnExit(); // just to be sure + try { + liaison.transform(in, out); + } finally { + out.delete(); + } + } + + @Test + public void testEncoding() throws Exception { + File xsl = getFile("/taskdefs/optional/xsltliaison-encoding-in.xsl"); + liaison.setStylesheet(xsl); + File in = getFile("/taskdefs/optional/xsltliaison-encoding-in.xml"); + File out = new File("xsltliaison-encoding.tmp"); + out.deleteOnExit(); // just to be sure + try { + liaison.transform(in, out); + Document doc = parseXML(out); + assertEquals("root",doc.getDocumentElement().getNodeName()); + assertEquals("message",doc.getDocumentElement().getFirstChild().getNodeName()); + assertEquals("\u00E9\u00E0\u00E8\u00EF\u00F9",doc.getDocumentElement().getFirstChild().getFirstChild().getNodeValue()); + } finally { + out.delete(); + } + } + + public Document parseXML(File file) throws Exception { + DocumentBuilderFactory dbfactory = DocumentBuilderFactory.newInstance(); + DocumentBuilder dbuilder = dbfactory.newDocumentBuilder(); + return dbuilder.parse(file); + } +} http://git-wip-us.apache.org/repos/asf/ant/blob/1ae68097/src/tests/junit/org/apache/tools/ant/taskdefs/optional/BeanShellScriptTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/BeanShellScriptTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/BeanShellScriptTest.java index 8802022..834f173 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/BeanShellScriptTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/BeanShellScriptTest.java @@ -1,48 +1,48 @@ -/* - * 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.apache.tools.ant.taskdefs.optional; - -import org.apache.tools.ant.BuildFileRule; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -/** - * Tests the examples of the <script> task docs. - * - * @since Ant 1.5.2 - */ -public class BeanShellScriptTest { - - @Rule - public BuildFileRule buildRule = new BuildFileRule(); - - @Before - public void setUp() { - buildRule.configureProject("src/etc/testcases/taskdefs/optional/script.xml"); - } - - @Test - public void testCanLoad() { - buildRule.executeTarget("useBeanshell"); - assertEquals("I'm here", buildRule.getLog()); - } - -} +/* + * 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.apache.tools.ant.taskdefs.optional; + +import org.apache.tools.ant.BuildFileRule; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +/** + * Tests the examples of the <script> task docs. + * + * @since Ant 1.5.2 + */ +public class BeanShellScriptTest { + + @Rule + public BuildFileRule buildRule = new BuildFileRule(); + + @Before + public void setUp() { + buildRule.configureProject("src/etc/testcases/taskdefs/optional/script.xml"); + } + + @Test + public void testCanLoad() { + buildRule.executeTarget("useBeanshell"); + assertEquals("I'm here", buildRule.getLog()); + } + +} http://git-wip-us.apache.org/repos/asf/ant/blob/1ae68097/src/tests/junit/org/apache/tools/ant/taskdefs/optional/EchoPropertiesTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/EchoPropertiesTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/EchoPropertiesTest.java index 925777c..2f351d4 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/EchoPropertiesTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/EchoPropertiesTest.java @@ -1,266 +1,266 @@ -/* - * 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.apache.tools.ant.taskdefs.optional; - -import static org.apache.tools.ant.AntAssert.assertContains; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import static org.junit.Assume.assumeTrue; - -import java.io.BufferedInputStream; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileReader; -import java.io.IOException; -import java.io.InputStream; -import java.util.Properties; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.BuildFileRule; -import org.apache.tools.ant.util.regexp.RegexpMatcherFactory; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; - -/** - * Tests the EchoProperties task. - * - * @created 17-Jan-2002 - * @since Ant 1.5 - */ -public class EchoPropertiesTest { - - private final static String TASKDEFS_DIR = "src/etc/testcases/taskdefs/optional/"; - private static final String GOOD_OUTFILE = "test.properties"; - private static final String GOOD_OUTFILE_XML = "test.xml"; - private static final String PREFIX_OUTFILE = "test-prefix.properties"; - private static final String TEST_VALUE = "isSet"; - - @Rule - public BuildFileRule buildRule = new BuildFileRule(); - - - @Before - public void setUp() { - buildRule.configureProject(TASKDEFS_DIR + "echoproperties.xml"); - buildRule.getProject().setProperty("test.property", TEST_VALUE); - } - - - @After - public void tearDown() { - buildRule.executeTarget("cleanup"); - } - - - @Test - public void testEchoToLog() { - buildRule.executeTarget("testEchoToLog"); - assertContains("test.property=" + TEST_VALUE, buildRule.getLog()); - } - - @Test - public void testEchoWithEmptyPrefixToLog() { - buildRule.executeTarget("testEchoWithEmptyPrefixToLog"); - assertContains("test.property="+TEST_VALUE, buildRule.getLog()); - } - - - @Test - public void testReadBadFile() { - try { - buildRule.executeTarget("testReadBadFile"); - fail("BuildException should have been thrown on bad file"); - } - catch(BuildException ex) { - assertContains("srcfile is a directory","srcfile is a directory!", ex.getMessage()); - } - } - - @Test - public void testReadBadFileNoFail() { - buildRule.executeTarget("testReadBadFileNoFail"); - assertContains("srcfile is a directory!", buildRule.getLog()); - } - - - @Test - public void testEchoToBadFile() { - try { - buildRule.executeTarget("testEchoToBadFile"); - fail("BuildException should have been thrown on destination file being a directory"); - } catch(BuildException ex) { - assertContains("destfile is a directory", "destfile is a directory!", ex.getMessage()); - } - } - - - @Test - public void testEchoToBadFileNoFail() { - buildRule.executeTarget("testEchoToBadFileNoFail"); - assertContains("destfile is a directory!", buildRule.getLog()); - } - - - @Test - public void testEchoToGoodFile() throws Exception { - buildRule.executeTarget("testEchoToGoodFile"); - assertGoodFile(); - } - - - @Test - public void testEchoToGoodFileXml() throws Exception { - buildRule.executeTarget("testEchoToGoodFileXml"); - - // read in the file - File f = createRelativeFile(GOOD_OUTFILE_XML); - FileReader fr = new FileReader(f); - BufferedReader br = new BufferedReader(fr); - try { - String read = null; - while ((read = br.readLine()) != null) { - if (read.indexOf("<property name=\"test.property\" value=\""+TEST_VALUE+"\" />") >= 0) { - // found the property we set - it's good. - return; - } - } - fail("did not encounter set property in generated file."); - } finally { - try { - fr.close(); - } catch(IOException e) {} - try { - br.close(); - } catch(IOException e) {} - } - } - - - @Test - public void testEchoToGoodFileFail() throws Exception { - buildRule.executeTarget("testEchoToGoodFileFail"); - assertGoodFile(); - } - - - @Test - public void testEchoToGoodFileNoFail() throws Exception { - buildRule.executeTarget("testEchoToGoodFileNoFail"); - assertGoodFile(); - } - - @Test - public void testEchoPrefix() throws Exception { - testEchoPrefixVarious("testEchoPrefix"); - } - - @Test - public void testEchoPrefixAsPropertyset() throws Exception { - testEchoPrefixVarious("testEchoPrefixAsPropertyset"); - } - - @Test - public void testEchoPrefixAsNegatedPropertyset() throws Exception { - testEchoPrefixVarious("testEchoPrefixAsNegatedPropertyset"); - } - - @Test - public void testEchoPrefixAsDoublyNegatedPropertyset() throws Exception { - testEchoPrefixVarious("testEchoPrefixAsDoublyNegatedPropertyset"); - } - - @Test - public void testWithPrefixAndRegex() throws Exception { - try { - buildRule.executeTarget("testWithPrefixAndRegex"); - fail("BuildException should have been thrown on Prefix and RegEx beng set"); - } catch (BuildException ex) { - assertEquals("The target must fail with prefix and regex attributes set", "Please specify either prefix or regex, but not both", ex.getMessage()); - } - } - - @Test - public void testWithEmptyPrefixAndRegex() throws Exception { - buildRule.executeTarget("testEchoWithEmptyPrefixToLog"); - assertContains("test.property="+TEST_VALUE, buildRule.getLog()); - } - - @Test - public void testWithRegex() throws Exception { - assumeTrue("Test skipped because no regexp matcher is present.", RegexpMatcherFactory.regexpMatcherPresent(buildRule.getProject())); - buildRule.executeTarget("testWithRegex"); - // the following line has been changed from checking ant.home to ant.version so the test will still work when run outside of an ant script - assertContains("ant.version=", buildRule.getFullLog()); - } - - private void testEchoPrefixVarious(String target) throws Exception { - buildRule.executeTarget(target); - Properties props = loadPropFile(PREFIX_OUTFILE); - assertEquals("prefix didn't include 'a.set' property", - "true", props.getProperty("a.set")); - assertNull("prefix failed to filter out property 'b.set'", - props.getProperty("b.set")); - } - - protected Properties loadPropFile(String relativeFilename) - throws IOException { - File f = createRelativeFile(relativeFilename); - Properties props=new Properties(); - InputStream in=null; - try { - in=new BufferedInputStream(new FileInputStream(f)); - props.load(in); - } finally { - if(in!=null) { - try { in.close(); } catch(IOException e) {} - } - } - return props; - } - - protected void assertGoodFile() throws Exception { - File f = createRelativeFile(GOOD_OUTFILE); - assertTrue("Did not create "+f.getAbsolutePath(), - f.exists()); - Properties props=loadPropFile(GOOD_OUTFILE); - props.list(System.out); - assertEquals("test property not found ", - TEST_VALUE, props.getProperty("test.property")); - } - - - protected String toAbsolute(String filename) { - return createRelativeFile(filename).getAbsolutePath(); - } - - - protected File createRelativeFile(String filename) { - if (filename.equals(".")) { - return buildRule.getProject().getBaseDir(); - } - // else - return new File(buildRule.getProject().getBaseDir(), filename); - } -} - +/* + * 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.apache.tools.ant.taskdefs.optional; + +import static org.apache.tools.ant.AntAssert.assertContains; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.junit.Assume.assumeTrue; + +import java.io.BufferedInputStream; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileReader; +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.BuildFileRule; +import org.apache.tools.ant.util.regexp.RegexpMatcherFactory; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; + +/** + * Tests the EchoProperties task. + * + * @created 17-Jan-2002 + * @since Ant 1.5 + */ +public class EchoPropertiesTest { + + private final static String TASKDEFS_DIR = "src/etc/testcases/taskdefs/optional/"; + private static final String GOOD_OUTFILE = "test.properties"; + private static final String GOOD_OUTFILE_XML = "test.xml"; + private static final String PREFIX_OUTFILE = "test-prefix.properties"; + private static final String TEST_VALUE = "isSet"; + + @Rule + public BuildFileRule buildRule = new BuildFileRule(); + + + @Before + public void setUp() { + buildRule.configureProject(TASKDEFS_DIR + "echoproperties.xml"); + buildRule.getProject().setProperty("test.property", TEST_VALUE); + } + + + @After + public void tearDown() { + buildRule.executeTarget("cleanup"); + } + + + @Test + public void testEchoToLog() { + buildRule.executeTarget("testEchoToLog"); + assertContains("test.property=" + TEST_VALUE, buildRule.getLog()); + } + + @Test + public void testEchoWithEmptyPrefixToLog() { + buildRule.executeTarget("testEchoWithEmptyPrefixToLog"); + assertContains("test.property="+TEST_VALUE, buildRule.getLog()); + } + + + @Test + public void testReadBadFile() { + try { + buildRule.executeTarget("testReadBadFile"); + fail("BuildException should have been thrown on bad file"); + } + catch(BuildException ex) { + assertContains("srcfile is a directory","srcfile is a directory!", ex.getMessage()); + } + } + + @Test + public void testReadBadFileNoFail() { + buildRule.executeTarget("testReadBadFileNoFail"); + assertContains("srcfile is a directory!", buildRule.getLog()); + } + + + @Test + public void testEchoToBadFile() { + try { + buildRule.executeTarget("testEchoToBadFile"); + fail("BuildException should have been thrown on destination file being a directory"); + } catch(BuildException ex) { + assertContains("destfile is a directory", "destfile is a directory!", ex.getMessage()); + } + } + + + @Test + public void testEchoToBadFileNoFail() { + buildRule.executeTarget("testEchoToBadFileNoFail"); + assertContains("destfile is a directory!", buildRule.getLog()); + } + + + @Test + public void testEchoToGoodFile() throws Exception { + buildRule.executeTarget("testEchoToGoodFile"); + assertGoodFile(); + } + + + @Test + public void testEchoToGoodFileXml() throws Exception { + buildRule.executeTarget("testEchoToGoodFileXml"); + + // read in the file + File f = createRelativeFile(GOOD_OUTFILE_XML); + FileReader fr = new FileReader(f); + BufferedReader br = new BufferedReader(fr); + try { + String read = null; + while ((read = br.readLine()) != null) { + if (read.indexOf("<property name=\"test.property\" value=\""+TEST_VALUE+"\" />") >= 0) { + // found the property we set - it's good. + return; + } + } + fail("did not encounter set property in generated file."); + } finally { + try { + fr.close(); + } catch(IOException e) {} + try { + br.close(); + } catch(IOException e) {} + } + } + + + @Test + public void testEchoToGoodFileFail() throws Exception { + buildRule.executeTarget("testEchoToGoodFileFail"); + assertGoodFile(); + } + + + @Test + public void testEchoToGoodFileNoFail() throws Exception { + buildRule.executeTarget("testEchoToGoodFileNoFail"); + assertGoodFile(); + } + + @Test + public void testEchoPrefix() throws Exception { + testEchoPrefixVarious("testEchoPrefix"); + } + + @Test + public void testEchoPrefixAsPropertyset() throws Exception { + testEchoPrefixVarious("testEchoPrefixAsPropertyset"); + } + + @Test + public void testEchoPrefixAsNegatedPropertyset() throws Exception { + testEchoPrefixVarious("testEchoPrefixAsNegatedPropertyset"); + } + + @Test + public void testEchoPrefixAsDoublyNegatedPropertyset() throws Exception { + testEchoPrefixVarious("testEchoPrefixAsDoublyNegatedPropertyset"); + } + + @Test + public void testWithPrefixAndRegex() throws Exception { + try { + buildRule.executeTarget("testWithPrefixAndRegex"); + fail("BuildException should have been thrown on Prefix and RegEx beng set"); + } catch (BuildException ex) { + assertEquals("The target must fail with prefix and regex attributes set", "Please specify either prefix or regex, but not both", ex.getMessage()); + } + } + + @Test + public void testWithEmptyPrefixAndRegex() throws Exception { + buildRule.executeTarget("testEchoWithEmptyPrefixToLog"); + assertContains("test.property="+TEST_VALUE, buildRule.getLog()); + } + + @Test + public void testWithRegex() throws Exception { + assumeTrue("Test skipped because no regexp matcher is present.", RegexpMatcherFactory.regexpMatcherPresent(buildRule.getProject())); + buildRule.executeTarget("testWithRegex"); + // the following line has been changed from checking ant.home to ant.version so the test will still work when run outside of an ant script + assertContains("ant.version=", buildRule.getFullLog()); + } + + private void testEchoPrefixVarious(String target) throws Exception { + buildRule.executeTarget(target); + Properties props = loadPropFile(PREFIX_OUTFILE); + assertEquals("prefix didn't include 'a.set' property", + "true", props.getProperty("a.set")); + assertNull("prefix failed to filter out property 'b.set'", + props.getProperty("b.set")); + } + + protected Properties loadPropFile(String relativeFilename) + throws IOException { + File f = createRelativeFile(relativeFilename); + Properties props=new Properties(); + InputStream in=null; + try { + in=new BufferedInputStream(new FileInputStream(f)); + props.load(in); + } finally { + if(in!=null) { + try { in.close(); } catch(IOException e) {} + } + } + return props; + } + + protected void assertGoodFile() throws Exception { + File f = createRelativeFile(GOOD_OUTFILE); + assertTrue("Did not create "+f.getAbsolutePath(), + f.exists()); + Properties props=loadPropFile(GOOD_OUTFILE); + props.list(System.out); + assertEquals("test property not found ", + TEST_VALUE, props.getProperty("test.property")); + } + + + protected String toAbsolute(String filename) { + return createRelativeFile(filename).getAbsolutePath(); + } + + + protected File createRelativeFile(String filename) { + if (filename.equals(".")) { + return buildRule.getProject().getBaseDir(); + } + // else + return new File(buildRule.getProject().getBaseDir(), filename); + } +} + http://git-wip-us.apache.org/repos/asf/ant/blob/1ae68097/src/tests/junit/org/apache/tools/ant/taskdefs/optional/JavahTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/JavahTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/JavahTest.java index 8b02fff..6e318ad 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/JavahTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/JavahTest.java @@ -1,60 +1,60 @@ -/* - * 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.apache.tools.ant.taskdefs.optional; - -import org.apache.tools.ant.BuildFileRule; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; - -import java.io.File; - -import static org.junit.Assert.assertTrue; - -public class JavahTest { - - private final static String BUILD_XML = - "src/etc/testcases/taskdefs/optional/javah/build.xml"; - - @Rule - public BuildFileRule buildRule = new BuildFileRule(); - - @Before - public void setUp() { - buildRule.configureProject(BUILD_XML); - } - - @After - public void tearDown() { - buildRule.executeTarget("tearDown"); - } - - @Test - public void testSimpleCompile() { - buildRule.executeTarget("simple-compile"); - assertTrue(new File(buildRule.getProject().getProperty("output"), "org_example_Foo.h") - .exists()); - } - - @Test - public void testCompileFileset() { - buildRule.executeTarget("test-fileset"); - assertTrue(new File(buildRule.getProject().getProperty("output"), "org_example_Foo.h").exists()); - } -} +/* + * 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.apache.tools.ant.taskdefs.optional; + +import org.apache.tools.ant.BuildFileRule; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; + +import java.io.File; + +import static org.junit.Assert.assertTrue; + +public class JavahTest { + + private final static String BUILD_XML = + "src/etc/testcases/taskdefs/optional/javah/build.xml"; + + @Rule + public BuildFileRule buildRule = new BuildFileRule(); + + @Before + public void setUp() { + buildRule.configureProject(BUILD_XML); + } + + @After + public void tearDown() { + buildRule.executeTarget("tearDown"); + } + + @Test + public void testSimpleCompile() { + buildRule.executeTarget("simple-compile"); + assertTrue(new File(buildRule.getProject().getProperty("output"), "org_example_Foo.h") + .exists()); + } + + @Test + public void testCompileFileset() { + buildRule.executeTarget("test-fileset"); + assertTrue(new File(buildRule.getProject().getProperty("output"), "org_example_Foo.h").exists()); + } +} http://git-wip-us.apache.org/repos/asf/ant/blob/1ae68097/src/tests/junit/org/apache/tools/ant/taskdefs/optional/JspcTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/JspcTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/JspcTest.java index 57475cc..62ba085 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/JspcTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/JspcTest.java @@ -1,200 +1,200 @@ -/* - * 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.apache.tools.ant.taskdefs.optional; - -import java.io.File; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.BuildFileRule; -import org.apache.tools.ant.taskdefs.optional.jsp.Jasper41Mangler; -import org.apache.tools.ant.taskdefs.optional.jsp.JspMangler; -import org.apache.tools.ant.taskdefs.optional.jsp.JspNameMangler; -import org.apache.tools.ant.taskdefs.optional.jsp.compilers.JspCompilerAdapter; -import org.apache.tools.ant.taskdefs.optional.jsp.compilers.JspCompilerAdapterFactory; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -/** - * Tests the Jspc task. - * - * created 07 March 2002 - * @since Ant 1.5 - */ -public class JspcTest { - - private final static String TASKDEFS_DIR = "src/etc/testcases/taskdefs/optional/"; - - - @Rule - public BuildFileRule buildRule = new BuildFileRule(); - - @Before - public void setUp() { - buildRule.configureProject(TASKDEFS_DIR + "jspc.xml"); - } - - - - @Test - public void testSimple() { - executeJspCompile("testSimple", "simple_jsp.java"); - } - - - @Test - public void testUriroot() throws Exception { - executeJspCompile("testUriroot", "uriroot_jsp.java"); - } - - - @Test - public void testXml() throws Exception { - executeJspCompile("testXml", "xml_jsp.java"); - } - - - /** - * try a keyword in a file - */ - @Test - public void testKeyword() throws Exception { - executeJspCompile("testKeyword", "default_jsp.java"); - } - - - /** - * what happens to 1nvalid-classname - */ - @Test - public void testInvalidClassname() throws Exception { - executeJspCompile("testInvalidClassname", - "_1nvalid_0002dclassname_jsp.java"); - } - - - @Test - public void testNoTld() throws Exception { - try { - buildRule.executeTarget("testNoTld"); - fail("Not found"); - } catch (BuildException ex) { - assertEquals("Java returned: 9", ex.getMessage()); - } - } - - - @Test - public void testNotAJspFile() throws Exception { - buildRule.executeTarget("testNotAJspFile"); - } - - /** - * webapp test is currently broken, because it picks up - * on the missing_tld file, and bails. - */ - @Ignore("picks up on the missing_tld file, and incorrectly bails") - @Test - public void testWebapp() throws Exception { - buildRule.executeTarget("testWebapp"); - } - - /** - * run a target then verify the named file gets created - * - * @param target Description of Parameter - * @param javafile Description of Parameter - */ - protected void executeJspCompile(String target, String javafile) { - buildRule.executeTarget(target); - assertJavaFileCreated(javafile); - } - - - /** - * verify that a named file was created - * - * @param filename Description of Parameter - */ - protected void assertJavaFileCreated(String filename) { - File file = getOutputFile(filename); - assertTrue("file " + filename + " not found", file.exists()); - assertTrue("file " + filename + " is empty", file.length() > 0); - } - - /** - * Gets the OutputFile attribute of the JspcTest object - * - * @param subpath Description of Parameter - * @return The OutputFile value - */ - protected File getOutputFile(String subpath) { - return new File(buildRule.getProject().getProperty("output"), subpath); - } - - /** - * verify that we select the appropriate mangler - */ - @Test - public void testJasperNameManglerSelection() { - JspCompilerAdapter adapter= - JspCompilerAdapterFactory.getCompiler("jasper", null,null); - JspMangler mangler=adapter.createMangler(); - assertTrue(mangler instanceof JspNameMangler); - adapter= JspCompilerAdapterFactory.getCompiler("jasper41", null, null); - mangler = adapter.createMangler(); - assertTrue(mangler instanceof Jasper41Mangler); - } - - @Test - public void testJasper41() { - JspMangler mangler = new Jasper41Mangler(); - //java keywords are not special - assertMapped(mangler, "for.jsp", "for_jsp"); - //underscores go in front of invalid start chars - assertMapped(mangler, "0.jsp", "_0_jsp"); - //underscores at the front get an underscore too - assertMapped(mangler, "_.jsp", "___jsp"); - //non java char at start => underscore then the the _hex value - assertMapped(mangler, "-.jsp", "__0002d_jsp"); - //and paths are stripped - char s = File.separatorChar; - assertMapped(mangler, "" + s + s + "somewhere" + s + "file" + s + "index.jsp", "index_jsp"); - } - - /** - * assert our mapping rules - * @param mangler - * @param filename - * @param classname - */ - protected void assertMapped(JspMangler mangler, String filename, String classname) { - String mappedname = mangler.mapJspToJavaName(new File(filename)); - assertTrue(filename+" should have mapped to "+classname - +" but instead mapped to "+mappedname, - classname.equals(mappedname)); - } - - -} - +/* + * 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.apache.tools.ant.taskdefs.optional; + +import java.io.File; + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.BuildFileRule; +import org.apache.tools.ant.taskdefs.optional.jsp.Jasper41Mangler; +import org.apache.tools.ant.taskdefs.optional.jsp.JspMangler; +import org.apache.tools.ant.taskdefs.optional.jsp.JspNameMangler; +import org.apache.tools.ant.taskdefs.optional.jsp.compilers.JspCompilerAdapter; +import org.apache.tools.ant.taskdefs.optional.jsp.compilers.JspCompilerAdapterFactory; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Rule; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +/** + * Tests the Jspc task. + * + * created 07 March 2002 + * @since Ant 1.5 + */ +public class JspcTest { + + private final static String TASKDEFS_DIR = "src/etc/testcases/taskdefs/optional/"; + + + @Rule + public BuildFileRule buildRule = new BuildFileRule(); + + @Before + public void setUp() { + buildRule.configureProject(TASKDEFS_DIR + "jspc.xml"); + } + + + + @Test + public void testSimple() { + executeJspCompile("testSimple", "simple_jsp.java"); + } + + + @Test + public void testUriroot() throws Exception { + executeJspCompile("testUriroot", "uriroot_jsp.java"); + } + + + @Test + public void testXml() throws Exception { + executeJspCompile("testXml", "xml_jsp.java"); + } + + + /** + * try a keyword in a file + */ + @Test + public void testKeyword() throws Exception { + executeJspCompile("testKeyword", "default_jsp.java"); + } + + + /** + * what happens to 1nvalid-classname + */ + @Test + public void testInvalidClassname() throws Exception { + executeJspCompile("testInvalidClassname", + "_1nvalid_0002dclassname_jsp.java"); + } + + + @Test + public void testNoTld() throws Exception { + try { + buildRule.executeTarget("testNoTld"); + fail("Not found"); + } catch (BuildException ex) { + assertEquals("Java returned: 9", ex.getMessage()); + } + } + + + @Test + public void testNotAJspFile() throws Exception { + buildRule.executeTarget("testNotAJspFile"); + } + + /** + * webapp test is currently broken, because it picks up + * on the missing_tld file, and bails. + */ + @Ignore("picks up on the missing_tld file, and incorrectly bails") + @Test + public void testWebapp() throws Exception { + buildRule.executeTarget("testWebapp"); + } + + /** + * run a target then verify the named file gets created + * + * @param target Description of Parameter + * @param javafile Description of Parameter + */ + protected void executeJspCompile(String target, String javafile) { + buildRule.executeTarget(target); + assertJavaFileCreated(javafile); + } + + + /** + * verify that a named file was created + * + * @param filename Description of Parameter + */ + protected void assertJavaFileCreated(String filename) { + File file = getOutputFile(filename); + assertTrue("file " + filename + " not found", file.exists()); + assertTrue("file " + filename + " is empty", file.length() > 0); + } + + /** + * Gets the OutputFile attribute of the JspcTest object + * + * @param subpath Description of Parameter + * @return The OutputFile value + */ + protected File getOutputFile(String subpath) { + return new File(buildRule.getProject().getProperty("output"), subpath); + } + + /** + * verify that we select the appropriate mangler + */ + @Test + public void testJasperNameManglerSelection() { + JspCompilerAdapter adapter= + JspCompilerAdapterFactory.getCompiler("jasper", null,null); + JspMangler mangler=adapter.createMangler(); + assertTrue(mangler instanceof JspNameMangler); + adapter= JspCompilerAdapterFactory.getCompiler("jasper41", null, null); + mangler = adapter.createMangler(); + assertTrue(mangler instanceof Jasper41Mangler); + } + + @Test + public void testJasper41() { + JspMangler mangler = new Jasper41Mangler(); + //java keywords are not special + assertMapped(mangler, "for.jsp", "for_jsp"); + //underscores go in front of invalid start chars + assertMapped(mangler, "0.jsp", "_0_jsp"); + //underscores at the front get an underscore too + assertMapped(mangler, "_.jsp", "___jsp"); + //non java char at start => underscore then the the _hex value + assertMapped(mangler, "-.jsp", "__0002d_jsp"); + //and paths are stripped + char s = File.separatorChar; + assertMapped(mangler, "" + s + s + "somewhere" + s + "file" + s + "index.jsp", "index_jsp"); + } + + /** + * assert our mapping rules + * @param mangler + * @param filename + * @param classname + */ + protected void assertMapped(JspMangler mangler, String filename, String classname) { + String mappedname = mangler.mapJspToJavaName(new File(filename)); + assertTrue(filename+" should have mapped to "+classname + +" but instead mapped to "+mappedname, + classname.equals(mappedname)); + } + + +} + http://git-wip-us.apache.org/repos/asf/ant/blob/1ae68097/src/tests/junit/org/apache/tools/ant/taskdefs/optional/Native2AsciiTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/Native2AsciiTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/Native2AsciiTest.java index 53da2af..3138e3a 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/Native2AsciiTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/Native2AsciiTest.java @@ -1,57 +1,57 @@ -/* - * 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.apache.tools.ant.taskdefs.optional; - -import java.io.File; - -import org.apache.tools.ant.BuildFileRule; -import org.apache.tools.ant.util.FileUtils; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; - -import static org.junit.Assert.assertTrue; - -public class Native2AsciiTest { - - private final static String BUILD_XML = - "src/etc/testcases/taskdefs/optional/native2ascii/build.xml"; - - @Rule - public BuildFileRule buildRule = new BuildFileRule(); - - @Before - public void setUp() { - buildRule.configureProject(BUILD_XML); - } - - @After - public void tearDown() { - buildRule.executeTarget("tearDown"); - } - - @Test - public void testIso8859_1() throws java.io.IOException { - buildRule.executeTarget("testIso8859-1"); - File in = buildRule.getProject().resolveFile("expected/iso8859-1.test"); - File out = new File(buildRule.getProject().getProperty("output"), "iso8859-1.test"); - assertTrue(FileUtils.getFileUtils().contentEquals(in, out, true)); - } -} +/* + * 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.apache.tools.ant.taskdefs.optional; + +import java.io.File; + +import org.apache.tools.ant.BuildFileRule; +import org.apache.tools.ant.util.FileUtils; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; + +import static org.junit.Assert.assertTrue; + +public class Native2AsciiTest { + + private final static String BUILD_XML = + "src/etc/testcases/taskdefs/optional/native2ascii/build.xml"; + + @Rule + public BuildFileRule buildRule = new BuildFileRule(); + + @Before + public void setUp() { + buildRule.configureProject(BUILD_XML); + } + + @After + public void tearDown() { + buildRule.executeTarget("tearDown"); + } + + @Test + public void testIso8859_1() throws java.io.IOException { + buildRule.executeTarget("testIso8859-1"); + File in = buildRule.getProject().resolveFile("expected/iso8859-1.test"); + File out = new File(buildRule.getProject().getProperty("output"), "iso8859-1.test"); + assertTrue(FileUtils.getFileUtils().contentEquals(in, out, true)); + } +}
