@Test(expected=BadDataException.class) public void processNegativeSize() throws BadDataException { final RecordProcessor<HashData> proc = new HashRecordProcessor(); proc.process(new String[] { Hex.encodeHexString(sha1), Hex.encodeHexString(md5), Hex.encodeHexString(crc32), name, String.valueOf(-1), String.valueOf(prod_code), os_code, special_code }); }
public HashData process(String[] col) throws BadDataException { if (col.length < 8) { throw new BadDataException("too few columns"); } else if (col.length > 8) { throw new BadDataException("too many columns"); } long size = 0; try { size = Long.parseLong(col[4]); } catch (NumberFormatException e) { throw new BadDataException(e); } if (size < 0) { throw new BadDataException("size < 0"); } int prod_code = 0; try { prod_code = Integer.parseInt(col[5]); } catch (NumberFormatException e) { throw new BadDataException(e); } if (prod_code < 0) { throw new BadDataException("prod_code < 0"); } byte[] sha1, md5, crc32; try { sha1 = (byte[]) hex.decode(col[0]); md5 = (byte[]) hex.decode(col[1]); crc32 = (byte[]) hex.decode(col[2]); } catch (DecoderException e) { throw new BadDataException(e); } return new HashData( sha1, md5, crc32, col[3], size, prod_code, col[6], col[7] ); }
HashRecordProcessor implements RecordProcessor<HashData> { public HashData process(String[] col) throws BadDataException { if (col.length < 8) { throw new BadDataException("too few columns"); } else if (col.length > 8) { throw new BadDataException("too many columns"); } long size = 0; try { size = Long.parseLong(col[4]); } catch (NumberFormatException e) { throw new BadDataException(e); } if (size < 0) { throw new BadDataException("size < 0"); } int prod_code = 0; try { prod_code = Integer.parseInt(col[5]); } catch (NumberFormatException e) { throw new BadDataException(e); } if (prod_code < 0) { throw new BadDataException("prod_code < 0"); } byte[] sha1, md5, crc32; try { sha1 = (byte[]) hex.decode(col[0]); md5 = (byte[]) hex.decode(col[1]); crc32 = (byte[]) hex.decode(col[2]); } catch (DecoderException e) { throw new BadDataException(e); } return new HashData( sha1, md5, crc32, col[3], size, prod_code, col[6], col[7] ); } }
HashRecordProcessor implements RecordProcessor<HashData> { public HashData process(String[] col) throws BadDataException { if (col.length < 8) { throw new BadDataException("too few columns"); } else if (col.length > 8) { throw new BadDataException("too many columns"); } long size = 0; try { size = Long.parseLong(col[4]); } catch (NumberFormatException e) { throw new BadDataException(e); } if (size < 0) { throw new BadDataException("size < 0"); } int prod_code = 0; try { prod_code = Integer.parseInt(col[5]); } catch (NumberFormatException e) { throw new BadDataException(e); } if (prod_code < 0) { throw new BadDataException("prod_code < 0"); } byte[] sha1, md5, crc32; try { sha1 = (byte[]) hex.decode(col[0]); md5 = (byte[]) hex.decode(col[1]); crc32 = (byte[]) hex.decode(col[2]); } catch (DecoderException e) { throw new BadDataException(e); } return new HashData( sha1, md5, crc32, col[3], size, prod_code, col[6], col[7] ); }  }
HashRecordProcessor implements RecordProcessor<HashData> { public HashData process(String[] col) throws BadDataException { if (col.length < 8) { throw new BadDataException("too few columns"); } else if (col.length > 8) { throw new BadDataException("too many columns"); } long size = 0; try { size = Long.parseLong(col[4]); } catch (NumberFormatException e) { throw new BadDataException(e); } if (size < 0) { throw new BadDataException("size < 0"); } int prod_code = 0; try { prod_code = Integer.parseInt(col[5]); } catch (NumberFormatException e) { throw new BadDataException(e); } if (prod_code < 0) { throw new BadDataException("prod_code < 0"); } byte[] sha1, md5, crc32; try { sha1 = (byte[]) hex.decode(col[0]); md5 = (byte[]) hex.decode(col[1]); crc32 = (byte[]) hex.decode(col[2]); } catch (DecoderException e) { throw new BadDataException(e); } return new HashData( sha1, md5, crc32, col[3], size, prod_code, col[6], col[7] ); }  HashData process(String[] col); }
HashRecordProcessor implements RecordProcessor<HashData> { public HashData process(String[] col) throws BadDataException { if (col.length < 8) { throw new BadDataException("too few columns"); } else if (col.length > 8) { throw new BadDataException("too many columns"); } long size = 0; try { size = Long.parseLong(col[4]); } catch (NumberFormatException e) { throw new BadDataException(e); } if (size < 0) { throw new BadDataException("size < 0"); } int prod_code = 0; try { prod_code = Integer.parseInt(col[5]); } catch (NumberFormatException e) { throw new BadDataException(e); } if (prod_code < 0) { throw new BadDataException("prod_code < 0"); } byte[] sha1, md5, crc32; try { sha1 = (byte[]) hex.decode(col[0]); md5 = (byte[]) hex.decode(col[1]); crc32 = (byte[]) hex.decode(col[2]); } catch (DecoderException e) { throw new BadDataException(e); } return new HashData( sha1, md5, crc32, col[3], size, prod_code, col[6], col[7] ); }  HashData process(String[] col);  }