@Test
public void simple() throws Exception {
// see src/test/dist/windgate/*
deployer.copy(new File("src/test/dist"), deployer.getHome());
JobFlowTester tester = new JobFlowTester(getClass());
tester.setFrameworkHomePath(deployer.getHome());
tester.input("line", Line.class).prepare(Arrays.asList(new Line("Hello, world!")));
tester.output("line", Line.class).verify(Arrays.asList(new Line("Hello, world!")), new ModelVerifier<Line>() {
@Override
public Object getKey(Line target) {
return target.getValueOption();
}
@Override
public Object verify(Line expected, Line actual) {
if (expected == null || actual == null) {
return "missmatch";
}
if (expected.getValueOption().equals(actual.getValueOption())) {
return null;
}
return "INVALID";
}
});
final AtomicBoolean call = new AtomicBoolean();
MockResourceProvider.callback(new MockResourceProvider.Callback() {
@Override
public void run(ResourceProfile profile) throws IOException {
// Only if this application does not contain plug-in resources
if (getClass().getClassLoader().getResource("testing") == null) {
// but the service context must have plug-in resources.
URL resource = profile.getContext().getClassLoader().getResource("testing");
assertThat("check plugin loading", resource, is(notNullValue()));
}
call.set(true);
}
});
tester.runTest(LineJobflow.class);
assertThat("check mock resource", call.get(), is(true));
File base = new File(deployer.getHome(), String.format("tmp/windgate/%s", System.getProperty("user.name")));
assertThat("check input file", new File(base, "input.txt").isFile(), is(true));