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"));
}
});
}
}
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);
}
});
}
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());
}
});
}
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);
}
});
}
Aggregations