View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *   http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   * 
17   */
18  
19  package org.apache.commons.compress.archivers.tar;
20  
21  import static org.junit.Assert.assertEquals;
22  import static org.junit.Assert.assertFalse;
23  import static org.junit.Assert.assertTrue;
24  import static org.junit.Assert.fail;
25  
26  import org.apache.commons.compress.archivers.zip.ZipEncoding;
27  import org.apache.commons.compress.archivers.zip.ZipEncodingHelper;
28  import org.apache.commons.compress.utils.CharsetNames;
29  import org.junit.Test;
30  
31  public class TarUtilsTest {
32  
33  
34      @Test
35      public void testName(){
36          byte [] buff = new byte[20];
37          final String sb1 = "abcdefghijklmnopqrstuvwxyz";
38          int off = TarUtils.formatNameBytes(sb1, buff, 1, buff.length-1);
39          assertEquals(off, 20);
40          String sb2 = TarUtils.parseName(buff, 1, 10);
41          assertEquals(sb2,sb1.substring(0,10));
42          sb2 = TarUtils.parseName(buff, 1, 19);
43          assertEquals(sb2,sb1.substring(0,19));
44          buff = new byte[30];
45          off = TarUtils.formatNameBytes(sb1, buff, 1, buff.length-1);
46          assertEquals(off, 30);
47          sb2 = TarUtils.parseName(buff, 1, buff.length-1);
48          assertEquals(sb1, sb2);
49      }
50  
51      @Test
52      public void testParseOctal() throws Exception{
53          long value; 
54          byte [] buffer;
55          final long MAX_OCTAL  = 077777777777L; // Allowed 11 digits
56          final long MAX_OCTAL_OVERFLOW  = 0777777777777L; // in fact 12 for some implementations
57          final String maxOctal = "777777777777"; // Maximum valid octal
58          buffer = maxOctal.getBytes(CharsetNames.UTF_8);
59          value = TarUtils.parseOctal(buffer,0, buffer.length);
60          assertEquals(MAX_OCTAL_OVERFLOW, value);
61          buffer[buffer.length - 1] = ' ';
62          value = TarUtils.parseOctal(buffer,0, buffer.length);
63          assertEquals(MAX_OCTAL, value);
64          buffer[buffer.length-1]=0;
65          value = TarUtils.parseOctal(buffer,0, buffer.length);
66          assertEquals(MAX_OCTAL, value);
67          buffer=new byte[]{0,0};
68          value = TarUtils.parseOctal(buffer,0, buffer.length);
69          assertEquals(0, value);
70          buffer=new byte[]{0,' '};
71          value = TarUtils.parseOctal(buffer,0, buffer.length);
72          assertEquals(0, value);
73          buffer=new byte[]{' ',0};
74          value = TarUtils.parseOctal(buffer,0, buffer.length);
75          assertEquals(0, value);
76      }
77  
78      @Test
79      public void testParseOctalInvalid() throws Exception{
80          byte [] buffer;
81          buffer=new byte[0]; // empty byte array
82          try {
83              TarUtils.parseOctal(buffer,0, buffer.length);
84              fail("Expected IllegalArgumentException - should be at least 2 bytes long");
85          } catch (final IllegalArgumentException expected) {
86          }
87          buffer=new byte[]{0}; // 1-byte array
88          try {
89              TarUtils.parseOctal(buffer,0, buffer.length);
90              fail("Expected IllegalArgumentException - should be at least 2 bytes long");
91          } catch (final IllegalArgumentException expected) {
92          }
93          buffer = "abcdef ".getBytes(CharsetNames.UTF_8); // Invalid input
94          try {
95              TarUtils.parseOctal(buffer,0, buffer.length);
96              fail("Expected IllegalArgumentException");
97          } catch (final IllegalArgumentException expected) {
98          }
99          buffer = " 0 07 ".getBytes(CharsetNames.UTF_8); // Invalid - embedded space
100         try {
101             TarUtils.parseOctal(buffer,0, buffer.length);
102             fail("Expected IllegalArgumentException - embedded space");
103         } catch (final IllegalArgumentException expected) {
104         }
105         buffer = " 0\00007 ".getBytes(CharsetNames.UTF_8); // Invalid - embedded NUL
106         try {
107             TarUtils.parseOctal(buffer,0, buffer.length);
108             fail("Expected IllegalArgumentException - embedded NUL");
109         } catch (final IllegalArgumentException expected) {
110         }
111     }
112 
113     private void checkRoundTripOctal(final long value, final int bufsize) {
114         final byte [] buffer = new byte[bufsize];
115         long parseValue;
116         TarUtils.formatLongOctalBytes(value, buffer, 0, buffer.length);
117         parseValue = TarUtils.parseOctal(buffer,0, buffer.length);
118         assertEquals(value,parseValue);
119     }
120 
121     private void checkRoundTripOctal(final long value) {
122         checkRoundTripOctal(value, TarConstants.SIZELEN);
123     }
124 
125     @Test
126     public void testRoundTripOctal() {
127         checkRoundTripOctal(0);
128         checkRoundTripOctal(1);
129 //        checkRoundTripOctal(-1); // TODO What should this do?
130         checkRoundTripOctal(TarConstants.MAXSIZE);
131 //        checkRoundTripOctal(0100000000000L); // TODO What should this do?
132 
133         checkRoundTripOctal(0, TarConstants.UIDLEN);
134         checkRoundTripOctal(1, TarConstants.UIDLEN);
135         checkRoundTripOctal(TarConstants.MAXID, 8);
136     }
137 
138     private void checkRoundTripOctalOrBinary(final long value, final int bufsize) {
139         final byte [] buffer = new byte[bufsize];
140         long parseValue;
141         TarUtils.formatLongOctalOrBinaryBytes(value, buffer, 0, buffer.length);
142         parseValue = TarUtils.parseOctalOrBinary(buffer,0, buffer.length);
143         assertEquals(value,parseValue);
144     }
145 
146     @Test
147     public void testRoundTripOctalOrBinary8() {
148         testRoundTripOctalOrBinary(8);
149     }
150 
151     @Test
152     public void testRoundTripOctalOrBinary12() {
153         testRoundTripOctalOrBinary(12);
154         checkRoundTripOctalOrBinary(Long.MAX_VALUE, 12);
155         checkRoundTripOctalOrBinary(Long.MIN_VALUE + 1, 12);
156     }
157 
158     private void testRoundTripOctalOrBinary(final int length) {
159         checkRoundTripOctalOrBinary(0, length);
160         checkRoundTripOctalOrBinary(1, length);
161         checkRoundTripOctalOrBinary(TarConstants.MAXSIZE, length); // will need binary format
162         checkRoundTripOctalOrBinary(-1, length); // will need binary format
163         checkRoundTripOctalOrBinary(0xffffffffffffffl, length);
164         checkRoundTripOctalOrBinary(-0xffffffffffffffl, length);
165     }
166 
167     // Check correct trailing bytes are generated
168     @Test
169     public void testTrailers() {
170         final byte [] buffer = new byte[12];
171         TarUtils.formatLongOctalBytes(123, buffer, 0, buffer.length);
172         assertEquals(' ', buffer[buffer.length-1]);
173         assertEquals('3', buffer[buffer.length-2]); // end of number
174         TarUtils.formatOctalBytes(123, buffer, 0, buffer.length);
175         assertEquals(0  , buffer[buffer.length-1]);
176         assertEquals(' ', buffer[buffer.length-2]);
177         assertEquals('3', buffer[buffer.length-3]); // end of number
178         TarUtils.formatCheckSumOctalBytes(123, buffer, 0, buffer.length);
179         assertEquals(' ', buffer[buffer.length-1]);
180         assertEquals(0  , buffer[buffer.length-2]);
181         assertEquals('3', buffer[buffer.length-3]); // end of number
182     }
183 
184     @Test
185     public void testNegative() throws Exception {
186         final byte [] buffer = new byte[22];
187         TarUtils.formatUnsignedOctalString(-1, buffer, 0, buffer.length);
188         assertEquals("1777777777777777777777", new String(buffer, CharsetNames.UTF_8));
189     }
190 
191     @Test
192     public void testOverflow() throws Exception {
193         final byte [] buffer = new byte[8-1]; // a lot of the numbers have 8-byte buffers (nul term)
194         TarUtils.formatUnsignedOctalString(07777777L, buffer, 0, buffer.length);
195         assertEquals("7777777", new String(buffer, CharsetNames.UTF_8));
196         try {
197             TarUtils.formatUnsignedOctalString(017777777L, buffer, 0, buffer.length);
198             fail("Should have cause IllegalArgumentException");
199         } catch (final IllegalArgumentException expected) {
200         }
201     }
202 
203     @Test
204     public void testRoundTripNames(){
205         checkName("");
206         checkName("The quick brown fox\n");
207         checkName("\177");
208         // checkName("\0"); // does not work, because NUL is ignored
209     }
210 
211     @Test
212     public void testRoundEncoding() throws Exception {
213         // COMPRESS-114
214         final ZipEncoding enc = ZipEncodingHelper.getZipEncoding(CharsetNames.ISO_8859_1);
215         final String s = "0302-0601-3\u00b1\u00b1\u00b1F06\u00b1W220\u00b1ZB\u00b1LALALA\u00b1\u00b1\u00b1\u00b1\u00b1\u00b1\u00b1\u00b1\u00b1\u00b1CAN\u00b1\u00b1DC\u00b1\u00b1\u00b104\u00b1060302\u00b1MOE.model";
216         final byte buff[] = new byte[100];
217         final int len = TarUtils.formatNameBytes(s, buff, 0, buff.length, enc);
218         assertEquals(s, TarUtils.parseName(buff, 0, len, enc));
219     }
220 
221     private void checkName(final String string) {
222         final byte buff[] = new byte[100];
223         final int len = TarUtils.formatNameBytes(string, buff, 0, buff.length);
224         assertEquals(string, TarUtils.parseName(buff, 0, len));
225     }
226 
227     @Test
228     public void testReadNegativeBinary8Byte() {
229         final byte[] b = new byte[] {
230             (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
231             (byte) 0xff, (byte) 0xff, (byte) 0xf1, (byte) 0xef,
232         };
233         assertEquals(-3601l, TarUtils.parseOctalOrBinary(b, 0, 8));
234     }
235 
236     @Test
237     public void testReadNegativeBinary12Byte() {
238         final byte[] b = new byte[] {
239             (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
240             (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
241             (byte) 0xff, (byte) 0xff, (byte) 0xf1, (byte) 0xef,
242         };
243         assertEquals(-3601l, TarUtils.parseOctalOrBinary(b, 0, 12));
244     }
245 
246 
247     @Test
248     public void testWriteNegativeBinary8Byte() {
249         final byte[] b = new byte[] {
250             (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
251             (byte) 0xff, (byte) 0xff, (byte) 0xf1, (byte) 0xef,
252         };
253         assertEquals(-3601l, TarUtils.parseOctalOrBinary(b, 0, 8));
254     }
255 
256     // https://issues.apache.org/jira/browse/COMPRESS-191
257     @Test
258     public void testVerifyHeaderCheckSum() {
259         final byte[] valid = { // from bla.tar
260                 116, 101, 115, 116, 49, 46, 120, 109, 108, 0, 0, 0, 0, 0, 0,
261                 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
262                 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
263                 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
264                 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
265                 0, 48, 48, 48, 48, 54, 52, 52, 0, 48, 48, 48, 48, 55, 54, 53,
266                 0, 48, 48, 48, 48, 55, 54, 53, 0, 48, 48, 48, 48, 48, 48, 48,
267                 49, 49, 52, 50, 0, 49, 48, 55, 49, 54, 53, 52, 53, 54, 50, 54,
268                 0, 48, 49, 50, 50, 54, 48, 0, 32, 48, 0, 0, 0, 0, 0, 0, 0, 0,
269                 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
270                 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
271                 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
272                 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
273                 0, 0, 0, 0, 0, 0, 0, 0, 117, 115, 116, 97, 114, 32, 32, 0,
274                 116, 99, 117, 114, 100, 116, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
275                 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 116, 99, 117,
276                 114, 100, 116, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
277                 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
278                 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
279                 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
280                 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
281                 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
282                 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
283                 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
284                 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
285                 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
286                 0, 0, 0, 0 };
287         assertTrue(TarUtils.verifyCheckSum(valid));
288 
289         final byte[] compress117 = { // from COMPRESS-117
290             (byte) 0x37, (byte) 0x7a, (byte) 0x43, (byte) 0x2e, (byte) 0x74, (byte) 0x78, (byte) 0x74, (byte) 0x00,
291             0, 0, 0, 0, 0, 0, 0, 0,
292             0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
293             0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
294             0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
295             0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
296             0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
297             0, 0, 0, 0, (byte) 0x31, (byte) 0x30, (byte) 0x30, (byte) 0x37,
298             (byte) 0x37, (byte) 0x37, (byte) 0x20, (byte) 0x00, (byte) 0x20, (byte) 0x20, (byte) 0x20, (byte) 0x20,
299             (byte) 0x20, (byte) 0x30, (byte) 0x20, (byte) 0x00, (byte) 0x20, (byte) 0x20, (byte) 0x20, (byte) 0x20,
300             (byte) 0x20, (byte) 0x30, (byte) 0x20, (byte) 0x00, (byte) 0x20, (byte) 0x20, (byte) 0x20, (byte) 0x20,
301             (byte) 0x20, (byte) 0x20, (byte) 0x31, (byte) 0x33, (byte) 0x30, (byte) 0x33, (byte) 0x33, (byte) 0x20,
302             (byte) 0x31, (byte) 0x31, (byte) 0x31, (byte) 0x31, (byte) 0x35, (byte) 0x31, (byte) 0x36, (byte) 0x36,
303             (byte) 0x30, (byte) 0x31, (byte) 0x36, (byte) 0x20, (byte) 0x20, (byte) 0x20, (byte) 0x35, (byte) 0x34,
304             (byte) 0x31, (byte) 0x37, (byte) 0x20, (byte) 0x00, (byte) 0x30, (byte) 0x00, 0, 0,
305             0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
306             0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
307             0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
308             0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
309             0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
310             0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
311             0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
312             0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
313             0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
314             0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
315             0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
316             0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
317             0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
318             0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
319             0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
320             0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
321             0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
322             0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
323             0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
324             0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
325             0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
326             0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
327         };
328         assertTrue(TarUtils.verifyCheckSum(compress117));
329 
330         final byte[] invalid = { // from the testAIFF.aif file in Tika
331                 70, 79, 82, 77, 0, 0, 15, 46, 65, 73, 70, 70, 67, 79, 77, 77,
332                 0, 0, 0, 18, 0, 2, 0, 0, 3, -64, 0, 16, 64, 14, -84, 68, 0, 0,
333                 0, 0, 0, 0, 83, 83, 78, 68, 0, 0, 15, 8, 0, 0, 0, 0, 0, 0, 0,
334                 0, 0, 1, -1, -1, 0, 1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 1, -1, -1,
335                 0, 0, 0, 0, 0, 0, -1, -1, 0, 2, -1, -2, 0, 2, -1, -1, 0, 0, 0,
336                 0, 0, 0, 0, 0, 0, 1, -1, -1, 0, 0, -1, -1, 0, 1, 0, 0, 0, 0,
337                 0, 0, 0, 1, -1, -1, 0, 1, -1, -2, 0, 1, -1, -1, 0, 1, 0, 0, 0,
338                 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, 0,
339                 2, -1, -2, 0, 2, -1, -1, 0, 0, 0, 1, -1, -1, 0, 1, -1, -1, 0,
340                 0, 0, 0, 0, 0, 0, 0, 0, 1, -1, -2, 0, 2, -1, -2, 0, 1, 0, 0,
341                 0, 1, -1, -1, 0, 0, 0, 1, -1, -1, 0, 0, 0, 1, -1, -2, 0, 2,
342                 -1, -1, 0, 0, 0, 0, 0, 0, -1, -1, 0, 1, 0, 0, 0, 0, 0, 0, 0,
343                 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, 0, 1, -1, -1, 0, 2, -1, -2,
344                 0, 2, -1, -2, 0, 2, -1, -2, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, -1,
345                 -2, 0, 2, -1, -2, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
346                 -1, -1, 0, 1, 0, 0, -1, -1, 0, 2, -1, -2, 0, 2, -1, -1, 0, 0,
347                 0, 0, 0, 0, -1, -1, 0, 1, -1, -1, 0, 1, -1, -1, 0, 2, -1, -2,
348                 0, 1, 0, 0, -1, -1, 0, 2, -1, -2, 0, 2, -1, -2, 0, 1, 0, 0, 0,
349                 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -1, -1, 0, 0, 0,
350                 0, -1, -1, 0, 1, 0, 0, 0, 0, 0, 1, -1, -1, 0, 0, 0, 0, 0, 0,
351                 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -1, -2, 0, 2, -1, -1, 0,
352                 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -1, -2, 0, 1, 0, 0, 0, 0, 0,
353                 0, 0, 0, 0, 0, 0, 1, -1, -1, 0, 0, 0, 0, -1, -1, 0, 2, -1, -2,
354                 0, 2, -1, -2, 0, 2, -1, -1, 0, 0, 0, 0, -1, -1, 0, 1, -1, -1,
355                 0, 1, -1, -1, 0, 1, -1, -1, 0, 1, -1, -1, 0, 1, 0, 0, 0, 0,
356                 -1, -1, 0, 2, -1, -2, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
357                 1, -1, -1, 0, 0, 0, 0, -1, -1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
358                 0, 0, 0, 0, 0, 1 };
359         assertFalse(TarUtils.verifyCheckSum(invalid));
360     }
361 
362     @Test
363     public void testParseOctalCompress330() throws Exception{
364         final long expected = 0100000;
365         final byte [] buffer = new byte[] {
366             32, 32, 32, 32, 32, 49, 48, 48, 48, 48, 48, 32
367         };
368         assertEquals(expected, TarUtils.parseOctalOrBinary(buffer, 0, buffer.length));
369     }
370 
371 }