/** * Test method for {@link * BasicProcessProvider#execute(com.asakusafw.windgate.core.resource.DriverFactory, * ProcessScript)}. * * @throws IOException expected */ @Test(expected = IOException.class) public void execute_transfer_failed() throws IOException { MockDriverFactory factory = new MockDriverFactory(); factory.add("testing", new MockSourceDriver<String>("source")); factory.add("testing", new MockDrainDriver<String>("drain")); ProcessScript<String> script = new ProcessScript<>("testing", "plain", String.class, driver("source"), driver("drain")); provider.execute(factory, script); }
/** * Test method for {@link * BasicProcessProvider#execute(com.asakusafw.windgate.core.resource.DriverFactory, * ProcessScript)}. * * @throws IOException expected */ @Test(expected = IOException.class) public void execute_invalid_drain() throws IOException { MockDriverFactory factory = new MockDriverFactory(); MockSourceDriver<String> source = factory.add("testing", new MockSourceDriver<String>("source")); ProcessScript<String> script = new ProcessScript<>("testing", "plain", String.class, driver("source"), driver("drain")); List<String> data = Arrays.asList("Hello", "world", "!"); source.setIterable(data); provider.execute(factory, script); }
/** * Test method for {@link * BasicProcessProvider#execute(com.asakusafw.windgate.core.resource.DriverFactory, * ProcessScript)}. * * @throws IOException expected */ @Test public void execute_simulated() throws IOException { RuntimeContext.set(RuntimeContext.DEFAULT.mode(ExecutionMode.SIMULATION)); MockDriverFactory factory = new MockDriverFactory(); factory.add( "testing", new MockSourceDriver<String>("source") { @Override public void prepare() throws IOException { throw new AssertionError(); } @Override public boolean next() throws IOException { throw new AssertionError(); } @Override public String get() throws IOException { throw new AssertionError(); } @Override public void close() throws IOException { return; } }); factory.add( "testing", new MockDrainDriver<String>("drain") { @Override public void prepare() throws IOException { throw new AssertionError(); } @Override public void put(String object) throws IOException { throw new AssertionError(); } @Override public void close() throws IOException { return; } }); ProcessScript<String> script = new ProcessScript<>("testing", "plain", String.class, driver("source"), driver("drain")); provider.execute(factory, script); // no exceptions }
/** * Test method for {@link * BasicProcessProvider#execute(com.asakusafw.windgate.core.resource.DriverFactory, * ProcessScript)}. * * @throws IOException if failed */ @Test public void execute() throws IOException { MockDriverFactory factory = new MockDriverFactory(); MockSourceDriver<String> source = factory.add("testing", new MockSourceDriver<String>("source")); MockDrainDriver<String> drain = factory.add("testing", new MockDrainDriver<String>("drain")); ProcessScript<String> script = new ProcessScript<>("testing", "plain", String.class, driver("source"), driver("drain")); List<String> data = Arrays.asList("Hello", "world", "!"); source.setIterable(data); provider.execute(factory, script); assertThat(drain.getResults(), is(data)); }