コード例 #1
0
  /**
   * 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);
  }
コード例 #2
0
  /**
   * 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
  }
コード例 #3
0
  /**
   * 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));
  }
コード例 #4
0
  /**
   * 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);
  }