You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by gi...@apache.org on 2017/11/29 16:18:22 UTC
[18/21] ant git commit: Normalise tabulation and line breaks
http://git-wip-us.apache.org/repos/asf/ant/blob/4422804d/src/tests/junit/org/apache/tools/ant/taskdefs/optional/SchemaValidateTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/SchemaValidateTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/SchemaValidateTest.java
index 5914001..667c890 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/SchemaValidateTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/SchemaValidateTest.java
@@ -1,128 +1,128 @@
-/*
- * 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.AntAssert;
-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;
-
-/**
- * Test schema validation
- */
-
-public class SchemaValidateTest {
-
- /**
- * 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 + "schemavalidate.xml");
- }
-
- /**
- * test with no namespace
- */
- @Test
- public void testNoNamespace() throws Exception {
- buildRule.executeTarget("testNoNamespace");
- }
-
- /**
- * add namespace awareness.
- */
- @Test
- public void testNSMapping() throws Exception {
- buildRule.executeTarget("testNSMapping");
- }
-
- @Test
- public void testNoEmptySchemaNamespace() throws Exception {
- try {
- buildRule.executeTarget("testNoEmptySchemaNamespace");
- fail("Empty namespace URI");
- } catch (BuildException ex) {
- AntAssert.assertContains(SchemaValidate.SchemaLocation.ERROR_NO_URI, ex.getMessage());
- }
- }
-
- @Test
- public void testNoEmptySchemaLocation() throws Exception {
- try {
- buildRule.executeTarget("testNoEmptySchemaLocation");
- fail("Empty schema location");
- } catch (BuildException ex) {
- AntAssert.assertContains(SchemaValidate.SchemaLocation.ERROR_NO_LOCATION,
- ex.getMessage());
- }
- }
-
- @Test
- public void testNoFile() throws Exception {
- try {
- buildRule.executeTarget("testNoFile");
- fail("No file at file attribute");
- } catch (BuildException ex) {
- AntAssert.assertContains(SchemaValidate.SchemaLocation.ERROR_NO_FILE,
- ex.getMessage());
- }
- }
-
- @Test
- public void testNoDoubleSchemaLocation() throws Exception {
- try {
- buildRule.executeTarget("testNoDoubleSchemaLocation");
- fail("Two locations for schemas");
- } catch (BuildException ex) {
- AntAssert.assertContains(SchemaValidate.SchemaLocation.ERROR_TWO_LOCATIONS,
- ex.getMessage());
- }
- }
-
- @Test
- public void testNoDuplicateSchema() throws Exception {
- try {
- buildRule.executeTarget("testNoDuplicateSchema");
- fail("duplicate schemas with different values");
- } catch (BuildException ex) {
- AntAssert.assertContains(SchemaValidate.ERROR_DUPLICATE_SCHEMA,
- ex.getMessage());
- }
- }
-
- @Test
- public void testEqualsSchemasOK() throws Exception {
- buildRule.executeTarget("testEqualsSchemasOK");
- }
-
- @Test
- public void testFileset() throws Exception {
- buildRule.executeTarget("testFileset");
- }
-}
+/*
+ * 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.AntAssert;
+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;
+
+/**
+ * Test schema validation
+ */
+
+public class SchemaValidateTest {
+
+ /**
+ * 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 + "schemavalidate.xml");
+ }
+
+ /**
+ * test with no namespace
+ */
+ @Test
+ public void testNoNamespace() throws Exception {
+ buildRule.executeTarget("testNoNamespace");
+ }
+
+ /**
+ * add namespace awareness.
+ */
+ @Test
+ public void testNSMapping() throws Exception {
+ buildRule.executeTarget("testNSMapping");
+ }
+
+ @Test
+ public void testNoEmptySchemaNamespace() throws Exception {
+ try {
+ buildRule.executeTarget("testNoEmptySchemaNamespace");
+ fail("Empty namespace URI");
+ } catch (BuildException ex) {
+ AntAssert.assertContains(SchemaValidate.SchemaLocation.ERROR_NO_URI, ex.getMessage());
+ }
+ }
+
+ @Test
+ public void testNoEmptySchemaLocation() throws Exception {
+ try {
+ buildRule.executeTarget("testNoEmptySchemaLocation");
+ fail("Empty schema location");
+ } catch (BuildException ex) {
+ AntAssert.assertContains(SchemaValidate.SchemaLocation.ERROR_NO_LOCATION,
+ ex.getMessage());
+ }
+ }
+
+ @Test
+ public void testNoFile() throws Exception {
+ try {
+ buildRule.executeTarget("testNoFile");
+ fail("No file at file attribute");
+ } catch (BuildException ex) {
+ AntAssert.assertContains(SchemaValidate.SchemaLocation.ERROR_NO_FILE,
+ ex.getMessage());
+ }
+ }
+
+ @Test
+ public void testNoDoubleSchemaLocation() throws Exception {
+ try {
+ buildRule.executeTarget("testNoDoubleSchemaLocation");
+ fail("Two locations for schemas");
+ } catch (BuildException ex) {
+ AntAssert.assertContains(SchemaValidate.SchemaLocation.ERROR_TWO_LOCATIONS,
+ ex.getMessage());
+ }
+ }
+
+ @Test
+ public void testNoDuplicateSchema() throws Exception {
+ try {
+ buildRule.executeTarget("testNoDuplicateSchema");
+ fail("duplicate schemas with different values");
+ } catch (BuildException ex) {
+ AntAssert.assertContains(SchemaValidate.ERROR_DUPLICATE_SCHEMA,
+ ex.getMessage());
+ }
+ }
+
+ @Test
+ public void testEqualsSchemasOK() throws Exception {
+ buildRule.executeTarget("testEqualsSchemasOK");
+ }
+
+ @Test
+ public void testFileset() throws Exception {
+ buildRule.executeTarget("testFileset");
+ }
+}
http://git-wip-us.apache.org/repos/asf/ant/blob/4422804d/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XmlValidateCatalogTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XmlValidateCatalogTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XmlValidateCatalogTest.java
index 02b11a3..c9948bb 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XmlValidateCatalogTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XmlValidateCatalogTest.java
@@ -1,71 +1,71 @@
-/*
- * 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;
-
-/**
- * Tests the XMLValidate optional task with nested external catalogs.
- *
- * @see XmlValidateTest
- * @since Ant 1.6
- */
-public class XmlValidateCatalogTest {
-
- /**
- * 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 + "xmlvalidate.xml");
- }
-
-
- /**
- * catalogfiles fileset should be ignored
- * if resolver.jar is not present, but will
- * be used if it is. either way, test should
- * work b/c we have a nested dtd with the same
- * entity
- */
- @Test
- public void testXmlCatalogFiles() {
- buildRule.executeTarget("xmlcatalogfiles");
- }
-
- /**
- * Test nested catalogpath.
- * It should be ignored if resolver.jar is not
- * present, but will be used if it is. either
- * way, test should work b/c we have a nested
- * dtd with the same entity
- */
- @Test
- public void testXmlCatalogPath() {
- buildRule.executeTarget("xmlcatalogpath");
- }
-
-}
+/*
+ * 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;
+
+/**
+ * Tests the XMLValidate optional task with nested external catalogs.
+ *
+ * @see XmlValidateTest
+ * @since Ant 1.6
+ */
+public class XmlValidateCatalogTest {
+
+ /**
+ * 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 + "xmlvalidate.xml");
+ }
+
+
+ /**
+ * catalogfiles fileset should be ignored
+ * if resolver.jar is not present, but will
+ * be used if it is. either way, test should
+ * work b/c we have a nested dtd with the same
+ * entity
+ */
+ @Test
+ public void testXmlCatalogFiles() {
+ buildRule.executeTarget("xmlcatalogfiles");
+ }
+
+ /**
+ * Test nested catalogpath.
+ * It should be ignored if resolver.jar is not
+ * present, but will be used if it is. either
+ * way, test should work b/c we have a nested
+ * dtd with the same entity
+ */
+ @Test
+ public void testXmlCatalogPath() {
+ buildRule.executeTarget("xmlcatalogpath");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/ant/blob/4422804d/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XmlValidateTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XmlValidateTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XmlValidateTest.java
index 869031f..58f7a4b 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XmlValidateTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XmlValidateTest.java
@@ -1,193 +1,193 @@
-/*
- * 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 org.junit.internal.AssumptionViolatedException;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-/**
- * Tests the XMLValidate optional task, by running targets in the test script
- * <code>src/etc/testcases/taskdefs/optional/xmlvalidate.xml</code>
- * <p>
- *
- * @see XmlValidateCatalogTest
- * @since Ant 1.5
- */
-public class XmlValidateTest {
-
- /**
- * 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 + "xmlvalidate.xml");
- }
-
- /**
- * Basic inline 'dtd' element test.
- */
- @Test
- public void testValidate() throws Exception {
- buildRule.executeTarget("testValidate");
- }
-
- /**
- * Test indirect validation.
- */
- @Test
- public void testDeepValidate() throws Exception {
- buildRule.executeTarget("testDeepValidate");
- }
-
- @Test
- public void testXmlCatalog() {
- buildRule.executeTarget("xmlcatalog");
- }
-
- @Test
- public void testXmlCatalogViaRefid() {
- buildRule.executeTarget("xmlcatalogViaRefid");
- }
-
- /**
- * Test that the nested dtd element is used when resolver.jar is not
- * present. This test should pass either way.
- */
- @Test
- public void testXmlCatalogFiles() {
- buildRule.executeTarget("xmlcatalogfiles-override");
- }
-
- /**
- * Test nested catalogpath.
- * Test that the nested dtd element is used when resolver.jar is not
- * present. This test should pass either way.
- */
- @Test
- public void testXmlCatalogPath() {
- buildRule.executeTarget("xmlcatalogpath-override");
- }
-
- /**
- * Test nested xmlcatalog definitions
- */
- @Test
- public void testXmlCatalogNested() {
- buildRule.executeTarget("xmlcatalognested");
- }
-
- /**
- * Test xml schema validation
- */
- @Test
- public void testXmlSchemaGood() throws BuildException {
- try {
- buildRule.executeTarget("testSchemaGood");
- } catch (BuildException e) {
- if (e
- .getMessage()
- .endsWith(" doesn't recognize feature http://apache.org/xml/features/validation/schema")
- || e.getMessage().endsWith(
- " doesn't support feature http://apache.org/xml/features/validation/schema")) {
- throw new AssumptionViolatedException("parser doesn't support schema");
- } else {
- throw e;
- }
- }
- }
- /**
- * Test xml schema validation
- */
- @Test
- public void testXmlSchemaBad() {
- try {
- buildRule.executeTarget("testSchemaBad");
- fail("Should throw BuildException because 'Bad Schema Validation'");
-
- } catch (BuildException e) {
- if (e
- .getMessage()
- .endsWith(" doesn't recognize feature http://apache.org/xml/features/validation/schema")
- || e.getMessage().endsWith(
- " doesn't support feature http://apache.org/xml/features/validation/schema")) {
- throw new AssumptionViolatedException("parser doesn't support schema");
- } else {
- assertTrue(
- e.getMessage().indexOf("not a valid XML document") > -1);
- }
- }
- }
-
- /**
- * iso-2022-jp.xml is valid but wouldn't get recognized on systems
- * with a different native encoding.
- *
- * Bug 11279
- */
- @Test
- public void testIso2022Jp() {
- buildRule.executeTarget("testIso2022Jp");
- }
-
- /**
- * utf-8.xml is invalid as it contains non-UTF-8 characters, but
- * would pass on systems with a native iso-8859-1 (or similar)
- * encoding.
- *
- * Bug 11279
- */
- @Test
- public void testUtf8() {
- try {
- buildRule.executeTarget("testUtf8");
- fail("Invalid characters in file");
- } catch(BuildException ex) {
- //TODO assert exception message
- }
- }
-
- // Tests property element, using XML schema properties as an example.
- @Test
- public void testPropertySchemaForValidXML() {
- buildRule.executeTarget("testProperty.validXML");
- }
-
- @Test
- public void testPropertySchemaForInvalidXML() {
- try {
- buildRule.executeTarget("testProperty.invalidXML");
- fail("XML file does not satisfy schema");
- } catch(BuildException ex) {
- //TODO assert exception message
- }
- }
-
-}
+/*
+ * 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 org.junit.internal.AssumptionViolatedException;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+/**
+ * Tests the XMLValidate optional task, by running targets in the test script
+ * <code>src/etc/testcases/taskdefs/optional/xmlvalidate.xml</code>
+ * <p>
+ *
+ * @see XmlValidateCatalogTest
+ * @since Ant 1.5
+ */
+public class XmlValidateTest {
+
+ /**
+ * 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 + "xmlvalidate.xml");
+ }
+
+ /**
+ * Basic inline 'dtd' element test.
+ */
+ @Test
+ public void testValidate() throws Exception {
+ buildRule.executeTarget("testValidate");
+ }
+
+ /**
+ * Test indirect validation.
+ */
+ @Test
+ public void testDeepValidate() throws Exception {
+ buildRule.executeTarget("testDeepValidate");
+ }
+
+ @Test
+ public void testXmlCatalog() {
+ buildRule.executeTarget("xmlcatalog");
+ }
+
+ @Test
+ public void testXmlCatalogViaRefid() {
+ buildRule.executeTarget("xmlcatalogViaRefid");
+ }
+
+ /**
+ * Test that the nested dtd element is used when resolver.jar is not
+ * present. This test should pass either way.
+ */
+ @Test
+ public void testXmlCatalogFiles() {
+ buildRule.executeTarget("xmlcatalogfiles-override");
+ }
+
+ /**
+ * Test nested catalogpath.
+ * Test that the nested dtd element is used when resolver.jar is not
+ * present. This test should pass either way.
+ */
+ @Test
+ public void testXmlCatalogPath() {
+ buildRule.executeTarget("xmlcatalogpath-override");
+ }
+
+ /**
+ * Test nested xmlcatalog definitions
+ */
+ @Test
+ public void testXmlCatalogNested() {
+ buildRule.executeTarget("xmlcatalognested");
+ }
+
+ /**
+ * Test xml schema validation
+ */
+ @Test
+ public void testXmlSchemaGood() throws BuildException {
+ try {
+ buildRule.executeTarget("testSchemaGood");
+ } catch (BuildException e) {
+ if (e
+ .getMessage()
+ .endsWith(" doesn't recognize feature http://apache.org/xml/features/validation/schema")
+ || e.getMessage().endsWith(
+ " doesn't support feature http://apache.org/xml/features/validation/schema")) {
+ throw new AssumptionViolatedException("parser doesn't support schema");
+ } else {
+ throw e;
+ }
+ }
+ }
+ /**
+ * Test xml schema validation
+ */
+ @Test
+ public void testXmlSchemaBad() {
+ try {
+ buildRule.executeTarget("testSchemaBad");
+ fail("Should throw BuildException because 'Bad Schema Validation'");
+
+ } catch (BuildException e) {
+ if (e
+ .getMessage()
+ .endsWith(" doesn't recognize feature http://apache.org/xml/features/validation/schema")
+ || e.getMessage().endsWith(
+ " doesn't support feature http://apache.org/xml/features/validation/schema")) {
+ throw new AssumptionViolatedException("parser doesn't support schema");
+ } else {
+ assertTrue(
+ e.getMessage().indexOf("not a valid XML document") > -1);
+ }
+ }
+ }
+
+ /**
+ * iso-2022-jp.xml is valid but wouldn't get recognized on systems
+ * with a different native encoding.
+ *
+ * Bug 11279
+ */
+ @Test
+ public void testIso2022Jp() {
+ buildRule.executeTarget("testIso2022Jp");
+ }
+
+ /**
+ * utf-8.xml is invalid as it contains non-UTF-8 characters, but
+ * would pass on systems with a native iso-8859-1 (or similar)
+ * encoding.
+ *
+ * Bug 11279
+ */
+ @Test
+ public void testUtf8() {
+ try {
+ buildRule.executeTarget("testUtf8");
+ fail("Invalid characters in file");
+ } catch(BuildException ex) {
+ //TODO assert exception message
+ }
+ }
+
+ // Tests property element, using XML schema properties as an example.
+ @Test
+ public void testPropertySchemaForValidXML() {
+ buildRule.executeTarget("testProperty.validXML");
+ }
+
+ @Test
+ public void testPropertySchemaForInvalidXML() {
+ try {
+ buildRule.executeTarget("testProperty.invalidXML");
+ fail("XML file does not satisfy schema");
+ } catch(BuildException ex) {
+ //TODO assert exception message
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/ant/blob/4422804d/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 594dada..0a57cc5 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,85 @@
-/*
- * 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/4422804d/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 01e0575..b119f37 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/4422804d/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 b8749c0..812979c 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,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.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/4422804d/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 a13a466..eeece1c 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,132 @@
-/*
- * 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/4422804d/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 54c6055..545b7cb 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/4422804d/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 a969499..aa483f6 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/4422804d/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 7591ada..c322401 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;
+ }
+ }
+}