Skip to content

Commit

Permalink
- Replacing custom "file:" constant with ResourceUtils.FILE_URL_PREFIX
Browse files Browse the repository at this point in the history
  • Loading branch information
Tucakovic, Vladimir committed Sep 6, 2023
1 parent 04cce6a commit 906cd2b
Showing 1 changed file with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
package de.ikor.sip.foundation.testkit.configurationproperties.models;

import static de.ikor.sip.foundation.core.util.SIPExchangeHelper.filterNonSerializableHeaders;
import static org.apache.commons.lang3.StringUtils.isNotBlank;

import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import lombok.Data;
import lombok.SneakyThrows;
import org.apache.camel.Exchange;
import org.apache.camel.support.MessageHelper;
import org.apache.commons.io.FileUtils;
import org.springframework.core.io.ClassPathResource;

import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;

import static de.ikor.sip.foundation.core.util.SIPExchangeHelper.filterNonSerializableHeaders;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
import static org.springframework.util.ResourceUtils.FILE_URL_PREFIX;

/** Class that holds a single message used in test cases */
@Data
public class MessageProperties {
public static final String FILE_PREXIX = "file:";
private String body;
private Map<String, Object> headers = new HashMap<>();

Expand All @@ -35,8 +36,8 @@ public static MessageProperties mapToMessageProperties(Exchange exchange) {

@SneakyThrows
public String getBody() {
if (isNotBlank(body) && body.startsWith(FILE_PREXIX)) {
String bodyLocation = body.substring(FILE_PREXIX.length());
if (isNotBlank(body) && body.startsWith(FILE_URL_PREFIX)) {
String bodyLocation = body.substring(FILE_URL_PREFIX.length());
body =
FileUtils.readFileToString(
new ClassPathResource(bodyLocation).getFile(), StandardCharsets.UTF_8);
Expand Down

0 comments on commit 906cd2b

Please sign in to comment.