Repository: ant Updated Branches: refs/heads/master 28cfaa46c -> 1ae680978
http://git-wip-us.apache.org/repos/asf/ant/blob/1ae68097/src/tests/junit/org/apache/tools/zip/ZipEntryTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/zip/ZipEntryTest.java b/src/tests/junit/org/apache/tools/zip/ZipEntryTest.java index 3c21f6f..804547a 100644 --- a/src/tests/junit/org/apache/tools/zip/ZipEntryTest.java +++ b/src/tests/junit/org/apache/tools/zip/ZipEntryTest.java @@ -1,228 +1,228 @@ -/* - * 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.zip; - -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.fail; - -/** - * JUnit 3 testcases for org.apache.tools.zip.ZipEntry. - * - */ -public class ZipEntryTest { - - - /** - * test handling of extra fields - */ - @Test - public void testExtraFields() { - AsiExtraField a = new AsiExtraField(); - a.setDirectory(true); - a.setMode(0755); - UnrecognizedExtraField u = new UnrecognizedExtraField(); - u.setHeaderId(ExtraFieldUtilsTest.UNRECOGNIZED_HEADER); - u.setLocalFileDataData(new byte[0]); - - ZipEntry ze = new ZipEntry("test/"); - ze.setExtraFields(new ZipExtraField[] {a, u}); - byte[] data1 = ze.getExtra(); - ZipExtraField[] result = ze.getExtraFields(); - assertEquals("first pass", 2, result.length); - assertSame(a, result[0]); - assertSame(u, result[1]); - - UnrecognizedExtraField u2 = new UnrecognizedExtraField(); - u2.setHeaderId(ExtraFieldUtilsTest.UNRECOGNIZED_HEADER); - u2.setLocalFileDataData(new byte[] {1}); - - ze.addExtraField(u2); - byte[] data2 = ze.getExtra(); - result = ze.getExtraFields(); - assertEquals("second pass", 2, result.length); - assertSame(a, result[0]); - assertSame(u2, result[1]); - assertEquals("length second pass", data1.length+1, data2.length); - - UnrecognizedExtraField u3 = new UnrecognizedExtraField(); - u3.setHeaderId(new ZipShort(2)); - u3.setLocalFileDataData(new byte[] {1}); - ze.addExtraField(u3); - result = ze.getExtraFields(); - assertEquals("third pass", 3, result.length); - - ze.removeExtraField(ExtraFieldUtilsTest.UNRECOGNIZED_HEADER); - byte[] data3 = ze.getExtra(); - result = ze.getExtraFields(); - assertEquals("fourth pass", 2, result.length); - assertSame(a, result[0]); - assertSame(u3, result[1]); - assertEquals("length fourth pass", data2.length, data3.length); - - try { - ze.removeExtraField(ExtraFieldUtilsTest.UNRECOGNIZED_HEADER); - fail("should be no such element"); - } catch (java.util.NoSuchElementException nse) { - //TODO assert exception values - } - } - - /** - * test handling of extra fields via central directory - */ - @Test - public void testExtraFieldMerging() { - AsiExtraField a = new AsiExtraField(); - a.setDirectory(true); - a.setMode(0755); - UnrecognizedExtraField u = new UnrecognizedExtraField(); - u.setHeaderId(ExtraFieldUtilsTest.UNRECOGNIZED_HEADER); - u.setLocalFileDataData(new byte[0]); - - ZipEntry ze = new ZipEntry("test/"); - ze.setExtraFields(new ZipExtraField[] {a, u}); - - // merge - // Header-ID 1 + length 1 + one byte of data - byte[] b = ExtraFieldUtilsTest.UNRECOGNIZED_HEADER.getBytes(); - ze.setCentralDirectoryExtra(new byte[] {b[0], b[1], 1, 0, 127}); - - ZipExtraField[] result = ze.getExtraFields(); - assertEquals("first pass", 2, result.length); - assertSame(a, result[0]); - assertEquals(ExtraFieldUtilsTest.UNRECOGNIZED_HEADER, - result[1].getHeaderId()); - assertEquals(new ZipShort(0), result[1].getLocalFileDataLength()); - assertEquals(new ZipShort(1), result[1].getCentralDirectoryLength()); - - // add new - // Header-ID 2 + length 0 - ze.setCentralDirectoryExtra(new byte[] {2, 0, 0, 0}); - - result = ze.getExtraFields(); - assertEquals("second pass", 3, result.length); - - // merge - // Header-ID 2 + length 1 + one byte of data - ze.setExtra(new byte[] {2, 0, 1, 0, 127}); - - result = ze.getExtraFields(); - assertEquals("third pass", 3, result.length); - assertSame(a, result[0]); - assertEquals(new ZipShort(2), result[2].getHeaderId()); - assertEquals(new ZipShort(1), result[2].getLocalFileDataLength()); - assertEquals(new ZipShort(0), result[2].getCentralDirectoryLength()); - } - - /** - * test handling of extra fields - */ - @Test - public void testAddAsFirstExtraField() { - AsiExtraField a = new AsiExtraField(); - a.setDirectory(true); - a.setMode(0755); - UnrecognizedExtraField u = new UnrecognizedExtraField(); - u.setHeaderId(ExtraFieldUtilsTest.UNRECOGNIZED_HEADER); - u.setLocalFileDataData(new byte[0]); - - ZipEntry ze = new ZipEntry("test/"); - ze.setExtraFields(new ZipExtraField[] {a, u}); - byte[] data1 = ze.getExtra(); - - UnrecognizedExtraField u2 = new UnrecognizedExtraField(); - u2.setHeaderId(ExtraFieldUtilsTest.UNRECOGNIZED_HEADER); - u2.setLocalFileDataData(new byte[] {1}); - - ze.addAsFirstExtraField(u2); - byte[] data2 = ze.getExtra(); - ZipExtraField[] result = ze.getExtraFields(); - assertEquals("second pass", 2, result.length); - assertSame(u2, result[0]); - assertSame(a, result[1]); - assertEquals("length second pass", data1.length + 1, data2.length); - - UnrecognizedExtraField u3 = new UnrecognizedExtraField(); - u3.setHeaderId(new ZipShort(2)); - u3.setLocalFileDataData(new byte[] {1}); - ze.addAsFirstExtraField(u3); - result = ze.getExtraFields(); - assertEquals("third pass", 3, result.length); - assertSame(u3, result[0]); - assertSame(u2, result[1]); - assertSame(a, result[2]); - } - - @Test - public void testUnixMode() { - ZipEntry ze = new ZipEntry("foo"); - assertEquals(0, ze.getPlatform()); - ze.setUnixMode(0755); - assertEquals(3, ze.getPlatform()); - assertEquals(0755, - (ze.getExternalAttributes() >> 16) & 0xFFFF); - assertEquals(0, ze.getExternalAttributes() & 0xFFFF); - - ze.setUnixMode(0444); - assertEquals(3, ze.getPlatform()); - assertEquals(0444, - (ze.getExternalAttributes() >> 16) & 0xFFFF); - assertEquals(1, ze.getExternalAttributes() & 0xFFFF); - - ze = new ZipEntry("foo/"); - assertEquals(0, ze.getPlatform()); - ze.setUnixMode(0777); - assertEquals(3, ze.getPlatform()); - assertEquals(0777, - (ze.getExternalAttributes() >> 16) & 0xFFFF); - assertEquals(0x10, ze.getExternalAttributes() & 0xFFFF); - - ze.setUnixMode(0577); - assertEquals(3, ze.getPlatform()); - assertEquals(0577, - (ze.getExternalAttributes() >> 16) & 0xFFFF); - assertEquals(0x11, ze.getExternalAttributes() & 0xFFFF); - } - - /** - * Test case for - * <a href="https://issues.apache.org/jira/browse/COMPRESS-94" - * >COMPRESS-94</a>. - */ - @Test - public void testNotEquals() { - ZipEntry entry1 = new ZipEntry("foo"); - ZipEntry entry2 = new ZipEntry("bar"); - assertFalse(entry1.equals(entry2)); - } - - @Test - public void testCopyConstructor() throws Exception { - ZipEntry archiveEntry = new ZipEntry("fred"); - archiveEntry.setUnixMode(0664); - archiveEntry.setMethod(ZipEntry.DEFLATED); - archiveEntry.getGeneralPurposeBit().useStrongEncryption(true); - ZipEntry copy = new ZipEntry(archiveEntry); - assertEquals(archiveEntry, copy); - } -} +/* + * 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.zip; + +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.fail; + +/** + * JUnit 3 testcases for org.apache.tools.zip.ZipEntry. + * + */ +public class ZipEntryTest { + + + /** + * test handling of extra fields + */ + @Test + public void testExtraFields() { + AsiExtraField a = new AsiExtraField(); + a.setDirectory(true); + a.setMode(0755); + UnrecognizedExtraField u = new UnrecognizedExtraField(); + u.setHeaderId(ExtraFieldUtilsTest.UNRECOGNIZED_HEADER); + u.setLocalFileDataData(new byte[0]); + + ZipEntry ze = new ZipEntry("test/"); + ze.setExtraFields(new ZipExtraField[] {a, u}); + byte[] data1 = ze.getExtra(); + ZipExtraField[] result = ze.getExtraFields(); + assertEquals("first pass", 2, result.length); + assertSame(a, result[0]); + assertSame(u, result[1]); + + UnrecognizedExtraField u2 = new UnrecognizedExtraField(); + u2.setHeaderId(ExtraFieldUtilsTest.UNRECOGNIZED_HEADER); + u2.setLocalFileDataData(new byte[] {1}); + + ze.addExtraField(u2); + byte[] data2 = ze.getExtra(); + result = ze.getExtraFields(); + assertEquals("second pass", 2, result.length); + assertSame(a, result[0]); + assertSame(u2, result[1]); + assertEquals("length second pass", data1.length+1, data2.length); + + UnrecognizedExtraField u3 = new UnrecognizedExtraField(); + u3.setHeaderId(new ZipShort(2)); + u3.setLocalFileDataData(new byte[] {1}); + ze.addExtraField(u3); + result = ze.getExtraFields(); + assertEquals("third pass", 3, result.length); + + ze.removeExtraField(ExtraFieldUtilsTest.UNRECOGNIZED_HEADER); + byte[] data3 = ze.getExtra(); + result = ze.getExtraFields(); + assertEquals("fourth pass", 2, result.length); + assertSame(a, result[0]); + assertSame(u3, result[1]); + assertEquals("length fourth pass", data2.length, data3.length); + + try { + ze.removeExtraField(ExtraFieldUtilsTest.UNRECOGNIZED_HEADER); + fail("should be no such element"); + } catch (java.util.NoSuchElementException nse) { + //TODO assert exception values + } + } + + /** + * test handling of extra fields via central directory + */ + @Test + public void testExtraFieldMerging() { + AsiExtraField a = new AsiExtraField(); + a.setDirectory(true); + a.setMode(0755); + UnrecognizedExtraField u = new UnrecognizedExtraField(); + u.setHeaderId(ExtraFieldUtilsTest.UNRECOGNIZED_HEADER); + u.setLocalFileDataData(new byte[0]); + + ZipEntry ze = new ZipEntry("test/"); + ze.setExtraFields(new ZipExtraField[] {a, u}); + + // merge + // Header-ID 1 + length 1 + one byte of data + byte[] b = ExtraFieldUtilsTest.UNRECOGNIZED_HEADER.getBytes(); + ze.setCentralDirectoryExtra(new byte[] {b[0], b[1], 1, 0, 127}); + + ZipExtraField[] result = ze.getExtraFields(); + assertEquals("first pass", 2, result.length); + assertSame(a, result[0]); + assertEquals(ExtraFieldUtilsTest.UNRECOGNIZED_HEADER, + result[1].getHeaderId()); + assertEquals(new ZipShort(0), result[1].getLocalFileDataLength()); + assertEquals(new ZipShort(1), result[1].getCentralDirectoryLength()); + + // add new + // Header-ID 2 + length 0 + ze.setCentralDirectoryExtra(new byte[] {2, 0, 0, 0}); + + result = ze.getExtraFields(); + assertEquals("second pass", 3, result.length); + + // merge + // Header-ID 2 + length 1 + one byte of data + ze.setExtra(new byte[] {2, 0, 1, 0, 127}); + + result = ze.getExtraFields(); + assertEquals("third pass", 3, result.length); + assertSame(a, result[0]); + assertEquals(new ZipShort(2), result[2].getHeaderId()); + assertEquals(new ZipShort(1), result[2].getLocalFileDataLength()); + assertEquals(new ZipShort(0), result[2].getCentralDirectoryLength()); + } + + /** + * test handling of extra fields + */ + @Test + public void testAddAsFirstExtraField() { + AsiExtraField a = new AsiExtraField(); + a.setDirectory(true); + a.setMode(0755); + UnrecognizedExtraField u = new UnrecognizedExtraField(); + u.setHeaderId(ExtraFieldUtilsTest.UNRECOGNIZED_HEADER); + u.setLocalFileDataData(new byte[0]); + + ZipEntry ze = new ZipEntry("test/"); + ze.setExtraFields(new ZipExtraField[] {a, u}); + byte[] data1 = ze.getExtra(); + + UnrecognizedExtraField u2 = new UnrecognizedExtraField(); + u2.setHeaderId(ExtraFieldUtilsTest.UNRECOGNIZED_HEADER); + u2.setLocalFileDataData(new byte[] {1}); + + ze.addAsFirstExtraField(u2); + byte[] data2 = ze.getExtra(); + ZipExtraField[] result = ze.getExtraFields(); + assertEquals("second pass", 2, result.length); + assertSame(u2, result[0]); + assertSame(a, result[1]); + assertEquals("length second pass", data1.length + 1, data2.length); + + UnrecognizedExtraField u3 = new UnrecognizedExtraField(); + u3.setHeaderId(new ZipShort(2)); + u3.setLocalFileDataData(new byte[] {1}); + ze.addAsFirstExtraField(u3); + result = ze.getExtraFields(); + assertEquals("third pass", 3, result.length); + assertSame(u3, result[0]); + assertSame(u2, result[1]); + assertSame(a, result[2]); + } + + @Test + public void testUnixMode() { + ZipEntry ze = new ZipEntry("foo"); + assertEquals(0, ze.getPlatform()); + ze.setUnixMode(0755); + assertEquals(3, ze.getPlatform()); + assertEquals(0755, + (ze.getExternalAttributes() >> 16) & 0xFFFF); + assertEquals(0, ze.getExternalAttributes() & 0xFFFF); + + ze.setUnixMode(0444); + assertEquals(3, ze.getPlatform()); + assertEquals(0444, + (ze.getExternalAttributes() >> 16) & 0xFFFF); + assertEquals(1, ze.getExternalAttributes() & 0xFFFF); + + ze = new ZipEntry("foo/"); + assertEquals(0, ze.getPlatform()); + ze.setUnixMode(0777); + assertEquals(3, ze.getPlatform()); + assertEquals(0777, + (ze.getExternalAttributes() >> 16) & 0xFFFF); + assertEquals(0x10, ze.getExternalAttributes() & 0xFFFF); + + ze.setUnixMode(0577); + assertEquals(3, ze.getPlatform()); + assertEquals(0577, + (ze.getExternalAttributes() >> 16) & 0xFFFF); + assertEquals(0x11, ze.getExternalAttributes() & 0xFFFF); + } + + /** + * Test case for + * <a href="https://issues.apache.org/jira/browse/COMPRESS-94" + * >COMPRESS-94</a>. + */ + @Test + public void testNotEquals() { + ZipEntry entry1 = new ZipEntry("foo"); + ZipEntry entry2 = new ZipEntry("bar"); + assertFalse(entry1.equals(entry2)); + } + + @Test + public void testCopyConstructor() throws Exception { + ZipEntry archiveEntry = new ZipEntry("fred"); + archiveEntry.setUnixMode(0664); + archiveEntry.setMethod(ZipEntry.DEFLATED); + archiveEntry.getGeneralPurposeBit().useStrongEncryption(true); + ZipEntry copy = new ZipEntry(archiveEntry); + assertEquals(archiveEntry, copy); + } +} http://git-wip-us.apache.org/repos/asf/ant/blob/1ae68097/src/tests/junit/org/apache/tools/zip/ZipLongTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/zip/ZipLongTest.java b/src/tests/junit/org/apache/tools/zip/ZipLongTest.java index a7ece04..8ec8019 100644 --- a/src/tests/junit/org/apache/tools/zip/ZipLongTest.java +++ b/src/tests/junit/org/apache/tools/zip/ZipLongTest.java @@ -1,94 +1,94 @@ -/* - * 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.zip; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertTrue; - -/** - * JUnit testcases for org.apache.tools.zip.ZipLong. - * - */ -public class ZipLongTest { - - /** - * Test conversion to bytes. - */ - @Test - public void testToBytes() { - ZipLong zl = new ZipLong(0x12345678); - byte[] result = zl.getBytes(); - assertEquals("length getBytes", 4, result.length); - assertEquals("first byte getBytes", 0x78, result[0]); - assertEquals("second byte getBytes", 0x56, result[1]); - assertEquals("third byte getBytes", 0x34, result[2]); - assertEquals("fourth byte getBytes", 0x12, result[3]); - } - - /** - * Test conversion from bytes. - */ - @Test - public void testFromBytes() { - byte[] val = new byte[] {0x78, 0x56, 0x34, 0x12}; - ZipLong zl = new ZipLong(val); - assertEquals("value from bytes", 0x12345678, zl.getValue()); - } - - /** - * Test the contract of the equals method. - */ - @Test - public void testEquals() { - ZipLong zl = new ZipLong(0x12345678); - ZipLong zl2 = new ZipLong(0x12345678); - ZipLong zl3 = new ZipLong(0x87654321); - - assertTrue("reflexive", zl.equals(zl)); - - assertTrue("works", zl.equals(zl2)); - assertTrue("works, part two", !zl.equals(zl3)); - - assertTrue("symmetric", zl2.equals(zl)); - - assertTrue("null handling", !zl.equals(null)); - assertTrue("non ZipLong handling", !zl.equals(new Integer(0x1234))); - } - - /** - * Test sign handling. - */ - @Test - public void testSign() { - ZipLong zl = new ZipLong(new byte[] {(byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}); - assertEquals(0x00000000FFFFFFFFl, zl.getValue()); - } - - @Test - public void testClone() { - ZipLong s1 = new ZipLong(42); - ZipLong s2 = (ZipLong) s1.clone(); - assertNotSame(s1, s2); - assertEquals(s1, s2); - assertEquals(s1.getValue(), s2.getValue()); - } -} +/* + * 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.zip; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotSame; +import static org.junit.Assert.assertTrue; + +/** + * JUnit testcases for org.apache.tools.zip.ZipLong. + * + */ +public class ZipLongTest { + + /** + * Test conversion to bytes. + */ + @Test + public void testToBytes() { + ZipLong zl = new ZipLong(0x12345678); + byte[] result = zl.getBytes(); + assertEquals("length getBytes", 4, result.length); + assertEquals("first byte getBytes", 0x78, result[0]); + assertEquals("second byte getBytes", 0x56, result[1]); + assertEquals("third byte getBytes", 0x34, result[2]); + assertEquals("fourth byte getBytes", 0x12, result[3]); + } + + /** + * Test conversion from bytes. + */ + @Test + public void testFromBytes() { + byte[] val = new byte[] {0x78, 0x56, 0x34, 0x12}; + ZipLong zl = new ZipLong(val); + assertEquals("value from bytes", 0x12345678, zl.getValue()); + } + + /** + * Test the contract of the equals method. + */ + @Test + public void testEquals() { + ZipLong zl = new ZipLong(0x12345678); + ZipLong zl2 = new ZipLong(0x12345678); + ZipLong zl3 = new ZipLong(0x87654321); + + assertTrue("reflexive", zl.equals(zl)); + + assertTrue("works", zl.equals(zl2)); + assertTrue("works, part two", !zl.equals(zl3)); + + assertTrue("symmetric", zl2.equals(zl)); + + assertTrue("null handling", !zl.equals(null)); + assertTrue("non ZipLong handling", !zl.equals(new Integer(0x1234))); + } + + /** + * Test sign handling. + */ + @Test + public void testSign() { + ZipLong zl = new ZipLong(new byte[] {(byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}); + assertEquals(0x00000000FFFFFFFFl, zl.getValue()); + } + + @Test + public void testClone() { + ZipLong s1 = new ZipLong(42); + ZipLong s2 = (ZipLong) s1.clone(); + assertNotSame(s1, s2); + assertEquals(s1, s2); + assertEquals(s1.getValue(), s2.getValue()); + } +} http://git-wip-us.apache.org/repos/asf/ant/blob/1ae68097/src/tests/junit/org/apache/tools/zip/ZipOutputStreamTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/zip/ZipOutputStreamTest.java b/src/tests/junit/org/apache/tools/zip/ZipOutputStreamTest.java index a69db6c..7040782 100644 --- a/src/tests/junit/org/apache/tools/zip/ZipOutputStreamTest.java +++ b/src/tests/junit/org/apache/tools/zip/ZipOutputStreamTest.java @@ -1,73 +1,73 @@ -/* - * 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.zip; - -import org.junit.Before; -import org.junit.Test; - -import java.util.Calendar; -import java.util.Date; - -import static org.junit.Assert.assertEquals; - -public class ZipOutputStreamTest { - - private Date time; - private ZipLong zl; - - @Before - public void setUp() throws Exception { - time = new Date(); - Calendar cal = Calendar.getInstance(); - cal.setTime(time); - int year = cal.get(Calendar.YEAR); - int month = cal.get(Calendar.MONTH) + 1; - long value = ((year - 1980) << 25) - | (month << 21) - | (cal.get(Calendar.DAY_OF_MONTH) << 16) - | (cal.get(Calendar.HOUR_OF_DAY) << 11) - | (cal.get(Calendar.MINUTE) << 5) - | (cal.get(Calendar.SECOND) >> 1); - - byte[] result = new byte[4]; - result[0] = (byte) ((value & 0xFF)); - result[1] = (byte) ((value & 0xFF00) >> 8); - result[2] = (byte) ((value & 0xFF0000) >> 16); - result[3] = (byte) ((value & 0xFF000000L) >> 24); - zl = new ZipLong(result); - } - - - @Test - public void testZipLong() throws Exception { - ZipLong test = ZipOutputStream.toDosTime(time); - assertEquals(test.getValue(), zl.getValue()); - } - - @Test - public void testAdjustToLong() { - assertEquals((long) Integer.MAX_VALUE, - ZipOutputStream.adjustToLong(Integer.MAX_VALUE)); - assertEquals(((long) Integer.MAX_VALUE) + 1, - ZipOutputStream.adjustToLong(Integer.MAX_VALUE + 1)); - assertEquals(2 * ((long) Integer.MAX_VALUE), - ZipOutputStream.adjustToLong(2 * Integer.MAX_VALUE)); - } - -} +/* + * 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.zip; + +import org.junit.Before; +import org.junit.Test; + +import java.util.Calendar; +import java.util.Date; + +import static org.junit.Assert.assertEquals; + +public class ZipOutputStreamTest { + + private Date time; + private ZipLong zl; + + @Before + public void setUp() throws Exception { + time = new Date(); + Calendar cal = Calendar.getInstance(); + cal.setTime(time); + int year = cal.get(Calendar.YEAR); + int month = cal.get(Calendar.MONTH) + 1; + long value = ((year - 1980) << 25) + | (month << 21) + | (cal.get(Calendar.DAY_OF_MONTH) << 16) + | (cal.get(Calendar.HOUR_OF_DAY) << 11) + | (cal.get(Calendar.MINUTE) << 5) + | (cal.get(Calendar.SECOND) >> 1); + + byte[] result = new byte[4]; + result[0] = (byte) ((value & 0xFF)); + result[1] = (byte) ((value & 0xFF00) >> 8); + result[2] = (byte) ((value & 0xFF0000) >> 16); + result[3] = (byte) ((value & 0xFF000000L) >> 24); + zl = new ZipLong(result); + } + + + @Test + public void testZipLong() throws Exception { + ZipLong test = ZipOutputStream.toDosTime(time); + assertEquals(test.getValue(), zl.getValue()); + } + + @Test + public void testAdjustToLong() { + assertEquals((long) Integer.MAX_VALUE, + ZipOutputStream.adjustToLong(Integer.MAX_VALUE)); + assertEquals(((long) Integer.MAX_VALUE) + 1, + ZipOutputStream.adjustToLong(Integer.MAX_VALUE + 1)); + assertEquals(2 * ((long) Integer.MAX_VALUE), + ZipOutputStream.adjustToLong(2 * Integer.MAX_VALUE)); + } + +} http://git-wip-us.apache.org/repos/asf/ant/blob/1ae68097/src/tests/junit/org/apache/tools/zip/ZipShortTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/zip/ZipShortTest.java b/src/tests/junit/org/apache/tools/zip/ZipShortTest.java index a6aa3e7..4b97471 100644 --- a/src/tests/junit/org/apache/tools/zip/ZipShortTest.java +++ b/src/tests/junit/org/apache/tools/zip/ZipShortTest.java @@ -1,92 +1,92 @@ -/* - * 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.zip; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertTrue; - -/** - * JUnit 3 testcases for org.apache.tools.zip.ZipShort. - * - */ -public class ZipShortTest { - - /** - * Test conversion to bytes. - */ - @Test - public void testToBytes() { - ZipShort zs = new ZipShort(0x1234); - byte[] result = zs.getBytes(); - assertEquals("length getBytes", 2, result.length); - assertEquals("first byte getBytes", 0x34, result[0]); - assertEquals("second byte getBytes", 0x12, result[1]); - } - - /** - * Test conversion from bytes. - */ - @Test - public void testFromBytes() { - byte[] val = new byte[] {0x34, 0x12}; - ZipShort zs = new ZipShort(val); - assertEquals("value from bytes", 0x1234, zs.getValue()); - } - - /** - * Test the contract of the equals method. - */ - @Test - public void testEquals() { - ZipShort zs = new ZipShort(0x1234); - ZipShort zs2 = new ZipShort(0x1234); - ZipShort zs3 = new ZipShort(0x5678); - - assertTrue("reflexive", zs.equals(zs)); - - assertTrue("works", zs.equals(zs2)); - assertTrue("works, part two", !zs.equals(zs3)); - - assertTrue("symmetric", zs2.equals(zs)); - - assertTrue("null handling", !zs.equals(null)); - assertTrue("non ZipShort handling", !zs.equals(new Integer(0x1234))); - } - - /** - * Test sign handling. - */ - @Test - public void testSign() { - ZipShort zs = new ZipShort(new byte[] {(byte)0xFF, (byte)0xFF}); - assertEquals(0x0000FFFF, zs.getValue()); - } - - @Test - public void testClone() { - ZipShort s1 = new ZipShort(42); - ZipShort s2 = (ZipShort) s1.clone(); - assertNotSame(s1, s2); - assertEquals(s1, s2); - assertEquals(s1.getValue(), s2.getValue()); - } -} +/* + * 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.zip; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotSame; +import static org.junit.Assert.assertTrue; + +/** + * JUnit 3 testcases for org.apache.tools.zip.ZipShort. + * + */ +public class ZipShortTest { + + /** + * Test conversion to bytes. + */ + @Test + public void testToBytes() { + ZipShort zs = new ZipShort(0x1234); + byte[] result = zs.getBytes(); + assertEquals("length getBytes", 2, result.length); + assertEquals("first byte getBytes", 0x34, result[0]); + assertEquals("second byte getBytes", 0x12, result[1]); + } + + /** + * Test conversion from bytes. + */ + @Test + public void testFromBytes() { + byte[] val = new byte[] {0x34, 0x12}; + ZipShort zs = new ZipShort(val); + assertEquals("value from bytes", 0x1234, zs.getValue()); + } + + /** + * Test the contract of the equals method. + */ + @Test + public void testEquals() { + ZipShort zs = new ZipShort(0x1234); + ZipShort zs2 = new ZipShort(0x1234); + ZipShort zs3 = new ZipShort(0x5678); + + assertTrue("reflexive", zs.equals(zs)); + + assertTrue("works", zs.equals(zs2)); + assertTrue("works, part two", !zs.equals(zs3)); + + assertTrue("symmetric", zs2.equals(zs)); + + assertTrue("null handling", !zs.equals(null)); + assertTrue("non ZipShort handling", !zs.equals(new Integer(0x1234))); + } + + /** + * Test sign handling. + */ + @Test + public void testSign() { + ZipShort zs = new ZipShort(new byte[] {(byte)0xFF, (byte)0xFF}); + assertEquals(0x0000FFFF, zs.getValue()); + } + + @Test + public void testClone() { + ZipShort s1 = new ZipShort(42); + ZipShort s2 = (ZipShort) s1.clone(); + assertNotSame(s1, s2); + assertEquals(s1, s2); + assertEquals(s1.getValue(), s2.getValue()); + } +} http://git-wip-us.apache.org/repos/asf/ant/blob/1ae68097/src/tests/junit/org/example/junit/JUnit4Skippable.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/example/junit/JUnit4Skippable.java b/src/tests/junit/org/example/junit/JUnit4Skippable.java index aa89ab7..e71345c 100644 --- a/src/tests/junit/org/example/junit/JUnit4Skippable.java +++ b/src/tests/junit/org/example/junit/JUnit4Skippable.java @@ -1,74 +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.example.junit; - -import org.junit.Assume; -import org.junit.Ignore; -import org.junit.Test; - -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -public class JUnit4Skippable { - - @Test - public void passingTest() { - assertTrue("This test passed", true); - } - - @Ignore("Please don't ignore me!") - @Test - public void explicitIgnoreTest() { - fail("This test should be skipped"); - } - - @Test - public void implicitlyIgnoreTest() { - Assume.assumeFalse("This test will be ignored", true); - fail("I told you, this test should have been ignored!"); - } - - @Test - @Ignore - public void explicitlyIgnoreTestNoMessage() { - fail("This test should be skipped"); - } - - @Test - public void implicitlyIgnoreTestNoMessage() { - Assume.assumeFalse(true); - fail("I told you, this test should have been ignored!"); - } - - @Test - public void failingTest() { - fail("I told you this test was going to fail"); - } - - @Test - public void failingTestNoMessage() { - fail(); - } - - @Test - public void errorTest() { - throw new RuntimeException("Whoops, this test went wrong"); - } - -} +/* + * 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.example.junit; + +import org.junit.Assume; +import org.junit.Ignore; +import org.junit.Test; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +public class JUnit4Skippable { + + @Test + public void passingTest() { + assertTrue("This test passed", true); + } + + @Ignore("Please don't ignore me!") + @Test + public void explicitIgnoreTest() { + fail("This test should be skipped"); + } + + @Test + public void implicitlyIgnoreTest() { + Assume.assumeFalse("This test will be ignored", true); + fail("I told you, this test should have been ignored!"); + } + + @Test + @Ignore + public void explicitlyIgnoreTestNoMessage() { + fail("This test should be skipped"); + } + + @Test + public void implicitlyIgnoreTestNoMessage() { + Assume.assumeFalse(true); + fail("I told you, this test should have been ignored!"); + } + + @Test + public void failingTest() { + fail("I told you this test was going to fail"); + } + + @Test + public void failingTestNoMessage() { + fail(); + } + + @Test + public void errorTest() { + throw new RuntimeException("Whoops, this test went wrong"); + } + +} http://git-wip-us.apache.org/repos/asf/ant/blob/1ae68097/src/tests/junit/org/example/junit/MultilineAsserts.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/example/junit/MultilineAsserts.java b/src/tests/junit/org/example/junit/MultilineAsserts.java index 06e1039..1b0cc59 100644 --- a/src/tests/junit/org/example/junit/MultilineAsserts.java +++ b/src/tests/junit/org/example/junit/MultilineAsserts.java @@ -1,27 +1,27 @@ -/* - * 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.example.junit; - -import junit.framework.TestCase; - -public class MultilineAsserts extends TestCase { - public void testFoo() { assertTrue("testFoo \nmessed up", false); } - public void testBar() { assertTrue("testBar \ndidn't work", true); } - public void testFee() { assertTrue("testFee \ncrashed", false); } - public void testFie() { assertTrue("testFie \nbroke", true); } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.example.junit; + +import junit.framework.TestCase; + +public class MultilineAsserts extends TestCase { + public void testFoo() { assertTrue("testFoo \nmessed up", false); } + public void testBar() { assertTrue("testBar \ndidn't work", true); } + public void testFee() { assertTrue("testFee \ncrashed", false); } + public void testFie() { assertTrue("testFie \nbroke", true); } +} http://git-wip-us.apache.org/repos/asf/ant/blob/1ae68097/src/tests/junit/org/example/junit/Output.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/example/junit/Output.java b/src/tests/junit/org/example/junit/Output.java index a7135f7..a536a47 100644 --- a/src/tests/junit/org/example/junit/Output.java +++ b/src/tests/junit/org/example/junit/Output.java @@ -1,37 +1,37 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.example.junit; - -import junit.framework.TestCase; - -/** - * Not really a test of Ant but a test that is run by the test of the - * junit task. Confused? - * - * @since Ant 1.5 - */ -public class Output extends TestCase { - - public Output(String s) { - super(s); - } - - public void testOutput() { - System.out.println("foo"); - } -} +/* + * 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.example.junit; + +import junit.framework.TestCase; + +/** + * Not really a test of Ant but a test that is run by the test of the + * junit task. Confused? + * + * @since Ant 1.5 + */ +public class Output extends TestCase { + + public Output(String s) { + super(s); + } + + public void testOutput() { + System.out.println("foo"); + } +} http://git-wip-us.apache.org/repos/asf/ant/blob/1ae68097/src/tests/junit/org/example/junit/ThreadedOutput.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/example/junit/ThreadedOutput.java b/src/tests/junit/org/example/junit/ThreadedOutput.java index 91f462a..f5ee38d 100644 --- a/src/tests/junit/org/example/junit/ThreadedOutput.java +++ b/src/tests/junit/org/example/junit/ThreadedOutput.java @@ -1,43 +1,43 @@ -/* - * 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.example.junit; - -import junit.framework.TestCase; - -/** - * Not really a test of Ant but a test that is run by the test of the - * junit task. Confused? - * - * @since Ant 1.5 - */ -public class ThreadedOutput extends TestCase { - - public ThreadedOutput(String s) { - super(s); - } - - public void testOutput() throws InterruptedException { - Thread t = new Thread(new Runnable() { - public void run() { - System.out.println("foo"); - } - }); - t.start(); - t.join(); - } -} +/* + * 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.example.junit; + +import junit.framework.TestCase; + +/** + * Not really a test of Ant but a test that is run by the test of the + * junit task. Confused? + * + * @since Ant 1.5 + */ +public class ThreadedOutput extends TestCase { + + public ThreadedOutput(String s) { + super(s); + } + + public void testOutput() throws InterruptedException { + Thread t = new Thread(new Runnable() { + public void run() { + System.out.println("foo"); + } + }); + t.start(); + t.join(); + } +} http://git-wip-us.apache.org/repos/asf/ant/blob/1ae68097/src/tests/junit/org/example/junit/Timeout.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/example/junit/Timeout.java b/src/tests/junit/org/example/junit/Timeout.java index 6a42ee7..54cb4e7 100644 --- a/src/tests/junit/org/example/junit/Timeout.java +++ b/src/tests/junit/org/example/junit/Timeout.java @@ -1,32 +1,32 @@ -/* - * 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.example.junit; - -import org.junit.After; -import org.junit.Test; - -public class Timeout { - @Test - public void testTimeout() throws InterruptedException { - Thread.sleep(5000); - } - @After - public void tearDown() { - System.out.println("tearDown called on Timeout"); - } -} +/* + * 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.example.junit; + +import org.junit.After; +import org.junit.Test; + +public class Timeout { + @Test + public void testTimeout() throws InterruptedException { + Thread.sleep(5000); + } + @After + public void tearDown() { + System.out.println("tearDown called on Timeout"); + } +} http://git-wip-us.apache.org/repos/asf/ant/blob/1ae68097/src/tests/junit/org/example/junit/XmlParserTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/example/junit/XmlParserTest.java b/src/tests/junit/org/example/junit/XmlParserTest.java index e5fae55..57d74f0 100644 --- a/src/tests/junit/org/example/junit/XmlParserTest.java +++ b/src/tests/junit/org/example/junit/XmlParserTest.java @@ -1,58 +1,58 @@ -/* - * 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.example.junit; - -import org.junit.Test; -import org.xml.sax.SAXException; -import org.xml.sax.XMLReader; -import org.xml.sax.helpers.XMLReaderFactory; - -import static org.junit.Assert.assertNotNull; - -/** - * created Aug 12, 2004 1:39:59 PM - */ - -public class XmlParserTest { - - - @Test - public void testXercesIsPresent() throws SAXException { - XMLReader xerces; - xerces = XMLReaderFactory.createXMLReader( - "org.apache.xerces.parsers.SAXParser"); - assertNotNull(xerces); - } - - @Test - public void testXercesHandlesSchema() throws SAXException { - XMLReader xerces; - xerces = XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser"); - xerces.setFeature("http://apache.org/xml/features/validation/schema", - true); - } - - @Test - public void testParserHandlesSchema() throws SAXException { - XMLReader xerces; - xerces = XMLReaderFactory.createXMLReader(); - xerces.setFeature("http://apache.org/xml/features/validation/schema", - true); - } - -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.example.junit; + +import org.junit.Test; +import org.xml.sax.SAXException; +import org.xml.sax.XMLReader; +import org.xml.sax.helpers.XMLReaderFactory; + +import static org.junit.Assert.assertNotNull; + +/** + * created Aug 12, 2004 1:39:59 PM + */ + +public class XmlParserTest { + + + @Test + public void testXercesIsPresent() throws SAXException { + XMLReader xerces; + xerces = XMLReaderFactory.createXMLReader( + "org.apache.xerces.parsers.SAXParser"); + assertNotNull(xerces); + } + + @Test + public void testXercesHandlesSchema() throws SAXException { + XMLReader xerces; + xerces = XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser"); + xerces.setFeature("http://apache.org/xml/features/validation/schema", + true); + } + + @Test + public void testParserHandlesSchema() throws SAXException { + XMLReader xerces; + xerces = XMLReaderFactory.createXMLReader(); + xerces.setFeature("http://apache.org/xml/features/validation/schema", + true); + } + +} http://git-wip-us.apache.org/repos/asf/ant/blob/1ae68097/src/tests/junit/org/example/tasks/TaskdefTestContainerTask.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/example/tasks/TaskdefTestContainerTask.java b/src/tests/junit/org/example/tasks/TaskdefTestContainerTask.java index a566d5c..0e0a599 100644 --- a/src/tests/junit/org/example/tasks/TaskdefTestContainerTask.java +++ b/src/tests/junit/org/example/tasks/TaskdefTestContainerTask.java @@ -1,25 +1,25 @@ -/* - * 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.example.tasks; - -import org.apache.tools.ant.taskdefs.Sequential; - -public class TaskdefTestContainerTask extends Sequential { - public TaskdefTestContainerTask() {} -} +/* + * 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.example.tasks; + +import org.apache.tools.ant.taskdefs.Sequential; + +public class TaskdefTestContainerTask extends Sequential { + public TaskdefTestContainerTask() {} +} http://git-wip-us.apache.org/repos/asf/ant/blob/1ae68097/src/tests/junit/org/example/tasks/TaskdefTestSimpleTask.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/example/tasks/TaskdefTestSimpleTask.java b/src/tests/junit/org/example/tasks/TaskdefTestSimpleTask.java index bce8cd5..4c0bc69 100644 --- a/src/tests/junit/org/example/tasks/TaskdefTestSimpleTask.java +++ b/src/tests/junit/org/example/tasks/TaskdefTestSimpleTask.java @@ -1,45 +1,45 @@ -/* - * 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.example.tasks; - -import org.apache.tools.ant.Project; -import org.apache.tools.ant.Task; - -public class TaskdefTestSimpleTask extends Task { - - public class Echo { - Echo() {} - private String message = null; - public void setMessage(String s) {message = s;} - } - - public TaskdefTestSimpleTask() {} - - private Echo echo; - public Echo createEcho() { - echo = new Echo(); - return echo; - } - - public void execute() { - log("simpletask: "+echo.message, Project.MSG_INFO); - } - -} - +/* + * 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.example.tasks; + +import org.apache.tools.ant.Project; +import org.apache.tools.ant.Task; + +public class TaskdefTestSimpleTask extends Task { + + public class Echo { + Echo() {} + private String message = null; + public void setMessage(String s) {message = s;} + } + + public TaskdefTestSimpleTask() {} + + private Echo echo; + public Echo createEcho() { + echo = new Echo(); + return echo; + } + + public void execute() { + log("simpletask: "+echo.message, Project.MSG_INFO); + } + +} + http://git-wip-us.apache.org/repos/asf/ant/blob/1ae68097/src/tests/junit/org/example/tasks/antlib.xml ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/example/tasks/antlib.xml b/src/tests/junit/org/example/tasks/antlib.xml index b920da7..2d876579 100644 --- a/src/tests/junit/org/example/tasks/antlib.xml +++ b/src/tests/junit/org/example/tasks/antlib.xml @@ -1,26 +1,26 @@ -<?xml version="1.0"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> -<antlib> -<macrodef name="simple"> - <element name="some-tasks" optional="yes" implicit="yes"/> - <sequential> - <some-tasks/> - </sequential> -</macrodef> -</antlib> - +<?xml version="1.0"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<antlib> +<macrodef name="simple"> + <element name="some-tasks" optional="yes" implicit="yes"/> + <sequential> + <some-tasks/> + </sequential> +</macrodef> +</antlib> + http://git-wip-us.apache.org/repos/asf/ant/blob/1ae68097/src/tests/junit/org/example/tasks/antlib2.xml ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/example/tasks/antlib2.xml b/src/tests/junit/org/example/tasks/antlib2.xml index b920da7..2d876579 100644 --- a/src/tests/junit/org/example/tasks/antlib2.xml +++ b/src/tests/junit/org/example/tasks/antlib2.xml @@ -1,26 +1,26 @@ -<?xml version="1.0"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> -<antlib> -<macrodef name="simple"> - <element name="some-tasks" optional="yes" implicit="yes"/> - <sequential> - <some-tasks/> - </sequential> -</macrodef> -</antlib> - +<?xml version="1.0"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<antlib> +<macrodef name="simple"> + <element name="some-tasks" optional="yes" implicit="yes"/> + <sequential> + <some-tasks/> + </sequential> +</macrodef> +</antlib> + http://git-wip-us.apache.org/repos/asf/ant/blob/1ae68097/src/tests/junit/org/example/types/TypedefTestType.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/example/types/TypedefTestType.java b/src/tests/junit/org/example/types/TypedefTestType.java index 235b76f..80eef22 100644 --- a/src/tests/junit/org/example/types/TypedefTestType.java +++ b/src/tests/junit/org/example/types/TypedefTestType.java @@ -1,25 +1,25 @@ -/* - * 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.example.types; - -import org.apache.tools.ant.ProjectComponent; - -public class TypedefTestType extends ProjectComponent { -} - +/* + * 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.example.types; + +import org.apache.tools.ant.ProjectComponent; + +public class TypedefTestType extends ProjectComponent { +} +
