private static YamlConfiguration createConfigurtion(Optional<File> configurationFile) throws BaleenException { if (configurationFile.isPresent()) { try (InputStream is = new FileInputStream(configurationFile.get())) { LOGGER.info("Configuration file provided {}", configurationFile.get().getAbsolutePath()); return new YamlConfiguration(configurationFile.get()); } catch (Exception ioe) { throw new BaleenException("Unable to read configuration file", ioe); } } else { LOGGER.info("No configuration file provided - default configuration will be used"); } try { return new YamlConfiguration(); } catch (Exception e) { throw new BaleenException("Unable to read configuration file", e); } }
private static YamlConfiguration createConfigurtion(Optional<File> configurationFile) throws BaleenException { if (configurationFile.isPresent()) { try (InputStream is = new FileInputStream(configurationFile.get())) { LOGGER.info("Configuration file provided {}", configurationFile.get().getAbsolutePath()); return new YamlConfiguration(configurationFile.get()); } catch (Exception ioe) { throw new BaleenException("Unable to read configuration file", ioe); } } else { LOGGER.info("No configuration file provided - default configuration will be used"); } try { return new YamlConfiguration(); } catch (Exception e) { throw new BaleenException("Unable to read configuration file", e); } }
BaleenManager baleen = new BaleenManager(new YamlConfiguration(yaml)); if (dryRun) { baleen.run(manager -> LOGGER.info("Dry run mode: closing immediately"));
@Before public void setup() throws IOException { config = new YamlConfiguration(YamlConfigurationTest.class, YAMLCONFIGURATION_YAML); }
@Test public void testNonExistentFile() { try { new YamlConfiguration(new File("missing.yaml")); } catch (IOException ioe) { return; } fail("Didn't throw expected IOException"); }
@Test public void testReadString() throws IOException { YamlConfiguration yc = new YamlConfiguration("example:\n color: red\n count: 7\n list:\n - a\n - b\n - c"); assertTrue(yc.getAsList("example.list").containsAll(Arrays.asList("a", "b", "c"))); assertEquals("red", yc.get(String.class, "example.color").get()); }
@Test public void testCleanTabs() throws IOException { assertEquals( "test: \"Hello\\tWorld!\"\n" + "testing:\n" + "- 1.. 2.. 3.. 4..\n", new YamlConfiguration("\t\ttest: Hello\tWorld!\n\t\ttesting:\n\t\t- 1.. 2.. 3.. 4.. ") .toString()); } }
public static void runServer(BaleenManager manager, Runnable run) throws BaleenException, IOException { BaleenWebApi web = new BaleenWebApi(manager); try { web.configure(new YamlConfiguration()); web.start(); // Wait for the server to be up try { Thread.sleep(2000); } catch (InterruptedException e) { // Do nothing } run.run(); } finally { web.stop(); } }
@Test public void testWithSinglePipeline() throws Exception { BaleenPipelineManager manager = new BaleenPipelineManager(); try { YamlConfiguration config = new YamlConfiguration(getClass(), "single.yaml"); manager.configure(config); assertEquals(1, manager.getAll().size()); assertTrue(manager.get("single").isPresent()); } finally { manager.stop(); } }
@Test public void testRemoveSinglePipeline() throws Exception { BaleenPipelineManager manager = new BaleenPipelineManager(); try { YamlConfiguration config = new YamlConfiguration(getClass(), "single.yaml"); manager.configure(config); manager.remove("single"); assertEquals(0, manager.getAll().size()); } finally { manager.stop(); } }
@Test public void testWithRemoveAllPipelines() throws Exception { BaleenPipelineManager manager = new BaleenPipelineManager(); try { YamlConfiguration config = new YamlConfiguration(getClass(), "multiplicity.yaml"); manager.configure(config); manager.removeAll("multi"); assertEquals(0, manager.getAll().size()); } finally { manager.stop(); } } }
@Test public void testWithDoublePipeline() throws Exception { BaleenPipelineManager manager = new BaleenPipelineManager(); try { YamlConfiguration config = new YamlConfiguration(getClass(), "double.yaml"); manager.configure(config); assertEquals(2, manager.getAll().size()); assertTrue(manager.get("one").isPresent()); assertTrue(manager.get("two").isPresent()); } finally { manager.stop(); } }
@Test public void testWithoutConfiguration() throws Exception { BaleenPipelineManager manager = new BaleenPipelineManager(); try { manager.configure(new YamlConfiguration()); assertEquals(0, manager.getAll().size()); } finally { manager.stop(); } }
@Test public void testWithMultiplicityPipeline() throws Exception { BaleenPipelineManager manager = new BaleenPipelineManager(); try { YamlConfiguration config = new YamlConfiguration(getClass(), "multiplicity.yaml"); manager.configure(config); assertEquals(4, manager.getAll().size()); assertTrue(manager.get("multi-1").isPresent()); assertTrue(manager.get("multi-2").isPresent()); assertTrue(manager.get("multi-3").isPresent()); assertTrue(manager.get("multi-4").isPresent()); } finally { manager.stop(); } }
@Test public void testAbstract() throws BaleenException, IOException { BCT bct = new BCT(); bct.configure(new YamlConfiguration()); bct.start(); bct.stop(); } }
@Test public void testConfiguration() throws Exception { YamlConfiguration configuration = new YamlConfiguration(MetricsFactoryTest.class, "reporters.yaml"); metrics.configure(configuration); metrics.start(); try { metrics.getCounter(MetricsFactoryTest.class, "testConfiguration").inc(); metrics.getCounter(MetricsFactoryTest.class, "testConfiguration").inc(); MetricsFactory.getMetrics("test", MetricsFactoryTest.class) .getCounter("testConfigurationMetric") .inc(); metrics.report(); Thread.sleep(1000); } finally { metrics.stop(); } // Delete the directory of CSV tests TestingUtils.deleteDirectory("test_csvmetrics"); } }
@Test public void testComponents() throws BaleenException, IOException { metrics.configure(new YamlConfiguration()); metrics.start(); metrics.getCounter(MetricsFactoryTest.class, "removeC"); metrics.stop(); assertTrue(metrics.getRegistry().getMetrics().isEmpty()); }
@Test public void run() throws Exception { BaleenWebApi web = new BaleenWebApi(baleenManager); try { web.configure(new YamlConfiguration()); web.start(); // Wait for the server to be up try { Thread.sleep(3000); } catch (InterruptedException e) { // Do nothing } String metrics = getResponse("/metrics"); assertFalse(metrics.isEmpty()); String status = getResponse("/status"); assertTrue(status.contains("ok")); String pipelines = getResponse("/pipelines"); assertFalse(pipelines.isEmpty()); } finally { web.stop(); } }
@Test public void config() throws Exception { YamlConfiguration configuration = new YamlConfiguration(BaleenLoggingTest.class, "dummyConfig.yaml");
new YamlConfiguration(BaleenSecureWebApiTest.class, "secure.yaml");