Java Code Examples for com.github.tomakehurst.wiremock.common.BinaryFile

The following examples show how to use com.github.tomakehurst.wiremock.common.BinaryFile. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: spring-cloud-contract   Source File: ResourcesFileSource.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public BinaryFile getBinaryFileNamed(String name) {
	for (FileSource resource : this.sources) {
		try {
			UrlResource uri = new UrlResource(resource.getUri());
			if (uri.exists()) {
				return resource.getBinaryFileNamed(name);
			}
		}
		catch (IOException e) {
			// Ignore
		}
	}
	throw new IllegalStateException("Cannot create file for " + name);
}
 
Example 2
Source Project: wiremock-body-transformer   Source File: BodyTransformer.java    License: Apache License 2.0 5 votes vote down vote up
private String getResponseBody(ResponseDefinition responseDefinition, FileSource fileSource) {
    String body;
    if (responseDefinition.getBody() != null) {
        body = responseDefinition.getBody();
    } else {
        BinaryFile binaryFile = fileSource.getBinaryFileNamed(responseDefinition.getBodyFileName());
        body = new String(binaryFile.readContents(), StandardCharsets.UTF_8);
    }
    return body;
}
 
Example 3
@Override
public BinaryFile getBinaryFileNamed(String name) {
    return new AndroidAssetsBinaryFile(assetManager, assetPath + "/" + name);
}