@Test public void testAfterProducer() throws Exception { String id = "12345"; String content = "Test content: åäö"; String encoding = StandardCharsets.ISO_8859_1.name(); int size = content.getBytes(encoding).length; Map<String, Object> options = new HashMap<>(); options.put("fileId", id); options.put("encoding", encoding); customizer.customize(component, options); Exchange inbound = new DefaultExchange(createCamelContext()); setBody(inbound, content, encoding); component.getAfterProducer().process(inbound); BoxFile file = inbound.getIn().getBody(BoxFile.class); assertNotNull(file); assertEquals(id, file.getId()); assertEquals(content, file.getContent()); assertEquals(size, file.getSize()); }
private void afterProducer(Exchange exchange) { BoxFile file = new BoxFile(); Message in = exchange.getIn(); file.setId(fileId); ByteArrayOutputStream output = in.getBody(ByteArrayOutputStream.class); try { file.setContent(new String(output.toByteArray(), encoding)); } catch (UnsupportedEncodingException e) { LOG.error("Failed to convert file content to String. Invalid file encoding: {}", encoding); } file.setSize(output.size()); in.setBody(file); }
BoxDownloadCustomizer implements ComponentProxyCustomizer { private void afterProducer(Exchange exchange) { BoxFile file = new BoxFile(); Message in = exchange.getIn(); file.setId(fileId); ByteArrayOutputStream output = in.getBody(ByteArrayOutputStream.class); try { file.setContent(new String(output.toByteArray(), encoding)); } catch (UnsupportedEncodingException e) { LOG.error("Failed to convert file content to String. Invalid file encoding: {}", encoding); } file.setSize(output.size()); in.setBody(file); } }
BoxDownloadCustomizer implements ComponentProxyCustomizer { private void afterProducer(Exchange exchange) { BoxFile file = new BoxFile(); Message in = exchange.getIn(); file.setId(fileId); ByteArrayOutputStream output = in.getBody(ByteArrayOutputStream.class); try { file.setContent(new String(output.toByteArray(), encoding)); } catch (UnsupportedEncodingException e) { LOG.error("Failed to convert file content to String. Invalid file encoding: {}", encoding); } file.setSize(output.size()); in.setBody(file); }  }
BoxDownloadCustomizer implements ComponentProxyCustomizer { private void afterProducer(Exchange exchange) { BoxFile file = new BoxFile(); Message in = exchange.getIn(); file.setId(fileId); ByteArrayOutputStream output = in.getBody(ByteArrayOutputStream.class); try { file.setContent(new String(output.toByteArray(), encoding)); } catch (UnsupportedEncodingException e) { LOG.error("Failed to convert file content to String. Invalid file encoding: {}", encoding); } file.setSize(output.size()); in.setBody(file); }  @Override void customize(ComponentProxyComponent component, Map<String, Object> options); }
BoxDownloadCustomizer implements ComponentProxyCustomizer { private void afterProducer(Exchange exchange) { BoxFile file = new BoxFile(); Message in = exchange.getIn(); file.setId(fileId); ByteArrayOutputStream output = in.getBody(ByteArrayOutputStream.class); try { file.setContent(new String(output.toByteArray(), encoding)); } catch (UnsupportedEncodingException e) { LOG.error("Failed to convert file content to String. Invalid file encoding: {}", encoding); } file.setSize(output.size()); in.setBody(file); }  @Override void customize(ComponentProxyComponent component, Map<String, Object> options);  }