Skip to content

Instantly share code, notes, and snippets.

@sakama
Created September 11, 2019 05:39
Show Gist options
  • Save sakama/0eb0b5d9a07940078401d7712445070f to your computer and use it in GitHub Desktop.
Save sakama/0eb0b5d9a07940078401d7712445070f to your computer and use it in GitHub Desktop.
Embulk Output Pluginのテスト
package org.embulk.output.hoge;
import okhttp3.mockwebserver.MockWebServer;
import org.embulk.spi.OutputPlugin;
import org.embulk.test.TestingEmbulk;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import java.nio.file.Path;
import java.nio.file.Paths;
import static org.hamcrest.Matchers.containsString;
public class TestHogeOutputPlugin
{
@Rule
public TestingEmbulk test = TestingEmbulk.builder()
.registerPlugin(OutputPlugin.class, "hoge", HogeOutputPlugin.class)
.build();
@Rule
public final ExpectedException exception = ExpectedException.none();
private MockWebServer mockWebServer;
@Before
public void setup()
throws Exception
{
mockWebServer = new MockWebServer();
mockWebServer.start(11220);
}
@After
public void shutdown()
throws Exception
{
if (mockWebServer != null) {
mockWebServer.shutdown();
}
}
private static Path resourcePath(String name)
{
return Paths.get("src/test/resources").resolve(name);
}
@Test
public void testEndpointValidation()
throws Exception
{
exception.expectMessage(containsString("endpoint option is invalid"));
test.runOutput(test.loadYamlResource("config/invalid_endpoint.yml"), resourcePath("simple.csv"));
}
}
@sakama
Copy link
Author

sakama commented Sep 11, 2019

invalid_endpoint.yml

type: hoge
endpoint: INVALID

@sakama
Copy link
Author

sakama commented Sep 11, 2019

build.gradle

plugins {
    id "com.jfrog.bintray" version "1.1"
    id "com.github.jruby-gradle.base" version "0.1.5"
    id "java"
    id "checkstyle"
    id "jacoco"
    id "findbugs"
}
import com.github.jrubygradle.JRubyExec
repositories {
    mavenCentral()
    jcenter()
}
configurations {
    provided
}

version = "0.1.2"

sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
    compile  "org.embulk:embulk-core:0.9.17"
    provided "org.embulk:embulk-core:0.9.17"
    compile "com.squareup.okhttp3:okhttp:3.10.0"
    testCompile "junit:junit:4.+"
    testCompile "org.embulk:embulk-test:0.9.17"
    testCompile "org.embulk:embulk-standards:0.9.17"
    testCompile "com.squareup.okhttp3:mockwebserver:3.10.0"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment