Comments (16)
Ok. Will give that a shot.
Thanks very much!
from hoverfly-java.
That worked great!
Looking forward to having that being done automatically.
For people that might stumble across this in the future, here is my code:
public class TestApi {
private static final String simulationFile = "simulation.json";
@ClassRule
public static final HoverflyRule hoverflyRule =
HoverflyRule.inSimulationMode(
SimulationSource.defaultPath(simulationFile),
HoverflyConfig.localConfigs()
.addCommands(
"-response-body-files-path",
getPathOfResource(simulationFile).getParent().toAbsolutePath().toString()));
private static URL findResourceOnClasspath(String resourceName) {
final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
return Optional.ofNullable(classLoader.getResource(resourceName))
.orElseThrow(
() -> new IllegalArgumentException("Resource not found with name: " + resourceName));
}
@SneakyThrows(URISyntaxException.class)
private static Path getPathOfResource(String resource) {
return Paths.get(
findResourceOnClasspath(HoverflyConstants.DEFAULT_HOVERFLY_RESOURCE_DIR + '/' + resource)
.toURI());
}
}
(@SneakyThrows
is from lombok. If you don't have that, just catch the exception and rethrow it wrapped in a RuntimeException
)
from hoverfly-java.
Issue still present on 0.14.0
from hoverfly-java.
👀
from hoverfly-java.
@BrainStone we haven't supported the bodyFile
feature in hoverfly-java properly yet. In hoverfly, there is a flag you can set the relative file path of a body file:
-response-body-files-path string
When a response contains a relative bodyFile, it will be resolved against this path (default is CWD)
will try to add the support to this in the next release
from hoverfly-java.
Awesome. When could I expect that to be done?
And excuse the question but is there a way to specify the flag when doing unit tests?
from hoverfly-java.
There are two workarounds actually:
- you can copy hoverfly binary to your test resource folder, and set its location with this config:
localConfigs().binaryLocation("/absolute/path/to/hoverfly/directory")
- or you can pass hoverfly flag using this config
localConfigs().addCommands("-response-body-files-path", "/absolute/path/to/your/test/resource/folder")
from hoverfly-java.
Related Issues (20)
- Hoverfly has not become healthy in 10 seconds while running on an environment connected to a VPN HOT 13
- Awaitility untilAsserted does not work HOT 2
- Supporting using different json files in Class/SubClass HOT 3
- Update hoverfly to latest (1.3.1 as of now) instead of the currently bundled 1.1.5 HOT 3
- Allow Java API access to the DiffView objects from HoverflyClient.getDiffs()
- JSON files should have newline character at the end of the file HOT 2
- Xpath Function is not working HOT 1
- provide leIncrementalCapture feature in hoverfly-java-junit5
- Hoverfly 0.14.1 will not run after upgrading to org.springframework.boot 2.5.5 appears to be issue with "com.fasterxml.jackson.dataformat" HOT 4
- Request for Webflux WebClient not captured HOT 6
- Hoverfly doesnt import multiple simulation files. HOT 1
- Upgrade okhttp due to CVE 2021-0341 HOT 2
- no configuration method for listen-on-host functionality HOT 4
- Wrong binary selected on arch64 machine
- Certificate issue in simulating HTTPS Api HOT 1
- Array and jwt matchers fail with invalid memory address or nil pointer dereference HOT 9
- importing hoverfly breaks the spring webflux/spring cloud gateway project HOT 3
- Form RequestFieldMatcher can not be constructed from Simulation HOT 10
- Multiple mapping with anyBody depends on orders declaration HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hoverfly-java.