List of usage examples for junit.framework Assert assertFalse
static public void assertFalse(boolean condition)
From source file:BQJDBC.QueryResultTest.BQScrollableResultSetFunctionTest.java
@Test public void TestResultSetNext() { try {/*from ww w.java 2s.c o m*/ Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.first()); Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.next()); Assert.assertEquals("yet", BQScrollableResultSetFunctionTest.Result.getString(1)); Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.next()); Assert.assertEquals("would", BQScrollableResultSetFunctionTest.Result.getString(1)); Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.next()); Assert.assertEquals("world", BQScrollableResultSetFunctionTest.Result.getString(1)); Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.next()); Assert.assertEquals("without", BQScrollableResultSetFunctionTest.Result.getString(1)); Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.next()); Assert.assertEquals("with", BQScrollableResultSetFunctionTest.Result.getString(1)); Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.next()); Assert.assertEquals("your", BQScrollableResultSetFunctionTest.Result.getString(1)); Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.next()); Assert.assertEquals("young", BQScrollableResultSetFunctionTest.Result.getString(1)); Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.next()); Assert.assertEquals("words", BQScrollableResultSetFunctionTest.Result.getString(1)); Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.next()); Assert.assertEquals("word", BQScrollableResultSetFunctionTest.Result.getString(1)); Assert.assertFalse(BQScrollableResultSetFunctionTest.Result.next()); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); Assert.fail("SQLException" + e.toString()); } try { Assert.assertEquals("", BQScrollableResultSetFunctionTest.Result.getString(1)); } catch (SQLException e) { boolean ct = e.toString().contains("Cursor is not in a valid Position"); if (ct == true) { Assert.assertTrue(ct); } else { this.logger.error("SQLexception" + e.toString()); Assert.fail("SQLException" + e.toString()); } } }
From source file:com.test.onesignal.MainOneSignalClassRunner.java
@Test public void shouldSendTags() throws Exception { OneSignalInit();// www . j av a2s. c o m OneSignal.sendTags(new JSONObject("{\"test1\": \"value1\", \"test2\": \"value2\"}")); threadAndTaskWait(); Assert.assertEquals(1, ShadowOneSignalRestClient.networkCallCount); Assert.assertEquals(ONESIGNAL_APP_ID, ShadowOneSignalRestClient.lastPost.getString("app_id")); Assert.assertEquals("value1", ShadowOneSignalRestClient.lastPost.getJSONObject("tags").getString("test1")); Assert.assertEquals("value2", ShadowOneSignalRestClient.lastPost.getJSONObject("tags").getString("test2")); // Should omit sending repeated tags ShadowOneSignalRestClient.lastPost = null; OneSignal.sendTags(new JSONObject("{\"test1\": \"value1\", \"test2\": \"value2\"}")); threadAndTaskWait(); Assert.assertEquals(1, ShadowOneSignalRestClient.networkCallCount); Assert.assertNull(ShadowOneSignalRestClient.lastPost); // Should only send changed and new tags OneSignal.sendTags( new JSONObject("{\"test1\": \"value1.5\", \"test2\": \"value2\", \"test3\": \"value3\"}")); threadAndTaskWait(); Assert.assertEquals(2, ShadowOneSignalRestClient.networkCallCount); JSONObject sentTags = ShadowOneSignalRestClient.lastPost.getJSONObject("tags"); Assert.assertEquals("value1.5", sentTags.getString("test1")); Assert.assertFalse(sentTags.has(("test2"))); Assert.assertEquals("value3", sentTags.getString("test3")); }
From source file:com.ebay.cloud.cms.query.service.QueryPaginationByIdTest.java
@Test public void testQueryIte_reverse() { String query = "VPool[exists @environment]{*}.parentCluster!Compute[@fqdns=~\".*.com\"]"; QueryContext qc = newQueryContext(STRATUS_REPO, IBranch.DEFAULT_BRANCH); qc.setPaginationMode(PaginationMode.ID_BASED); qc.setAllowFullTableScan(true);// w w w . j a v a 2 s.c o m qc.getCursor().setLimits(new int[] { 1, 2 }); qc.setSourceIP("127.0.0.1"); IQueryResult result = queryService.query(query, qc); Assert.assertTrue(result.hasMoreResults()); Assert.assertNotNull(result.getNextCursor().getJoinCursorValues()); Assert.assertNull(result.getNextCursor().getSkips()); int[] nLimit = result.getNextCursor().getLimits(); int hint = result.getNextCursor().getHint(); Assert.assertEquals(0, hint); Assert.assertEquals(2, nLimit.length); Assert.assertEquals(1, nLimit[0]); Assert.assertEquals(2, nLimit[1]); int count = result.getEntities().size(); System.out.println("fetch size: " + count); int iterateCount = 1; while (result.hasMoreResults()) { iterateCount++; System.out.println("iterate round: " + iterateCount + ", next skip _oids: " + ArrayUtils.toString(result.getNextCursor().getJoinCursorValues()) + ",next limits: " + ArrayUtils.toString(result.getNextCursor().getLimits())); qc.setCursor(result.getNextCursor()); result = queryService.query(query, qc); System.out.println("fetch size: " + result.getEntities().size()); count += result.getEntities().size(); } Assert.assertEquals(11, iterateCount); QueryContext qc1 = newQueryContext(STRATUS_REPO, IBranch.DEFAULT_BRANCH); qc1.setAllowFullTableScan(true); qc.setPaginationMode(PaginationMode.ID_BASED); qc1.setSourceIP("127.0.0.1"); IQueryResult result1 = queryService.query(query, qc1); Assert.assertFalse(result1.hasMoreResults()); Assert.assertNull(result.getNextCursor()); Assert.assertTrue(count >= result1.getEntities().size()); }
From source file:com.linkedin.pinot.core.data.manager.realtime.LLRealtimeSegmentDataManagerTest.java
@Test public void testOnlineTransitionAfterStop() throws Exception { LLCRealtimeSegmentZKMetadata metadata = new LLCRealtimeSegmentZKMetadata(); final long finalOffset = _startOffset + 600; metadata.setEndOffset(finalOffset);/* www . j a va 2 s. c om*/ { FakeLLRealtimeSegmentDataManager segmentDataManager = createFakeSegmentManager(); segmentDataManager._stopWaitTimeMs = 0; segmentDataManager._state.set(segmentDataManager, LLRealtimeSegmentDataManager.State.COMMITTED); segmentDataManager.goOnlineFromConsuming(metadata); Assert.assertFalse(segmentDataManager._downloadAndReplaceCalled); Assert.assertFalse(segmentDataManager._buildAndReplaceCalled); } { FakeLLRealtimeSegmentDataManager segmentDataManager = createFakeSegmentManager(); segmentDataManager._stopWaitTimeMs = 0; segmentDataManager._state.set(segmentDataManager, LLRealtimeSegmentDataManager.State.RETAINED); segmentDataManager.goOnlineFromConsuming(metadata); Assert.assertFalse(segmentDataManager._downloadAndReplaceCalled); Assert.assertFalse(segmentDataManager._buildAndReplaceCalled); } { FakeLLRealtimeSegmentDataManager segmentDataManager = createFakeSegmentManager(); segmentDataManager._stopWaitTimeMs = 0; segmentDataManager._state.set(segmentDataManager, LLRealtimeSegmentDataManager.State.DISCARDED); segmentDataManager.goOnlineFromConsuming(metadata); Assert.assertTrue(segmentDataManager._downloadAndReplaceCalled); Assert.assertFalse(segmentDataManager._buildAndReplaceCalled); } { FakeLLRealtimeSegmentDataManager segmentDataManager = createFakeSegmentManager(); segmentDataManager._stopWaitTimeMs = 0; segmentDataManager._state.set(segmentDataManager, LLRealtimeSegmentDataManager.State.ERROR); segmentDataManager.goOnlineFromConsuming(metadata); Assert.assertTrue(segmentDataManager._downloadAndReplaceCalled); Assert.assertFalse(segmentDataManager._buildAndReplaceCalled); } // If holding, but we have overshot the expected final offset, the download and replace { FakeLLRealtimeSegmentDataManager segmentDataManager = createFakeSegmentManager(); segmentDataManager._stopWaitTimeMs = 0; segmentDataManager._state.set(segmentDataManager, LLRealtimeSegmentDataManager.State.HOLDING); segmentDataManager.setCurrentOffset(finalOffset + 1); segmentDataManager.goOnlineFromConsuming(metadata); Assert.assertTrue(segmentDataManager._downloadAndReplaceCalled); Assert.assertFalse(segmentDataManager._buildAndReplaceCalled); } // If catching up, but we have overshot the expected final offset, the download and replace { FakeLLRealtimeSegmentDataManager segmentDataManager = createFakeSegmentManager(); segmentDataManager._stopWaitTimeMs = 0; segmentDataManager._state.set(segmentDataManager, LLRealtimeSegmentDataManager.State.CATCHING_UP); segmentDataManager.setCurrentOffset(finalOffset + 1); segmentDataManager.goOnlineFromConsuming(metadata); Assert.assertTrue(segmentDataManager._downloadAndReplaceCalled); Assert.assertFalse(segmentDataManager._buildAndReplaceCalled); } // If catching up, but we did not get to the final offset, then download and replace { FakeLLRealtimeSegmentDataManager segmentDataManager = createFakeSegmentManager(); segmentDataManager._stopWaitTimeMs = 0; segmentDataManager._state.set(segmentDataManager, LLRealtimeSegmentDataManager.State.CATCHING_UP); segmentDataManager._consumeOffsets.add(finalOffset - 1); segmentDataManager.goOnlineFromConsuming(metadata); Assert.assertTrue(segmentDataManager._downloadAndReplaceCalled); Assert.assertFalse(segmentDataManager._buildAndReplaceCalled); } // But then if we get to the exact offset, we get to build and replace, not download { FakeLLRealtimeSegmentDataManager segmentDataManager = createFakeSegmentManager(); segmentDataManager._stopWaitTimeMs = 0; segmentDataManager._state.set(segmentDataManager, LLRealtimeSegmentDataManager.State.CATCHING_UP); segmentDataManager._consumeOffsets.add(finalOffset); segmentDataManager.goOnlineFromConsuming(metadata); Assert.assertFalse(segmentDataManager._downloadAndReplaceCalled); Assert.assertTrue(segmentDataManager._buildAndReplaceCalled); } }
From source file:es.tekniker.framework.ktek.questionnaire.mng.server.test.TestQuestionnaireMngServer.java
public void testSaveKtekQuestionnaireMonitoringIT18() { log.info("*************************************************************"); log.info("testSaveKtekQuestionnaireMonitoringIT18: START "); String result = TestDefines.RESULT_OK; String token = null;//w ww. ja va 2 s .c om KtekQuestionnaireResultEntity resultData = null; QuestionnaireMngServer manager = new QuestionnaireMngServer(); int boolOK = 0; try { token = TestData.getLoginToken(); resultData = es.tekniker.framework.ktek.questionnaire.mng.db.TestData .getKtekQuestionnaireMonitoringResultEntityIT18(); boolOK = manager.saveQuestionnaireModel(token, resultData); if (boolOK == 1) { log.info("testSaveKtekQuestionnaireMonitoringIT18: SAVE OK "); Assert.assertTrue(true); } else { log.error("testSaveKtekQuestionnaireMonitoringIT18: SAVE ERROR "); result = TestDefines.RESULT_ERROR; Assert.assertTrue(false); } } catch (KtekExceptionEntity e) { System.out.println("testSaveKtekQuestionnaireMonitoringIT18: exception " + e.getMessage()); e.printStackTrace(); Assert.assertFalse(false); } log.info("testSaveKtekQuestionnaireMonitoringIT18: RESULT " + result); log.info("testSaveKtekQuestionnaireMonitoringIT18: END "); log.info("*************************************************************"); log.info(""); }
From source file:com.ibm.team.build.internal.hjplugin.tests.BuildConfigurationIT.java
public void testOldLoadRules() throws Exception { // Create build definition with old style load rules // load directory missing // don't delete directory before loading (dir has other stuff that will not be deleted) // don't accept changes before loading // create a build engine // create a build request // verify that the buildConfiguration returns the load rules // as the workspace to be loaded // checkout based on the request // make sure only the contents identified by the load rule was loaded // verify extra stuff from sandbox directory not deleted // verify no changes accepted if (Config.DEFAULT.isConfigured()) { RTCLoginInfo loginInfo = Config.DEFAULT.getLoginInfo(); String testName = getTestName() + System.currentTimeMillis(); @SuppressWarnings("unchecked") Map<String, String> setupArtifacts = (Map<String, String>) testingFacade.invoke("testOldLoadRules", new Class[] { String.class, // serverURL, String.class, // userId, String.class, // password, int.class, // timeout, String.class, // workspaceName, String.class, // componentName, String.class }, // hjPath, loginInfo.getServerUri(), loginInfo.getUserId(), loginInfo.getPassword(), loginInfo.getTimeout(), testName, getTestName(), sandboxDir.getPath()); try {//from w w w .ja v a2s.c o m TaskListener listener = new StreamTaskListener(System.out, null); File changeLogFile = new File(sandboxDir, "RTCChangeLogFile"); FileOutputStream changeLog = new FileOutputStream(changeLogFile); assertTrue(new File(sandboxDir, "abc").mkdirs()); assertTrue(new File(sandboxDir, "def").mkdirs()); assertTrue(new File(sandboxDir, "hij").mkdirs()); // checkout the changes @SuppressWarnings("unchecked") Map<String, String> buildProperties = (Map<String, String>) testingFacade.invoke("checkout", new Class[] { String.class, // serverURL, String.class, // userId, String.class, // password, int.class, // timeout, String.class, // buildResultUUID, String.class, // workspaceName, String.class, // hjWorkspacePath, OutputStream.class, // changeLog, String.class, // baselineSetName, Object.class, // listener Locale.class }, // clientLocale loginInfo.getServerUri(), loginInfo.getUserId(), loginInfo.getPassword(), loginInfo.getTimeout(), setupArtifacts.get("buildResultItemId"), null, sandboxDir.getCanonicalPath(), changeLog, "Snapshot", listener, Locale.getDefault()); String[] children = sandboxDir.list(); Assert.assertEquals(6, children.length); // change log + 3 dirs made + metadata + file loaded Assert.assertTrue(new File(sandboxDir, "a.txt").exists()); Assert.assertFalse(new File(sandboxDir, "h.txt").exists()); Assert.assertTrue(new File(sandboxDir, "abc").exists()); Assert.assertTrue(new File(sandboxDir, "def").exists()); Assert.assertTrue(new File(sandboxDir, "hij").exists()); RTCChangeLogParser parser = new RTCChangeLogParser(); FileReader changeLogReader = new FileReader(changeLogFile); RTCChangeLogSet result = (RTCChangeLogSet) parser.parse(null, null, changeLogReader); // verify the result int changeCount = result.getComponentChangeCount() + result.getChangeSetsAcceptedCount() + result.getChangeSetsDiscardedCount(); // no accept done Assert.assertEquals(0, changeCount); Assert.assertNull(result.getBaselineSetItemId()); validateBuildProperties(setupArtifacts.get(ARTIFACT_WORKSPACE_ITEM_ID), null, false, false, setupArtifacts.get("LoadRuleProperty"), false, "", result.getBaselineSetItemId(), changeCount, false, buildProperties); } finally { // clean up testingFacade.invoke("tearDown", new Class[] { String.class, // serverURL, String.class, // userId, String.class, // password, int.class, // timeout, Map.class }, // setupArtifacts loginInfo.getServerUri(), loginInfo.getUserId(), loginInfo.getPassword(), loginInfo.getTimeout(), setupArtifacts); } } }
From source file:BQJDBC.QueryResultTest.BQResultSetFunctionTest.java
@Test public void TestResultSetPrevious() { try {/* w w w.j a va 2s.c o m*/ Assert.assertTrue(BQResultSetFunctionTest.Result.last()); Assert.assertTrue(BQResultSetFunctionTest.Result.previous()); Assert.assertEquals("words", BQResultSetFunctionTest.Result.getString(1)); Assert.assertTrue(BQResultSetFunctionTest.Result.previous()); Assert.assertEquals("young", BQResultSetFunctionTest.Result.getString(1)); Assert.assertTrue(BQResultSetFunctionTest.Result.previous()); Assert.assertEquals("your", BQResultSetFunctionTest.Result.getString(1)); Assert.assertTrue(BQResultSetFunctionTest.Result.previous()); Assert.assertEquals("with", BQResultSetFunctionTest.Result.getString(1)); Assert.assertTrue(BQResultSetFunctionTest.Result.previous()); Assert.assertEquals("without", BQResultSetFunctionTest.Result.getString(1)); Assert.assertTrue(BQResultSetFunctionTest.Result.previous()); Assert.assertEquals("world", BQResultSetFunctionTest.Result.getString(1)); Assert.assertTrue(BQResultSetFunctionTest.Result.previous()); Assert.assertEquals("would", BQResultSetFunctionTest.Result.getString(1)); Assert.assertTrue(BQResultSetFunctionTest.Result.previous()); Assert.assertEquals("yet", BQResultSetFunctionTest.Result.getString(1)); Assert.assertTrue(BQResultSetFunctionTest.Result.previous()); Assert.assertEquals("you", BQResultSetFunctionTest.Result.getString(1)); Assert.assertFalse(BQResultSetFunctionTest.Result.previous()); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); Assert.fail("SQLException" + e.toString()); } try { Assert.assertEquals("", BQResultSetFunctionTest.Result.getString(1)); } catch (SQLException e) { boolean ct = e.toString().contains("Cursor is not in a valid Position"); if (ct == true) { Assert.assertTrue(ct); } else { this.logger.error("SQLexception" + e.toString()); Assert.fail("SQLException" + e.toString()); } } }
From source file:es.tekniker.framework.ktek.questionnaire.mng.server.test.TestQuestionnaireMngServer.java
@org.junit.Test public void getQuestionnaires4TypeMonitoringActivityPlannedByToken() { log.info("*************************************************************"); log.info("getQuestionnaires4TypeMonitoringActivityPlannedByToken: START "); String result = TestDefines.RESULT_OK; QuestionnaireMngServer manager = new QuestionnaireMngServer(); String token = null;/*from w w w . j a v a 2 s . c o m*/ int idlang = 1; KtekQuestionnaireModelEntity[] array = null; short status = KtekQuestionnaireStatus.QUESTIONNAIRE_STATUS_PENDING; String codtelecareprogram = "TBP1"; try { token = TestData.getLoginToken(); array = manager.getQuestionnaires4TypeMonitoringActivityPlannedByToken(token, codtelecareprogram, idlang, KtekApplicationitemType.STATUSPARAMETERS, status); if (array != null) { log.info("getQuestionnaires4TypeMonitoringActivityPlannedByToken: array is NOT NULL " + array.length); Assert.assertTrue(true); } else { log.error("getQuestionnaires4TypeMonitoringActivityPlannedByToken: array is NULL "); result = TestDefines.RESULT_ERROR; Assert.assertTrue(true); } } catch (KtekExceptionEntity e) { System.out.println( "getQuestionnaires4TypeMonitoringActivityPlannedByToken: exception " + e.getMessage()); e.printStackTrace(); Assert.assertFalse(false); } log.info("getQuestionnaires4TypeMonitoringActivityPlannedByToken: RESULT " + result); log.info("getQuestionnaires4TypeMonitoringActivityPlannedByToken: END "); log.info("*************************************************************"); log.info(""); }
From source file:com.test.onesignal.MainOneSignalClassRunner.java
@Test public void testSendTagNonStringValues() throws Exception { OneSignalInit();/* w w w .j ava2 s .c om*/ OneSignal.sendTags("{\"int\": 122, \"bool\": true, \"null\": null, \"array\": [123], \"object\": {}}"); GetTags(); Assert.assertEquals(String.class, lastGetTags.get("int").getClass()); Assert.assertEquals("122", lastGetTags.get("int")); Assert.assertEquals(String.class, lastGetTags.get("bool").getClass()); Assert.assertEquals("true", lastGetTags.get("bool")); // null should be the same as a blank string. Assert.assertFalse(lastGetTags.has("null")); Assert.assertFalse(lastGetTags.has("array")); Assert.assertFalse(lastGetTags.has("object")); }
From source file:BQJDBC.QueryResultTest.BQScrollableResultSetFunctionTest.java
@Test public void TestResultSetPrevious() { try {/*w w w.j av a 2s . co m*/ Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.last()); Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.previous()); Assert.assertEquals("words", BQScrollableResultSetFunctionTest.Result.getString(1)); Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.previous()); Assert.assertEquals("young", BQScrollableResultSetFunctionTest.Result.getString(1)); Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.previous()); Assert.assertEquals("your", BQScrollableResultSetFunctionTest.Result.getString(1)); Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.previous()); Assert.assertEquals("with", BQScrollableResultSetFunctionTest.Result.getString(1)); Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.previous()); Assert.assertEquals("without", BQScrollableResultSetFunctionTest.Result.getString(1)); Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.previous()); Assert.assertEquals("world", BQScrollableResultSetFunctionTest.Result.getString(1)); Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.previous()); Assert.assertEquals("would", BQScrollableResultSetFunctionTest.Result.getString(1)); Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.previous()); Assert.assertEquals("yet", BQScrollableResultSetFunctionTest.Result.getString(1)); Assert.assertTrue(BQScrollableResultSetFunctionTest.Result.previous()); Assert.assertEquals("you", BQScrollableResultSetFunctionTest.Result.getString(1)); Assert.assertFalse(BQScrollableResultSetFunctionTest.Result.previous()); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); Assert.fail("SQLException" + e.toString()); } try { Assert.assertEquals("", BQScrollableResultSetFunctionTest.Result.getString(1)); } catch (SQLException e) { boolean ct = e.toString().contains("Cursor is not in a valid Position"); if (ct == true) { Assert.assertTrue(ct); } else { this.logger.error("SQLexception" + e.toString()); Assert.fail("SQLException" + e.toString()); } } }