Skip to content

Commit

Permalink
Merge pull request wiremock#2622 from pks-1981/StringUtils_replace
Browse files Browse the repository at this point in the history
Replace org.apache.commons.lang3.StringUtils
  • Loading branch information
leeturner authored Mar 7, 2024
2 parents b773056 + 92bc595 commit 3ae7ed2
Show file tree
Hide file tree
Showing 41 changed files with 720 additions and 162 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ dependencies {
compileOnly(platform("org.junit:junit-bom:$versions.junitJupiter"))
compileOnly("org.junit.jupiter:junit-jupiter")

api 'org.apache.commons:commons-lang3:3.14.0'
api "com.github.jknack:handlebars:$versions.handlebars", {
exclude group: 'org.mozilla', module: 'rhino'
}
api("com.github.jknack:handlebars-helpers:$versions.handlebars") {
exclude group: 'org.mozilla', module: 'rhino'
exclude group: 'org.apache.commons', module: 'commons-lang3'
}

api 'commons-fileupload:commons-fileupload:1.5', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import static com.github.tomakehurst.wiremock.client.WireMock.*;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.apache.commons.lang3.RandomStringUtils.randomAscii;

public class LoadTestConfiguration {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2023 Thomas Akehurst
* Copyright (C) 2011-2024 Thomas Akehurst
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,6 +17,7 @@

import static com.github.tomakehurst.wiremock.common.Exceptions.throwUnchecked;
import static com.github.tomakehurst.wiremock.common.HttpClientUtils.getEntityAsStringAndCloseStream;
import static com.github.tomakehurst.wiremock.common.Strings.isNotBlank;
import static com.github.tomakehurst.wiremock.security.NoClientAuthenticator.noClientAuthenticator;
import static java.util.Objects.requireNonNull;
import static org.apache.hc.core5.http.HttpHeaders.HOST;
Expand Down Expand Up @@ -49,7 +50,6 @@
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import org.apache.commons.lang3.StringUtils;
import org.apache.hc.client5.http.classic.methods.HttpGet;
import org.apache.hc.client5.http.classic.methods.HttpPost;
import org.apache.hc.client5.http.classic.methods.HttpPut;
Expand Down Expand Up @@ -438,7 +438,7 @@ public int port() {
}

private ProxySettings createProxySettings(String proxyHost, int proxyPort) {
if (StringUtils.isNotBlank(proxyHost)) {
if (isNotBlank(proxyHost)) {
return new ProxySettings(proxyHost, proxyPort);
}
return ProxySettings.NO_PROXY;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2016-2023 Thomas Akehurst
* Copyright (C) 2016-2024 Thomas Akehurst
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,9 +16,9 @@
package com.github.tomakehurst.wiremock.common;

import static com.github.tomakehurst.wiremock.common.Strings.stringFromBytes;
import static com.github.tomakehurst.wiremock.common.Strings.substringAfterLast;
import static com.github.tomakehurst.wiremock.common.TextType.JSON;
import static java.util.Arrays.asList;
import static org.apache.commons.lang3.StringUtils.substringAfterLast;

import com.fasterxml.jackson.databind.JsonNode;
import com.github.tomakehurst.wiremock.common.xml.Xml;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2015-2023 Thomas Akehurst
* Copyright (C) 2015-2024 Thomas Akehurst
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,8 +16,8 @@
package com.github.tomakehurst.wiremock.common;

import static com.github.tomakehurst.wiremock.common.Exceptions.throwUnchecked;
import static com.github.tomakehurst.wiremock.common.Strings.DEFAULT_CHARSET;
import static com.github.tomakehurst.wiremock.common.Strings.bytesFromString;
import static java.nio.charset.StandardCharsets.UTF_8;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
Expand Down Expand Up @@ -49,7 +49,7 @@ public static String unGzipToString(byte[] gzippedContent) {
}

public static byte[] gzip(String plainContent) {
return gzip(plainContent, DEFAULT_CHARSET);
return gzip(plainContent, UTF_8);
}

public static byte[] gzip(String plainContent, Charset charset) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2023 Thomas Akehurst
* Copyright (C) 2023-2024 Thomas Akehurst
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -33,6 +33,16 @@ public static <T> T getFirstNonNull(T first, T second) {
throw new NullPointerException("Both parameters are null");
}

public static <T> T getFirstNonNull(T first, T second, String etr) {
if (first != null) {
return first;
}
if (second != null) {
return second;
}
throw new NullPointerException(etr);
}

public static void checkParameter(boolean condition, String errorMessage) {
if (!condition) {
throw new IllegalArgumentException(errorMessage);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2013-2023 Thomas Akehurst
* Copyright (C) 2013-2024 Thomas Akehurst
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,7 +16,7 @@
package com.github.tomakehurst.wiremock.common;

import static com.github.tomakehurst.wiremock.common.ParameterUtils.checkParameter;
import static org.apache.commons.lang3.StringUtils.isEmpty;
import static com.github.tomakehurst.wiremock.common.Strings.isNotEmpty;

import java.net.MalformedURLException;
import java.net.URL;
Expand Down Expand Up @@ -54,7 +54,7 @@ public static ProxySettings fromString(String config) {
ProxySettings proxySettings =
new ProxySettings(
proxyUrl.getHost(), proxyUrl.getPort() == -1 ? DEFAULT_PORT : proxyUrl.getPort());
if (!isEmpty(proxyUrl.getUserInfo())) {
if (isNotEmpty(proxyUrl.getUserInfo())) {
String[] userInfoArray = proxyUrl.getUserInfo().split(":");
proxySettings.setUsername(userInfoArray[0]);
if (userInfoArray.length > 1) {
Expand Down Expand Up @@ -99,6 +99,6 @@ public String toString() {
}

return String.format(
"%s:%s%s", host(), port(), (!isEmpty(this.username) ? " (with credentials)" : ""));
"%s:%s%s", host(), port(), (isNotEmpty(this.username) ? " (with credentials)" : ""));
}
}
Loading

0 comments on commit 3ae7ed2

Please sign in to comment.