Search in sources :

Example 1 with ThrowingRunnable

use of org.testng.Assert.ThrowingRunnable in project incubator-gobblin by apache.

the class TestingEventBusAsserterTest method testAssertNext.

@Test
public void testAssertNext() throws InterruptedException, TimeoutException, IOException {
    EventBus testBus = TestingEventBuses.getEventBus("TestingEventBusAsserterTest.testHappyPath");
    try (final TestingEventBusAsserter asserter = new TestingEventBusAsserter("TestingEventBusAsserterTest.testHappyPath")) {
        testBus.post(new TestingEventBuses.Event("event1"));
        testBus.post(new TestingEventBuses.Event("event2"));
        asserter.assertNextValueEq("event1");
        Assert.assertThrows(new ThrowingRunnable() {

            @Override
            public void run() throws Throwable {
                asserter.assertNextValueEq("event3");
            }
        });
        testBus.post(new TestingEventBuses.Event("event13"));
        testBus.post(new TestingEventBuses.Event("event11"));
        testBus.post(new TestingEventBuses.Event("event12"));
        testBus.post(new TestingEventBuses.Event("event10"));
        asserter.assertNextValuesEq(Arrays.asList("event10", "event11", "event12", "event13"));
        testBus.post(new TestingEventBuses.Event("event22"));
        testBus.post(new TestingEventBuses.Event("event20"));
        Assert.assertThrows(new ThrowingRunnable() {

            @Override
            public void run() throws Throwable {
                asserter.assertNextValuesEq(Arrays.asList("event22", "event21"));
            }
        });
    }
}
Also used : EventBus(com.google.common.eventbus.EventBus) ThrowingRunnable(org.testng.Assert.ThrowingRunnable) Test(org.testng.annotations.Test)

Example 2 with ThrowingRunnable

use of org.testng.Assert.ThrowingRunnable in project incubator-gobblin by apache.

the class TestHadoopKerberosKeytabAuthenticationPlugin method testMissingOptions.

@Test
public void testMissingOptions() {
    final Config testConfig1 = ConfigFactory.parseMap(ImmutableMap.<String, Object>builder().put("hadoop-inject.hadoop.security.authentication", "simple").put("hadoop.loginUser", "foo").put("gobblin.instance.hadoop.loginUserKeytabFile", "/tmp/bar").build());
    final GobblinInstanceDriver instance1 = Mockito.mock(GobblinInstanceDriver.class);
    Mockito.when(instance1.getSysConfig()).thenReturn(DefaultConfigurableImpl.createFromConfig(testConfig1));
    Assert.assertThrows(new ThrowingRunnable() {

        @Override
        public void run() throws Throwable {
            (new HadoopKerberosKeytabAuthenticationPlugin.ConfigBasedFactory()).createPlugin(instance1);
        }
    });
    final Config testConfig2 = ConfigFactory.parseMap(ImmutableMap.<String, Object>builder().put("hadoop-inject.hadoop.security.authentication", "simple").put("gobblin.instance.hadoop.loginUser", "foo").put("hadoop.loginUserKeytabFile", "/tmp/bar").build());
    final GobblinInstanceDriver instance2 = Mockito.mock(GobblinInstanceDriver.class);
    Mockito.when(instance1.getSysConfig()).thenReturn(DefaultConfigurableImpl.createFromConfig(testConfig2));
    Assert.assertThrows(new ThrowingRunnable() {

        @Override
        public void run() throws Throwable {
            (new HadoopKerberosKeytabAuthenticationPlugin.ConfigBasedFactory()).createPlugin(instance2);
        }
    });
}
Also used : Config(com.typesafe.config.Config) GobblinInstanceDriver(org.apache.gobblin.runtime.api.GobblinInstanceDriver) ThrowingRunnable(org.testng.Assert.ThrowingRunnable) Test(org.testng.annotations.Test)

Example 3 with ThrowingRunnable

use of org.testng.Assert.ThrowingRunnable in project incubator-gobblin by apache.

