Package com.asakusafw.testdriver

Examples of com.asakusafw.testdriver.JobFlowTester


    @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));
View Full Code Here

TOP

Related Classes of com.asakusafw.testdriver.JobFlowTester

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.