Remove commons-io dependency
This commit is contained in:
5
pom.xml
5
pom.xml
@@ -46,11 +46,6 @@
|
||||
<artifactId>cglib</artifactId>
|
||||
<version>3.2.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
|
||||
@@ -16,9 +16,6 @@
|
||||
|
||||
package org.springframework.cloud.contract.stubrunner;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
|
||||
@@ -67,7 +67,7 @@ class StubRunnerRibbonBeanPostProcessor implements BeanPostProcessor {
|
||||
@Override
|
||||
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
|
||||
if (bean instanceof ServerList && !(bean instanceof StubRunnerRibbonServerList)) {
|
||||
return new StubRunnerRibbonServerList(stubFinder(), stubMapperProperties(), clientConfig(), (ServerList) bean);
|
||||
return new StubRunnerRibbonServerList(stubFinder(), stubMapperProperties(), clientConfig(), (ServerList<?>) bean);
|
||||
}
|
||||
return bean;
|
||||
}
|
||||
|
||||
@@ -16,17 +16,18 @@
|
||||
|
||||
package org.springframework.cloud.contract.stubrunner.junit;
|
||||
|
||||
import static org.assertj.core.api.BDDAssertions.then;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.assertj.core.api.BDDAssertions;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.BDDAssertions.then;
|
||||
import org.springframework.util.StreamUtils;
|
||||
|
||||
/**
|
||||
* @author Marcin Grzejszczak
|
||||
@@ -79,7 +80,7 @@ public class StubRunnerRuleCustomPortJUnitTest {
|
||||
|
||||
private String httpGet(String url) throws Exception {
|
||||
try(InputStream stream = URI.create(url).toURL().openStream()) {
|
||||
return IOUtils.toString(stream);
|
||||
return StreamUtils.copyToString(stream, Charset.forName("UTF-8"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,17 +16,18 @@
|
||||
|
||||
package org.springframework.cloud.contract.stubrunner.junit;
|
||||
|
||||
import static org.assertj.core.api.BDDAssertions.then;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.assertj.core.api.BDDAssertions;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.BDDAssertions.then;
|
||||
import org.springframework.util.StreamUtils;
|
||||
|
||||
/**
|
||||
* @author Marcin Grzejszczak
|
||||
@@ -75,7 +76,7 @@ public class StubRunnerRuleJUnitTest {
|
||||
|
||||
private String httpGet(String url) throws Exception {
|
||||
try(InputStream stream = URI.create(url).toURL().openStream()) {
|
||||
return IOUtils.toString(stream);
|
||||
return StreamUtils.copyToString(stream, Charset.forName("UTF-8"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,16 +16,19 @@
|
||||
|
||||
package org.springframework.cloud.contract.verifier.wiremock
|
||||
|
||||
import org.apache.commons.io.FileUtils
|
||||
import org.apache.commons.io.filefilter.TrueFileFilter
|
||||
import groovy.io.FileType
|
||||
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.Paths
|
||||
|
||||
import org.junit.Rule
|
||||
import org.junit.rules.TemporaryFolder
|
||||
import org.springframework.cloud.contract.verifier.config.ContractVerifierConfigProperties
|
||||
import org.springframework.cloud.contract.verifier.converter.SingleFileConverter
|
||||
import spock.lang.Specification
|
||||
import org.springframework.util.FileSystemUtils
|
||||
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.Paths
|
||||
import spock.lang.Specification
|
||||
|
||||
class RecursiveFilesConverterSpec extends Specification {
|
||||
|
||||
@@ -41,7 +44,7 @@ class RecursiveFilesConverterSpec extends Specification {
|
||||
File originalSourceRootDirectory = new File(this.getClass().getResource("/converter/source").toURI())
|
||||
properties.contractsDslDir = tmpFolder.newFolder("source")
|
||||
properties.stubsOutputDir = tmpFolder.newFolder("target")
|
||||
FileUtils.copyDirectory(originalSourceRootDirectory, properties.contractsDslDir)
|
||||
FileSystemUtils.copyRecursively(originalSourceRootDirectory, properties.contractsDslDir)
|
||||
and:
|
||||
def singleFileConverterStub = Stub(SingleFileConverter)
|
||||
singleFileConverterStub.canHandleFileName(_) >> { String fileName -> fileName.endsWith(".groovy") }
|
||||
@@ -52,7 +55,8 @@ class RecursiveFilesConverterSpec extends Specification {
|
||||
when:
|
||||
recursiveFilesConverter.processFiles()
|
||||
then:
|
||||
Collection<File> createdFiles = FileUtils.listFiles(properties.stubsOutputDir, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE)
|
||||
Collection<File> createdFiles = [] as List
|
||||
properties.stubsOutputDir.eachFileRecurse(FileType.FILES) {it -> createdFiles << it}
|
||||
Set<String> relativizedCreatedFiles = getRelativePathsForFilesInDirectory(createdFiles, properties.stubsOutputDir)
|
||||
EXPECTED_TARGET_FILES == relativizedCreatedFiles
|
||||
and:
|
||||
@@ -66,7 +70,7 @@ class RecursiveFilesConverterSpec extends Specification {
|
||||
properties.contractsDslDir = tmpFolder.newFolder("source")
|
||||
properties.stubsOutputDir = tmpFolder.newFolder("target")
|
||||
properties.excludedFiles = ["dir1/**"]
|
||||
FileUtils.copyDirectory(originalSourceRootDirectory, properties.contractsDslDir)
|
||||
FileSystemUtils.copyRecursively(originalSourceRootDirectory, properties.contractsDslDir)
|
||||
and:
|
||||
def singleFileConverterStub = Stub(SingleFileConverter)
|
||||
singleFileConverterStub.canHandleFileName(_) >> { String fileName -> fileName.endsWith(".groovy") }
|
||||
@@ -77,7 +81,8 @@ class RecursiveFilesConverterSpec extends Specification {
|
||||
when:
|
||||
recursiveFilesConverter.processFiles()
|
||||
then:
|
||||
Collection<File> createdFiles = FileUtils.listFiles(properties.stubsOutputDir, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE)
|
||||
Collection<File> createdFiles = [] as List
|
||||
properties.stubsOutputDir.eachFileRecurse(FileType.FILES) {it -> createdFiles << it}
|
||||
Set<String> relativizedCreatedFiles = getRelativePathsForFilesInDirectory(createdFiles, properties.stubsOutputDir)
|
||||
[Paths.get("dslRoot.json"), Paths.get("dir2/dsl2.json")] as Set == relativizedCreatedFiles as Set
|
||||
and:
|
||||
|
||||
@@ -21,10 +21,6 @@
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-contract-verifier-testing-utils</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
|
||||
@@ -16,11 +16,7 @@
|
||||
|
||||
package org.springframework.cloud.contract.verifier.file
|
||||
|
||||
import com.google.common.collect.ArrayListMultimap
|
||||
import com.google.common.collect.ListMultimap
|
||||
import groovy.transform.CompileStatic
|
||||
import org.apache.commons.io.FilenameUtils
|
||||
import org.apache.commons.lang3.SystemUtils
|
||||
|
||||
import java.nio.file.FileSystem
|
||||
import java.nio.file.FileSystems
|
||||
@@ -28,6 +24,11 @@ import java.nio.file.Path
|
||||
import java.nio.file.PathMatcher
|
||||
import java.util.regex.Pattern
|
||||
|
||||
import org.apache.commons.lang3.SystemUtils
|
||||
|
||||
import com.google.common.collect.ArrayListMultimap
|
||||
import com.google.common.collect.ListMultimap
|
||||
|
||||
/**
|
||||
* Scans the provided file path for the DSLs. There's a possibility to provide
|
||||
* inclusion and exclusion filters.
|
||||
@@ -107,6 +108,21 @@ class ContractFileScanner {
|
||||
}
|
||||
|
||||
private boolean isContractFile(File file) {
|
||||
return file.isFile() && FilenameUtils.getExtension(file.toString()).equalsIgnoreCase("groovy")
|
||||
return file.isFile() && getFilenameExtension(file.toString())?.equalsIgnoreCase("groovy")
|
||||
}
|
||||
|
||||
private static String getFilenameExtension(String path) {
|
||||
if (path == null) {
|
||||
return null;
|
||||
}
|
||||
int extIndex = path.lastIndexOf('.');
|
||||
if (extIndex == -1) {
|
||||
return null;
|
||||
}
|
||||
int folderIndex = path.lastIndexOf('/');
|
||||
if (folderIndex > extIndex) {
|
||||
return null;
|
||||
}
|
||||
return path.substring(extIndex + 1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user