the class TestImmutableFSJobCatalog method testConfigAccessor.

@Test
public void testConfigAccessor() throws Exception {
    Config sysConfig1 = ConfigFactory.parseMap(ImmutableMap.<String, Object>builder().put(ConfigurationKeys.JOB_CONFIG_FILE_GENERAL_PATH_KEY, "/tmp").build());
    ImmutableFSJobCatalog.ConfigAccessor cfgAccessor1 = new ImmutableFSJobCatalog.ConfigAccessor(sysConfig1);
    Assert.assertEquals(cfgAccessor1.getJobConfDir(), "/tmp");
    Assert.assertEquals(cfgAccessor1.getJobConfDirPath(), new Path("/tmp"));
    Assert.assertEquals(cfgAccessor1.getJobConfDirFileSystem().getClass(), FileSystem.get(new Configuration()).getClass());
    Assert.assertEquals(cfgAccessor1.getPollingInterval(), ConfigurationKeys.DEFAULT_JOB_CONFIG_FILE_MONITOR_POLLING_INTERVAL);
    Config sysConfig2 = ConfigFactory.parseMap(ImmutableMap.<String, Object>builder().put(ConfigurationKeys.JOB_CONFIG_FILE_DIR_KEY, "/tmp2").put(ConfigurationKeys.JOB_CONFIG_FILE_MONITOR_POLLING_INTERVAL_KEY, 100).build());
    ImmutableFSJobCatalog.ConfigAccessor cfgAccessor2 = new ImmutableFSJobCatalog.ConfigAccessor(sysConfig2);
    Assert.assertEquals(cfgAccessor2.getJobConfDir(), "file:///tmp2");
    Assert.assertEquals(cfgAccessor2.getJobConfDirPath(), new Path("file:///tmp2"));
    Assert.assertTrue(cfgAccessor2.getJobConfDirFileSystem() instanceof LocalFileSystem);
    Assert.assertEquals(cfgAccessor2.getPollingInterval(), 100);
    Assert.assertThrows(new ThrowingRunnable() {

        @Override
        public void run() throws Throwable {
            new ImmutableFSJobCatalog.ConfigAccessor(ConfigFactory.empty());
        }
    });
}
Also used : Path(org.apache.hadoop.fs.Path) Configuration(org.apache.hadoop.conf.Configuration) Config(com.typesafe.config.Config) LocalFileSystem(org.apache.hadoop.fs.LocalFileSystem) ThrowingRunnable(org.testng.Assert.ThrowingRunnable) Test(org.testng.annotations.Test)

Example 4 with ThrowingRunnable

use of org.testng.Assert.ThrowingRunnable in project incubator-gobblin by apache.

the class TestHttpClientConfiguratorLoader method testConfigureFromConfig.

@Test
public void testConfigureFromConfig() {
    final Config config = ConfigFactory.empty().withValue(HttpClientConfiguratorLoader.HTTP_CLIENT_CONFIGURATOR_TYPE_KEY, ConfigValueFactory.fromAnyRef("blah"));
    Assert.assertThrows(new ThrowingRunnable() {

        @Override
        public void run() throws Throwable {
            new HttpClientConfiguratorLoader(config);
        }
    });
}
Also used : Config(com.typesafe.config.Config) ThrowingRunnable(org.testng.Assert.ThrowingRunnable) Test(org.testng.annotations.Test)

Aggregations

ThrowingRunnable (org.testng.Assert.ThrowingRunnable)4 Test (org.testng.annotations.Test)4 Config (com.typesafe.config.Config)3 EventBus (com.google.common.eventbus.EventBus)1 GobblinInstanceDriver (org.apache.gobblin.runtime.api.GobblinInstanceDriver)1 Configuration (org.apache.hadoop.conf.Configuration)1 LocalFileSystem (org.apache.hadoop.fs.LocalFileSystem)1 Path (org.apache.hadoop.fs.Path)1