diff options
Diffstat (limited to 'framework/src/ant/apache-ant-1.9.6/src/tests/junit/org/apache/tools/ant/taskdefs/condition')
12 files changed, 847 insertions, 0 deletions
diff --git a/framework/src/ant/apache-ant-1.9.6/src/tests/junit/org/apache/tools/ant/taskdefs/condition/AntVersionTest.java b/framework/src/ant/apache-ant-1.9.6/src/tests/junit/org/apache/tools/ant/taskdefs/condition/AntVersionTest.java new file mode 100644 index 00000000..b70a1381 --- /dev/null +++ b/framework/src/ant/apache-ant-1.9.6/src/tests/junit/org/apache/tools/ant/taskdefs/condition/AntVersionTest.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.tools.ant.taskdefs.condition; + +import org.apache.tools.ant.BuildFileRule; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; + +/** + * Testcases for the <antversion> condition. + * + */ +public class AntVersionTest { + + @Rule + public BuildFileRule buildRule = new BuildFileRule(); + + @Before + public void setUp() throws Exception { + buildRule.configureProject("src/etc/testcases/taskdefs/conditions/antversion.xml"); + } + + @Test + public void testAtLeast() { + buildRule.executeTarget("testatleast"); + } + + @Test + public void testExactly() { + buildRule.executeTarget("testexactly"); + } +} diff --git a/framework/src/ant/apache-ant-1.9.6/src/tests/junit/org/apache/tools/ant/taskdefs/condition/ContainsTest.java b/framework/src/ant/apache-ant-1.9.6/src/tests/junit/org/apache/tools/ant/taskdefs/condition/ContainsTest.java new file mode 100644 index 00000000..a45b511a --- /dev/null +++ b/framework/src/ant/apache-ant-1.9.6/src/tests/junit/org/apache/tools/ant/taskdefs/condition/ContainsTest.java @@ -0,0 +1,42 @@ +/* + * 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.condition; + +import org.junit.Test; + +import static org.junit.Assert.assertTrue; + +/** + * Testcase for the <contains> condition. + * + */ +public class ContainsTest { + + @Test + public void testCaseSensitive() { + Contains con = new Contains(); + con.setString("abc"); + con.setSubstring("A"); + assertTrue(!con.eval()); + + con.setCasesensitive(false); + assertTrue(con.eval()); + } + +} diff --git a/framework/src/ant/apache-ant-1.9.6/src/tests/junit/org/apache/tools/ant/taskdefs/condition/EqualsTest.java b/framework/src/ant/apache-ant-1.9.6/src/tests/junit/org/apache/tools/ant/taskdefs/condition/EqualsTest.java new file mode 100644 index 00000000..5f9b996a --- /dev/null +++ b/framework/src/ant/apache-ant-1.9.6/src/tests/junit/org/apache/tools/ant/taskdefs/condition/EqualsTest.java @@ -0,0 +1,56 @@ +/* + * 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.condition; + +import org.junit.Test; + +import static org.junit.Assert.assertTrue; + +/** + * Testcase for the <equals> condition. + * + */ +public class EqualsTest { + + @Test + public void testTrim() { + Equals eq = new Equals(); + eq.setArg1("a"); + eq.setArg2(" a"); + assertTrue(!eq.eval()); + + eq.setTrim(true); + assertTrue(eq.eval()); + + eq.setArg2("a\t"); + assertTrue(eq.eval()); + } + + @Test + public void testCaseSensitive() { + Equals eq = new Equals(); + eq.setArg1("a"); + eq.setArg2("A"); + assertTrue(!eq.eval()); + + eq.setCasesensitive(false); + assertTrue(eq.eval()); + } + +} diff --git a/framework/src/ant/apache-ant-1.9.6/src/tests/junit/org/apache/tools/ant/taskdefs/condition/HttpTest.java b/framework/src/ant/apache-ant-1.9.6/src/tests/junit/org/apache/tools/ant/taskdefs/condition/HttpTest.java new file mode 100644 index 00000000..15a9d2d3 --- /dev/null +++ b/framework/src/ant/apache-ant-1.9.6/src/tests/junit/org/apache/tools/ant/taskdefs/condition/HttpTest.java @@ -0,0 +1,76 @@ +/* + * 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.condition; + +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.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; + +/** + * Testcases for the <http> condition. All these tests require + * us to be online as they attempt to get the status of various pages + * on the Ant Apache web site. + */ +public class HttpTest { + + @Rule + public BuildFileRule buildRule = new BuildFileRule(); + + @Before + public void setUp() { + buildRule.configureProject("src/etc/testcases/taskdefs/conditions/http.xml"); + } + + @Test + public void testNoMethod() { + buildRule.executeTarget("basic-no-method"); + assertEquals("true", buildRule.getProject().getProperty("basic-no-method")); + assertNull(buildRule.getProject().getProperty("basic-no-method-bad-url")); + } + + @Test + public void testHeadRequest() { + buildRule.executeTarget("test-head-request"); + assertEquals("true", buildRule.getProject().getProperty("test-head-request")); + assertNull(buildRule.getProject().getProperty("test-head-request-bad-url")); + } + + @Test + public void testGetRequest() { + buildRule.executeTarget("test-get-request"); + assertEquals("true", buildRule.getProject().getProperty("test-get-request")); + assertNull(buildRule.getProject().getProperty("test-get-request-bad-url")); + } + + @Test + public void testBadRequestMethod() { + try { + buildRule.executeTarget("bad-request-method"); + fail("Exception should have been thrown as invalid HTTP request method specified"); + } catch (BuildException ex) { + //TODO we should assert the correct build exception was thrown + } + } + +} diff --git a/framework/src/ant/apache-ant-1.9.6/src/tests/junit/org/apache/tools/ant/taskdefs/condition/IsFailureTest.java b/framework/src/ant/apache-ant-1.9.6/src/tests/junit/org/apache/tools/ant/taskdefs/condition/IsFailureTest.java new file mode 100644 index 00000000..86594765 --- /dev/null +++ b/framework/src/ant/apache-ant-1.9.6/src/tests/junit/org/apache/tools/ant/taskdefs/condition/IsFailureTest.java @@ -0,0 +1,44 @@ +/* + * 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.condition; + +import org.apache.tools.ant.BuildFileRule; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; + +/** + * Testcases for the <isfailure> condition. + * + */ +public class IsFailureTest { + + @Rule + public BuildFileRule buildRule = new BuildFileRule(); + + @Before + public void setUp() { + buildRule.configureProject("src/etc/testcases/taskdefs/conditions/isfailure.xml"); + } + + @Test + public void testIsFailure() { + buildRule.executeTarget("testisfailure"); + } + +} diff --git a/framework/src/ant/apache-ant-1.9.6/src/tests/junit/org/apache/tools/ant/taskdefs/condition/IsFileSelectedTest.java b/framework/src/ant/apache-ant-1.9.6/src/tests/junit/org/apache/tools/ant/taskdefs/condition/IsFileSelectedTest.java new file mode 100644 index 00000000..84d88a55 --- /dev/null +++ b/framework/src/ant/apache-ant-1.9.6/src/tests/junit/org/apache/tools/ant/taskdefs/condition/IsFileSelectedTest.java @@ -0,0 +1,74 @@ +/* + * 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.condition; + +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; + +/** + * Testcase for the <isfileselected> condition. + * + */ +public class IsFileSelectedTest { + + @Rule + public BuildFileRule buildRule = new BuildFileRule(); + + @Before + public void setUp() { + buildRule.configureProject("src/etc/testcases/taskdefs/conditions/isfileselected.xml"); + } + + @Test + public void testSimple() { + buildRule.executeTarget("simple"); + } + + @Test + public void testName() { + buildRule.executeTarget("name"); + } + + @Test + public void testBaseDir() { + buildRule.executeTarget("basedir"); + } + + @Test + public void testType() { + buildRule.executeTarget("type"); + } + + @Test + public void testNotSelector() { + try { + buildRule.executeTarget("not.selector"); + fail("Exception should have been thrown: checking for use as a selector (not allowed)"); + } catch(BuildException ex) { + AntAssert.assertContains("fileset doesn't support the nested \"isfile", + ex.getMessage()); + } + } +} diff --git a/framework/src/ant/apache-ant-1.9.6/src/tests/junit/org/apache/tools/ant/taskdefs/condition/IsReachableTest.java b/framework/src/ant/apache-ant-1.9.6/src/tests/junit/org/apache/tools/ant/taskdefs/condition/IsReachableTest.java new file mode 100644 index 00000000..d036834c --- /dev/null +++ b/framework/src/ant/apache-ant-1.9.6/src/tests/junit/org/apache/tools/ant/taskdefs/condition/IsReachableTest.java @@ -0,0 +1,116 @@ +/* + * 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.condition; + +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.Ignore; +import org.junit.Rule; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +/** + * test for reachable things + */ +public class IsReachableTest { + + @Rule + public BuildFileRule buildRule = new BuildFileRule(); + + @Before + public void setUp() { + buildRule.configureProject( + "src/etc/testcases/taskdefs/conditions/isreachable.xml"); + } + + + @Test + public void testLocalhost() throws Exception { + buildRule.executeTarget("testLocalhost"); + } + + @Test + public void testLocalhostURL() throws Exception { + buildRule.executeTarget("testLocalhostURL"); + } + + @Test + public void testIpv4localhost() throws Exception { + buildRule.executeTarget("testIpv4localhost"); + } + + @Test + public void testFTPURL() throws Exception { + buildRule.executeTarget("testFTPURL"); + } + + @Test + public void testBoth() throws Exception { + try { + buildRule.executeTarget("testBoth"); + fail("Build exception expected: error on two targets"); + } catch(BuildException ex) { + assertEquals(IsReachable.ERROR_BOTH_TARGETS, ex.getMessage()); + } + } + + @Test + public void testNoTargets() throws Exception { + try { + buildRule.executeTarget("testNoTargets"); + fail("Build exception expected: no params"); + } catch(BuildException ex) { + assertEquals(IsReachable.ERROR_NO_HOSTNAME, ex.getMessage()); + } + } + + @Test + public void testBadTimeout() throws Exception { + try { + buildRule.executeTarget("testBadTimeout"); + fail("Build exception expected: error on -ve timeout"); + } catch(BuildException ex) { + assertEquals(IsReachable.ERROR_BAD_TIMEOUT, ex.getMessage()); + } + } + + @Test + @Ignore("Previously named in a way to prevent execution") + public void NotestFile() throws Exception { + try { + buildRule.executeTarget("testFile"); + fail("Build exception expected: error on file URL"); + } catch(BuildException ex) { + assertEquals(IsReachable.ERROR_NO_HOST_IN_URL, ex.getMessage()); + } + } + + @Test + public void testBadURL() throws Exception { + try { + buildRule.executeTarget("testBadURL"); + fail("Build exception expected: error in URL"); + } catch(BuildException ex) { + AntAssert.assertContains(IsReachable.ERROR_BAD_URL, ex.getMessage()); + } + } +} diff --git a/framework/src/ant/apache-ant-1.9.6/src/tests/junit/org/apache/tools/ant/taskdefs/condition/IsReferenceTest.java b/framework/src/ant/apache-ant-1.9.6/src/tests/junit/org/apache/tools/ant/taskdefs/condition/IsReferenceTest.java new file mode 100644 index 00000000..01b6b47c --- /dev/null +++ b/framework/src/ant/apache-ant-1.9.6/src/tests/junit/org/apache/tools/ant/taskdefs/condition/IsReferenceTest.java @@ -0,0 +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.condition; + +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.assertEquals; +import static org.junit.Assert.fail; +import static org.junit.Assert.assertNull; + +/** + * Testcases for the <isreference> condition. + * + */ +public class IsReferenceTest { + + @Rule + public BuildFileRule buildRule = new BuildFileRule(); + + @Before + public void setUp() { + buildRule.configureProject("src/etc/testcases/taskdefs/conditions/isreference.xml"); + } + + @Test + public void testBasic() { + buildRule.executeTarget("basic"); + assertEquals("true", buildRule.getProject().getProperty("global-path")); + assertEquals("true", buildRule.getProject().getProperty("target-path")); + assertNull(buildRule.getProject().getProperty("undefined")); + } + + @Test + public void testNotEnoughArgs() { + try { + buildRule.executeTarget("isreference-incomplete"); + fail("Build exception expected: refid attirbute has been omitted"); + } catch(BuildException ex) { + assertEquals("No reference specified for isreference condition", ex.getMessage()); + } + } + + @Test + public void testType() { + buildRule.executeTarget("type"); + assertEquals("true", buildRule.getProject().getProperty("global-path")); + assertNull(buildRule.getProject().getProperty("global-path-as-fileset")); + assertNull(buildRule.getProject().getProperty("global-path-as-foo")); + assertEquals("true", buildRule.getProject().getProperty("global-echo")); + } + +} diff --git a/framework/src/ant/apache-ant-1.9.6/src/tests/junit/org/apache/tools/ant/taskdefs/condition/IsSignedTest.java b/framework/src/ant/apache-ant-1.9.6/src/tests/junit/org/apache/tools/ant/taskdefs/condition/IsSignedTest.java new file mode 100644 index 00000000..0f4001c3 --- /dev/null +++ b/framework/src/ant/apache-ant-1.9.6/src/tests/junit/org/apache/tools/ant/taskdefs/condition/IsSignedTest.java @@ -0,0 +1,59 @@ +/* + * 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.condition; + +import org.apache.tools.ant.BuildFileRule; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; + +/** + * Testcase for the <issigned> condition. + * + */ +public class IsSignedTest { + + @Rule + public BuildFileRule buildRule = new BuildFileRule(); + + @Before + public void setUp() { + buildRule.configureProject("src/etc/testcases/taskdefs/conditions/issigned.xml"); + } + + @Test + public void testPass() { + buildRule.executeTarget("pass"); + } + + @Test + public void testPassword() { + buildRule.executeTarget("password"); + } + + @Test + public void testAPassword() { + buildRule.executeTarget("apassword"); + } + + @Test + public void testAllSigned() { + buildRule.executeTarget("allsigned"); + } +} diff --git a/framework/src/ant/apache-ant-1.9.6/src/tests/junit/org/apache/tools/ant/taskdefs/condition/ParserSupportsTest.java b/framework/src/ant/apache-ant-1.9.6/src/tests/junit/org/apache/tools/ant/taskdefs/condition/ParserSupportsTest.java new file mode 100644 index 00000000..2a2354ff --- /dev/null +++ b/framework/src/ant/apache-ant-1.9.6/src/tests/junit/org/apache/tools/ant/taskdefs/condition/ParserSupportsTest.java @@ -0,0 +1,95 @@ +/* + * 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.condition; + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.BuildFileRule; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Rule; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +/** + + */ +public class ParserSupportsTest { + + @Rule + public BuildFileRule buildRule = new BuildFileRule(); + + @Before + public void setUp() { + buildRule.configureProject("src/etc/testcases/taskdefs/conditions/parsersupports.xml"); + } + + @Test + public void testEmpty() { + try { + buildRule.executeTarget("testEmpty"); + fail("Build exception expected: " + ParserSupports.ERROR_NO_ATTRIBUTES); + } catch(BuildException ex) { + assertEquals(ParserSupports.ERROR_NO_ATTRIBUTES, ex.getMessage()); + } + } + + @Test + public void testBoth() { + try { + buildRule.executeTarget("testBoth"); + fail("Build exception expected: " + ParserSupports.ERROR_BOTH_ATTRIBUTES); + } catch(BuildException ex) { + assertEquals(ParserSupports.ERROR_BOTH_ATTRIBUTES, ex.getMessage()); + } + } + + @Test + public void testNamespaces() { + buildRule.executeTarget("testNamespaces"); + } + + @Test + public void testPropertyNoValue() { + try { + buildRule.executeTarget("testPropertyNoValue"); + fail("Build exception expected: " + ParserSupports.ERROR_NO_VALUE); + } catch(BuildException ex) { + assertEquals(ParserSupports.ERROR_NO_VALUE, ex.getMessage()); + } + } + + @Test + public void testUnknownProperty() { + buildRule.executeTarget("testUnknownProperty"); + } + + @Test + @Ignore("Previously named in a manner to prevent execution") + public void NotestPropertyInvalid() { + buildRule.executeTarget("testPropertyInvalid"); + } + + @Test + @Ignore("Previously named in a manner to prevent execution") + public void NotestXercesProperty() { + buildRule.executeTarget("testXercesProperty"); + } +} diff --git a/framework/src/ant/apache-ant-1.9.6/src/tests/junit/org/apache/tools/ant/taskdefs/condition/TypeFoundTest.java b/framework/src/ant/apache-ant-1.9.6/src/tests/junit/org/apache/tools/ant/taskdefs/condition/TypeFoundTest.java new file mode 100644 index 00000000..ab284943 --- /dev/null +++ b/framework/src/ant/apache-ant-1.9.6/src/tests/junit/org/apache/tools/ant/taskdefs/condition/TypeFoundTest.java @@ -0,0 +1,91 @@ +/* + * 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.condition; + +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.assertEquals; +import static org.junit.Assert.fail; +import static org.junit.Assert.assertNull; + +/** + * test the typeexists condition + */ +public class TypeFoundTest { + + @Rule + public BuildFileRule buildRule = new BuildFileRule(); + + @Before + public void setUp() { + buildRule.configureProject("src/etc/testcases/taskdefs/conditions/typefound.xml"); + } + + @Test + public void testTask() { + buildRule.executeTarget("testTask"); + assertEquals("true", buildRule.getProject().getProperty("testTask")); + } + + @Test + public void testUndefined() { + try { + buildRule.executeTarget("testUndefined"); + fail("Build exception expected: left out the name attribute"); + } catch(BuildException ex) { + AntAssert.assertContains("No type specified", ex.getMessage()); + } + } + + @Test + public void testTaskThatIsntDefined() { + buildRule.executeTarget("testTaskThatIsntDefined"); + assertNull(buildRule.getProject().getProperty("testTaskThatIsntDefined")); + } + + @Test + public void testTaskThatDoesntReallyExist() { + buildRule.executeTarget("testTaskThatDoesntReallyExist"); + assertNull(buildRule.getProject().getProperty("testTaskThatDoesntReallyExist")); + } + + @Test + public void testType() { + buildRule.executeTarget("testType"); + assertEquals("true", buildRule.getProject().getProperty("testType")); + } + + @Test + public void testPreset() { + buildRule.executeTarget("testPreset"); + assertEquals("true", buildRule.getProject().getProperty("testPreset")); + } + + @Test + public void testMacro() { + buildRule.executeTarget("testMacro"); + assertEquals("true", buildRule.getProject().getProperty("testMacro")); + } + + +} diff --git a/framework/src/ant/apache-ant-1.9.6/src/tests/junit/org/apache/tools/ant/taskdefs/condition/XorTest.java b/framework/src/ant/apache-ant-1.9.6/src/tests/junit/org/apache/tools/ant/taskdefs/condition/XorTest.java new file mode 100644 index 00000000..4f04c357 --- /dev/null +++ b/framework/src/ant/apache-ant-1.9.6/src/tests/junit/org/apache/tools/ant/taskdefs/condition/XorTest.java @@ -0,0 +1,75 @@ +/* + * 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.condition; + +import org.apache.tools.ant.BuildFileRule; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; + +/** + * Test that Xor follows the conventional boolean logic semantics + * (a ^ b) === (a||b)&!(a&&b) + */ +public class XorTest { + + @Rule + public BuildFileRule buildRule = new BuildFileRule(); + + + @Before + public void setUp() { + buildRule.configureProject("src/etc/testcases/taskdefs/conditions/xor.xml"); + } + + @Test + public void testEmpty() { + buildRule.executeTarget("testEmpty"); + } + + @Test + public void test0() { + buildRule.executeTarget("test0"); + } + + @Test + public void test1() { + buildRule.executeTarget("test1"); + } + + @Test + public void test00() { + buildRule.executeTarget("test00"); + } + + @Test + public void test10() { + buildRule.executeTarget("test10"); + } + + @Test + public void test01() { + buildRule.executeTarget("test01"); + } + + @Test + public void test11() { + buildRule.executeTarget("test11"); + } + +} |