@Test(description = "Given a POST request with an image file upload, " + "the serializeData object should return the boundaries with the serialized data") public void execute_uploadFileImageContent() throws FMSException, IOException { requestParams.put(REQ_PARAM_METHOD_TYPE, "POST"); message.getRequestElements().setRequestParameters(requestParams); BufferedImage image = new BufferedImage(10, 10, BufferedImage.TYPE_INT_RGB); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ImageIO.write(image, "jpg", baos); InputStream mockedStream = new ByteArrayInputStream(baos.toByteArray()); message.getRequestElements().setAction("upload"); message.getRequestElements().getUploadRequestElements().setDocContent(mockedStream); message.getRequestElements().getUploadRequestElements().setBoundaryForContent("ContentBoundary"); message.getRequestElements().getUploadRequestElements().setBoundaryForEntity("EntityBoundary"); Attachable attachable = new Attachable(); attachable.setContentType("something/jpeg"); message.getRequestElements().setEntity(attachable); message.getRequestElements().setObjectToSerialize(jaxbElement); serializeInterceptor.execute(message); Assert.assertEquals(message.getRequestElements().getSerializedData(), "EntityBoundary{\"foo\":\"bar\"}ContentBoundary"); }
@Override public void execute(IntuitMessage intuitMessage) throws FMSException { LOG.debug("Enter SerializeInterceptor..."); String serializedData = null; RequestElements requestElements = intuitMessage.getRequestElements(); String methodType = requestElements.getRequestParameters().get(RequestElements.REQ_PARAM_METHOD_TYPE); if (methodType.equals(MethodType.POST.toString())) { String serializeFormat = getSerializationRequestFormat(); LOG.info("serialization format : " + serializeFormat); if (StringUtils.hasText(requestElements.getPostString())) { serializedData = requestElements.getPostString(); } else if (StringUtils.hasText(serializeFormat)) { IEntitySerializer serializer = SerializerFactory.getSerializer(serializeFormat); serializedData = serializer.serialize(requestElements.getObjectToSerialize()); String action = requestElements.getAction(); if (action != null && action.equals(OperationType.UPLOAD.toString())) { UploadRequestElements uploadRequestElements = requestElements.getUploadRequestElements(); StringBuilder input = new StringBuilder(); input.append(uploadRequestElements.getBoundaryForEntity()).append(serializedData); input.append(uploadRequestElements.getBoundaryForContent()); serializedData = input.toString(); requestElements.setUploadFile(getUploadFileContent(requestElements)); } } else { LOG.debug("Serialization doesn't applicable for this request"); } } else { LOG.debug("Serialization doesn't applicable for the GET request"); } LOG.debug("Exit SerializeInterceptor."); requestElements.setSerializedData(serializedData); }
SerializeInterceptor implements Interceptor { @Override public void execute(IntuitMessage intuitMessage) throws FMSException { LOG.debug("Enter SerializeInterceptor..."); String serializedData = null; RequestElements requestElements = intuitMessage.getRequestElements(); String methodType = requestElements.getRequestParameters().get(RequestElements.REQ_PARAM_METHOD_TYPE); if (methodType.equals(MethodType.POST.toString())) { String serializeFormat = getSerializationRequestFormat(); LOG.info("serialization format : " + serializeFormat); if (StringUtils.hasText(requestElements.getPostString())) { serializedData = requestElements.getPostString(); } else if (StringUtils.hasText(serializeFormat)) { IEntitySerializer serializer = SerializerFactory.getSerializer(serializeFormat); serializedData = serializer.serialize(requestElements.getObjectToSerialize()); String action = requestElements.getAction(); if (action != null && action.equals(OperationType.UPLOAD.toString())) { UploadRequestElements uploadRequestElements = requestElements.getUploadRequestElements(); StringBuilder input = new StringBuilder(); input.append(uploadRequestElements.getBoundaryForEntity()).append(serializedData); input.append(uploadRequestElements.getBoundaryForContent()); serializedData = input.toString(); requestElements.setUploadFile(getUploadFileContent(requestElements)); } } else { LOG.debug("Serialization doesn't applicable for this request"); } } else { LOG.debug("Serialization doesn't applicable for the GET request"); } LOG.debug("Exit SerializeInterceptor."); requestElements.setSerializedData(serializedData); } }
SerializeInterceptor implements Interceptor { @Override public void execute(IntuitMessage intuitMessage) throws FMSException { LOG.debug("Enter SerializeInterceptor..."); String serializedData = null; RequestElements requestElements = intuitMessage.getRequestElements(); String methodType = requestElements.getRequestParameters().get(RequestElements.REQ_PARAM_METHOD_TYPE); if (methodType.equals(MethodType.POST.toString())) { String serializeFormat = getSerializationRequestFormat(); LOG.info("serialization format : " + serializeFormat); if (StringUtils.hasText(requestElements.getPostString())) { serializedData = requestElements.getPostString(); } else if (StringUtils.hasText(serializeFormat)) { IEntitySerializer serializer = SerializerFactory.getSerializer(serializeFormat); serializedData = serializer.serialize(requestElements.getObjectToSerialize()); String action = requestElements.getAction(); if (action != null && action.equals(OperationType.UPLOAD.toString())) { UploadRequestElements uploadRequestElements = requestElements.getUploadRequestElements(); StringBuilder input = new StringBuilder(); input.append(uploadRequestElements.getBoundaryForEntity()).append(serializedData); input.append(uploadRequestElements.getBoundaryForContent()); serializedData = input.toString(); requestElements.setUploadFile(getUploadFileContent(requestElements)); } } else { LOG.debug("Serialization doesn't applicable for this request"); } } else { LOG.debug("Serialization doesn't applicable for the GET request"); } LOG.debug("Exit SerializeInterceptor."); requestElements.setSerializedData(serializedData); }  }
SerializeInterceptor implements Interceptor { @Override public void execute(IntuitMessage intuitMessage) throws FMSException { LOG.debug("Enter SerializeInterceptor..."); String serializedData = null; RequestElements requestElements = intuitMessage.getRequestElements(); String methodType = requestElements.getRequestParameters().get(RequestElements.REQ_PARAM_METHOD_TYPE); if (methodType.equals(MethodType.POST.toString())) { String serializeFormat = getSerializationRequestFormat(); LOG.info("serialization format : " + serializeFormat); if (StringUtils.hasText(requestElements.getPostString())) { serializedData = requestElements.getPostString(); } else if (StringUtils.hasText(serializeFormat)) { IEntitySerializer serializer = SerializerFactory.getSerializer(serializeFormat); serializedData = serializer.serialize(requestElements.getObjectToSerialize()); String action = requestElements.getAction(); if (action != null && action.equals(OperationType.UPLOAD.toString())) { UploadRequestElements uploadRequestElements = requestElements.getUploadRequestElements(); StringBuilder input = new StringBuilder(); input.append(uploadRequestElements.getBoundaryForEntity()).append(serializedData); input.append(uploadRequestElements.getBoundaryForContent()); serializedData = input.toString(); requestElements.setUploadFile(getUploadFileContent(requestElements)); } } else { LOG.debug("Serialization doesn't applicable for this request"); } } else { LOG.debug("Serialization doesn't applicable for the GET request"); } LOG.debug("Exit SerializeInterceptor."); requestElements.setSerializedData(serializedData); }  @Override void execute(IntuitMessage intuitMessage); }
SerializeInterceptor implements Interceptor { @Override public void execute(IntuitMessage intuitMessage) throws FMSException { LOG.debug("Enter SerializeInterceptor..."); String serializedData = null; RequestElements requestElements = intuitMessage.getRequestElements(); String methodType = requestElements.getRequestParameters().get(RequestElements.REQ_PARAM_METHOD_TYPE); if (methodType.equals(MethodType.POST.toString())) { String serializeFormat = getSerializationRequestFormat(); LOG.info("serialization format : " + serializeFormat); if (StringUtils.hasText(requestElements.getPostString())) { serializedData = requestElements.getPostString(); } else if (StringUtils.hasText(serializeFormat)) { IEntitySerializer serializer = SerializerFactory.getSerializer(serializeFormat); serializedData = serializer.serialize(requestElements.getObjectToSerialize()); String action = requestElements.getAction(); if (action != null && action.equals(OperationType.UPLOAD.toString())) { UploadRequestElements uploadRequestElements = requestElements.getUploadRequestElements(); StringBuilder input = new StringBuilder(); input.append(uploadRequestElements.getBoundaryForEntity()).append(serializedData); input.append(uploadRequestElements.getBoundaryForContent()); serializedData = input.toString(); requestElements.setUploadFile(getUploadFileContent(requestElements)); } } else { LOG.debug("Serialization doesn't applicable for this request"); } } else { LOG.debug("Serialization doesn't applicable for the GET request"); } LOG.debug("Exit SerializeInterceptor."); requestElements.setSerializedData(serializedData); }  @Override void execute(IntuitMessage intuitMessage);  }