PageRenderTime 17ms CodeModel.GetById 1ms app.highlight 13ms RepoModel.GetById 1ms app.codeStats 0ms

/src/test/java/org/jhove2/module/format/arc/ArcVersionHeaderTest.java

https://bitbucket.org/moabrichard/jhove2
Java | 330 lines | 284 code | 5 blank | 41 comment | 0 complexity | a473c81d25a9e21cf8bed8e814c598b5 MD5 | raw file
  1/**
  2 * JHOVE2 - Next-generation architecture for format-aware characterization
  3 * <p>
  4 * Copyright (c) 2009 by The Regents of the University of California, Ithaka
  5 * Harbors, Inc., and The Board of Trustees of the Leland Stanford Junior
  6 * University. All rights reserved.
  7 * </p>
  8 * <p>
  9 * Redistribution and use in source and binary forms, with or without
 10 * modification, are permitted provided that the following conditions are met:
 11 * </p>
 12 * <ul>
 13 * <li>Redistributions of source code must retain the above copyright notice,
 14 * this list of conditions and the following disclaimer.</li>
 15 * <li>Redistributions in binary form must reproduce the above copyright notice,
 16 * this list of conditions and the following disclaimer in the documentation
 17 * and/or other materials provided with the distribution.</li>
 18 * <li>Neither the name of the University of California/California Digital
 19 * Library, Ithaka Harbors/Portico, or Stanford University, nor the names of its
 20 * contributors may be used to endorse or promote products derived from this
 21 * software without specific prior written permission.</li>
 22 * </ul>
 23 * <p>
 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 27 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 28 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 34 * POSSIBILITY OF SUCH DAMAGE.
 35 * </p>
 36 */
 37package org.jhove2.module.format.arc;
 38
 39import org.jhove2.module.format.Validator.Validity;
 40import org.junit.Test;
 41
 42/**
 43 * Tests of ARC Module
 44 * @see org.jhove2.module.warc.ArcModule
 45 * @author nicl
 46 */
 47public class ArcVersionHeaderTest extends ArcModuleTestBase {
 48
 49	Object[][] cases = new Object[][] {
 50			{Validity.False, "invalid-versionheader-1.arc", new String[][] {
 51					{
 52						"[ERROR/OBJECT] Invalid ARC file"
 53					}
 54			}, new String[] {
 55			}},
 56			{Validity.False, "invalid-versionheader-2.arc", new String[][] {
 57					{
 58						"[ERROR/OBJECT] Invalid ARC file"
 59					}
 60			}, new String[] {
 61			}},
 62			{Validity.False, "invalid-versionheader-3.arc", new String[][] {
 63					{
 64						"[ERROR/OBJECT] Error in ARC version block, reason 'Version line empty'",
 65						"[ERROR/OBJECT] Error in ARC version block, reason 'Block definition empty'",
 66						"[ERROR/OBJECT] Error in ARC version block, reason 'Version block is not valid!'"
 67					}
 68			}, new String[] {
 69			}},
 70			{Validity.False, "invalid-versionheader-4.arc", new String[][] {
 71					{
 72						"[ERROR/OBJECT] Error in ARC version block, reason 'Version line empty'",
 73						"[ERROR/OBJECT] Error in ARC version block, reason 'Block definition empty'",
 74						"[ERROR/OBJECT] Error in ARC version block, reason 'Version block is not valid!'"
 75					}
 76			}, new String[] {
 77			}},
 78			{Validity.False, "invalid-versionheader-5.arc", new String[][] {
 79					{
 80						"[ERROR/OBJECT] Error in ARC version block, reason 'Version line empty'",
 81						"[ERROR/OBJECT] Error in ARC version block, reason 'Block definition empty'",
 82						"[ERROR/OBJECT] Error in ARC version block, reason 'Version block is not valid!'"
 83					}
 84			}, new String[] {
 85			}},
 86			{Validity.False, "invalid-versionheader-6.arc", new String[][] {
 87					{
 88						"[ERROR/OBJECT] Error in ARC version block, reason 'Version line empty'",
 89						"[ERROR/OBJECT] Error in ARC version block, reason 'Block definition empty'",
 90						"[ERROR/OBJECT] Error in ARC version block, reason 'Version block is not valid!'"
 91					}
 92			}, new String[] {
 93			}},
 94			{Validity.False, "invalid-versionheader-7.arc", new String[][] {
 95					{
 96						"[ERROR/OBJECT] Error in ARC version block, reason 'Version line empty'",
 97						"[ERROR/OBJECT] Error in ARC version block, reason 'Version block is not valid!'"
 98					}
 99			}, new String[] {
100			}},
101			{Validity.False, "invalid-versionheader-8.arc", new String[][] {
102					{
103						"[ERROR/OBJECT] Error in ARC version block, reason 'Version line empty'",
104						"[ERROR/OBJECT] Error in ARC version block, reason 'Version block is not valid!'",
105						"[ERROR/OBJECT] Invalid ARC record does not match the version block definition, value: '2', expected: '1'"
106					}
107			}, new String[] {
108			}},
109			{Validity.False, "invalid-versionheader-9.arc", new String[][] {
110					{
111						"[ERROR/OBJECT] Error in ARC version block, reason 'Version line empty'",
112						"[ERROR/OBJECT] Error in ARC version block, reason 'Version block is not valid!'",
113						"[ERROR/OBJECT] Invalid ARC record does not match the version block definition, value: '1', expected: '2'"
114					}
115			}, new String[] {
116			}},
117			{Validity.False, "invalid-versionheader-10.arc", new String[][] {
118					{
119						"[ERROR/OBJECT] Error in ARC version block, reason 'Version line empty'",
120						"[ERROR/OBJECT] Error in ARC version block, reason 'Version block is not valid!'"
121					}
122			}, new String[] {
123			}},
124			{Validity.False, "invalid-versionheader-11.arc", new String[][] {
125					{
126						"[ERROR/OBJECT] Error in ARC version block, reason 'Block definition empty'",
127						"[ERROR/OBJECT] Error in ARC version block, reason 'Version block is not valid!'"
128					}
129			}, new String[] {
130			}},
131			{Validity.False, "invalid-versionheader-12.arc", new String[][] {
132					{
133						"[ERROR/OBJECT] Error in ARC version block, reason 'Block definition empty'",
134						"[ERROR/OBJECT] Error in ARC version block, reason 'Version block is not valid!'"
135					}
136			}, new String[] {
137			}},
138			{Validity.False, "invalid-versionheader-13.arc", new String[][] {
139					{
140						"[ERROR/OBJECT] Error in ARC version block, reason 'Block definition empty'",
141						"[ERROR/OBJECT] Error in ARC version block, reason 'Version block is not valid!'"
142					}
143			}, new String[] {
144			}},
145			{Validity.False, "invalid-versionheader-14.arc", new String[][] {
146					{
147						"[ERROR/OBJECT] Error in ARC version block, reason 'Block definition empty'",
148						"[ERROR/OBJECT] Error in ARC version block, reason 'Version block is not valid!'"
149					}
150			}, new String[] {
151			}},
152			{Validity.False, "invalid-versionheader-15.arc", new String[][] {
153					{
154						"[ERROR/OBJECT] Error in ARC version block, reason 'Block definition empty'",
155						"[ERROR/OBJECT] Error in ARC version block, reason 'Version block is not valid!'"
156					}
157			}, new String[] {
158			}},
159			{Validity.False, "invalid-versionheader-16.arc", new String[][] {
160					{
161						"[ERROR/OBJECT] Error in ARC version block, reason 'Block definition empty'",
162						"[ERROR/OBJECT] Error in ARC version block, reason 'Version block is not valid!'"
163					}
164			}, new String[] {
165			}},
166			{Validity.False, "invalid-versionheader-17.arc", new String[][] {
167					{
168						"[ERROR/OBJECT] Invalid 'Version-number' value, value: 'x', expected: 'Numeric format'",
169						"[ERROR/OBJECT] Invalid ARC version block",
170						"[ERROR/OBJECT] Error in ARC version block, reason 'Block definition empty'",
171						"[ERROR/OBJECT] Error in ARC version block, reason 'Version block is not valid!'"
172					}
173			}, new String[] {
174			}},
175			{Validity.False, "invalid-versionheader-18.arc", new String[][] {
176					{
177						"[ERROR/OBJECT] Invalid 'Version-number' value, value: 'x', expected: 'Numeric format'",
178						"[ERROR/OBJECT] Invalid ARC version block",
179						"[ERROR/OBJECT] Error in ARC version block, reason 'Block definition empty'",
180						"[ERROR/OBJECT] Error in ARC version block, reason 'Version block is not valid!'"
181					}
182			}, new String[] {
183			}},
184			{Validity.False, "invalid-versionheader-19.arc", new String[][] {
185					{
186						"[ERROR/OBJECT] Invalid 'Reserved' value, value: 'x', expected: 'Numeric format'",
187						"[ERROR/OBJECT] Invalid ARC version block",
188						"[ERROR/OBJECT] Error in ARC version block, reason 'Block definition empty'",
189						"[ERROR/OBJECT] Error in ARC version block, reason 'Version block is not valid!'"
190					}
191			}, new String[] {
192			}},
193			{Validity.False, "invalid-versionheader-20.arc", new String[][] {
194					{
195						"[ERROR/OBJECT] Invalid 'Reserved' value, value: 'x', expected: 'Numeric format'",
196						"[ERROR/OBJECT] Invalid ARC version block",
197						"[ERROR/OBJECT] Error in ARC version block, reason 'Block definition empty'",
198						"[ERROR/OBJECT] Error in ARC version block, reason 'Version block is not valid!'"
199					}
200			}, new String[] {
201			}},
202			{Validity.False, "invalid-versionheader-21.arc", new String[][] {
203					{
204						"[ERROR/OBJECT] Invalid ARC version block",
205						"[ERROR/OBJECT] Error in ARC version block, reason 'Version block is not valid!'"
206					}
207			}, new String[] {
208			}},
209			{Validity.False, "invalid-versionheader-22.arc", new String[][] {
210					{
211						"[ERROR/OBJECT] Invalid ARC version block",
212						"[ERROR/OBJECT] Error in ARC version block, reason 'Version block is not valid!'"
213					}
214			}, new String[] {
215			}},
216			{Validity.False, "invalid-versionheader-23.arc", new String[][] {
217					{
218						"[ERROR/OBJECT] Invalid ARC version block",
219						"[ERROR/OBJECT] Error in ARC version block, reason 'Block definition empty'",
220						"[ERROR/OBJECT] Error in ARC version block, reason 'Version block is not valid!'"
221					}
222			}, new String[] {
223			}},
224			{Validity.False, "invalid-versionheader-24.arc", new String[][] {
225					{
226						"[ERROR/OBJECT] Invalid ARC version block",
227						"[ERROR/OBJECT] Error in ARC version block, reason 'Block definition empty'",
228						"[ERROR/OBJECT] Error in ARC version block, reason 'Version block is not valid!'"
229					}
230			}, new String[] {
231			}},
232			{Validity.False, "invalid-versionheader-25.arc", new String[][] {
233					{
234						"[ERROR/OBJECT] Invalid ARC version block",
235						"[ERROR/OBJECT] Error in ARC version block, reason 'Block definition empty'",
236						"[ERROR/OBJECT] Error in ARC version block, reason 'Version block is not valid!'"
237					}
238			}, new String[] {
239			}},
240			{Validity.False, "invalid-versionheader-26.arc", new String[][] {
241					{
242						"[ERROR/OBJECT] Invalid ARC version block",
243						"[ERROR/OBJECT] Error in ARC version block, reason 'Block definition empty'",
244						"[ERROR/OBJECT] Error in ARC version block, reason 'Version block is not valid!'"
245					}
246			}, new String[] {
247			}},
248			{Validity.False, "invalid-versionheader-27.arc", new String[][] {
249					{
250						"[ERROR/OBJECT] Invalid ARC version block",
251						"[ERROR/OBJECT] Error in ARC version block, reason 'Version block is not valid!'"
252					}
253			}, new String[] {
254			}},
255			{Validity.False, "invalid-versionheader-28.arc", new String[][] {
256					{
257						"[ERROR/OBJECT] Invalid ARC version block",
258						"[ERROR/OBJECT] Error in ARC version block, reason 'Version block is not valid!'",
259						"[ERROR/OBJECT] Invalid ARC record does not match the version block definition, value: '2', expected: '1'"
260					}
261			}, new String[] {
262			}},
263			{Validity.False, "invalid-versionheader-29.arc", new String[][] {
264					{
265						"[ERROR/OBJECT] Invalid ARC version block",
266						"[ERROR/OBJECT] Error in ARC version block, reason 'Version block is not valid!'",
267						"[ERROR/OBJECT] Invalid ARC record does not match the version block definition, value: '1', expected: '2'"
268					}
269			}, new String[] {
270			}},
271			{Validity.False, "invalid-versionheader-30.arc", new String[][] {
272					{
273						"[ERROR/OBJECT] Invalid ARC version block",
274						"[ERROR/OBJECT] Error in ARC version block, reason 'Version block is not valid!'"
275					}
276			}, new String[] {
277			}},
278			{Validity.False, "invalid-versionheader-31.arc", new String[][] {
279					{
280						"[ERROR/OBJECT] Invalid ARC version block",
281						"[ERROR/OBJECT] Error in ARC version block, reason 'Version block is not valid!'",
282						"[ERROR/OBJECT] Invalid ARC record does not match the version block definition, value: '1', expected: '2'"
283					}
284			}, new String[] {
285			}},
286			{Validity.False, "invalid-versionheader-32.arc", new String[][] {
287					{
288						"[ERROR/OBJECT] Invalid ARC version block",
289						"[ERROR/OBJECT] Error in ARC version block, reason 'Version block is not valid!'"
290					}
291			}, new String[] {
292			}},
293			{Validity.False, "invalid-versionheader-33.arc", new String[][] {
294					{
295						"[ERROR/OBJECT] Invalid ARC record does not match the version block definition, value: '2', expected: '1'"
296					}
297			}, new String[] {
298			}},
299			{Validity.False, "invalid-versionheader-34.arc", new String[][] {
300					{
301						"[ERROR/OBJECT] Invalid ARC record does not match the version block definition, value: '2', expected: '1'"
302					}
303			}, new String[] {
304			}},
305			{Validity.False, "invalid-versionheader-35.arc", new String[][] {
306					{
307						"[ERROR/OBJECT] Invalid ARC record does not match the version block definition, value: '1', expected: '2'"
308					}
309			}, new String[] {
310			}},
311			{Validity.True, "valid-versionheader-1.arc", new String[][] {
312					{}
313			}, new String[] {
314			}},
315			{Validity.True, "valid-versionheader-2.arc", new String[][] {
316					{}
317			}, new String[] {
318			}},
319			{Validity.True, "valid-versionheader-3.arc", new String[][] {
320					{}
321			}, new String[] {
322			}}
323	};
324
325	@Test
326	public void test_arcversionheaders() {
327		test_cases(cases, false);
328	}
329
330}