http://git-wip-us.apache.org/repos/asf/ant/blob/1ae68097/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XsltTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XsltTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XsltTest.java index a5b71de..594dada 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XsltTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XsltTest.java @@ -1,86 +1,86 @@ -/* - * 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.junit.Before; -import org.junit.Rule; -import org.junit.Test; - -import static org.junit.Assert.fail; - -/** - * Tests the {@link org.apache.tools.ant.taskdefs.XSLTProcess} task. - * TODO merge with {@link org.apache.tools.ant.taskdefs.StyleTest}? - * @since Ant 1.5 - */ -public class XsltTest { - - /** - * where tasks run - */ - 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 + "xslt.xml"); - } - - - @Test - public void testCatchNoDtd() { - try { - buildRule.executeTarget("testCatchNoDtd"); - fail("Expected failure"); - } catch(BuildException ex) { - //TODO assert exception message - } - } - - @Test - public void testCatalog() throws Exception { - buildRule.executeTarget("testCatalog"); - } - - @Test - public void testOutputProperty() throws Exception { - buildRule.executeTarget("testOutputProperty"); - } - - @Test - public void testXMLWithEntitiesInNonAsciiPath() throws Exception { - buildRule.executeTarget("testXMLWithEntitiesInNonAsciiPath"); - } - - /** - * check that the system id gets set properly on stylesheets. - * @throws Exception if something goes wrong. - */ - @Test - public void testStyleSheetWithInclude() throws Exception { - buildRule.executeTarget("testStyleSheetWithInclude"); - if (buildRule.getLog().indexOf("java.io.FileNotFoundException") != -1) { - fail("xsl:include was not found"); - } - } -} - +/* + * 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.junit.Before; +import org.junit.Rule; +import org.junit.Test; + +import static org.junit.Assert.fail; + +/** + * Tests the {@link org.apache.tools.ant.taskdefs.XSLTProcess} task. + * TODO merge with {@link org.apache.tools.ant.taskdefs.StyleTest}? + * @since Ant 1.5 + */ +public class XsltTest { + + /** + * where tasks run + */ + 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 + "xslt.xml"); + } + + + @Test + public void testCatchNoDtd() { + try { + buildRule.executeTarget("testCatchNoDtd"); + fail("Expected failure"); + } catch(BuildException ex) { + //TODO assert exception message + } + } + + @Test + public void testCatalog() throws Exception { + buildRule.executeTarget("testCatalog"); + } + + @Test + public void testOutputProperty() throws Exception { + buildRule.executeTarget("testOutputProperty"); + } + + @Test + public void testXMLWithEntitiesInNonAsciiPath() throws Exception { + buildRule.executeTarget("testXMLWithEntitiesInNonAsciiPath"); + } + + /** + * check that the system id gets set properly on stylesheets. + * @throws Exception if something goes wrong. + */ + @Test + public void testStyleSheetWithInclude() throws Exception { + buildRule.executeTarget("testStyleSheetWithInclude"); + if (buildRule.getLog().indexOf("java.io.FileNotFoundException") != -1) { + fail("xsl:include was not found"); + } + } +} +
http://git-wip-us.apache.org/repos/asf/ant/blob/1ae68097/src/tests/junit/org/apache/tools/ant/taskdefs/optional/depend/DependTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/depend/DependTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/depend/DependTest.java index 95c1eb0..01e0575 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/depend/DependTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/depend/DependTest.java @@ -1,213 +1,213 @@ -/* - * 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.depend; - -import java.io.File; -import java.util.Hashtable; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.BuildFileRule; -import org.apache.tools.ant.DirectoryScanner; -import org.apache.tools.ant.FileUtilities; -import org.apache.tools.ant.types.FileSet; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; - -import static org.apache.tools.ant.AntAssert.assertContains; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -/** - * Testcase for the Depend optional task. - * - */ -public class DependTest { - public static final String RESULT_FILESET = "result"; - - public static final String TEST_BUILD_FILE - = "src/etc/testcases/taskdefs/optional/depend/depend.xml"; - - @Rule - public BuildFileRule buildRule = new BuildFileRule(); - - @Before - public void setUp() { - buildRule.configureProject(TEST_BUILD_FILE); - } - - /** - * Test direct dependency removal - */ - @Test - public void testDirect() { - buildRule.executeTarget("src1setup"); - buildRule.executeTarget("compile"); - - FileUtilities.rollbackTimetamps(new File(buildRule.getProject().getProperty("tempsrc.dir")), 5); - FileUtilities.rollbackTimetamps(new File(buildRule.getProject().getProperty("classes.dir")), 5); - - buildRule.executeTarget("testdirect"); - Hashtable files = getResultFiles(); - assertEquals("Depend did not leave correct number of files", 3, - files.size()); - assertTrue("Result did not contain A.class", - files.containsKey("A.class")); - assertTrue("Result did not contain D.class", - files.containsKey("D.class")); - } - - /** - * Test dependency traversal (closure) - */ - @Test - public void testClosure() { - buildRule.executeTarget("src1setup"); - buildRule.executeTarget("compile"); - - FileUtilities.rollbackTimetamps(new File(buildRule.getProject().getProperty("tempsrc.dir")), 5); - FileUtilities.rollbackTimetamps(new File(buildRule.getProject().getProperty("classes.dir")), 5); - - buildRule.executeTarget("testclosure"); - Hashtable files = getResultFiles(); - assertTrue("Depend did not leave correct number of files", - files.size() <= 2); - assertTrue("Result did not contain D.class", - files.containsKey("D.class")); - } - - /** - * Test that inner class dependencies trigger deletion of the outer class - */ - @Test - public void testInner() { - buildRule.executeTarget("src2setup"); - buildRule.executeTarget("compile"); - - FileUtilities.rollbackTimetamps(new File(buildRule.getProject().getProperty("tempsrc.dir")), 5); - FileUtilities.rollbackTimetamps(new File(buildRule.getProject().getProperty("classes.dir")), 5); - - - buildRule.executeTarget("testinner"); - assertEquals("Depend did not leave correct number of files", 0, - getResultFiles().size()); - } - - /** - * Test that multi-leve inner class dependencies trigger deletion of - * the outer class - */ - @Test - public void testInnerInner() { - buildRule.executeTarget("src3setup"); - buildRule.executeTarget("compile"); - - FileUtilities.rollbackTimetamps(new File(buildRule.getProject().getProperty("tempsrc.dir")), 5); - FileUtilities.rollbackTimetamps(new File(buildRule.getProject().getProperty("classes.dir")), 5); - - buildRule.executeTarget("testinnerinner"); - assertEquals("Depend did not leave correct number of files", 0, - getResultFiles().size()); - } - - /** - * Test that an exception is thrown when there is no source - */ - @Test - public void testNoSource() { - try { - buildRule.executeTarget("testnosource"); - fail("Build exception expected: No source specified"); - } catch(BuildException ex) { - assertContains("srcdir attribute must be set", ex.getMessage()); - } - } - - /** - * Test that an exception is thrown when the source attribute is empty - */ - @Test - public void testEmptySource() { - try { - buildRule.executeTarget("testemptysource"); - fail("Build exception expected: No source specified"); - } catch(BuildException ex) { - assertContains("srcdir attribute must be non-empty", ex.getMessage()); - } - } - - /** - * Read the result fileset into a Hashtable - * - * @return a Hashtable containing the names of the files in the result - * fileset - */ - private Hashtable getResultFiles() { - FileSet resultFileSet = (FileSet) buildRule.getProject().getReference(RESULT_FILESET); - DirectoryScanner scanner = resultFileSet.getDirectoryScanner(buildRule.getProject()); - String[] scannedFiles = scanner.getIncludedFiles(); - Hashtable files = new Hashtable(); - for (int i = 0; i < scannedFiles.length; ++i) { - files.put(scannedFiles[i], scannedFiles[i]); - } - return files; - } - - - /** - * Test mutual dependency between inner and outer do not cause both to be - * deleted - */ - @Test - public void testInnerClosure() { - buildRule.executeTarget("testinnerclosure"); - assertEquals("Depend did not leave correct number of files", 4, - getResultFiles().size()); - } - - /** - * Test the operation of the cache - */ - @Test - public void testCache() { - buildRule.executeTarget("testcache"); - } - - /** - * Test the detection and warning of non public classes - */ - @Test - public void testNonPublic() { - buildRule.executeTarget("src5setup"); - buildRule.executeTarget("compile"); - - FileUtilities.rollbackTimetamps(new File(buildRule.getProject().getProperty("tempsrc.dir")), 5); - FileUtilities.rollbackTimetamps(new File(buildRule.getProject().getProperty("classes.dir")), 5); - - buildRule.executeTarget("testnonpublic"); - String log = buildRule.getLog(); - assertContains("Expected warning about APrivate", - "The class APrivate in file", log); - assertContains("but has not been deleted because its source file " - + "could not be determined", - "The class APrivate in file", log); - } - -} +/* + * 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.depend; + +import java.io.File; +import java.util.Hashtable; + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.BuildFileRule; +import org.apache.tools.ant.DirectoryScanner; +import org.apache.tools.ant.FileUtilities; +import org.apache.tools.ant.types.FileSet; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; + +import static org.apache.tools.ant.AntAssert.assertContains; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +/** + * Testcase for the Depend optional task. + * + */ +public class DependTest { + public static final String RESULT_FILESET = "result"; + + public static final String TEST_BUILD_FILE + = "src/etc/testcases/taskdefs/optional/depend/depend.xml"; + + @Rule + public BuildFileRule buildRule = new BuildFileRule(); + + @Before + public void setUp() { + buildRule.configureProject(TEST_BUILD_FILE); + } + + /** + * Test direct dependency removal + */ + @Test + public void testDirect() { + buildRule.executeTarget("src1setup"); + buildRule.executeTarget("compile"); + + FileUtilities.rollbackTimetamps(new File(buildRule.getProject().getProperty("tempsrc.dir")), 5); + FileUtilities.rollbackTimetamps(new File(buildRule.getProject().getProperty("classes.dir")), 5); + + buildRule.executeTarget("testdirect"); + Hashtable files = getResultFiles(); + assertEquals("Depend did not leave correct number of files", 3, + files.size()); + assertTrue("Result did not contain A.class", + files.containsKey("A.class")); + assertTrue("Result did not contain D.class", + files.containsKey("D.class")); + } + + /** + * Test dependency traversal (closure) + */ + @Test + public void testClosure() { + buildRule.executeTarget("src1setup"); + buildRule.executeTarget("compile"); + + FileUtilities.rollbackTimetamps(new File(buildRule.getProject().getProperty("tempsrc.dir")), 5); + FileUtilities.rollbackTimetamps(new File(buildRule.getProject().getProperty("classes.dir")), 5); + + buildRule.executeTarget("testclosure"); + Hashtable files = getResultFiles(); + assertTrue("Depend did not leave correct number of files", + files.size() <= 2); + assertTrue("Result did not contain D.class", + files.containsKey("D.class")); + } + + /** + * Test that inner class dependencies trigger deletion of the outer class + */ + @Test + public void testInner() { + buildRule.executeTarget("src2setup"); + buildRule.executeTarget("compile"); + + FileUtilities.rollbackTimetamps(new File(buildRule.getProject().getProperty("tempsrc.dir")), 5); + FileUtilities.rollbackTimetamps(new File(buildRule.getProject().getProperty("classes.dir")), 5); + + + buildRule.executeTarget("testinner"); + assertEquals("Depend did not leave correct number of files", 0, + getResultFiles().size()); + } + + /** + * Test that multi-leve inner class dependencies trigger deletion of + * the outer class + */ + @Test + public void testInnerInner() { + buildRule.executeTarget("src3setup"); + buildRule.executeTarget("compile"); + + FileUtilities.rollbackTimetamps(new File(buildRule.getProject().getProperty("tempsrc.dir")), 5); + FileUtilities.rollbackTimetamps(new File(buildRule.getProject().getProperty("classes.dir")), 5); + + buildRule.executeTarget("testinnerinner"); + assertEquals("Depend did not leave correct number of files", 0, + getResultFiles().size()); + } + + /** + * Test that an exception is thrown when there is no source + */ + @Test + public void testNoSource() { + try { + buildRule.executeTarget("testnosource"); + fail("Build exception expected: No source specified"); + } catch(BuildException ex) { + assertContains("srcdir attribute must be set", ex.getMessage()); + } + } + + /** + * Test that an exception is thrown when the source attribute is empty + */ + @Test + public void testEmptySource() { + try { + buildRule.executeTarget("testemptysource"); + fail("Build exception expected: No source specified"); + } catch(BuildException ex) { + assertContains("srcdir attribute must be non-empty", ex.getMessage()); + } + } + + /** + * Read the result fileset into a Hashtable + * + * @return a Hashtable containing the names of the files in the result + * fileset + */ + private Hashtable getResultFiles() { + FileSet resultFileSet = (FileSet) buildRule.getProject().getReference(RESULT_FILESET); + DirectoryScanner scanner = resultFileSet.getDirectoryScanner(buildRule.getProject()); + String[] scannedFiles = scanner.getIncludedFiles(); + Hashtable files = new Hashtable(); + for (int i = 0; i < scannedFiles.length; ++i) { + files.put(scannedFiles[i], scannedFiles[i]); + } + return files; + } + + + /** + * Test mutual dependency between inner and outer do not cause both to be + * deleted + */ + @Test + public void testInnerClosure() { + buildRule.executeTarget("testinnerclosure"); + assertEquals("Depend did not leave correct number of files", 4, + getResultFiles().size()); + } + + /** + * Test the operation of the cache + */ + @Test + public void testCache() { + buildRule.executeTarget("testcache"); + } + + /** + * Test the detection and warning of non public classes + */ + @Test + public void testNonPublic() { + buildRule.executeTarget("src5setup"); + buildRule.executeTarget("compile"); + + FileUtilities.rollbackTimetamps(new File(buildRule.getProject().getProperty("tempsrc.dir")), 5); + FileUtilities.rollbackTimetamps(new File(buildRule.getProject().getProperty("classes.dir")), 5); + + buildRule.executeTarget("testnonpublic"); + String log = buildRule.getLog(); + assertContains("Expected warning about APrivate", + "The class APrivate in file", log); + assertContains("but has not been deleted because its source file " + + "could not be determined", + "The class APrivate in file", log); + } + +} http://git-wip-us.apache.org/repos/asf/ant/blob/1ae68097/src/tests/junit/org/apache/tools/ant/taskdefs/optional/i18n/TranslateTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/i18n/TranslateTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/i18n/TranslateTest.java index 6abc4f2..b8749c0 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/i18n/TranslateTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/i18n/TranslateTest.java @@ -1,87 +1,87 @@ -/* - * 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.i18n; - -import org.apache.tools.ant.BuildFileRule; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; - -import static org.junit.Assert.assertTrue; - -/** - * Tests the Translate task. - * - * @since Ant 1.6 - */ -public class TranslateTest { - - @Rule - public final BuildFileRule buildRule = new BuildFileRule(); - - static private final int BUF_SIZE = 32768; - - private final static String TASKDEFS_DIR = "src/etc/testcases/taskdefs/optional/i18n/translate"; - - - - @Before - public void setUp() { - buildRule.configureProject(TASKDEFS_DIR + "/translate.xml"); - } - - @Test - public void test1() throws IOException { - buildRule.executeTarget("test1"); - assertTrue("translation of "+ TASKDEFS_DIR + "/input/template.txt",compareFiles(new File(buildRule.getProject().getBaseDir(), "expected/de/template.txt"), - new File(buildRule.getOutputDir(), "de/template.txt"))); - } - private boolean compareFiles(File file1, File file2) throws IOException { - if (!file1.exists() || !file2.exists()) { - return false; - } - - if (file1.length() != file2.length()) { - return false; - } - - // byte - byte compare - byte[] buffer1 = new byte[BUF_SIZE]; - byte[] buffer2 = new byte[BUF_SIZE]; - - FileInputStream fis1 = new FileInputStream(file1); - FileInputStream fis2 = new FileInputStream(file2); - int index = 0; - int read = 0; - while ((read = fis1.read(buffer1)) != -1) { - fis2.read(buffer2); - for (int i = 0; i < read; ++i, ++index) { - if (buffer1[i] != buffer2[i]) { - return false; - } - } - } - return 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.i18n; + +import org.apache.tools.ant.BuildFileRule; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; + +import static org.junit.Assert.assertTrue; + +/** + * Tests the Translate task. + * + * @since Ant 1.6 + */ +public class TranslateTest { + + @Rule + public final BuildFileRule buildRule = new BuildFileRule(); + + static private final int BUF_SIZE = 32768; + + private final static String TASKDEFS_DIR = "src/etc/testcases/taskdefs/optional/i18n/translate"; + + + + @Before + public void setUp() { + buildRule.configureProject(TASKDEFS_DIR + "/translate.xml"); + } + + @Test + public void test1() throws IOException { + buildRule.executeTarget("test1"); + assertTrue("translation of "+ TASKDEFS_DIR + "/input/template.txt",compareFiles(new File(buildRule.getProject().getBaseDir(), "expected/de/template.txt"), + new File(buildRule.getOutputDir(), "de/template.txt"))); + } + private boolean compareFiles(File file1, File file2) throws IOException { + if (!file1.exists() || !file2.exists()) { + return false; + } + + if (file1.length() != file2.length()) { + return false; + } + + // byte - byte compare + byte[] buffer1 = new byte[BUF_SIZE]; + byte[] buffer2 = new byte[BUF_SIZE]; + + FileInputStream fis1 = new FileInputStream(file1); + FileInputStream fis2 = new FileInputStream(file2); + int index = 0; + int read = 0; + while ((read = fis1.read(buffer1)) != -1) { + fis2.read(buffer2); + for (int i = 0; i < read; ++i, ++index) { + if (buffer1[i] != buffer2[i]) { + return false; + } + } + } + return true; + } +} + http://git-wip-us.apache.org/repos/asf/ant/blob/1ae68097/src/tests/junit/org/apache/tools/ant/taskdefs/optional/image/ImageTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/image/ImageTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/image/ImageTest.java index be79262..a13a466 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/image/ImageTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/image/ImageTest.java @@ -1,133 +1,133 @@ -/* - * 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.image; - -import org.apache.tools.ant.AntAssert; -import org.apache.tools.ant.BuildFileRule; -import org.apache.tools.ant.util.FileUtils; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; - -import java.io.File; - -import static org.junit.Assert.assertTrue; -import static org.junit.Assume.assumeTrue; - - -/** - * Tests the Image task. - * - * @since Ant 1.5 - */ -public class ImageTest { - - private final static String TASKDEFS_DIR = - "src/etc/testcases/taskdefs/optional/image/"; - private final static String LARGEIMAGE = "largeimage.jpg"; - - private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); - - @Rule - public BuildFileRule buildRule = new BuildFileRule(); - - @Before - public void setUp() { - buildRule.configureProject(TASKDEFS_DIR + "image.xml"); - } - - - @Test - public void testEchoToLog() { - buildRule.executeTarget("testEchoToLog"); - AntAssert.assertContains("Processing File", buildRule.getLog()); - } - - @Test - public void testSimpleScale(){ - buildRule.executeTarget("testSimpleScale"); - AntAssert.assertContains("Processing File", buildRule.getLog()); - - File f = new File(buildRule.getOutputDir(), LARGEIMAGE); - assertTrue( - "Did not create "+f.getAbsolutePath(), - f.exists()); - - } - - @Test - public void testOverwriteTrue() throws InterruptedException { - buildRule.executeTarget("testSimpleScale"); - AntAssert.assertContains("Processing File", buildRule.getLog()); - File f = new File(buildRule.getOutputDir(), LARGEIMAGE); - assumeTrue("Could not change file modificaiton date", - f.setLastModified(f.lastModified() - (FILE_UTILS.getFileTimestampGranularity() * 2))); - long lastModified = f.lastModified(); - buildRule.executeTarget("testOverwriteTrue"); - AntAssert.assertContains("Processing File", buildRule.getLog()); - f = new File(buildRule.getOutputDir(), LARGEIMAGE); - long overwrittenLastModified = f.lastModified(); - assertTrue("File was not overwritten.", - lastModified < overwrittenLastModified); - } - - @Test - public void testOverwriteFalse() { - buildRule.executeTarget("testSimpleScale"); - AntAssert.assertContains("Processing File", buildRule.getLog()); - File f = new File(buildRule.getOutputDir(), LARGEIMAGE); - long lastModified = f.lastModified(); - buildRule.executeTarget("testOverwriteFalse"); - AntAssert.assertContains("Processing File", buildRule.getLog()); - f = new File(buildRule.getOutputDir(), LARGEIMAGE); - long overwrittenLastModified = f.lastModified(); - assertTrue("File was overwritten.", - lastModified == overwrittenLastModified); - } - - @Test - public void testSimpleScaleWithMapper() { - buildRule.executeTarget("testSimpleScaleWithMapper"); - AntAssert.assertContains("Processing File", buildRule.getLog()); - File f = new File(buildRule.getOutputDir(), "scaled-" + LARGEIMAGE); - assertTrue( - "Did not create "+f.getAbsolutePath(), - f.exists()); - - } - - @Test - @Ignore("Previously named in a manner to prevent execution") - public void testFailOnError() { - try { - buildRule.executeTarget("testFailOnError"); - AntAssert.assertContains("Unable to process image stream", buildRule.getLog()); - } - catch (RuntimeException re){ - assertTrue("Run time exception should say " - + "'Unable to process image stream'. :" - + re.toString(), - re.toString() - .indexOf("Unable to process image stream") > -1); - } - } - -} - +/* + * 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.image; + +import org.apache.tools.ant.AntAssert; +import org.apache.tools.ant.BuildFileRule; +import org.apache.tools.ant.util.FileUtils; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Rule; +import org.junit.Test; + +import java.io.File; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assume.assumeTrue; + + +/** + * Tests the Image task. + * + * @since Ant 1.5 + */ +public class ImageTest { + + private final static String TASKDEFS_DIR = + "src/etc/testcases/taskdefs/optional/image/"; + private final static String LARGEIMAGE = "largeimage.jpg"; + + private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); + + @Rule + public BuildFileRule buildRule = new BuildFileRule(); + + @Before + public void setUp() { + buildRule.configureProject(TASKDEFS_DIR + "image.xml"); + } + + + @Test + public void testEchoToLog() { + buildRule.executeTarget("testEchoToLog"); + AntAssert.assertContains("Processing File", buildRule.getLog()); + } + + @Test + public void testSimpleScale(){ + buildRule.executeTarget("testSimpleScale"); + AntAssert.assertContains("Processing File", buildRule.getLog()); + + File f = new File(buildRule.getOutputDir(), LARGEIMAGE); + assertTrue( + "Did not create "+f.getAbsolutePath(), + f.exists()); + + } + + @Test + public void testOverwriteTrue() throws InterruptedException { + buildRule.executeTarget("testSimpleScale"); + AntAssert.assertContains("Processing File", buildRule.getLog()); + File f = new File(buildRule.getOutputDir(), LARGEIMAGE); + assumeTrue("Could not change file modificaiton date", + f.setLastModified(f.lastModified() - (FILE_UTILS.getFileTimestampGranularity() * 2))); + long lastModified = f.lastModified(); + buildRule.executeTarget("testOverwriteTrue"); + AntAssert.assertContains("Processing File", buildRule.getLog()); + f = new File(buildRule.getOutputDir(), LARGEIMAGE); + long overwrittenLastModified = f.lastModified(); + assertTrue("File was not overwritten.", + lastModified < overwrittenLastModified); + } + + @Test + public void testOverwriteFalse() { + buildRule.executeTarget("testSimpleScale"); + AntAssert.assertContains("Processing File", buildRule.getLog()); + File f = new File(buildRule.getOutputDir(), LARGEIMAGE); + long lastModified = f.lastModified(); + buildRule.executeTarget("testOverwriteFalse"); + AntAssert.assertContains("Processing File", buildRule.getLog()); + f = new File(buildRule.getOutputDir(), LARGEIMAGE); + long overwrittenLastModified = f.lastModified(); + assertTrue("File was overwritten.", + lastModified == overwrittenLastModified); + } + + @Test + public void testSimpleScaleWithMapper() { + buildRule.executeTarget("testSimpleScaleWithMapper"); + AntAssert.assertContains("Processing File", buildRule.getLog()); + File f = new File(buildRule.getOutputDir(), "scaled-" + LARGEIMAGE); + assertTrue( + "Did not create "+f.getAbsolutePath(), + f.exists()); + + } + + @Test + @Ignore("Previously named in a manner to prevent execution") + public void testFailOnError() { + try { + buildRule.executeTarget("testFailOnError"); + AntAssert.assertContains("Unable to process image stream", buildRule.getLog()); + } + catch (RuntimeException re){ + assertTrue("Run time exception should say " + + "'Unable to process image stream'. :" + + re.toString(), + re.toString() + .indexOf("Unable to process image stream") > -1); + } + } + +} + http://git-wip-us.apache.org/repos/asf/ant/blob/1ae68097/src/tests/junit/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTest.java index 545b7cb..54c6055 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTest.java @@ -1,99 +1,99 @@ -/* - * 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.jdepend; - -import org.apache.tools.ant.AntAssert; -import org.apache.tools.ant.BuildFileRule; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; - -/** - * Testcase for the JDepend optional task. - * - */ -public class JDependTest { - - @Rule - public BuildFileRule buildRule = new BuildFileRule(); - - @Before - public void setUp() { - buildRule.configureProject( - "src/etc/testcases/taskdefs/optional/jdepend/jdepend.xml"); - } - - /** - * Test simple - */ - @Test - public void testSimple() { - buildRule.executeTarget("simple"); - AntAssert.assertContains("Package: org.apache.tools.ant.util.facade", - buildRule.getOutput()); - } - - /** - * Test xml - */ - @Test - public void testXml() { - buildRule.executeTarget("xml"); - AntAssert.assertContains("<DependsUpon>", buildRule.getOutput()); - } - - /** - * Test fork - * - forked output goes to log - */ - @Test - public void testFork() { - buildRule.executeTarget("fork"); - AntAssert.assertContains("Package: org.apache.tools.ant.util.facade", buildRule.getLog()); - } - - /** - * Test fork xml - */ - @Test - public void testForkXml() { - buildRule.executeTarget("fork-xml"); - AntAssert.assertContains("<DependsUpon>", buildRule.getLog()); - } - - /** - * Test timeout - */ - @Test - public void testTimeout() { - buildRule.executeTarget("fork-xml"); - AntAssert.assertContains( "JDepend FAILED - Timed out", buildRule.getLog()); - } - - - /** - * Test timeout without timing out - */ - @Test - public void testTimeoutNot() { - buildRule.executeTarget("fork-timeout-not"); - AntAssert.assertContains("Package: org.apache.tools.ant.util.facade", 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.jdepend; + +import org.apache.tools.ant.AntAssert; +import org.apache.tools.ant.BuildFileRule; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; + +/** + * Testcase for the JDepend optional task. + * + */ +public class JDependTest { + + @Rule + public BuildFileRule buildRule = new BuildFileRule(); + + @Before + public void setUp() { + buildRule.configureProject( + "src/etc/testcases/taskdefs/optional/jdepend/jdepend.xml"); + } + + /** + * Test simple + */ + @Test + public void testSimple() { + buildRule.executeTarget("simple"); + AntAssert.assertContains("Package: org.apache.tools.ant.util.facade", + buildRule.getOutput()); + } + + /** + * Test xml + */ + @Test + public void testXml() { + buildRule.executeTarget("xml"); + AntAssert.assertContains("<DependsUpon>", buildRule.getOutput()); + } + + /** + * Test fork + * - forked output goes to log + */ + @Test + public void testFork() { + buildRule.executeTarget("fork"); + AntAssert.assertContains("Package: org.apache.tools.ant.util.facade", buildRule.getLog()); + } + + /** + * Test fork xml + */ + @Test + public void testForkXml() { + buildRule.executeTarget("fork-xml"); + AntAssert.assertContains("<DependsUpon>", buildRule.getLog()); + } + + /** + * Test timeout + */ + @Test + public void testTimeout() { + buildRule.executeTarget("fork-xml"); + AntAssert.assertContains( "JDepend FAILED - Timed out", buildRule.getLog()); + } + + + /** + * Test timeout without timing out + */ + @Test + public void testTimeoutNot() { + buildRule.executeTarget("fork-timeout-not"); + AntAssert.assertContains("Package: org.apache.tools.ant.util.facade", buildRule.getLog()); + } + +} http://git-wip-us.apache.org/repos/asf/ant/blob/1ae68097/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/BatchTestTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/BatchTestTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/BatchTestTest.java index 52a12ec..a969499 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/BatchTestTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/BatchTestTest.java @@ -1,121 +1,121 @@ -/* - * 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.junit; - - -import static org.junit.Assert.fail; -import static org.junit.Assert.assertArrayEquals; - -import org.junit.Test; - -/** - * - * @author Marian Petras - */ -public class BatchTestTest { - - @Test - public void testParseTestMethodNamesList() { - try { - JUnitTest.parseTestMethodNamesList(null); - fail("IllegalArgumentException expected when the param is <null>"); - } catch (IllegalArgumentException ex) { - //this is an expected exception - } - - assertArrayEquals(new String[0], JUnitTest.parseTestMethodNamesList("")); - assertArrayEquals(new String[0], JUnitTest.parseTestMethodNamesList(" ")); - assertArrayEquals(new String[0], JUnitTest.parseTestMethodNamesList(" ")); - - checkParseCausesIAE(","); - checkParseCausesIAE(" ,"); - checkParseCausesIAE(", "); - checkParseCausesIAE(" , "); - checkParseCausesIAE(",a"); - checkParseCausesIAE(" ,a"); - checkParseCausesIAE(" ,a"); - checkParseCausesIAE(" , a"); - checkParseCausesIAE(" ,a "); - checkParseCausesIAE(" ,a ,"); - checkParseCausesIAE("ab,,cd"); - checkParseCausesIAE("ab, ,cd"); - checkParseCausesIAE("ab, ,cd"); - checkParseCausesIAE("ab, ,cd,"); - checkParseCausesIAE(",ab, ,cd,"); - - assertArrayEquals(new String[] {"abc"}, JUnitTest.parseTestMethodNamesList("abc")); - assertArrayEquals(new String[] {"abc"}, JUnitTest.parseTestMethodNamesList("abc ")); - assertArrayEquals(new String[] {"abc"}, JUnitTest.parseTestMethodNamesList(" abc")); - assertArrayEquals(new String[] {"abc"}, JUnitTest.parseTestMethodNamesList(" abc ")); - assertArrayEquals(new String[] {"abc"}, JUnitTest.parseTestMethodNamesList("abc ")); - assertArrayEquals(new String[] {"abc"}, JUnitTest.parseTestMethodNamesList("abc,")); - assertArrayEquals(new String[] {"abc"}, JUnitTest.parseTestMethodNamesList("abc, ")); - assertArrayEquals(new String[] {"abc"}, JUnitTest.parseTestMethodNamesList("abc ,")); - assertArrayEquals(new String[] {"abc"}, JUnitTest.parseTestMethodNamesList("abc , ")); - assertArrayEquals(new String[] {"abc"}, JUnitTest.parseTestMethodNamesList(" abc ,")); - - /* legal Java identifiers: */ - assertArrayEquals(new String[] {"a"}, JUnitTest.parseTestMethodNamesList("a")); - assertArrayEquals(new String[] {"a1"}, JUnitTest.parseTestMethodNamesList("a1")); - assertArrayEquals(new String[] {"a$"}, JUnitTest.parseTestMethodNamesList("a$")); - assertArrayEquals(new String[] {"a$1"}, JUnitTest.parseTestMethodNamesList("a$1")); - assertArrayEquals(new String[] {"_bc"}, JUnitTest.parseTestMethodNamesList("_bc")); - assertArrayEquals(new String[] {"___"}, JUnitTest.parseTestMethodNamesList("___")); - - /* illegal Java identifiers: */ - checkParseCausesIAE("1"); - checkParseCausesIAE("1a"); - checkParseCausesIAE("1ab"); - checkParseCausesIAE("1abc"); - checkParseCausesIAE("1abc d"); - checkParseCausesIAE("1abc de"); - checkParseCausesIAE("1abc def"); - checkParseCausesIAE("1abc def,"); - checkParseCausesIAE(",1abc def"); - - assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList("abc,def")); - assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList("abc,def,")); - assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList("abc,def ")); - assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList("abc, def")); - assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList("abc, def ")); - assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList("abc ,def")); - assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList("abc ,def ")); - assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList("abc , def")); - assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList("abc , def ")); - assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList(" abc,def")); - assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList(" abc,def ")); - assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList(" abc, def")); - assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList(" abc, def ")); - assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList(" abc ,def")); - assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList(" abc ,def ")); - assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList(" abc , def")); - assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList(" abc , def ")); - assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList(" abc , def ,")); - } - - private static void checkParseCausesIAE(String param) { - try { - JUnitTest.parseTestMethodNamesList(param); - fail("IllegalArgumentException expected when the param is \"" + param + '"'); - } catch (IllegalArgumentException ex) { - //this is an expected exception - } - } - -} +/* + * 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.junit; + + +import static org.junit.Assert.fail; +import static org.junit.Assert.assertArrayEquals; + +import org.junit.Test; + +/** + * + * @author Marian Petras + */ +public class BatchTestTest { + + @Test + public void testParseTestMethodNamesList() { + try { + JUnitTest.parseTestMethodNamesList(null); + fail("IllegalArgumentException expected when the param is <null>"); + } catch (IllegalArgumentException ex) { + //this is an expected exception + } + + assertArrayEquals(new String[0], JUnitTest.parseTestMethodNamesList("")); + assertArrayEquals(new String[0], JUnitTest.parseTestMethodNamesList(" ")); + assertArrayEquals(new String[0], JUnitTest.parseTestMethodNamesList(" ")); + + checkParseCausesIAE(","); + checkParseCausesIAE(" ,"); + checkParseCausesIAE(", "); + checkParseCausesIAE(" , "); + checkParseCausesIAE(",a"); + checkParseCausesIAE(" ,a"); + checkParseCausesIAE(" ,a"); + checkParseCausesIAE(" , a"); + checkParseCausesIAE(" ,a "); + checkParseCausesIAE(" ,a ,"); + checkParseCausesIAE("ab,,cd"); + checkParseCausesIAE("ab, ,cd"); + checkParseCausesIAE("ab, ,cd"); + checkParseCausesIAE("ab, ,cd,"); + checkParseCausesIAE(",ab, ,cd,"); + + assertArrayEquals(new String[] {"abc"}, JUnitTest.parseTestMethodNamesList("abc")); + assertArrayEquals(new String[] {"abc"}, JUnitTest.parseTestMethodNamesList("abc ")); + assertArrayEquals(new String[] {"abc"}, JUnitTest.parseTestMethodNamesList(" abc")); + assertArrayEquals(new String[] {"abc"}, JUnitTest.parseTestMethodNamesList(" abc ")); + assertArrayEquals(new String[] {"abc"}, JUnitTest.parseTestMethodNamesList("abc ")); + assertArrayEquals(new String[] {"abc"}, JUnitTest.parseTestMethodNamesList("abc,")); + assertArrayEquals(new String[] {"abc"}, JUnitTest.parseTestMethodNamesList("abc, ")); + assertArrayEquals(new String[] {"abc"}, JUnitTest.parseTestMethodNamesList("abc ,")); + assertArrayEquals(new String[] {"abc"}, JUnitTest.parseTestMethodNamesList("abc , ")); + assertArrayEquals(new String[] {"abc"}, JUnitTest.parseTestMethodNamesList(" abc ,")); + + /* legal Java identifiers: */ + assertArrayEquals(new String[] {"a"}, JUnitTest.parseTestMethodNamesList("a")); + assertArrayEquals(new String[] {"a1"}, JUnitTest.parseTestMethodNamesList("a1")); + assertArrayEquals(new String[] {"a$"}, JUnitTest.parseTestMethodNamesList("a$")); + assertArrayEquals(new String[] {"a$1"}, JUnitTest.parseTestMethodNamesList("a$1")); + assertArrayEquals(new String[] {"_bc"}, JUnitTest.parseTestMethodNamesList("_bc")); + assertArrayEquals(new String[] {"___"}, JUnitTest.parseTestMethodNamesList("___")); + + /* illegal Java identifiers: */ + checkParseCausesIAE("1"); + checkParseCausesIAE("1a"); + checkParseCausesIAE("1ab"); + checkParseCausesIAE("1abc"); + checkParseCausesIAE("1abc d"); + checkParseCausesIAE("1abc de"); + checkParseCausesIAE("1abc def"); + checkParseCausesIAE("1abc def,"); + checkParseCausesIAE(",1abc def"); + + assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList("abc,def")); + assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList("abc,def,")); + assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList("abc,def ")); + assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList("abc, def")); + assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList("abc, def ")); + assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList("abc ,def")); + assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList("abc ,def ")); + assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList("abc , def")); + assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList("abc , def ")); + assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList(" abc,def")); + assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList(" abc,def ")); + assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList(" abc, def")); + assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList(" abc, def ")); + assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList(" abc ,def")); + assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList(" abc ,def ")); + assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList(" abc , def")); + assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList(" abc , def ")); + assertArrayEquals(new String[] {"abc", "def"}, JUnitTest.parseTestMethodNamesList(" abc , def ,")); + } + + private static void checkParseCausesIAE(String param) { + try { + JUnitTest.parseTestMethodNamesList(param); + fail("IllegalArgumentException expected when the param is \"" + param + '"'); + } catch (IllegalArgumentException ex) { + //this is an expected exception + } + } + +} http://git-wip-us.apache.org/repos/asf/ant/blob/1ae68097/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/DOMUtilTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/DOMUtilTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/DOMUtilTest.java index b72f69c..7591ada 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/DOMUtilTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/DOMUtilTest.java @@ -1,53 +1,53 @@ -/* - * 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.junit; - -import static org.junit.Assert.assertEquals; - -import java.io.IOException; -import java.io.InputStream; - -import javax.xml.parsers.DocumentBuilder; - -import org.apache.tools.ant.util.JAXPUtils; -import org.junit.Test; -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.SAXException; - -public class DOMUtilTest { - - @Test - public void testListChildNodes() throws SAXException, IOException { - DocumentBuilder db = JAXPUtils.getDocumentBuilder(); - InputStream is = this.getClass().getClassLoader().getResourceAsStream("taskdefs/optional/junit/matches.xml"); - Document doc = db.parse(is); - NodeList nl = DOMUtil.listChildNodes(doc.getDocumentElement(), new FooNodeFilter(), true); - assertEquals("expecting 3", 3, nl.getLength()); - } - - public class FooNodeFilter implements DOMUtil.NodeFilter { - public boolean accept(Node node) { - if (node.getNodeName().equals("foo")) { - return true; - } - return false; - } - } -} +/* + * 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.junit; + +import static org.junit.Assert.assertEquals; + +import java.io.IOException; +import java.io.InputStream; + +import javax.xml.parsers.DocumentBuilder; + +import org.apache.tools.ant.util.JAXPUtils; +import org.junit.Test; +import org.w3c.dom.Document; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.SAXException; + +public class DOMUtilTest { + + @Test + public void testListChildNodes() throws SAXException, IOException { + DocumentBuilder db = JAXPUtils.getDocumentBuilder(); + InputStream is = this.getClass().getClassLoader().getResourceAsStream("taskdefs/optional/junit/matches.xml"); + Document doc = db.parse(is); + NodeList nl = DOMUtil.listChildNodes(doc.getDocumentElement(), new FooNodeFilter(), true); + assertEquals("expecting 3", 3, nl.getLength()); + } + + public class FooNodeFilter implements DOMUtil.NodeFilter { + public boolean accept(Node node) { + if (node.getNodeName().equals("foo")) { + return true; + } + return false; + } + } +} http://git-wip-us.apache.org/repos/asf/ant/blob/1ae68097/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitClassLoaderTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitClassLoaderTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitClassLoaderTest.java index 4baf741..0c303c1 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitClassLoaderTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitClassLoaderTest.java @@ -1,37 +1,37 @@ -/* - * 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.junit; - -import static org.junit.Assert.assertSame; - -import org.junit.Test; - -/** - * Test to ensure that the classloader loading JUnit testcase - * is also the context classloader. - * - */ -public class JUnitClassLoaderTest { - - @Test - public void testContextClassLoader(){ - ClassLoader context = Thread.currentThread().getContextClassLoader(); - ClassLoader caller = getClass().getClassLoader(); - assertSame(context, caller); - } -} +/* + * 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.junit; + +import static org.junit.Assert.assertSame; + +import org.junit.Test; + +/** + * Test to ensure that the classloader loading JUnit testcase + * is also the context classloader. + * + */ +public class JUnitClassLoaderTest { + + @Test + public void testContextClassLoader(){ + ClassLoader context = Thread.currentThread().getContextClassLoader(); + ClassLoader caller = getClass().getClassLoader(); + assertSame(context, caller); + } +} http://git-wip-us.apache.org/repos/asf/ant/blob/1ae68097/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java index c5b6feb..63eb197 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java @@ -1,211 +1,211 @@ -/* - * 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.junit; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.apache.tools.ant.AntAssert.assertContains; -import static org.junit.Assert.fail; - -import java.io.File; -import java.io.FileReader; -import java.io.InputStream; -import java.net.URL; - -import org.apache.tools.ant.BuildFileRule; -import org.apache.tools.ant.util.FileUtils; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; - -/** - * Small testcase for the junitreporttask. - * First test added to reproduce an fault, still a lot to improve - * - */ -public class JUnitReportTest { - - @Rule - public BuildFileRule buildRule = new BuildFileRule(); - - @Before - public void setUp() { - buildRule.configureProject("src/etc/testcases/taskdefs/optional/junitreport.xml"); - } - - /** - * Verifies that no empty junit-noframes.html is generated when frames - * output is selected via the default. - * Needs reports1 task from junitreport.xml. - */ - @Test - public void testNoFileJUnitNoFrames() { - buildRule.executeTarget("reports1"); - assertFalse("No file junit-noframes.html expected", (new File(System.getProperty("root"), "src/etc/testcases/taskdefs/optional/junitreport/test/html/junit-noframes.html").exists())); - - } - - public void assertIndexCreated() { - if (!new File(buildRule.getProject().getProperty("output"), "html/index.html").exists()) { - fail("No file index file found"); - } - - } - - - @Test - public void testEmptyFile() throws Exception { - buildRule.executeTarget("testEmptyFile"); - assertIndexCreated(); - assertContains("Required text not found in log", XMLResultAggregator.WARNING_EMPTY_FILE, buildRule.getLog()); - } - - @Test - public void testIncompleteFile() throws Exception { - buildRule.executeTarget("testIncompleteFile"); - assertIndexCreated(); - assertContains("Required text not found in log", XMLResultAggregator.WARNING_IS_POSSIBLY_CORRUPTED, buildRule.getLog()); - } - - @Test - public void testWrongElement() throws Exception { - buildRule.executeTarget("testWrongElement"); - assertIndexCreated(); - assertContains("Required text not found in log", XMLResultAggregator.WARNING_INVALID_ROOT_ELEMENT, buildRule.getLog()); - } - - // Bugzilla Report 34963 - @Test - public void testStackTraceLineBreaks() throws Exception { - buildRule.executeTarget("testStackTraceLineBreaks"); - assertIndexCreated(); - FileReader r = null; - try { - r = new FileReader(new File(buildRule.getOutputDir(), "html/sampleproject/coins/0_CoinTest.html")); - String report = FileUtils.readFully(r); - assertContains("output must contain <br>:\n" + report, "junit.framework.AssertionFailedError: DOEG<br>", report); - assertContains("#51049: output must translate line breaks:\n" + report, "cur['line.separator'] = '\\r\\n';", report); - } finally { - FileUtils.close(r); - } - } - - - // Bugzilla Report 38477 - @Test - public void testSpecialSignsInSrcPath() throws Exception { - buildRule.executeTarget("testSpecialSignsInSrcPath"); - File reportFile = new File(buildRule.getOutputDir(), "html/index.html"); - // tests one the file object - assertTrue("No index.html present. Not generated?", reportFile.exists() ); - assertTrue("Cant read the report file.", reportFile.canRead() ); - assertTrue("File shouldn't be empty.", reportFile.length() > 0 ); - // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report - URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) ); - InputStream reportStream = reportUrl.openStream(); - assertTrue("This shouldn't be an empty stream.", reportStream.available() > 0); - } - - @Test - public void testSpecialSignsInHtmlPath() throws Exception { - buildRule.executeTarget("testSpecialSignsInHtmlPath"); - File reportFile = new File(buildRule.getOutputDir(), "html# $%\u00A7&-!report/index.html"); - // tests one the file object - assertTrue("No index.html present. Not generated?", reportFile.exists() ); - assertTrue("Cant read the report file.", reportFile.canRead() ); - assertTrue("File shouldn't be empty.", reportFile.length() > 0 ); - // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report - URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) ); - InputStream reportStream = reportUrl.openStream(); - assertTrue("This shouldn't be an empty stream.", reportStream.available() > 0); - } - - //Bugzilla Report 39708 - @Test - public void testWithStyleFromDir() throws Exception { - buildRule.executeTarget("testWithStyleFromDir"); - File reportFile = new File(buildRule.getOutputDir(), "html/index.html"); - // tests one the file object - assertTrue("No index.html present. Not generated?", reportFile.exists() ); - assertTrue("Cant read the report file.", reportFile.canRead() ); - assertTrue("File shouldn't be empty.", reportFile.length() > 0 ); - // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report - URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) ); - InputStream reportStream = reportUrl.openStream(); - assertTrue("This shouldn't be an empty stream.", reportStream.available() > 0); - } - - //Bugzilla Report 40021 - @Test - public void testNoFrames() throws Exception { - buildRule.executeTarget("testNoFrames"); - File reportFile = new File(buildRule.getOutputDir(), "html/junit-noframes.html"); - // tests one the file object - assertTrue("No junit-noframes.html present. Not generated?", reportFile.exists() ); - assertTrue("Cant read the report file.", reportFile.canRead() ); - assertTrue("File shouldn't be empty.", reportFile.length() > 0 ); - // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report - URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) ); - InputStream reportStream = reportUrl.openStream(); - assertTrue("This shouldn't be an empty stream.", reportStream.available() > 0); - } - //Bugzilla Report 39708 - @Test - public void testWithStyleFromDirAndXslImport() throws Exception { - buildRule.executeTarget("testWithStyleFromDirAndXslImport"); - File reportFile = new File(buildRule.getOutputDir(), "html/index.html"); - // tests one the file object - assertTrue("No index.html present. Not generated?", reportFile.exists() ); - assertTrue("Cant read the report file.", reportFile.canRead() ); - assertTrue("File shouldn't be empty.", reportFile.length() > 0 ); - // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report - URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) ); - InputStream reportStream = reportUrl.openStream(); - assertTrue("This shouldn't be an empty stream.", reportStream.available() > 0); - } - - @Test - public void testWithStyleFromClasspath() throws Exception { - buildRule.executeTarget("testWithStyleFromClasspath"); - File reportFile = new File(buildRule.getOutputDir(), "html/index.html"); - // tests one the file object - assertTrue("No index.html present. Not generated?", reportFile.exists() ); - assertTrue("Cant read the report file.", reportFile.canRead() ); - assertTrue("File shouldn't be empty.", reportFile.length() > 0 ); - // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report - URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) ); - InputStream reportStream = reportUrl.openStream(); - assertTrue("This shouldn't be an empty stream.", reportStream.available() > 0); - } - - @Test - public void testWithParams() throws Exception { - buildRule.executeTarget("testWithParams"); - assertContains("key1=value1,key2=value2", buildRule.getLog()); - File reportFile = new File(buildRule.getOutputDir(), "html/index.html"); - // tests one the file object - assertTrue("No index.html present. Not generated?", reportFile.exists() ); - assertTrue("Cant read the report file.", reportFile.canRead() ); - assertTrue("File shouldn't be empty.", reportFile.length() > 0 ); - // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report - URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) ); - InputStream reportStream = reportUrl.openStream(); - assertTrue("This shouldn't be an empty stream.", reportStream.available() > 0); - } -} +/* + * 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.junit; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.apache.tools.ant.AntAssert.assertContains; +import static org.junit.Assert.fail; + +import java.io.File; +import java.io.FileReader; +import java.io.InputStream; +import java.net.URL; + +import org.apache.tools.ant.BuildFileRule; +import org.apache.tools.ant.util.FileUtils; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; + +/** + * Small testcase for the junitreporttask. + * First test added to reproduce an fault, still a lot to improve + * + */ +public class JUnitReportTest { + + @Rule + public BuildFileRule buildRule = new BuildFileRule(); + + @Before + public void setUp() { + buildRule.configureProject("src/etc/testcases/taskdefs/optional/junitreport.xml"); + } + + /** + * Verifies that no empty junit-noframes.html is generated when frames + * output is selected via the default. + * Needs reports1 task from junitreport.xml. + */ + @Test + public void testNoFileJUnitNoFrames() { + buildRule.executeTarget("reports1"); + assertFalse("No file junit-noframes.html expected", (new File(System.getProperty("root"), "src/etc/testcases/taskdefs/optional/junitreport/test/html/junit-noframes.html").exists())); + + } + + public void assertIndexCreated() { + if (!new File(buildRule.getProject().getProperty("output"), "html/index.html").exists()) { + fail("No file index file found"); + } + + } + + + @Test + public void testEmptyFile() throws Exception { + buildRule.executeTarget("testEmptyFile"); + assertIndexCreated(); + assertContains("Required text not found in log", XMLResultAggregator.WARNING_EMPTY_FILE, buildRule.getLog()); + } + + @Test + public void testIncompleteFile() throws Exception { + buildRule.executeTarget("testIncompleteFile"); + assertIndexCreated(); + assertContains("Required text not found in log", XMLResultAggregator.WARNING_IS_POSSIBLY_CORRUPTED, buildRule.getLog()); + } + + @Test + public void testWrongElement() throws Exception { + buildRule.executeTarget("testWrongElement"); + assertIndexCreated(); + assertContains("Required text not found in log", XMLResultAggregator.WARNING_INVALID_ROOT_ELEMENT, buildRule.getLog()); + } + + // Bugzilla Report 34963 + @Test + public void testStackTraceLineBreaks() throws Exception { + buildRule.executeTarget("testStackTraceLineBreaks"); + assertIndexCreated(); + FileReader r = null; + try { + r = new FileReader(new File(buildRule.getOutputDir(), "html/sampleproject/coins/0_CoinTest.html")); + String report = FileUtils.readFully(r); + assertContains("output must contain <br>:\n" + report, "junit.framework.AssertionFailedError: DOEG<br>", report); + assertContains("#51049: output must translate line breaks:\n" + report, "cur['line.separator'] = '\\r\\n';", report); + } finally { + FileUtils.close(r); + } + } + + + // Bugzilla Report 38477 + @Test + public void testSpecialSignsInSrcPath() throws Exception { + buildRule.executeTarget("testSpecialSignsInSrcPath"); + File reportFile = new File(buildRule.getOutputDir(), "html/index.html"); + // tests one the file object + assertTrue("No index.html present. Not generated?", reportFile.exists() ); + assertTrue("Cant read the report file.", reportFile.canRead() ); + assertTrue("File shouldn't be empty.", reportFile.length() > 0 ); + // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report + URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) ); + InputStream reportStream = reportUrl.openStream(); + assertTrue("This shouldn't be an empty stream.", reportStream.available() > 0); + } + + @Test + public void testSpecialSignsInHtmlPath() throws Exception { + buildRule.executeTarget("testSpecialSignsInHtmlPath"); + File reportFile = new File(buildRule.getOutputDir(), "html# $%\u00A7&-!report/index.html"); + // tests one the file object + assertTrue("No index.html present. Not generated?", reportFile.exists() ); + assertTrue("Cant read the report file.", reportFile.canRead() ); + assertTrue("File shouldn't be empty.", reportFile.length() > 0 ); + // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report + URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) ); + InputStream reportStream = reportUrl.openStream(); + assertTrue("This shouldn't be an empty stream.", reportStream.available() > 0); + } + + //Bugzilla Report 39708 + @Test + public void testWithStyleFromDir() throws Exception { + buildRule.executeTarget("testWithStyleFromDir"); + File reportFile = new File(buildRule.getOutputDir(), "html/index.html"); + // tests one the file object + assertTrue("No index.html present. Not generated?", reportFile.exists() ); + assertTrue("Cant read the report file.", reportFile.canRead() ); + assertTrue("File shouldn't be empty.", reportFile.length() > 0 ); + // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report + URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) ); + InputStream reportStream = reportUrl.openStream(); + assertTrue("This shouldn't be an empty stream.", reportStream.available() > 0); + } + + //Bugzilla Report 40021 + @Test + public void testNoFrames() throws Exception { + buildRule.executeTarget("testNoFrames"); + File reportFile = new File(buildRule.getOutputDir(), "html/junit-noframes.html"); + // tests one the file object + assertTrue("No junit-noframes.html present. Not generated?", reportFile.exists() ); + assertTrue("Cant read the report file.", reportFile.canRead() ); + assertTrue("File shouldn't be empty.", reportFile.length() > 0 ); + // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report + URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) ); + InputStream reportStream = reportUrl.openStream(); + assertTrue("This shouldn't be an empty stream.", reportStream.available() > 0); + } + //Bugzilla Report 39708 + @Test + public void testWithStyleFromDirAndXslImport() throws Exception { + buildRule.executeTarget("testWithStyleFromDirAndXslImport"); + File reportFile = new File(buildRule.getOutputDir(), "html/index.html"); + // tests one the file object + assertTrue("No index.html present. Not generated?", reportFile.exists() ); + assertTrue("Cant read the report file.", reportFile.canRead() ); + assertTrue("File shouldn't be empty.", reportFile.length() > 0 ); + // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report + URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) ); + InputStream reportStream = reportUrl.openStream(); + assertTrue("This shouldn't be an empty stream.", reportStream.available() > 0); + } + + @Test + public void testWithStyleFromClasspath() throws Exception { + buildRule.executeTarget("testWithStyleFromClasspath"); + File reportFile = new File(buildRule.getOutputDir(), "html/index.html"); + // tests one the file object + assertTrue("No index.html present. Not generated?", reportFile.exists() ); + assertTrue("Cant read the report file.", reportFile.canRead() ); + assertTrue("File shouldn't be empty.", reportFile.length() > 0 ); + // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report + URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) ); + InputStream reportStream = reportUrl.openStream(); + assertTrue("This shouldn't be an empty stream.", reportStream.available() > 0); + } + + @Test + public void testWithParams() throws Exception { + buildRule.executeTarget("testWithParams"); + assertContains("key1=value1,key2=value2", buildRule.getLog()); + File reportFile = new File(buildRule.getOutputDir(), "html/index.html"); + // tests one the file object + assertTrue("No index.html present. Not generated?", reportFile.exists() ); + assertTrue("Cant read the report file.", reportFile.canRead() ); + assertTrue("File shouldn't be empty.", reportFile.length() > 0 ); + // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report + URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) ); + InputStream reportStream = reportUrl.openStream(); + assertTrue("This shouldn't be an empty stream.", reportStream.available() > 0); + } +}
