@Test public void ShouldWriteMessageUsingKey() throws Exception { final CountDownLatch lcd = new CountDownLatch(1); KZApplication k = new KZApplication(AppSettings.KZ_TENANT, AppSettings.KZ_APP, AppSettings.KZ_KEY, false); k.WriteLog( "ShouldWriteMessageUsingKey", "LoggingIntegrationTests", LogLevel.LogLevelCritical, createCallback(lcd)); assertTrue(lcd.await(TEST_TIMEOUT_IN_MINUTES, TimeUnit.MINUTES)); }
@Test public void ShouldLogIntegerWithMessage() throws Exception { final CountDownLatch lcd = new CountDownLatch(1); kidozen.WriteLog("ShouldLogInteger", 365, LogLevel.LogLevelCritical, createCallback(lcd)); assertTrue(lcd.await(TEST_TIMEOUT_IN_MINUTES, TimeUnit.MINUTES)); }
@Test public void ShouldLogJSONObjectWithMessage() throws Exception { final CountDownLatch lcd = new CountDownLatch(1); JSONObject data = new JSONObject().put("myProperty", 128); kidozen.WriteLog("ShouldLogJSONObject", data, LogLevel.LogLevelCritical, createCallback(lcd)); assertTrue(lcd.await(TEST_TIMEOUT_IN_MINUTES, TimeUnit.MINUTES)); }
@Test public void ShouldLogStringWithMessage() throws Exception { final CountDownLatch lcd = new CountDownLatch(1); String data = "string content"; kidozen.WriteLog("ShouldLogString", data, LogLevel.LogLevelCritical, createCallback(lcd)); assertTrue(lcd.await(TEST_TIMEOUT_IN_MINUTES, TimeUnit.MINUTES)); }
@Test public void ShouldLogArrayOfStrings() throws Exception { ArrayList<String> intArray = new ArrayList<String>(); intArray.add("a"); intArray.add("b"); intArray.add("c"); intArray.add("d"); final CountDownLatch lcd = new CountDownLatch(1); kidozen.WriteLog( "ShouldLogArrayOfStrings", intArray, LogLevel.LogLevelCritical, createCallback(lcd)); assertTrue(lcd.await(TEST_TIMEOUT_IN_MINUTES, TimeUnit.MINUTES)); }
@Test public void ShouldLogDictionaryOfStrings() throws Exception { Map<String, String> intArray = new HashMap<String, String>(); intArray.put("a", "1"); intArray.put("b", "2"); intArray.put("c", "3"); intArray.put("d", "4"); final CountDownLatch lcd = new CountDownLatch(1); kidozen.WriteLog( "ShouldLogDictionaryOfStrings", intArray, LogLevel.LogLevelCritical, createCallback(lcd)); assertTrue(lcd.await(TEST_TIMEOUT_IN_MINUTES, TimeUnit.MINUTES)); }
@Test public void ShouldTruncateLog() throws Exception { final CountDownLatch lcd = new CountDownLatch(1); kidozen.ClearLog( new ServiceEventListener() { @Override public void onFinish(ServiceEvent e) { assertThat(e.StatusCode, equalTo(HttpStatus.SC_NO_CONTENT)); lcd.countDown(); } }); assertTrue(lcd.await(TEST_TIMEOUT_IN_MINUTES, TimeUnit.MINUTES)); }
@Before public void Setup() { try { final CountDownLatch signal = new CountDownLatch(1); kidozen = new KZApplication(AppSettings.KZ_TENANT, AppSettings.KZ_APP, AppSettings.KZ_KEY, false); kidozen.Authenticate( AppSettings.KZ_USER, AppSettings.KZ_PASS, AppSettings.KZ_PROVIDER, kidoAuthCallback(signal)); signal.await(TEST_TIMEOUT_IN_MINUTES, TimeUnit.MINUTES); } catch (Exception e) { fail(e.getMessage()); } }
@Test public void QueryShouldReturnInvalidQuery() throws Exception { final CountDownLatch lcd = new CountDownLatch(1); kidozen.QueryLog( "{fail}", new ServiceEventListener() { @Override public void onFinish(ServiceEvent e) { assertThat(e.StatusCode, equalTo(HttpStatus.SC_BAD_REQUEST)); assertTrue(e.Body.indexOf("Invalid query. It must be compliant to elasticsearch") > -1); lcd.countDown(); } }); assertTrue(lcd.await(TEST_TIMEOUT_IN_MINUTES, TimeUnit.MINUTES)); }