List of usage examples for junit.framework Assert assertTrue
static public void assertTrue(boolean condition)
From source file:org.springsource.examples.expenses.TestDatabaseChargeService.java
@Test public void testChargeReconciliation() throws Throwable { List<Charge> eligibleCharges = chargeService.getEligibleCharges(); Assert.assertNotNull(eligibleCharges); Assert.assertTrue(eligibleCharges.size() == 2); for (Charge c : eligibleCharges) { chargeService.markAsPaid(c.getId()); }/* www .j a v a2s .c o m*/ Assert.assertTrue(chargeService.getEligibleCharges().size() == 0); }
From source file:com.github.ipaas.ideploy.agent.handler.DownloadCodeHandlerTest.java
/** * ??,???,// www .j a v a 2 s. c o m * * @throws Exception */ @Test public void downloadCodeTest() throws Exception { String usingRoot = "/www/apptemp/" + USING_VERSION; String doingRoot = "/www/apptemp/" + DOING_VERSION; DownloadCodeHandler downLoadHandler = new DownloadCodeHandler(); File usingfile = new File(usingRoot); if (usingfile.exists()) { FileUtils.forceDelete(usingfile); } File doingFile = new File(doingRoot); if (doingFile.exists()) { FileUtils.forceDelete(doingFile); } String flowId = "flowIdNotNeed"; String cmd = "cmdNotNeed"; Integer hostStatus4New = 1; Integer updateAll = 1; Map<String, Object> firstDownLoadParams = new HashMap<String, Object>(); firstDownLoadParams.put("doingCodeVerPath", TEST_GROUP + TAGS + "/" + USING_VERSION); firstDownLoadParams.put("hostStatus", hostStatus4New); firstDownLoadParams.put("savePath", usingRoot);// ?? firstDownLoadParams.put("updateAll", updateAll); downLoadHandler.execute(flowId, cmd, firstDownLoadParams, null); Assert.assertTrue(new File(usingRoot + "/update.txt").exists()); Integer notUpdateAll = 2; Integer hostStatus4Old = 2; Map<String, Object> secondDownLoadParams = new HashMap<String, Object>(); secondDownLoadParams.put("doingCodeVerPath", TEST_GROUP + TAGS + "/" + DOING_VERSION); secondDownLoadParams.put("usingCodeVerPath", TEST_GROUP + TAGS + "/" + USING_VERSION); secondDownLoadParams.put("hostStatus", hostStatus4Old); secondDownLoadParams.put("savePath", doingRoot);// ?? secondDownLoadParams.put("updateAll", notUpdateAll); downLoadHandler.execute(flowId, cmd, secondDownLoadParams, null); File updateFile = new File(doingRoot + "/update.txt"); Assert.assertTrue(updateFile.exists()); // ? //String do List<String> updateList = FileUtils.readLines(updateFile); for (String str : updateList) { if (str.startsWith("+")) { Assert.assertTrue( new File(doingRoot + "/code" + StringUtils.removeStart(str, "+").trim()).exists()); } else if (str.startsWith("-")) { String f = usingRoot + "/code" + StringUtils.removeStart(str, "-").trim(); Assert.assertTrue(new File(f).exists()); } } if (usingfile.exists()) { FileUtils.forceDelete(usingfile); } if (doingFile.exists()) { FileUtils.forceDelete(doingFile); } }
From source file:com.facebook.TestUtils.java
public static void assertAtLeastExpectedPermissions(final Collection<String> expected, final Collection<String> actual) { if (expected != null) { for (String p : expected) { Assert.assertTrue(actual.contains(p)); }//from ww w .j a v a2 s . c o m } }
From source file:alpha.portal.webapp.listener.StartupListenerTest.java
/** * Test context initialized.//from w ww .j a v a 2s . com */ public void testContextInitialized() { this.listener.contextInitialized(new ServletContextEvent(this.sc)); Assert.assertTrue(this.sc.getAttribute(Constants.CONFIG) != null); final Map config = (Map) this.sc.getAttribute(Constants.CONFIG); Assert.assertEquals(config.get(Constants.CSS_THEME), "simplicity"); Assert.assertTrue( this.sc.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE) != null); Assert.assertTrue(this.sc.getAttribute(Constants.AVAILABLE_ROLES) != null); }
From source file:io.cloudslang.lang.compiler.PreCompileTransformersTest.java
@Test public void testPreCompileSensitiveInputsAndOutputsWithAndWithoutDefault() throws Exception { URI resource = getClass().getResource("/check_weather_flow_sensitive_inputs_outputs.sl").toURI(); ExecutableModellingResult result = compiler.preCompileSource(SlangSource.fromFile(resource)); Assert.assertNotNull(result);/*from www . j a v a 2 s. c o m*/ List<RuntimeException> errors = result.getErrors(); Assert.assertNotNull(errors); Assert.assertTrue(errors.size() == 0); Executable executable = result.getExecutable(); Assert.assertNotNull(executable); List<Input> inputs = executable.getInputs(); Assert.assertEquals(3, inputs.size()); Assert.assertEquals("flow_input_1", inputs.get(0).getName()); Assert.assertEquals("defaultValue", inputs.get(0).getValue().get()); Assert.assertEquals(false, inputs.get(0).getValue().isSensitive()); Assert.assertEquals("flow_input_0", inputs.get(1).getName()); Assert.assertEquals("${flow_input_1}", inputs.get(1).getValue().get()); Assert.assertEquals(true, inputs.get(1).getValue().isSensitive()); Assert.assertEquals("flow_input_sensitive", inputs.get(2).getName()); Assert.assertEquals(null, inputs.get(2).getValue().get()); Assert.assertEquals(true, inputs.get(2).getValue().isSensitive()); List<Output> outputs = executable.getOutputs(); Assert.assertEquals(2, outputs.size()); Assert.assertEquals("flow_output_0", outputs.get(0).getName()); Assert.assertEquals("${flow_input_1}", outputs.get(0).getValue().get()); Assert.assertEquals(true, outputs.get(0).getValue().isSensitive()); Assert.assertEquals("flow_output_1", outputs.get(1).getName()); Assert.assertEquals("${flow_output_1}", outputs.get(1).getValue().get()); Assert.assertEquals(true, outputs.get(1).getValue().isSensitive()); }
From source file:com.espertech.esper.multithread.StmtJoinCallable.java
public Object call() throws Exception { try {/*from www .ja v a 2 s. c om*/ // Add assertListener SupportMTUpdateListener assertListener = new SupportMTUpdateListener(); ThreadLogUtil.trace("adding listeners ", assertListener); stmt.addListener(assertListener); for (int loop = 0; loop < numRepeats; loop++) { long id = threadNum * 100000000 + loop; Object eventS0 = makeEvent("s0", id); Object eventS1 = makeEvent("s1", id); ThreadLogUtil.trace("SENDING s0 event ", id, eventS0); engine.getEPRuntime().sendEvent(eventS0); ThreadLogUtil.trace("SENDING s1 event ", id, eventS1); engine.getEPRuntime().sendEvent(eventS1); //ThreadLogUtil.info("sent", eventS0, eventS1); // Should have received one that's mine, possible multiple since the statement is used by other threads boolean found = false; EventBean[] events = assertListener.getNewDataListFlattened(); for (EventBean theEvent : events) { Object s0Received = theEvent.get("s0"); Object s1Received = theEvent.get("s1"); //ThreadLogUtil.info("received", event.get("s0"), event.get("s1")); if ((s0Received == eventS0) && (s1Received == eventS1)) { found = true; } } if (!found) { } Assert.assertTrue(found); assertListener.reset(); } } catch (AssertionFailedError ex) { log.fatal("Assertion error in thread " + Thread.currentThread().getId(), ex); return false; } catch (Exception ex) { log.fatal("Error in thread " + Thread.currentThread().getId(), ex); return false; } return true; }
From source file:com.impetus.kundera.EntityManagerImplTest.java
@Test public void testSingleEntityCRUD_EmNotCleared() { // Persist//from w w w . j av a 2 s . co m final SampleEntity entity = new SampleEntity(); entity.setKey(1); entity.setName("Amry"); entity.setCity("Delhi"); em.persist(entity); SampleEntity found = em.find(SampleEntity.class, 1); assertSampleEntity(found); Assert.assertTrue(em.contains(found)); found.setName("Xamry"); found.setCity("Noida"); em.merge(found); SampleEntity foundAfterMerge = em.find(SampleEntity.class, 1); assertUpdatedSampleEntity(foundAfterMerge); em.flush(); em.remove(foundAfterMerge); SampleEntity foundAfterDeletion = em.find(SampleEntity.class, 1); Assert.assertNull(foundAfterDeletion); }
From source file:de.itsvs.cwtrpc.controller.config.RemoteServiceGroupConfigBeanDefinitionParserTest.java
@Test public void test2() { RemoteServiceGroupConfig config;/* w w w . j a v a 2 s .c om*/ config = appContext.getBean("serviceGroup102", RemoteServiceGroupConfig.class); Assert.assertTrue(config.getResponseCompressionEnabled()); }
From source file:com.couchbase.lite.performance2.Test07_PushReplication.java
public double runOne(final int numberOfDocuments, final int sizeOfDocuments) throws Exception { String[] bigObj = new String[sizeOfDocuments]; for (int i = 0; i < sizeOfDocuments; i++) { bigObj[i] = _propertyValue;/*from www . j a v a2 s. c om*/ } final Map<String, Object> props = new HashMap<String, Object>(); props.put("bigArray", bigObj); String docIdTimestamp = Long.toString(System.currentTimeMillis()); for (int i = 0; i < numberOfDocuments; i++) { String docId = String.format("doc%d-%s", i, docIdTimestamp); try { addDocWithId(docId, props, "attachment.png", false); //addDocWithId(docId, null, false); } catch (IOException ioex) { Log.v("PerformanceStats", TAG + ", Add document directly to sync gateway failed", ioex); fail(); } } URL remote = getReplicationURL(); long startMillis = System.currentTimeMillis(); final Replication repl = database.createPushReplication(remote); repl.setContinuous(false); if (!isSyncGateway(remote)) { repl.setCreateTarget(true); Assert.assertTrue(repl.shouldCreateTarget()); } Log.v("PerformanceStats", TAG + ", Starting push operation with: " + repl); runReplication(repl); Log.v("PerformanceStats", TAG + ", Push operation finished with: " + repl); double executionTime = Long.valueOf(System.currentTimeMillis() - startMillis); Log.v("PerformanceStats", TAG + ", " + executionTime + "," + numberOfDocuments + "," + sizeOfDocuments); return executionTime; }
From source file:com.github.ipaas.ideploy.agent.handler.UpdateCodeHandlerTest.java
/** * ??,???,/* w ww .j a va2 s . c o m*/ * * @throws Exception */ @Test public void updateCodeTest() throws Exception { String usingRoot = "/www/apptemp/" + USING_VERSION; String doingRoot = "/www/apptemp/" + DOING_VERSION; DownloadCodeHandler downLoadHandler = new DownloadCodeHandler(); File usingfile = new File(usingRoot); if (usingfile.exists()) { FileUtils.forceDelete(usingfile); } File doingFile = new File(doingRoot); if (doingFile.exists()) { FileUtils.forceDelete(doingFile); } String flowId = "flowIdNotNeed"; String cmd = "cmdNotNeed"; Integer hostStatus4New = 1; Integer updateAll = 1; Map<String, Object> firstDownLoadParams = new HashMap<String, Object>(); firstDownLoadParams.put("doingCodeVerPath", TEST_GROUP + TAGS + "/" + USING_VERSION); firstDownLoadParams.put("hostStatus", hostStatus4New); firstDownLoadParams.put("savePath", usingRoot);// ?? firstDownLoadParams.put("updateAll", updateAll); downLoadHandler.execute(flowId, cmd, firstDownLoadParams, null); Assert.assertTrue(new File(usingRoot + "/update.txt").exists()); Integer notUpdateAll = 2; Integer hostStatus4Old = 2; Map<String, Object> secondDownLoadParams = new HashMap<String, Object>(); secondDownLoadParams.put("doingCodeVerPath", TEST_GROUP + TAGS + "/" + DOING_VERSION); secondDownLoadParams.put("usingCodeVerPath", TEST_GROUP + TAGS + "/" + USING_VERSION); secondDownLoadParams.put("hostStatus", hostStatus4Old); secondDownLoadParams.put("savePath", doingRoot);// ?? secondDownLoadParams.put("updateAll", notUpdateAll); downLoadHandler.execute(flowId, cmd, secondDownLoadParams, null); File updateFile = new File(doingRoot + "/update.txt"); List<String> updateList = FileUtils.readLines(updateFile); UpdateCodeHandler updateHandler = new UpdateCodeHandler(); Map<String, Object> updateParam = new HashMap<String, Object>(); updateParam.put("targetPath", usingRoot + "/code"); updateParam.put("srcPath", doingRoot); updateHandler.execute(null, null, updateParam, null);// ?doingRoot?usingRoot // ? // String do for (String str : updateList) { if (str.startsWith("+")) { Assert.assertTrue( new File(usingRoot + "/code" + StringUtils.removeStart(str, "+").trim()).exists()); } else if (str.startsWith("-")) { String f = usingRoot + "/code" + StringUtils.removeStart(str, "-").trim(); Assert.assertFalse(new File(f).exists()); } } if (usingfile.exists()) { FileUtils.forceDelete(usingfile); } }