@Test public void invalidStream() { final String invalidMarcXMLStream = randomString(); when (message.getBody(String.class)).thenReturn(invalidMarcXMLStream); try { cut.process(exchange); fail(); } catch (final Exception expected) { assertTrue(expected instanceof MarcException); } }
@Override public void process(final Exchange exchange) throws Exception { final String marcXmlRecord = exchange.getIn().getBody(String.class); try { final MarcReader reader = new MarcXmlReader(new ByteArrayInputStream(marcXmlRecord.getBytes("UTF-8"))); if (reader.hasNext()) { final Record record = reader.next(); exchange.getIn().setBody(record); } else { log.error(MessageCatalog._00047_EMPTY_INCOMING_RECORD_STREAM); throw new IllegalArgumentException(MessageCatalog._00047_EMPTY_INCOMING_RECORD_STREAM); } } catch (final IllegalArgumentException exception) { throw exception; } catch (final Exception exception) { log.error(MessageCatalog._00047_EMPTY_INCOMING_RECORD_STREAM, exception); throw exception; } }
MarcXmlRecordToMarcRecordTranslator implements Processor { @Override public void process(final Exchange exchange) throws Exception { final String marcXmlRecord = exchange.getIn().getBody(String.class); try { final MarcReader reader = new MarcXmlReader(new ByteArrayInputStream(marcXmlRecord.getBytes("UTF-8"))); if (reader.hasNext()) { final Record record = reader.next(); exchange.getIn().setBody(record); } else { log.error(MessageCatalog._00047_EMPTY_INCOMING_RECORD_STREAM); throw new IllegalArgumentException(MessageCatalog._00047_EMPTY_INCOMING_RECORD_STREAM); } } catch (final IllegalArgumentException exception) { throw exception; } catch (final Exception exception) { log.error(MessageCatalog._00047_EMPTY_INCOMING_RECORD_STREAM, exception); throw exception; } } }
MarcXmlRecordToMarcRecordTranslator implements Processor { @Override public void process(final Exchange exchange) throws Exception { final String marcXmlRecord = exchange.getIn().getBody(String.class); try { final MarcReader reader = new MarcXmlReader(new ByteArrayInputStream(marcXmlRecord.getBytes("UTF-8"))); if (reader.hasNext()) { final Record record = reader.next(); exchange.getIn().setBody(record); } else { log.error(MessageCatalog._00047_EMPTY_INCOMING_RECORD_STREAM); throw new IllegalArgumentException(MessageCatalog._00047_EMPTY_INCOMING_RECORD_STREAM); } } catch (final IllegalArgumentException exception) { throw exception; } catch (final Exception exception) { log.error(MessageCatalog._00047_EMPTY_INCOMING_RECORD_STREAM, exception); throw exception; } }  }
MarcXmlRecordToMarcRecordTranslator implements Processor { @Override public void process(final Exchange exchange) throws Exception { final String marcXmlRecord = exchange.getIn().getBody(String.class); try { final MarcReader reader = new MarcXmlReader(new ByteArrayInputStream(marcXmlRecord.getBytes("UTF-8"))); if (reader.hasNext()) { final Record record = reader.next(); exchange.getIn().setBody(record); } else { log.error(MessageCatalog._00047_EMPTY_INCOMING_RECORD_STREAM); throw new IllegalArgumentException(MessageCatalog._00047_EMPTY_INCOMING_RECORD_STREAM); } } catch (final IllegalArgumentException exception) { throw exception; } catch (final Exception exception) { log.error(MessageCatalog._00047_EMPTY_INCOMING_RECORD_STREAM, exception); throw exception; } }  @Override void process(final Exchange exchange); }
MarcXmlRecordToMarcRecordTranslator implements Processor { @Override public void process(final Exchange exchange) throws Exception { final String marcXmlRecord = exchange.getIn().getBody(String.class); try { final MarcReader reader = new MarcXmlReader(new ByteArrayInputStream(marcXmlRecord.getBytes("UTF-8"))); if (reader.hasNext()) { final Record record = reader.next(); exchange.getIn().setBody(record); } else { log.error(MessageCatalog._00047_EMPTY_INCOMING_RECORD_STREAM); throw new IllegalArgumentException(MessageCatalog._00047_EMPTY_INCOMING_RECORD_STREAM); } } catch (final IllegalArgumentException exception) { throw exception; } catch (final Exception exception) { log.error(MessageCatalog._00047_EMPTY_INCOMING_RECORD_STREAM, exception); throw exception; } }  @Override void process(final Exchange exchange);  }