http://git-wip-us.apache.org/repos/asf/ant/blob/1ae68097/src/tests/junit/org/apache/tools/ant/util/StringUtilsTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/util/StringUtilsTest.java b/src/tests/junit/org/apache/tools/ant/util/StringUtilsTest.java index 53ef1b2..4dc43ee 100644 --- a/src/tests/junit/org/apache/tools/ant/util/StringUtilsTest.java +++ b/src/tests/junit/org/apache/tools/ant/util/StringUtilsTest.java @@ -1,170 +1,170 @@ -/* - * 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.util; - -import java.util.Vector; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -/** - * Test for StringUtils - */ -public class StringUtilsTest { - - @Test - public void testSplit(){ - final String data = "a,b,,"; - Vector res = StringUtils.split(data, ','); - assertEquals(4, res.size()); - assertEquals("a", res.elementAt(0)); - assertEquals("b", res.elementAt(1)); - assertEquals("", res.elementAt(2)); - assertEquals("", res.elementAt(3)); - } - - @Test - public void testSplitLines(){ - final String data = "a\r\nb\nc\nd\ne"; - Vector res = StringUtils.lineSplit(data); - assertEquals(5, res.size()); - assertEquals("a\r", res.elementAt(0)); - assertEquals("b", res.elementAt(1)); - assertEquals("c", res.elementAt(2)); - assertEquals("d", res.elementAt(3)); - assertEquals("e", res.elementAt(4)); - } - - @Test - public void testReplace() { - final String data = "abcabcabca"; - String res = StringUtils.replace(data, "a", ""); - assertEquals("bcbcbc", res); - } - - @Test - public void testEndsWithBothEmpty() { - assertTrue( StringUtils.endsWith( new StringBuffer(), "") ); - } - - @Test - public void testEndsWithEmptyString() { - assertTrue( StringUtils.endsWith( new StringBuffer("12234545"), "") ); - } - - @Test - public void testEndsWithShorterString() { - assertTrue( StringUtils.endsWith( new StringBuffer("12345678"), "78")); - } - - @Test - public void testEndsWithSameString() { - assertTrue( StringUtils.endsWith( new StringBuffer("123"), "123")); - } - - @Test - public void testEndsWithLongerString() { - assertFalse( StringUtils.endsWith( new StringBuffer("12"), "1245")); - } - - @Test - public void testEndsWithNoMatch() { - assertFalse( StringUtils.endsWith( new StringBuffer("12345678"), "789")); - } - - @Test - public void testEndsWithEmptyBuffer() { - assertFalse( StringUtils.endsWith( new StringBuffer(""), "12345667") ); - } - - @Test - public void testEndsWithJDKPerf() { - StringBuffer buf = getFilledBuffer(1024*300, 'a'); - for (int i = 0; i < 1000; i++) { - assertTrue(buf.toString().endsWith("aa")); - } - } - - @Test - public void testEndsWithPerf() { - StringBuffer buf = getFilledBuffer(1024*300, 'a'); - for (int i = 0; i < 1000; i++) { - assertTrue(StringUtils.endsWith(buf, "aa")); - } - } - - private StringBuffer getFilledBuffer(int size, char ch) { - StringBuffer buf = new StringBuffer(size); - for (int i = 0; i < size; i++) { buf.append(ch); }; - return buf; - } - - @Test - public void testParseHumanSizes() throws Exception { - final long KILOBYTE = 1024; - final long MEGABYTE = KILOBYTE * 1024; - final long GIGABYTE = MEGABYTE * 1024; - final long TERABYTE = GIGABYTE * 1024; - final long PETABYTE = TERABYTE * 1024; - assertEquals(StringUtils.parseHumanSizes("1K"), KILOBYTE); - assertEquals(StringUtils.parseHumanSizes("1M"), MEGABYTE); - assertEquals(StringUtils.parseHumanSizes("1G"), GIGABYTE); - assertEquals(StringUtils.parseHumanSizes("1T"), TERABYTE); - assertEquals(StringUtils.parseHumanSizes("1P"), PETABYTE); - assertEquals(StringUtils.parseHumanSizes("1"), 1L); - } - - @Test - public void testRemoveSuffix() { - String prefix = "Prefix"; - String name = "Name"; - String suffix = "Suffix"; - String input = prefix + name + suffix; - assertEquals( - "Does not remove the suffix right.", - prefix + name, - StringUtils.removeSuffix(input, suffix) - ); - assertEquals( - "Should leave the string unattended.", - prefix + name + suffix, - StringUtils.removeSuffix(input, "bla") - ); - } - - @Test - public void testRemovePrefix() { - String prefix = "Prefix"; - String name = "Name"; - String suffix = "Suffix"; - String input = prefix + name + suffix; - assertEquals( - "Does not remove the prefix right.", - name + suffix, - StringUtils.removePrefix(input, prefix) - ); - assertEquals( - "Should leave the string unattended.", - prefix + name + suffix, - StringUtils.removePrefix(input, "bla") - ); - } -} +/* + * 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.util; + +import java.util.Vector; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +/** + * Test for StringUtils + */ +public class StringUtilsTest { + + @Test + public void testSplit(){ + final String data = "a,b,,"; + Vector res = StringUtils.split(data, ','); + assertEquals(4, res.size()); + assertEquals("a", res.elementAt(0)); + assertEquals("b", res.elementAt(1)); + assertEquals("", res.elementAt(2)); + assertEquals("", res.elementAt(3)); + } + + @Test + public void testSplitLines(){ + final String data = "a\r\nb\nc\nd\ne"; + Vector res = StringUtils.lineSplit(data); + assertEquals(5, res.size()); + assertEquals("a\r", res.elementAt(0)); + assertEquals("b", res.elementAt(1)); + assertEquals("c", res.elementAt(2)); + assertEquals("d", res.elementAt(3)); + assertEquals("e", res.elementAt(4)); + } + + @Test + public void testReplace() { + final String data = "abcabcabca"; + String res = StringUtils.replace(data, "a", ""); + assertEquals("bcbcbc", res); + } + + @Test + public void testEndsWithBothEmpty() { + assertTrue( StringUtils.endsWith( new StringBuffer(), "") ); + } + + @Test + public void testEndsWithEmptyString() { + assertTrue( StringUtils.endsWith( new StringBuffer("12234545"), "") ); + } + + @Test + public void testEndsWithShorterString() { + assertTrue( StringUtils.endsWith( new StringBuffer("12345678"), "78")); + } + + @Test + public void testEndsWithSameString() { + assertTrue( StringUtils.endsWith( new StringBuffer("123"), "123")); + } + + @Test + public void testEndsWithLongerString() { + assertFalse( StringUtils.endsWith( new StringBuffer("12"), "1245")); + } + + @Test + public void testEndsWithNoMatch() { + assertFalse( StringUtils.endsWith( new StringBuffer("12345678"), "789")); + } + + @Test + public void testEndsWithEmptyBuffer() { + assertFalse( StringUtils.endsWith( new StringBuffer(""), "12345667") ); + } + + @Test + public void testEndsWithJDKPerf() { + StringBuffer buf = getFilledBuffer(1024*300, 'a'); + for (int i = 0; i < 1000; i++) { + assertTrue(buf.toString().endsWith("aa")); + } + } + + @Test + public void testEndsWithPerf() { + StringBuffer buf = getFilledBuffer(1024*300, 'a'); + for (int i = 0; i < 1000; i++) { + assertTrue(StringUtils.endsWith(buf, "aa")); + } + } + + private StringBuffer getFilledBuffer(int size, char ch) { + StringBuffer buf = new StringBuffer(size); + for (int i = 0; i < size; i++) { buf.append(ch); }; + return buf; + } + + @Test + public void testParseHumanSizes() throws Exception { + final long KILOBYTE = 1024; + final long MEGABYTE = KILOBYTE * 1024; + final long GIGABYTE = MEGABYTE * 1024; + final long TERABYTE = GIGABYTE * 1024; + final long PETABYTE = TERABYTE * 1024; + assertEquals(StringUtils.parseHumanSizes("1K"), KILOBYTE); + assertEquals(StringUtils.parseHumanSizes("1M"), MEGABYTE); + assertEquals(StringUtils.parseHumanSizes("1G"), GIGABYTE); + assertEquals(StringUtils.parseHumanSizes("1T"), TERABYTE); + assertEquals(StringUtils.parseHumanSizes("1P"), PETABYTE); + assertEquals(StringUtils.parseHumanSizes("1"), 1L); + } + + @Test + public void testRemoveSuffix() { + String prefix = "Prefix"; + String name = "Name"; + String suffix = "Suffix"; + String input = prefix + name + suffix; + assertEquals( + "Does not remove the suffix right.", + prefix + name, + StringUtils.removeSuffix(input, suffix) + ); + assertEquals( + "Should leave the string unattended.", + prefix + name + suffix, + StringUtils.removeSuffix(input, "bla") + ); + } + + @Test + public void testRemovePrefix() { + String prefix = "Prefix"; + String name = "Name"; + String suffix = "Suffix"; + String input = prefix + name + suffix; + assertEquals( + "Does not remove the prefix right.", + name + suffix, + StringUtils.removePrefix(input, prefix) + ); + assertEquals( + "Should leave the string unattended.", + prefix + name + suffix, + StringUtils.removePrefix(input, "bla") + ); + } +}
http://git-wip-us.apache.org/repos/asf/ant/blob/1ae68097/src/tests/junit/org/apache/tools/ant/util/SymlinkUtilsTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/util/SymlinkUtilsTest.java b/src/tests/junit/org/apache/tools/ant/util/SymlinkUtilsTest.java index d1de1b1..6f4b037 100644 --- a/src/tests/junit/org/apache/tools/ant/util/SymlinkUtilsTest.java +++ b/src/tests/junit/org/apache/tools/ant/util/SymlinkUtilsTest.java @@ -1,40 +1,40 @@ -/* - * 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.util; - -import static org.junit.Assert.assertFalse; - -import java.io.IOException; - -import org.apache.tools.ant.taskdefs.condition.Os; -import org.junit.Assume; -import org.junit.Test; - -public class SymlinkUtilsTest { - - private static final SymbolicLinkUtils SYMLINK_UTILS = - SymbolicLinkUtils.getSymbolicLinkUtils(); - - @Test - public void testRootIsNoSymlink() throws IOException { - Assume.assumeFalse("Symlink doesn't work on Windows", Os.isFamily("windows")); - assertFalse(SYMLINK_UTILS.isSymbolicLink("/")); - } - -} +/* + * 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.util; + +import static org.junit.Assert.assertFalse; + +import java.io.IOException; + +import org.apache.tools.ant.taskdefs.condition.Os; +import org.junit.Assume; +import org.junit.Test; + +public class SymlinkUtilsTest { + + private static final SymbolicLinkUtils SYMLINK_UTILS = + SymbolicLinkUtils.getSymbolicLinkUtils(); + + @Test + public void testRootIsNoSymlink() throws IOException { + Assume.assumeFalse("Symlink doesn't work on Windows", Os.isFamily("windows")); + assertFalse(SYMLINK_UTILS.isSymbolicLink("/")); + } + +} http://git-wip-us.apache.org/repos/asf/ant/blob/1ae68097/src/tests/junit/org/apache/tools/ant/util/UnPackageNameMapperTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/util/UnPackageNameMapperTest.java b/src/tests/junit/org/apache/tools/ant/util/UnPackageNameMapperTest.java index 7586950..18bf7ab 100644 --- a/src/tests/junit/org/apache/tools/ant/util/UnPackageNameMapperTest.java +++ b/src/tests/junit/org/apache/tools/ant/util/UnPackageNameMapperTest.java @@ -1,42 +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.util; - -import java.io.File; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class UnPackageNameMapperTest { - - @Test - public void testMapping() { - UnPackageNameMapper mapper = new UnPackageNameMapper(); - mapper.setFrom("TEST-*.xml"); - mapper.setTo("*.java"); - String file ="TEST-org.apache.tools.ant.util.UnPackageNameMapperTest.xml"; - String result = mapper.mapFileName(file)[0]; - String expected = fixupPath("org/apache/tools/ant/util/UnPackageNameMapperTest.java"); - - assertEquals(expected, result); - } - - private String fixupPath(String file) { - return file.replace('/', File.separatorChar); - } -} +/* + * 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.util; + +import java.io.File; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class UnPackageNameMapperTest { + + @Test + public void testMapping() { + UnPackageNameMapper mapper = new UnPackageNameMapper(); + mapper.setFrom("TEST-*.xml"); + mapper.setTo("*.java"); + String file ="TEST-org.apache.tools.ant.util.UnPackageNameMapperTest.xml"; + String result = mapper.mapFileName(file)[0]; + String expected = fixupPath("org/apache/tools/ant/util/UnPackageNameMapperTest.java"); + + assertEquals(expected, result); + } + + private String fixupPath(String file) { + return file.replace('/', File.separatorChar); + } +} http://git-wip-us.apache.org/repos/asf/ant/blob/1ae68097/src/tests/junit/org/apache/tools/ant/util/VectorSetTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/util/VectorSetTest.java b/src/tests/junit/org/apache/tools/ant/util/VectorSetTest.java index 11491e3..524a187 100644 --- a/src/tests/junit/org/apache/tools/ant/util/VectorSetTest.java +++ b/src/tests/junit/org/apache/tools/ant/util/VectorSetTest.java @@ -1,295 +1,295 @@ -/* - * 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.util; - -import java.util.ArrayList; -import java.util.Arrays; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -public class VectorSetTest { - - private static final Object O = new Object(); - private VectorSet v = new VectorSet(); - - @Test - public void testAdd() { - assertTrue(v.add(O)); - assertFalse(v.add(O)); - assertEquals(1, v.size()); - } - - @Test - public void testAdd2() { - v.add(0, O); - v.add(1, O); - assertEquals(1, v.size()); - } - - @Test - public void testAddElement() { - v.addElement(O); - v.addElement(O); - assertEquals(1, v.size()); - } - - @Test - public void testAddAll() { - assertTrue(v.addAll(Arrays.asList(new Object[] {O, O}))); - assertEquals(1, v.size()); - } - - @Test - public void testAddAll2() { - assertTrue(v.addAll(0, Arrays.asList(new Object[] {O, O}))); - assertEquals(1, v.size()); - } - - @Test - public void testClear() { - v.add(O); - v.clear(); - assertEquals(0, v.size()); - } - - @Test - public void testClone() { - v.add(O); - Object o = v.clone(); - assertTrue(o instanceof VectorSet); - VectorSet vs = (VectorSet) o; - assertEquals(1, vs.size()); - assertTrue(vs.contains(O)); - } - - @Test - public void testContains() { - assertFalse(v.contains(O)); - v.add(O); - assertTrue(v.contains(O)); - assertFalse(v.contains(null)); - } - - @Test - public void testContainsAll() { - assertFalse(v.containsAll(Arrays.asList(new Object[] {O, O}))); - v.add(O); - assertTrue(v.containsAll(Arrays.asList(new Object[] {O, O}))); - assertFalse(v.containsAll(Arrays.asList(new Object[] {O, null}))); - } - - @Test - public void testInsertElementAt() { - v.insertElementAt(O, 0); - v.insertElementAt(O, 1); - assertEquals(1, v.size()); - } - - @Test - public void testRemoveIndex() { - v.add(O); - assertSame(O, v.remove(0)); - assertEquals(0, v.size()); - try { - v.remove(0); - fail("expected an AIOBE"); - } catch (ArrayIndexOutOfBoundsException e) { - //TODO assert exception values - // expected - } - } - - @Test - public void testRemoveObject() { - v.add(O); - assertTrue(v.remove(O)); - assertEquals(0, v.size()); - assertFalse(v.remove(O)); - } - - @Test - public void testRemoveAtEndWhenSizeEqualsCapacity() { - v = new VectorSet(3, 1); - Object a = new Object(); - v.add(a); - Object b = new Object(); - v.add(b); - v.add(O); - assertEquals(3, v.size()); - assertEquals(3, v.capacity()); - assertTrue(v.remove(O)); - assertEquals(2, v.size()); - assertFalse(v.remove(O)); - assertSame(a, v.elementAt(0)); - assertSame(b, v.elementAt(1)); - } - - @Test - public void testRemoveAtFrontWhenSizeEqualsCapacity() { - v = new VectorSet(3, 1); - v.add(O); - Object a = new Object(); - v.add(a); - Object b = new Object(); - v.add(b); - assertEquals(3, v.size()); - assertEquals(3, v.capacity()); - assertTrue(v.remove(O)); - assertEquals(2, v.size()); - assertFalse(v.remove(O)); - assertSame(a, v.elementAt(0)); - assertSame(b, v.elementAt(1)); - } - - @Test - public void testRemoveInMiddleWhenSizeEqualsCapacity() { - v = new VectorSet(3, 1); - Object a = new Object(); - v.add(a); - v.add(O); - Object b = new Object(); - v.add(b); - assertEquals(3, v.size()); - assertEquals(3, v.capacity()); - assertTrue(v.remove(O)); - assertEquals(2, v.size()); - assertFalse(v.remove(O)); - assertSame(a, v.elementAt(0)); - assertSame(b, v.elementAt(1)); - } - - @Test - public void testRemoveAll() { - v.add(O); - assertTrue(v.removeAll(Arrays.asList(new Object[] {O, O}))); - assertEquals(0, v.size()); - assertFalse(v.removeAll(Arrays.asList(new Object[] {O, O}))); - } - - @Test - public void testRemoveAllElements() { - v.add(O); - v.removeAllElements(); - assertEquals(0, v.size()); - } - - @Test - public void testRemoveElement() { - v.add(O); - assertTrue(v.removeElement(O)); - assertEquals(0, v.size()); - assertFalse(v.removeElement(O)); - } - - @Test - public void testRemoveElementAt() { - v.add(O); - v.removeElementAt(0); - assertEquals(0, v.size()); - try { - v.removeElementAt(0); - fail("expected an AIOBE"); - } catch (ArrayIndexOutOfBoundsException e) { - //TODO assert exception values - // expected - } - } - - @Test - public void testRemoveRange() { - Object a = new Object(); - Object b = new Object(); - Object c = new Object(); - v.addAll(Arrays.asList(new Object[] {O, a, b, c})); - v.removeRange(1, 3); - assertEquals(2, v.size()); - assertTrue(v.contains(O)); - assertTrue(v.contains(c)); - } - - @Test - public void testRetainAll() { - Object a = new Object(); - Object b = new Object(); - Object c = new Object(); - v.addAll(Arrays.asList(new Object[] {O, a, b, c})); - assertEquals(0, v.indexOf(O)); - assertTrue(v.retainAll(Arrays.asList(new Object[] {c, O}))); - assertEquals(2, v.size()); - assertTrue(v.contains(O)); - assertTrue(v.contains(c)); - assertEquals(0, v.indexOf(O)); - } - - @Test - public void testRetainAllReturnValueAndEmptiness() { - v.add(1); - v.add(2); - v.add(3); - assertTrue(v.retainAll(Arrays.asList(1, 2))); - assertEquals(2, v.size()); - assertFalse(v.retainAll(Arrays.asList(1, 2))); - assertEquals(2, v.size()); - assertTrue(v.retainAll(Arrays.asList(4, 5))); - assertEquals(0, v.size()); - assertFalse(v.retainAll(Arrays.asList(4, 5))); - } - - @Test - public void testSet() { - v.add(O); - Object a = new Object(); - assertSame(O, v.set(0, a)); - assertSame(a, v.get(0)); - assertEquals(1, v.size()); - } - - @Test - public void testSetElementAt() { - v.add(O); - Object a = new Object(); - v.setElementAt(a, 0); - assertSame(a, v.get(0)); - assertEquals(1, v.size()); - } - - @Test - public void testRetainAllSpeed() { - int size = 50000; - for (int i = 0; i < size; i++) { - v.add(i); - v.add(i); - } - assertEquals(size, v.size()); - ArrayList<Integer> list = new ArrayList<Integer>(); - for (int i = size - 4; i < 2 * size; i++) { - list.add(i); - v.add(i); - } - assertTrue(v.retainAll(list)); - assertEquals(v.toString(), size + 4, v.size()); - } - -} +/* + * 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.util; + +import java.util.ArrayList; +import java.util.Arrays; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +public class VectorSetTest { + + private static final Object O = new Object(); + private VectorSet v = new VectorSet(); + + @Test + public void testAdd() { + assertTrue(v.add(O)); + assertFalse(v.add(O)); + assertEquals(1, v.size()); + } + + @Test + public void testAdd2() { + v.add(0, O); + v.add(1, O); + assertEquals(1, v.size()); + } + + @Test + public void testAddElement() { + v.addElement(O); + v.addElement(O); + assertEquals(1, v.size()); + } + + @Test + public void testAddAll() { + assertTrue(v.addAll(Arrays.asList(new Object[] {O, O}))); + assertEquals(1, v.size()); + } + + @Test + public void testAddAll2() { + assertTrue(v.addAll(0, Arrays.asList(new Object[] {O, O}))); + assertEquals(1, v.size()); + } + + @Test + public void testClear() { + v.add(O); + v.clear(); + assertEquals(0, v.size()); + } + + @Test + public void testClone() { + v.add(O); + Object o = v.clone(); + assertTrue(o instanceof VectorSet); + VectorSet vs = (VectorSet) o; + assertEquals(1, vs.size()); + assertTrue(vs.contains(O)); + } + + @Test + public void testContains() { + assertFalse(v.contains(O)); + v.add(O); + assertTrue(v.contains(O)); + assertFalse(v.contains(null)); + } + + @Test + public void testContainsAll() { + assertFalse(v.containsAll(Arrays.asList(new Object[] {O, O}))); + v.add(O); + assertTrue(v.containsAll(Arrays.asList(new Object[] {O, O}))); + assertFalse(v.containsAll(Arrays.asList(new Object[] {O, null}))); + } + + @Test + public void testInsertElementAt() { + v.insertElementAt(O, 0); + v.insertElementAt(O, 1); + assertEquals(1, v.size()); + } + + @Test + public void testRemoveIndex() { + v.add(O); + assertSame(O, v.remove(0)); + assertEquals(0, v.size()); + try { + v.remove(0); + fail("expected an AIOBE"); + } catch (ArrayIndexOutOfBoundsException e) { + //TODO assert exception values + // expected + } + } + + @Test + public void testRemoveObject() { + v.add(O); + assertTrue(v.remove(O)); + assertEquals(0, v.size()); + assertFalse(v.remove(O)); + } + + @Test + public void testRemoveAtEndWhenSizeEqualsCapacity() { + v = new VectorSet(3, 1); + Object a = new Object(); + v.add(a); + Object b = new Object(); + v.add(b); + v.add(O); + assertEquals(3, v.size()); + assertEquals(3, v.capacity()); + assertTrue(v.remove(O)); + assertEquals(2, v.size()); + assertFalse(v.remove(O)); + assertSame(a, v.elementAt(0)); + assertSame(b, v.elementAt(1)); + } + + @Test + public void testRemoveAtFrontWhenSizeEqualsCapacity() { + v = new VectorSet(3, 1); + v.add(O); + Object a = new Object(); + v.add(a); + Object b = new Object(); + v.add(b); + assertEquals(3, v.size()); + assertEquals(3, v.capacity()); + assertTrue(v.remove(O)); + assertEquals(2, v.size()); + assertFalse(v.remove(O)); + assertSame(a, v.elementAt(0)); + assertSame(b, v.elementAt(1)); + } + + @Test + public void testRemoveInMiddleWhenSizeEqualsCapacity() { + v = new VectorSet(3, 1); + Object a = new Object(); + v.add(a); + v.add(O); + Object b = new Object(); + v.add(b); + assertEquals(3, v.size()); + assertEquals(3, v.capacity()); + assertTrue(v.remove(O)); + assertEquals(2, v.size()); + assertFalse(v.remove(O)); + assertSame(a, v.elementAt(0)); + assertSame(b, v.elementAt(1)); + } + + @Test + public void testRemoveAll() { + v.add(O); + assertTrue(v.removeAll(Arrays.asList(new Object[] {O, O}))); + assertEquals(0, v.size()); + assertFalse(v.removeAll(Arrays.asList(new Object[] {O, O}))); + } + + @Test + public void testRemoveAllElements() { + v.add(O); + v.removeAllElements(); + assertEquals(0, v.size()); + } + + @Test + public void testRemoveElement() { + v.add(O); + assertTrue(v.removeElement(O)); + assertEquals(0, v.size()); + assertFalse(v.removeElement(O)); + } + + @Test + public void testRemoveElementAt() { + v.add(O); + v.removeElementAt(0); + assertEquals(0, v.size()); + try { + v.removeElementAt(0); + fail("expected an AIOBE"); + } catch (ArrayIndexOutOfBoundsException e) { + //TODO assert exception values + // expected + } + } + + @Test + public void testRemoveRange() { + Object a = new Object(); + Object b = new Object(); + Object c = new Object(); + v.addAll(Arrays.asList(new Object[] {O, a, b, c})); + v.removeRange(1, 3); + assertEquals(2, v.size()); + assertTrue(v.contains(O)); + assertTrue(v.contains(c)); + } + + @Test + public void testRetainAll() { + Object a = new Object(); + Object b = new Object(); + Object c = new Object(); + v.addAll(Arrays.asList(new Object[] {O, a, b, c})); + assertEquals(0, v.indexOf(O)); + assertTrue(v.retainAll(Arrays.asList(new Object[] {c, O}))); + assertEquals(2, v.size()); + assertTrue(v.contains(O)); + assertTrue(v.contains(c)); + assertEquals(0, v.indexOf(O)); + } + + @Test + public void testRetainAllReturnValueAndEmptiness() { + v.add(1); + v.add(2); + v.add(3); + assertTrue(v.retainAll(Arrays.asList(1, 2))); + assertEquals(2, v.size()); + assertFalse(v.retainAll(Arrays.asList(1, 2))); + assertEquals(2, v.size()); + assertTrue(v.retainAll(Arrays.asList(4, 5))); + assertEquals(0, v.size()); + assertFalse(v.retainAll(Arrays.asList(4, 5))); + } + + @Test + public void testSet() { + v.add(O); + Object a = new Object(); + assertSame(O, v.set(0, a)); + assertSame(a, v.get(0)); + assertEquals(1, v.size()); + } + + @Test + public void testSetElementAt() { + v.add(O); + Object a = new Object(); + v.setElementAt(a, 0); + assertSame(a, v.get(0)); + assertEquals(1, v.size()); + } + + @Test + public void testRetainAllSpeed() { + int size = 50000; + for (int i = 0; i < size; i++) { + v.add(i); + v.add(i); + } + assertEquals(size, v.size()); + ArrayList<Integer> list = new ArrayList<Integer>(); + for (int i = size - 4; i < 2 * size; i++) { + list.add(i); + v.add(i); + } + assertTrue(v.retainAll(list)); + assertEquals(v.toString(), size + 4, v.size()); + } + +} http://git-wip-us.apache.org/repos/asf/ant/blob/1ae68097/src/tests/junit/org/apache/tools/ant/util/XMLFragmentTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/util/XMLFragmentTest.java b/src/tests/junit/org/apache/tools/ant/util/XMLFragmentTest.java index 0ac938f..72c42b3 100644 --- a/src/tests/junit/org/apache/tools/ant/util/XMLFragmentTest.java +++ b/src/tests/junit/org/apache/tools/ant/util/XMLFragmentTest.java @@ -1,91 +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.util; - -import org.apache.tools.ant.BuildFileRule; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -public class XMLFragmentTest { - - @Rule - public BuildFileRule buildRule = new BuildFileRule(); - - @Before - public void setUp() { - buildRule.configureProject("src/etc/testcases/types/xmlfragment.xml"); - } - - @Test - public void testNestedText() { - XMLFragment x = (XMLFragment) buildRule.getProject().getReference("nested-text"); - assertNotNull(x); - Node n = x.getFragment(); - assertTrue("No attributes", !n.hasAttributes()); - NodeList nl = n.getChildNodes(); - assertEquals(1, nl.getLength()); - assertEquals(Node.TEXT_NODE, nl.item(0).getNodeType()); - assertEquals("foo", nl.item(0).getNodeValue()); - } - - @Test - public void testNestedChildren() { - XMLFragment x = - (XMLFragment) buildRule.getProject().getReference("with-children"); - assertNotNull(x); - Node n = x.getFragment(); - assertTrue("No attributes", !n.hasAttributes()); - NodeList nl = n.getChildNodes(); - assertEquals(3, nl.getLength()); - - assertEquals(Node.ELEMENT_NODE, nl.item(0).getNodeType()); - Element child1 = (Element) nl.item(0); - assertEquals("child1", child1.getTagName()); - assertTrue(!child1.hasAttributes()); - NodeList nl2 = child1.getChildNodes(); - assertEquals(1, nl2.getLength()); - assertEquals(Node.TEXT_NODE, nl2.item(0).getNodeType()); - assertEquals("foo", nl2.item(0).getNodeValue()); - - assertEquals(Node.ELEMENT_NODE, nl.item(1).getNodeType()); - Element child2 = (Element) nl.item(1); - assertEquals("child2", child2.getTagName()); - assertTrue(child2.hasAttributes()); - nl2 = child2.getChildNodes(); - assertEquals(0, nl2.getLength()); - assertEquals("bar", child2.getAttribute("foo")); - - assertEquals(Node.ELEMENT_NODE, nl.item(2).getNodeType()); - Element child3 = (Element) nl.item(2); - assertEquals("child3", child3.getTagName()); - assertTrue(!child3.hasAttributes()); - nl2 = child3.getChildNodes(); - assertEquals(1, nl2.getLength()); - assertEquals(Node.ELEMENT_NODE, nl2.item(0).getNodeType()); - assertEquals("child4", ((Element) nl2.item(0)).getTagName()); - } -} +/* + * 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.util; + +import org.apache.tools.ant.BuildFileRule; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +public class XMLFragmentTest { + + @Rule + public BuildFileRule buildRule = new BuildFileRule(); + + @Before + public void setUp() { + buildRule.configureProject("src/etc/testcases/types/xmlfragment.xml"); + } + + @Test + public void testNestedText() { + XMLFragment x = (XMLFragment) buildRule.getProject().getReference("nested-text"); + assertNotNull(x); + Node n = x.getFragment(); + assertTrue("No attributes", !n.hasAttributes()); + NodeList nl = n.getChildNodes(); + assertEquals(1, nl.getLength()); + assertEquals(Node.TEXT_NODE, nl.item(0).getNodeType()); + assertEquals("foo", nl.item(0).getNodeValue()); + } + + @Test + public void testNestedChildren() { + XMLFragment x = + (XMLFragment) buildRule.getProject().getReference("with-children"); + assertNotNull(x); + Node n = x.getFragment(); + assertTrue("No attributes", !n.hasAttributes()); + NodeList nl = n.getChildNodes(); + assertEquals(3, nl.getLength()); + + assertEquals(Node.ELEMENT_NODE, nl.item(0).getNodeType()); + Element child1 = (Element) nl.item(0); + assertEquals("child1", child1.getTagName()); + assertTrue(!child1.hasAttributes()); + NodeList nl2 = child1.getChildNodes(); + assertEquals(1, nl2.getLength()); + assertEquals(Node.TEXT_NODE, nl2.item(0).getNodeType()); + assertEquals("foo", nl2.item(0).getNodeValue()); + + assertEquals(Node.ELEMENT_NODE, nl.item(1).getNodeType()); + Element child2 = (Element) nl.item(1); + assertEquals("child2", child2.getTagName()); + assertTrue(child2.hasAttributes()); + nl2 = child2.getChildNodes(); + assertEquals(0, nl2.getLength()); + assertEquals("bar", child2.getAttribute("foo")); + + assertEquals(Node.ELEMENT_NODE, nl.item(2).getNodeType()); + Element child3 = (Element) nl.item(2); + assertEquals("child3", child3.getTagName()); + assertTrue(!child3.hasAttributes()); + nl2 = child3.getChildNodes(); + assertEquals(1, nl2.getLength()); + assertEquals(Node.ELEMENT_NODE, nl2.item(0).getNodeType()); + assertEquals("child4", ((Element) nl2.item(0)).getTagName()); + } +} http://git-wip-us.apache.org/repos/asf/ant/blob/1ae68097/src/tests/junit/org/apache/tools/ant/util/facade/FacadeTaskHelperTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/util/facade/FacadeTaskHelperTest.java b/src/tests/junit/org/apache/tools/ant/util/facade/FacadeTaskHelperTest.java index df2d43b..3377d73 100644 --- a/src/tests/junit/org/apache/tools/ant/util/facade/FacadeTaskHelperTest.java +++ b/src/tests/junit/org/apache/tools/ant/util/facade/FacadeTaskHelperTest.java @@ -1,64 +1,64 @@ -/* - * 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.util.facade; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -/** - * @since Ant 1.5 - */ -public class FacadeTaskHelperTest { - - @Test - public void testPrecedenceRules() { - FacadeTaskHelper fth = new FacadeTaskHelper("foo"); - assertEquals("foo", fth.getImplementation()); - - fth.setMagicValue("bar"); - assertEquals("bar", fth.getImplementation()); - - fth = new FacadeTaskHelper("foo", "bar"); - assertEquals("bar", fth.getImplementation()); - - fth = new FacadeTaskHelper("foo", null); - assertEquals("foo", fth.getImplementation()); - - fth = new FacadeTaskHelper("foo"); - fth.setMagicValue("bar"); - fth.setImplementation("baz"); - assertEquals("baz", fth.getImplementation()); - } - - @Test - public void testHasBeenSet() { - FacadeTaskHelper fth = new FacadeTaskHelper("foo"); - assertTrue("nothing set", !fth.hasBeenSet()); - fth.setMagicValue(null); - assertTrue("magic has not been set", !fth.hasBeenSet()); - fth.setMagicValue("foo"); - assertTrue("magic has been set", fth.hasBeenSet()); - fth.setMagicValue(null); - assertTrue(!fth.hasBeenSet()); - fth.setImplementation("baz"); - assertTrue("set explicitly", fth.hasBeenSet()); - } -} +/* + * 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.util.facade; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +/** + * @since Ant 1.5 + */ +public class FacadeTaskHelperTest { + + @Test + public void testPrecedenceRules() { + FacadeTaskHelper fth = new FacadeTaskHelper("foo"); + assertEquals("foo", fth.getImplementation()); + + fth.setMagicValue("bar"); + assertEquals("bar", fth.getImplementation()); + + fth = new FacadeTaskHelper("foo", "bar"); + assertEquals("bar", fth.getImplementation()); + + fth = new FacadeTaskHelper("foo", null); + assertEquals("foo", fth.getImplementation()); + + fth = new FacadeTaskHelper("foo"); + fth.setMagicValue("bar"); + fth.setImplementation("baz"); + assertEquals("baz", fth.getImplementation()); + } + + @Test + public void testHasBeenSet() { + FacadeTaskHelper fth = new FacadeTaskHelper("foo"); + assertTrue("nothing set", !fth.hasBeenSet()); + fth.setMagicValue(null); + assertTrue("magic has not been set", !fth.hasBeenSet()); + fth.setMagicValue("foo"); + assertTrue("magic has been set", fth.hasBeenSet()); + fth.setMagicValue(null); + assertTrue(!fth.hasBeenSet()); + fth.setImplementation("baz"); + assertTrue("set explicitly", fth.hasBeenSet()); + } +} http://git-wip-us.apache.org/repos/asf/ant/blob/1ae68097/src/tests/junit/org/apache/tools/ant/util/facade/ImplementationSpecificArgumentTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/util/facade/ImplementationSpecificArgumentTest.java b/src/tests/junit/org/apache/tools/ant/util/facade/ImplementationSpecificArgumentTest.java index a1b97d1..7a678bc 100644 --- a/src/tests/junit/org/apache/tools/ant/util/facade/ImplementationSpecificArgumentTest.java +++ b/src/tests/junit/org/apache/tools/ant/util/facade/ImplementationSpecificArgumentTest.java @@ -1,59 +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.util.facade; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -/** - * @since Ant 1.5 - */ -public class ImplementationSpecificArgumentTest { - - @Test - public void testDependsOnImplementation() { - ImplementationSpecificArgument ia = - new ImplementationSpecificArgument(); - ia.setLine("A B"); - String[] parts = ia.getParts(); - assertNotNull(parts); - assertEquals(2, parts.length); - assertEquals("A", parts[0]); - assertEquals("B", parts[1]); - - parts = ia.getParts(null); - assertNotNull(parts); - assertEquals(2, parts.length); - assertEquals("A", parts[0]); - assertEquals("B", parts[1]); - - ia.setImplementation("foo"); - parts = ia.getParts(null); - assertNotNull(parts); - assertEquals(0, parts.length); - - parts = ia.getParts("foo"); - assertNotNull(parts); - assertEquals(2, parts.length); - assertEquals("A", parts[0]); - assertEquals("B", parts[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.util.facade; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +/** + * @since Ant 1.5 + */ +public class ImplementationSpecificArgumentTest { + + @Test + public void testDependsOnImplementation() { + ImplementationSpecificArgument ia = + new ImplementationSpecificArgument(); + ia.setLine("A B"); + String[] parts = ia.getParts(); + assertNotNull(parts); + assertEquals(2, parts.length); + assertEquals("A", parts[0]); + assertEquals("B", parts[1]); + + parts = ia.getParts(null); + assertNotNull(parts); + assertEquals(2, parts.length); + assertEquals("A", parts[0]); + assertEquals("B", parts[1]); + + ia.setImplementation("foo"); + parts = ia.getParts(null); + assertNotNull(parts); + assertEquals(0, parts.length); + + parts = ia.getParts("foo"); + assertNotNull(parts); + assertEquals(2, parts.length); + assertEquals("A", parts[0]); + assertEquals("B", parts[1]); + } +} http://git-wip-us.apache.org/repos/asf/ant/blob/1ae68097/src/tests/junit/org/apache/tools/ant/util/regexp/JakartaOroMatcherTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/util/regexp/JakartaOroMatcherTest.java b/src/tests/junit/org/apache/tools/ant/util/regexp/JakartaOroMatcherTest.java index d1405f4..073cf86 100644 --- a/src/tests/junit/org/apache/tools/ant/util/regexp/JakartaOroMatcherTest.java +++ b/src/tests/junit/org/apache/tools/ant/util/regexp/JakartaOroMatcherTest.java @@ -1,35 +1,35 @@ -/* - * 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.util.regexp; - -/** - * Tests for the jakarta-oro implementation of the RegexpMatcher interface. - * - */ -public class JakartaOroMatcherTest extends RegexpMatcherTest { - - public RegexpMatcher getImplementation() { - return new JakartaOroMatcher(); - } - - public JakartaOroMatcherTest(String name) { - super(name); - } - -} +/* + * 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.util.regexp; + +/** + * Tests for the jakarta-oro implementation of the RegexpMatcher interface. + * + */ +public class JakartaOroMatcherTest extends RegexpMatcherTest { + + public RegexpMatcher getImplementation() { + return new JakartaOroMatcher(); + } + + public JakartaOroMatcherTest(String name) { + super(name); + } + +} http://git-wip-us.apache.org/repos/asf/ant/blob/1ae68097/src/tests/junit/org/apache/tools/ant/util/regexp/JakartaOroRegexpTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/util/regexp/JakartaOroRegexpTest.java b/src/tests/junit/org/apache/tools/ant/util/regexp/JakartaOroRegexpTest.java index e869c62..340e602 100644 --- a/src/tests/junit/org/apache/tools/ant/util/regexp/JakartaOroRegexpTest.java +++ b/src/tests/junit/org/apache/tools/ant/util/regexp/JakartaOroRegexpTest.java @@ -1,35 +1,35 @@ -/* - * 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.util.regexp; - -/** - * Tests for the jakarta-oro implementation of the Regexp interface. - * - */ -public class JakartaOroRegexpTest extends RegexpTest { - - public Regexp getRegexpImplementation() { - return new JakartaOroRegexp(); - } - - public JakartaOroRegexpTest(String name) { - super(name); - } - -} +/* + * 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.util.regexp; + +/** + * Tests for the jakarta-oro implementation of the Regexp interface. + * + */ +public class JakartaOroRegexpTest extends RegexpTest { + + public Regexp getRegexpImplementation() { + return new JakartaOroRegexp(); + } + + public JakartaOroRegexpTest(String name) { + super(name); + } + +} http://git-wip-us.apache.org/repos/asf/ant/blob/1ae68097/src/tests/junit/org/apache/tools/ant/util/regexp/JakartaRegexpMatcherTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/util/regexp/JakartaRegexpMatcherTest.java b/src/tests/junit/org/apache/tools/ant/util/regexp/JakartaRegexpMatcherTest.java index 3340b59..0b1bb55 100644 --- a/src/tests/junit/org/apache/tools/ant/util/regexp/JakartaRegexpMatcherTest.java +++ b/src/tests/junit/org/apache/tools/ant/util/regexp/JakartaRegexpMatcherTest.java @@ -1,63 +1,63 @@ -/* - * 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.util.regexp; - -import java.io.IOException; - -import junit.framework.AssertionFailedError; - -/** - * Tests for the jakarta-regexp implementation of the RegexpMatcher interface. - * - */ -public class JakartaRegexpMatcherTest extends RegexpMatcherTest { - - public RegexpMatcher getImplementation() { - return new JakartaRegexpMatcher(); - } - - public JakartaRegexpMatcherTest(String name) { - super(name); - } - - public void testWindowsLineSeparator2() throws IOException { - try { - super.testWindowsLineSeparator2(); - fail("Should trigger when this bug is fixed. {@since 1.2}"); - } catch (AssertionFailedError e) { - } - } - - /** - * Fails for the same reason as "default" mode in doEndTest2. - */ - public void testUnixLineSeparator() throws IOException { - try { - super.testUnixLineSeparator(); - fail("Should trigger once this bug is fixed. {@since 1.2}"); - } catch (AssertionFailedError e) { - } - } - - - /** - * Fails for "default" mode. - */ - protected void doEndTest2(String text) {} -} +/* + * 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.util.regexp; + +import java.io.IOException; + +import junit.framework.AssertionFailedError; + +/** + * Tests for the jakarta-regexp implementation of the RegexpMatcher interface. + * + */ +public class JakartaRegexpMatcherTest extends RegexpMatcherTest { + + public RegexpMatcher getImplementation() { + return new JakartaRegexpMatcher(); + } + + public JakartaRegexpMatcherTest(String name) { + super(name); + } + + public void testWindowsLineSeparator2() throws IOException { + try { + super.testWindowsLineSeparator2(); + fail("Should trigger when this bug is fixed. {@since 1.2}"); + } catch (AssertionFailedError e) { + } + } + + /** + * Fails for the same reason as "default" mode in doEndTest2. + */ + public void testUnixLineSeparator() throws IOException { + try { + super.testUnixLineSeparator(); + fail("Should trigger once this bug is fixed. {@since 1.2}"); + } catch (AssertionFailedError e) { + } + } + + + /** + * Fails for "default" mode. + */ + protected void doEndTest2(String text) {} +} http://git-wip-us.apache.org/repos/asf/ant/blob/1ae68097/src/tests/junit/org/apache/tools/ant/util/regexp/JakartaRegexpRegexpTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/util/regexp/JakartaRegexpRegexpTest.java b/src/tests/junit/org/apache/tools/ant/util/regexp/JakartaRegexpRegexpTest.java index 078fbb1..ea2b963 100644 --- a/src/tests/junit/org/apache/tools/ant/util/regexp/JakartaRegexpRegexpTest.java +++ b/src/tests/junit/org/apache/tools/ant/util/regexp/JakartaRegexpRegexpTest.java @@ -1,62 +1,62 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.util.regexp; - -import java.io.IOException; - -import junit.framework.AssertionFailedError; - -/** - * Tests for the jakarta-regexp implementation of the Regexp interface. - * - */ -public class JakartaRegexpRegexpTest extends RegexpTest { - - public Regexp getRegexpImplementation() { - return new JakartaRegexpRegexp(); - } - - public JakartaRegexpRegexpTest(String name) { - super(name); - } - - public void testWindowsLineSeparator2() throws IOException { - try { - super.testWindowsLineSeparator2(); - fail("Should trigger when this bug is fixed. {@since 1.2}"); - } catch (AssertionFailedError e){ - } - } - - /** - * Fails for the same reason as "default" mode in doEndTest2. - */ - public void testUnixLineSeparator() throws IOException { - try { - super.testUnixLineSeparator(); - fail("Should trigger once this bug is fixed. {@since 1.2}"); - } catch (AssertionFailedError e){ - } - } - - /** - * Fails for "default" mode. - */ - protected void doEndTest2(String text) {} -} +/* + * 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.util.regexp; + +import java.io.IOException; + +import junit.framework.AssertionFailedError; + +/** + * Tests for the jakarta-regexp implementation of the Regexp interface. + * + */ +public class JakartaRegexpRegexpTest extends RegexpTest { + + public Regexp getRegexpImplementation() { + return new JakartaRegexpRegexp(); + } + + public JakartaRegexpRegexpTest(String name) { + super(name); + } + + public void testWindowsLineSeparator2() throws IOException { + try { + super.testWindowsLineSeparator2(); + fail("Should trigger when this bug is fixed. {@since 1.2}"); + } catch (AssertionFailedError e){ + } + } + + /** + * Fails for the same reason as "default" mode in doEndTest2. + */ + public void testUnixLineSeparator() throws IOException { + try { + super.testUnixLineSeparator(); + fail("Should trigger once this bug is fixed. {@since 1.2}"); + } catch (AssertionFailedError e){ + } + } + + /** + * Fails for "default" mode. + */ + protected void doEndTest2(String text) {} +} http://git-wip-us.apache.org/repos/asf/ant/blob/1ae68097/src/tests/junit/org/apache/tools/ant/util/regexp/Jdk14RegexpMatcherTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/util/regexp/Jdk14RegexpMatcherTest.java b/src/tests/junit/org/apache/tools/ant/util/regexp/Jdk14RegexpMatcherTest.java index c042e71..fdb3e7d 100644 --- a/src/tests/junit/org/apache/tools/ant/util/regexp/Jdk14RegexpMatcherTest.java +++ b/src/tests/junit/org/apache/tools/ant/util/regexp/Jdk14RegexpMatcherTest.java @@ -1,70 +1,70 @@ -/* - * 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.util.regexp; - -import java.io.IOException; - -import junit.framework.AssertionFailedError; - -/** - * Tests for the JDK 1.4 implementation of the RegexpMatcher interface. - * - */ -public class Jdk14RegexpMatcherTest extends RegexpMatcherTest { - - public RegexpMatcher getImplementation() { - return new Jdk14RegexpMatcher(); - } - - public Jdk14RegexpMatcherTest(String name) { - super(name); - } - - public void testParagraphCharacter() throws IOException { - try { - super.testParagraphCharacter(); - fail("Should trigger once fixed. {@since JDK 1.4RC1}"); - } catch (AssertionFailedError e){ - } - } - - public void testLineSeparatorCharacter() throws IOException { - try { - super.testLineSeparatorCharacter(); - fail("Should trigger once fixed. {@since JDK 1.4RC1}"); - } catch (AssertionFailedError e){ - } - } - - public void testStandaloneCR() throws IOException { - try { - super.testStandaloneCR(); - fail("Should trigger once fixed. {@since JDK 1.4RC1}"); - } catch (AssertionFailedError e){ - } - } - - public void testWindowsLineSeparator() throws IOException { - try { - super.testWindowsLineSeparator(); - fail("Should trigger once fixed. {@since JDK 1.4RC1}"); - } catch (AssertionFailedError e){ - } - } -} +/* + * 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.util.regexp; + +import java.io.IOException; + +import junit.framework.AssertionFailedError; + +/** + * Tests for the JDK 1.4 implementation of the RegexpMatcher interface. + * + */ +public class Jdk14RegexpMatcherTest extends RegexpMatcherTest { + + public RegexpMatcher getImplementation() { + return new Jdk14RegexpMatcher(); + } + + public Jdk14RegexpMatcherTest(String name) { + super(name); + } + + public void testParagraphCharacter() throws IOException { + try { + super.testParagraphCharacter(); + fail("Should trigger once fixed. {@since JDK 1.4RC1}"); + } catch (AssertionFailedError e){ + } + } + + public void testLineSeparatorCharacter() throws IOException { + try { + super.testLineSeparatorCharacter(); + fail("Should trigger once fixed. {@since JDK 1.4RC1}"); + } catch (AssertionFailedError e){ + } + } + + public void testStandaloneCR() throws IOException { + try { + super.testStandaloneCR(); + fail("Should trigger once fixed. {@since JDK 1.4RC1}"); + } catch (AssertionFailedError e){ + } + } + + public void testWindowsLineSeparator() throws IOException { + try { + super.testWindowsLineSeparator(); + fail("Should trigger once fixed. {@since JDK 1.4RC1}"); + } catch (AssertionFailedError e){ + } + } +} http://git-wip-us.apache.org/repos/asf/ant/blob/1ae68097/src/tests/junit/org/apache/tools/ant/util/regexp/Jdk14RegexpRegexpTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/util/regexp/Jdk14RegexpRegexpTest.java b/src/tests/junit/org/apache/tools/ant/util/regexp/Jdk14RegexpRegexpTest.java index 2b60406..7843adc 100644 --- a/src/tests/junit/org/apache/tools/ant/util/regexp/Jdk14RegexpRegexpTest.java +++ b/src/tests/junit/org/apache/tools/ant/util/regexp/Jdk14RegexpRegexpTest.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.util.regexp; - -import java.io.IOException; - -import junit.framework.AssertionFailedError; - -/** - * Tests for the JDK 1.4 implementation of the Regexp interface. - * - */ -public class Jdk14RegexpRegexpTest extends RegexpTest { - - public Regexp getRegexpImplementation() { - return new Jdk14RegexpRegexp(); - } - - public Jdk14RegexpRegexpTest(String name) { - super(name); - } - - public void testParagraphCharacter() throws IOException { - try { - super.testParagraphCharacter(); - fail("Should trigger once fixed. {@since JDK 1.4RC1}"); - } catch (AssertionFailedError e){ - } - } - - public void testLineSeparatorCharacter() throws IOException { - try { - super.testLineSeparatorCharacter(); - fail("Should trigger once fixed. {@since JDK 1.4RC1}"); - } catch (AssertionFailedError e){ - } - } - - public void testStandaloneCR() throws IOException { - try { - super.testStandaloneCR(); - fail("Should trigger once fixed. {@since JDK 1.4RC1}"); - } catch (AssertionFailedError e){ - } - } - - public void testWindowsLineSeparator() throws IOException { - try { - super.testWindowsLineSeparator(); - fail("Should trigger once fixed. {@since JDK 1.4RC1}"); - } catch (AssertionFailedError e){ - } - } - -} +/* + * 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.util.regexp; + +import java.io.IOException; + +import junit.framework.AssertionFailedError; + +/** + * Tests for the JDK 1.4 implementation of the Regexp interface. + * + */ +public class Jdk14RegexpRegexpTest extends RegexpTest { + + public Regexp getRegexpImplementation() { + return new Jdk14RegexpRegexp(); + } + + public Jdk14RegexpRegexpTest(String name) { + super(name); + } + + public void testParagraphCharacter() throws IOException { + try { + super.testParagraphCharacter(); + fail("Should trigger once fixed. {@since JDK 1.4RC1}"); + } catch (AssertionFailedError e){ + } + } + + public void testLineSeparatorCharacter() throws IOException { + try { + super.testLineSeparatorCharacter(); + fail("Should trigger once fixed. {@since JDK 1.4RC1}"); + } catch (AssertionFailedError e){ + } + } + + public void testStandaloneCR() throws IOException { + try { + super.testStandaloneCR(); + fail("Should trigger once fixed. {@since JDK 1.4RC1}"); + } catch (AssertionFailedError e){ + } + } + + public void testWindowsLineSeparator() throws IOException { + try { + super.testWindowsLineSeparator(); + fail("Should trigger once fixed. {@since JDK 1.4RC1}"); + } catch (AssertionFailedError e){ + } + } + +}
