org.mockserver.maven.MockServerPort Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mockserver-maven-plugin Show documentation
Show all versions of mockserver-maven-plugin Show documentation
A maven plugin to start and stop the MockServer
package org.mockserver.maven;
import com.google.common.base.Splitter;
import org.mockserver.log.model.LogEntry;
import org.mockserver.logging.MockServerLogger;
import org.slf4j.event.Level;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class MockServerPort {
private static final MockServerLogger MOCK_SERVER_LOGGER = new MockServerLogger();
public static List mockServerPort() {
final String mockServerPort = System.getProperty("mockserver.mockServerPort");
try {
return toList(mockServerPort);
} catch (NumberFormatException nfe) {
MOCK_SERVER_LOGGER.logEvent(
new LogEntry()
.setType(LogEntry.LogMessageType.EXCEPTION)
.setLogLevel(Level.ERROR)
.setMessageFormat("NumberFormatException converting " + "mockserver.mockServerPort" + " with value [" + mockServerPort + "]")
.setThrowable(nfe)
);
return Collections.emptyList();
}
}
private static List toList(String integers) {
List integerList = new ArrayList<>();
for (String integer : Splitter.on(",").split(integers)) {
try {
integerList.add(Integer.parseInt(integer.trim()));
} catch (NumberFormatException throwable) {
MOCK_SERVER_LOGGER.logEvent(
new LogEntry()
.setType(LogEntry.LogMessageType.EXCEPTION)
.setLogLevel(Level.ERROR)
.setMessageFormat("NumberFormatException converting " + integer + " to integer")
.setThrowable(throwable)
);
}
}
return integerList;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy