diff options
author | James Ahlborn <jtahlborn@yahoo.com> | 2013-06-02 02:23:36 +0000 |
---|---|---|
committer | James Ahlborn <jtahlborn@yahoo.com> | 2013-06-02 02:23:36 +0000 |
commit | 52df2373c7bb61b784b3d983c6ee42ae4b1cb030 (patch) | |
tree | 12f0679c793fe97f8ca9e44e9c21fa10db205890 /test | |
parent | 99f648a340dd45967550a511f8a27a16c2c5b5f3 (diff) | |
download | jackcess-52df2373c7bb61b784b3d983c6ee42ae4b1cb030.tar.gz jackcess-52df2373c7bb61b784b3d983c6ee42ae4b1cb030.zip |
add methods to get the actual attachment content
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@733 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'test')
-rw-r--r-- | test/src/java/com/healthmarketscience/jackcess/ComplexColumnTest.java | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/test/src/java/com/healthmarketscience/jackcess/ComplexColumnTest.java b/test/src/java/com/healthmarketscience/jackcess/ComplexColumnTest.java index 019dd74..6dbcbed 100644 --- a/test/src/java/com/healthmarketscience/jackcess/ComplexColumnTest.java +++ b/test/src/java/com/healthmarketscience/jackcess/ComplexColumnTest.java @@ -367,11 +367,12 @@ public class ComplexColumnTest extends TestCase assertEquals(fileNames.length, attachments.size()); for(int i = 0; i < fileNames.length; ++i) { String fname = fileNames[i]; - byte[] dataBytes = getFileBytes(fname); Attachment a = attachments.get(i); assertEquals(fname, a.getFileName()); assertEquals("txt", a.getFileType()); - assertTrue(Arrays.equals(dataBytes, a.getFileData())); + assertTrue(Arrays.equals(getFileBytes(fname), a.getFileData())); + assertTrue(Arrays.equals(getDecodedFileBytes(fname), + a.getDecodedFileData())); } } } @@ -430,17 +431,41 @@ public class ComplexColumnTest extends TestCase throw new RuntimeException("unexpected bytes"); } + private static byte[] getDecodedFileBytes(String fname) throws Exception + { + if("test_data.txt".equals(fname)) { + return TEST_DEC_BYTES; + } + if("test_data2.txt".equals(fname)) { + return TEST2_DEC_BYTES; + } + throw new RuntimeException("unexpected bytes"); + } + private static byte b(int i) { return (byte)i; } + private static byte[] getAsciiBytes(String str) { + try { + return str.getBytes("US-ASCII"); + } catch(Exception e) { + throw new RuntimeException(e); + } + } + private static final byte[] TEST_BYTES = new byte[] { b(0x01),b(0x00),b(0x00),b(0x00),b(0x3A),b(0x00),b(0x00),b(0x00),b(0x78),b(0x5E),b(0x13),b(0x61),b(0x60),b(0x60),b(0x60),b(0x04),b(0x62),b(0x16),b(0x20),b(0x2E),b(0x61),b(0xA8),b(0x00),b(0x62), b(0x20),b(0x9D),b(0x91),b(0x59),b(0xAC),b(0x00),b(0x44),b(0xC5),b(0xF9),b(0xB9),b(0xA9),b(0x0A),b(0x25),b(0xA9),b(0xC5),b(0x25),b(0x0A),b(0x29),b(0x89),b(0x25),b(0x89),b(0x0A),b(0x69),b(0xF9), b(0x45),b(0x0A),b(0x89),b(0x25),b(0x25),b(0x89),b(0xC9),b(0x19),b(0xB9),b(0xA9),b(0x79),b(0x25),b(0x7A),b(0x00),b(0x52),b(0xA9),b(0x0F),b(0x7A) }; + + private static final byte[] TEST_DEC_BYTES = getAsciiBytes("this is some test data for attachment."); private static final byte[] TEST2_BYTES = new byte[] { b(0x01),b(0x00),b(0x00),b(0x00),b(0x3F),b(0x00),b(0x00),b(0x00),b(0x78),b(0x5E),b(0x13),b(0x61),b(0x60),b(0x60),b(0x60),b(0x04),b(0x62),b(0x16),b(0x20),b(0x2E),b(0x61),b(0xA8),b(0x00),b(0x62), b(0x20),b(0x9D),b(0x91),b(0x59),b(0xAC),b(0x00),b(0x44),b(0xC5),b(0xF9),b(0xB9),b(0xA9),b(0x0A),b(0xB9),b(0xF9),b(0x45),b(0xA9),b(0x0A),b(0x25),b(0xA9),b(0xC5),b(0x25),b(0x0A),b(0x29),b(0x89), b(0x25),b(0x89),b(0x0A),b(0x69),b(0xF9),b(0x45),b(0x0A),b(0x89),b(0x25),b(0x25),b(0x89),b(0xC9),b(0x19),b(0xB9),b(0xA9),b(0x79),b(0x25),b(0x7A),b(0x00),b(0xA5),b(0x0B),b(0x11),b(0x4D) }; + + private static final byte[] TEST2_DEC_BYTES = getAsciiBytes("this is some more test data for attachment."); + } |