List of usage examples for junit.framework Assert assertTrue
static public void assertTrue(String message, boolean condition)
From source file:com.espertech.esper.multithread.StmtListenerAddRemoveCallable.java
public Object call() throws Exception { try {//ww w . j a v a 2s .c o m for (int loop = 0; loop < numRepeats; loop++) { // Add assertListener SupportMTUpdateListener assertListener = new SupportMTUpdateListener(); LogUpdateListener logListener; if (isEPL) { logListener = new LogUpdateListener(null); } else { logListener = new LogUpdateListener("a"); } ThreadLogUtil.trace("adding listeners ", assertListener, logListener); stmt.addListener(assertListener); stmt.addListener(logListener); // send event Object theEvent = makeEvent(); ThreadLogUtil.trace("sending event ", theEvent); engine.getEPRuntime().sendEvent(theEvent); // Should have received one or more events, one of them must be mine EventBean[] newEvents = assertListener.getNewDataListFlattened(); Assert.assertTrue("No event received", newEvents.length >= 1); ThreadLogUtil.trace("assert received, size is", newEvents.length); boolean found = false; for (int i = 0; i < newEvents.length; i++) { Object underlying = newEvents[i].getUnderlying(); if (!isEPL) { underlying = newEvents[i].get("a"); } if (underlying == theEvent) { found = true; } } Assert.assertTrue(found); assertListener.reset(); // Remove assertListener ThreadLogUtil.trace("removing assertListener"); stmt.removeListener(assertListener); stmt.removeListener(logListener); // Send another event theEvent = makeEvent(); ThreadLogUtil.trace("send non-matching event ", theEvent); engine.getEPRuntime().sendEvent(theEvent); // Make sure the event was not received newEvents = assertListener.getNewDataListFlattened(); found = false; for (int i = 0; i < newEvents.length; i++) { Object underlying = newEvents[i].getUnderlying(); if (!isEPL) { underlying = newEvents[i].get("a"); } if (underlying == theEvent) { found = true; } } Assert.assertFalse(found); } } 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.sap.prd.mobile.ios.mios.SpecificTargetTest.java
private void assertCorrectTargetBuild(File logFile) throws IOException { BufferedReader reader = new BufferedReader(new FileReader(logFile)); try {//from ww w . java 2s . c o m String line; boolean target1Built = false; boolean target2Built = false; while ((line = reader.readLine()) != null) { target1Built |= line.matches( "=== BUILD.*TARGET Target1 OF PROJECT MultipleTargets WITH CONFIGURATION Release ==="); target2Built |= line.matches( "=== BUILD.*TARGET Target2 OF PROJECT MultipleTargets WITH CONFIGURATION Release ==="); } Assert.assertFalse("Target1 must not be built", target1Built); Assert.assertTrue("Target2 must be built", target2Built); } finally { IOUtils.closeQuietly(reader); } }
From source file:eu.stratosphere.nephele.services.iomanager.IOManagerPerformanceBenchmark.java
@After public void afterTest() throws Exception { ioManager.shutdown();/*from w w w . j a v a2s . com*/ Assert.assertTrue("IO Manager has not properly shut down.", ioManager.isProperlyShutDown()); Assert.assertTrue("Not all memory was returned to the memory manager in the test.", memManager.verifyEmpty()); memManager.shutdown(); memManager = null; }
From source file:mx.com.adolfogarcia.popularmovies.data.TestUtilities.java
/** * Verifies the row the {@link Cursor} is pointing at, contains the same * information as that in the {@link ContentValues}. * * @param expectedValues values expected to be in the row. * @param valueCursor data to verify./* w ww. jav a 2 s .c o m*/ */ static void assertRowEquals(ContentValues expectedValues, Cursor valueCursor) { Set<Map.Entry<String, Object>> valueSet = expectedValues.valueSet(); for (Map.Entry<String, Object> entry : valueSet) { String columnName = entry.getKey(); int columnIdx = valueCursor.getColumnIndex(columnName); Assert.assertTrue("Column '" + columnName + "' should exist.", columnIdx != -1); String expectedValue = entry.getValue().toString(); Assert.assertEquals("Value must be equal to'" + expectedValue + "'.", expectedValue, valueCursor.getString(columnIdx)); } }
From source file:org.wso2.ei.businessprocess.integration.tests.bpmn.rest.BPMNRestExecutionTest.java
@Test(groups = { "wso2.bps.bpmn.rest" }, description = "get executions", priority = 1, singleThreaded = true) public void testGetExecutions() throws Exception { BPMNProcess[] bpmnProcesses = workflowServiceClient.getProcesses(); String processId = null;// w w w. j ava 2s . c o m //start a ExecutionResourceTest process for (BPMNProcess process : bpmnProcesses) { if (process.getKey().equals("processOneExec")) { processId = process.getProcessId(); workflowServiceClient.getInstanceServiceStub().startProcess(processId); break; } } HttpResponse response = BPMNTestUtils.getRequestResponse(backEndUrl + executionsUrl); JSONObject jsonObject = new JSONObject(EntityUtils.toString(response.getEntity())); //at least two executions should return, processOne starts two executions Assert.assertTrue("runtime/executions test", (jsonObject.getInt("total") > 1)); List<BPMNInstance> bpmnInstances = workflowServiceClient.getProcessInstancesByProcessId(processId); //request with process id response = BPMNTestUtils .getRequestResponse(backEndUrl + executionsUrl + "?processDefinitionId=" + processId); jsonObject = new JSONObject(EntityUtils.toString(response.getEntity())); JSONArray dataArray = (JSONArray) (jsonObject.get("data")); //assuming only two instances exist for (int i = 0; i < jsonObject.getInt("size"); i++) { String instanceId = ((JSONObject) dataArray.get(i)).getString("processInstanceId"); Assert.assertTrue("runtime/executions?processDefinitionId test", instanceId.equals(bpmnInstances.get(0).getInstanceId()) || instanceId.equals(bpmnInstances.get(1).getInstanceId())); } //{executionId} String executionId = ((JSONObject) dataArray.get(0)).getString("id"); response = BPMNTestUtils.getRequestResponse(backEndUrl + executionsUrl + "/" + executionId); jsonObject = new JSONObject(EntityUtils.toString(response.getEntity())); Assert.assertEquals("runtime/executions/{executionId} test", executionId, jsonObject.getString("id")); response = BPMNTestUtils.getRequestResponse(backEndUrl + executionsUrl + "/" + executionId + "/activities"); String result = EntityUtils.toString(response.getEntity()); Assert.assertTrue("runtime/executions/{executionId}/activities test", result.contains("processTask")); //TODO:post requests do not work with given payload for variables, returns 400 saying no variables found (worked well with a rest client (postman) ) // String variable = "[{\"name\":\"intProcVar\", \"type\":\"integer\", \"value\":123, \"scope\":\"local\"}]"; // response = BPMNTestUtils.postRequest(backEndUrl + executionsUrl + "/" + executionId + "/variables",new JSONArray(variable)); // result = EntityUtils.toString(response.getEntity()); for (BPMNProcess process : bpmnProcesses) { if (process.getKey().equals("processOneSignal")) { processId = process.getProcessId(); workflowServiceClient.getInstanceServiceStub().startProcess(processId); break; } } bpmnInstances = workflowServiceClient.getProcessInstancesByProcessId(processId); String action = "{" + "\"action\":\"signal\"" + "}"; response = BPMNTestUtils.putRequest(backEndUrl + executionsUrl + "/" + bpmnInstances.get(0).getInstanceId(), new JSONObject(action)); Assert.assertEquals("PUT runtime/executions/{executionId} test", 200, response.getStatusLine().getStatusCode()); //get the executin again to check the state response = BPMNTestUtils .getRequestResponse(backEndUrl + executionsUrl + "/" + bpmnInstances.get(0).getInstanceId()); jsonObject = new JSONObject(EntityUtils.toString(response.getEntity())); //should go to the wait state after a signal Assert.assertEquals("PUT runtime/executions/{executionId} test", "anotherWaitState", jsonObject.getString("activityId")); }
From source file:my.adam.smo.EncryptionTest.java
@Test public void symetricEncryptionLongMessage() { ApplicationContext clientContext = new ClassPathXmlApplicationContext("Context.xml"); SymmetricEncryptionBox box = clientContext.getBean(SymmetricEncryptionBox.class); int plainTextLength = 17; byte[] plainText = new byte[plainTextLength]; random.nextBytes(plainText);/*from w w w. jav a 2 s. c om*/ byte[] cryptogram = box.encrypt(plainText); Assert.assertFalse("plain text leaked!!!", Arrays.equals(plainText, Arrays.copyOfRange(cryptogram, SymmetricEncryptionBox.ivLength, cryptogram.length))); byte[] decrypted = box.decrypt(cryptogram); Assert.assertTrue("unable to decrypt", Arrays.equals(plainText, decrypted)); }
From source file:com.espertech.esper.multithread.IsolateUnisolateCallable.java
private void findEvent(SupportMTUpdateListener listener, int loop, Object theEvent) { String message = "Failed in loop " + loop + " threads " + Thread.currentThread(); Assert.assertTrue(message, listener.isInvoked()); List<EventBean[]> eventBeans = listener.getNewDataListCopy(); boolean found = false; for (EventBean[] events : eventBeans) { Assert.assertEquals(message, 1, events.length); if (events[0].getUnderlying() == theEvent) { found = true;/* ww w. ja va 2 s. co m*/ } } Assert.assertTrue(message, found); listener.reset(); }
From source file:org.outermedia.solrfusion.adapter.solr.DefaultSolrAdapterTest.java
@Test @Ignore/*from www . j a v a 2 s. c om*/ public void testHttpClientGet() throws IOException, URISyntaxException { HttpClient client = HttpClientBuilder.create().build(); URI uri = new URI("http", null, "www.outermedia.de", 80, "/", "q=bla", null); HttpGet request = new HttpGet(uri); HttpResponse response = client.execute(request); Header[] header = response.getHeaders("Server"); Assert.assertTrue("Server is Ubuntu", header[0].getValue().contains("Ubuntu")); // Get the response HttpEntity entity = response.getEntity(); Assert.assertEquals("Content-type is utf8 hmtl", "text/html; charset=utf-8", entity.getContentType().getValue()); String content = new Scanner(response.getEntity().getContent(), "UTF-8").useDelimiter("\\A").next(); System.out.println(content); }
From source file:eu.stratosphere.pact.test.cancelling.CancellingTestBase.java
private void verifyJvmOptions() { final long heap = Runtime.getRuntime().maxMemory() >> 20; Assert.assertTrue( "Insufficient java heap space " + heap + "mb - set JVM option: -Xmx" + MINIMUM_HEAP_SIZE_MB + "m", heap > MINIMUM_HEAP_SIZE_MB - 50); }
From source file:org.wso2.carbon.esb.api.apidefinition.ESBJAVA4936SwaggerGenerationJsonYamlTestCase.java
@Test(groups = "wso2.esb", description = "Test API definition for JSON is generated correctly") public void jsonDefinitionTest() throws Exception { String restURL = getMainSequenceURL() + "StockQuoteAPI?swagger.json"; SimpleHttpClient httpClient = new SimpleHttpClient(); HttpResponse response = httpClient.doGet(restURL, null); String payload = httpClient.getResponsePayload(response); log.info("JSON Definition Response : " + payload); Assert.assertTrue("Swagger JSON definition did not contained in the response", payload.contains("API Definition of StockQuoteAPI")); }