use of com.github.tomakehurst.wiremock.common.ClasspathFileSource in project wiremock by wiremock.
the class JsonFileMappingsSourceTest method loadsMappingsViaClasspathFileSource.
@Test
public void loadsMappingsViaClasspathFileSource() {
ClasspathFileSource fileSource = new ClasspathFileSource("jar-filesource");
JsonFileMappingsSource source = new JsonFileMappingsSource(fileSource);
InMemoryStubMappings stubMappings = new InMemoryStubMappings();
source.loadMappingsInto(stubMappings);
List<StubMapping> allMappings = stubMappings.getAll();
assertThat(allMappings, hasSize(2));
List<String> mappingRequestUrls = asList(allMappings.get(0).getRequest().getUrl(), allMappings.get(1).getRequest().getUrl());
assertThat(mappingRequestUrls, is(asList("/second_test", "/test")));
}
use of com.github.tomakehurst.wiremock.common.ClasspathFileSource in project spring-cloud-contract by spring-cloud.
the class ResourcesFileSource method toSources.
private static FileSource[] toSources(Resource[] resources) {
FileSource[] sources = new FileSource[resources.length];
for (int i = 0; i < resources.length; i++) {
Resource resource = resources[i];
if (resource instanceof ClassPathResource) {
ClassPathResource classes = (ClassPathResource) resource;
sources[i] = new ClasspathFileSource(classes.getPath());
} else if (resource instanceof FileSystemResource) {
FileSystemResource files = (FileSystemResource) resource;
sources[i] = new SingleRootFileSource(files.getFile());
} else if (resource instanceof UrlResource) {
sources[i] = fileOrFallbackToClasspath(resource);
} else {
throw new IllegalArgumentException("Unsupported resource type for file source: " + resource.getClass());
}
}
return sources;
}
Aggregations