Skip to content

Commit

Permalink
chore(deps): migrate to commons lang3
Browse files Browse the repository at this point in the history
  • Loading branch information
bbortt committed Nov 24, 2023
1 parent 3eb2cd8 commit 4f5b9ff
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 37 deletions.
4 changes: 2 additions & 2 deletions core/citrus-base/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
</dependency>

<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@

package org.citrusframework.report;

import org.citrusframework.TestResult;
import org.citrusframework.exceptions.CitrusRuntimeException;
import org.citrusframework.util.FileUtils;
import org.citrusframework.util.PropertyUtils;
import org.citrusframework.util.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
Expand All @@ -30,14 +38,7 @@
import java.util.Optional;
import java.util.Properties;

import org.citrusframework.TestResult;
import org.citrusframework.exceptions.CitrusRuntimeException;
import org.citrusframework.util.FileUtils;
import org.citrusframework.util.PropertyUtils;
import org.apache.commons.lang.StringEscapeUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.citrusframework.util.StringUtils;
import static org.apache.commons.lang3.StringEscapeUtils.escapeXml;

/**
* @author Christoph Deppisch
Expand Down Expand Up @@ -112,12 +113,12 @@ private String createReportContent(String suiteName, List<TestResult> results, R
for (TestResult result: results) {
Properties detailProps = new Properties();
detailProps.put("test.class", result.getClassName());
detailProps.put("test.name", StringEscapeUtils.escapeXml(result.getTestName()));
detailProps.put("test.name", escapeXml(result.getTestName()));
detailProps.put("test.duration", "0.0");

if (result.isFailed()) {
detailProps.put("test.error.cause", Optional.ofNullable(result.getCause()).map(Object::getClass).map(Class::getName).orElseGet(() -> Objects.toString(result.getFailureType(), "")));
detailProps.put("test.error.msg", StringEscapeUtils.escapeXml(result.getErrorMessage()));
detailProps.put("test.error.msg", escapeXml(result.getErrorMessage()));
detailProps.put("test.error.stackTrace", Optional.ofNullable(result.getCause()).map(cause -> {
StringWriter writer = new StringWriter();
cause.printStackTrace(new PrintWriter(writer));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.citrusframework.variable.dictionary;

import org.apache.commons.lang.NotImplementedException;
import org.apache.commons.lang3.NotImplementedException;
import org.apache.tools.ant.filters.StringInputStream;
import org.citrusframework.context.TestContext;
import org.citrusframework.exceptions.CitrusRuntimeException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,6 @@

package org.citrusframework.mail.message;

import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.nio.charset.Charset;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import javax.xml.transform.Source;

import jakarta.mail.MessagingException;
import jakarta.mail.Multipart;
import jakarta.mail.Session;
Expand All @@ -56,6 +42,20 @@
import org.springframework.mail.javamail.MimeMailMessage;
import org.springframework.mail.javamail.MimeMessageHelper;

import javax.xml.transform.Source;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.nio.charset.Charset;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;

/**
* @author Christoph Deppisch
* @author Christian Guggenmos
Expand Down Expand Up @@ -398,9 +398,9 @@ static String parseContentType(String contentType) throws IOException {
*/
static String parseCharsetFromContentType(String contentType) {
final String charsetPrefix = "charset=";
if (org.apache.commons.lang.StringUtils.contains(contentType, charsetPrefix)) {
String charsetName = org.apache.commons.lang.StringUtils.substringAfter(contentType, charsetPrefix);
return org.apache.commons.lang.StringUtils.substringBefore(charsetName, ";");
if (org.apache.commons.lang3.StringUtils.contains(contentType, charsetPrefix)) {
String charsetName = org.apache.commons.lang3.StringUtils.substringAfter(contentType, charsetPrefix);
return org.apache.commons.lang3.StringUtils.substringBefore(charsetName, ";");
} else {
return CitrusSettings.CITRUS_FILE_ENCODING;
}
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@
<commons.cli.version>1.5.0</commons.cli.version>
<commons.codec.version>1.16.0</commons.codec.version>
<commons.io.version>2.14.0</commons.io.version>
<commons.lang.version>2.6</commons.lang.version>
<commons.lang.version>3.14.0</commons.lang.version>
<commons.logging.version>1.2</commons.logging.version>
<commons.net.version>3.10.0</commons.net.version>
<cucumber.version>7.14.0</cucumber.version>
Expand Down Expand Up @@ -323,8 +323,8 @@
<version>${commons.codec.version}</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons.lang.version}</version>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@

package org.citrusframework.functions.core;

import java.util.List;

import org.citrusframework.context.TestContext;
import org.citrusframework.exceptions.InvalidFunctionUsageException;
import org.citrusframework.functions.Function;
import org.apache.commons.lang.StringEscapeUtils;

import java.util.List;

import static org.apache.commons.lang3.StringEscapeUtils.escapeXml;

/**
* Escapes XML fragment with escaped characters for '<', '>'.
Expand All @@ -36,7 +37,7 @@ public String execute(List<String> parameterList, TestContext context) {
throw new InvalidFunctionUsageException("Invalid function parameter usage! Expected single parameter but found: " + parameterList.size());
}

return StringEscapeUtils.escapeXml(parameterList.get(0));
return escapeXml(parameterList.get(0));
}

}

0 comments on commit 4f5b9ff

Please sign in to comment.