List of usage examples for junit.framework Assert assertTrue
static public void assertTrue(boolean condition)
From source file:se.vgregion.urlservice.services.SambaFacilitiesServiceTest.java
@Test public void testSuccessfulNoResources() throws Exception { when(httpEntity.getContent()).thenReturn(new FileInputStream("src/test/resources/samba2.xml")); List<Facility> actual = facilityService.findNearbyFacilities(pos); Assert.assertTrue(actual.isEmpty()); }
From source file:com.couchbase.lite.BlobStoreTest.java
public void testReopen() throws Exception { if (!isSQLiteDB()) return;//w ww . j a v a 2 s . c om byte[] item = "this is an item".getBytes("UTF8"); BlobKey key = new BlobKey(); Assert.assertTrue(store.storeBlob(item, key)); BlobStore store2 = new BlobStore(manager.getContext(), store.getPath(), store.getEncryptionKey(), true); Assert.assertNotNull("Couldn't re-open store", store2); byte[] readItem = store2.blobForKey(key); Assert.assertTrue(Arrays.equals(readItem, item)); readItem = store.blobForKey(key); Assert.assertTrue(Arrays.equals(readItem, item)); verifyRawBlob(key, item); }
From source file:org.apache.gobblin.writer.AsyncHttpWriterTest.java
/** * Test successful writes of 4 records/* w w w . j av a2 s . c o m*/ */ @Test public void testSuccessfulWrites() { MockHttpClient client = new MockHttpClient(); MockRequestBuilder requestBuilder = new MockRequestBuilder(); MockResponseHandler responseHandler = new MockResponseHandler(); MockAsyncHttpWriterBuilder builder = new MockAsyncHttpWriterBuilder(client, requestBuilder, responseHandler); TestAsyncHttpWriter asyncHttpWriter = new TestAsyncHttpWriter(builder); List<MockWriteCallback> callbacks = new ArrayList<>(); for (int i = 0; i < 4; i++) { callbacks.add(new MockWriteCallback()); } asyncHttpWriter.write(new Object(), callbacks.get(0)); asyncHttpWriter.write(new Object(), callbacks.get(1)); asyncHttpWriter.write(new Object(), callbacks.get(2)); try { asyncHttpWriter.flush(); } catch (IOException e) { Assert.fail("Flush failed"); } asyncHttpWriter.write(new Object(), callbacks.get(3)); try { asyncHttpWriter.close(); } catch (IOException e) { Assert.fail("Close failed"); } // Assert all successful callbacks are invoked for (MockWriteCallback callback : callbacks) { Assert.assertTrue(callback.isSuccess); } Assert.assertTrue(client.isCloseCalled); }
From source file:com.hybris.instore.widgets.listtracker.ListTrackerControllerTest.java
@Test public void testActiveIndex() { final Object modelList = controller.getValue(ListTrackerController.MODEL_LIST, Object.class); Assert.assertTrue(modelList instanceof List); Assert.assertTrue(((List) modelList).size() == 10); Assert.assertTrue(Integer.valueOf(0) .equals(controller.getValue(ListTrackerController.MODEL_ACTIVE_INDEX, Integer.class))); controller.setActiveIndex(Integer.valueOf(1)); Assert.assertTrue(Integer.valueOf(1) .equals(controller.getValue(ListTrackerController.MODEL_ACTIVE_INDEX, Integer.class))); // make sure out of bounds is covered (illegal value should be ignored) controller.setActiveIndex(Integer.valueOf(10)); Assert.assertTrue(Integer.valueOf(10) .equals(controller.getValue(ListTrackerController.MODEL_ACTIVE_INDEX, Integer.class))); }
From source file:eu.trentorise.smartcampus.ac.provider.repository.persistence.AcDaoPersistenceImplTest.java
@Test public void searchUserByAttr() { Assert.assertTrue(!dao.readUsers(loadAttributes()).isEmpty()); List<Attribute> attrs = new ArrayList<Attribute>(); Authority auth = new Authority(); auth.setName("FAKE_TrentoRise"); auth.setRedirectUrl("http://www.trentorise.eu"); Attribute a = new Attribute(); a.setKey("projectName"); a.setValue("SC"); a.setAuthority(auth);//from ww w. j ava 2 s . co m attrs.add(a); Assert.assertTrue(dao.readUsers(attrs).isEmpty()); }
From source file:es.tid.fiware.rss.expenditureLimit.processing.test.ProcessingLimitUtilTest.java
/** * Check the valid next period to start. *//* www. j av a 2 s . com*/ @Test public void updateNextPeriodToStart() throws RSSException { DbeExpendControl control = new DbeExpendControl(); DbeExpendLimitPK id = new DbeExpendLimitPK(); id.setTxElType(ProcessingLimitService.DAY_PERIOD_TYPE); control.setId(id); Date currentDate = new Date(); control.setDtNextPeriodStart(currentDate); ProcessingLimitUtilTest.logger.debug("Current date: {}", control.getDtNextPeriodStart().toString()); utils.updateNextPeriodToStart(control); ProcessingLimitUtilTest.logger.debug("New date: {}", control.getDtNextPeriodStart().toString()); Assert.assertTrue(currentDate.compareTo(control.getDtNextPeriodStart()) < 0); // Week id.setTxElType(ProcessingLimitService.WEEK_TYPE); control.setId(id); currentDate = new Date(); control.setDtNextPeriodStart(currentDate); ProcessingLimitUtilTest.logger.debug("Current date: {}", control.getDtNextPeriodStart().toString()); utils.updateNextPeriodToStart(control); ProcessingLimitUtilTest.logger.debug("New date: {}", control.getDtNextPeriodStart().toString()); Assert.assertTrue(currentDate.compareTo(control.getDtNextPeriodStart()) < 0); // Month id.setTxElType(ProcessingLimitService.MONTH_PERIOD_TYPE); control.setId(id); currentDate = new Date(); control.setDtNextPeriodStart(currentDate); ProcessingLimitUtilTest.logger.debug("Current date: {}", control.getDtNextPeriodStart().toString()); utils.updateNextPeriodToStart(control); ProcessingLimitUtilTest.logger.debug("New date: {}", control.getDtNextPeriodStart().toString()); Assert.assertTrue(currentDate.compareTo(control.getDtNextPeriodStart()) < 0); }
From source file:com.couchbase.capi.TestCouchbase.java
protected void validateSuccessfulPoolResponse(HttpResponse response) throws IOException, JsonParseException, JsonMappingException { Assert.assertEquals(200, response.getStatusLine().getStatusCode()); HttpEntity entity = response.getEntity(); Map<String, Map<String, Object>> details = null; if (entity != null) { InputStream input = entity.getContent(); try {//w w w. j a v a 2s . c o m details = mapper.readValue(input, Map.class); } finally { input.close(); } } Assert.assertTrue(details.containsKey("buckets")); Assert.assertTrue(details.get("buckets").containsKey("uri")); Assert.assertEquals("/pools/default/buckets?uuid=00000000000000000000000000000000", details.get("buckets").get("uri")); }
From source file:io.cloudslang.engine.queue.services.assigner.ExecutionAssignerServiceTest.java
@Test public void assign() throws Exception { Multimap<String, String> groupWorkersMap = ArrayListMultimap.create(); groupWorkersMap.put("DefaultGroup", "worker1"); groupWorkersMap.put("DefaultGroup", "worker2"); List<ExecutionMessage> assignMessages = new ArrayList<>(); ExecutionMessage msg1 = new ExecutionMessage(1, ExecutionMessage.EMPTY_WORKER, "DefaultGroup", "msg1", ExecStatus.PENDING, null, 0, (new Date(0)).getTime()); ExecutionMessage msg2 = new ExecutionMessage(2, ExecutionMessage.EMPTY_WORKER, "DefaultGroup", "msg2", ExecStatus.PENDING, null, 0, (new Date(0)).getTime()); assignMessages.add(msg1);/*from ww w . j a v a2 s .c o m*/ assignMessages.add(msg2); Mockito.reset(executionQueueService); Mockito.reset(workerNodeService); Mockito.when(workerNodeService .readGroupWorkersMapActiveAndRunningAndVersion(engineVersionService.getEngineVersionId())) .thenReturn(groupWorkersMap); final List<ExecutionMessage> messagesInQ = executionAssignerService.assignWorkers(assignMessages); Assert.assertEquals(2, messagesInQ.size()); for (ExecutionMessage msg : messagesInQ) { Assert.assertEquals(ExecStatus.ASSIGNED.getNumber(), msg.getStatus().getNumber()); Assert.assertEquals(1, msg.getMsgSeqId()); Assert.assertTrue(msg.getWorkerId().equals("worker1") || msg.getWorkerId().equals("worker2")); } }
From source file:org.opencastproject.workspace.impl.WorkspaceImplTest.java
@Test public void testLongFilenames() throws Exception { WorkingFileRepository repo = EasyMock.createNiceMock(WorkingFileRepository.class); EasyMock.expect(repo.getBaseUri()).andReturn(new URI("http://localhost:8080/files")).anyTimes(); EasyMock.replay(repo);/* w w w . ja v a 2s . c o m*/ workspace.setRepository(repo); File source = new File( "target/test-classes/../test-classes/../test-classes/../test-classes/../test-classes/../test-classes/../test-classes/../test-classes/../test-classes/../test-classes/../test-classes/../test-classes/../test-classes/../test-classes/../test-classes/../test-classes/opencast_header.gif"); URL urlToSource = source.toURI().toURL(); TrustedHttpClient httpClient = EasyMock.createNiceMock(TrustedHttpClient.class); HttpEntity entity = EasyMock.createNiceMock(HttpEntity.class); EasyMock.expect(entity.getContent()).andReturn(new FileInputStream(source)); StatusLine statusLine = EasyMock.createNiceMock(StatusLine.class); EasyMock.expect(statusLine.getStatusCode()).andReturn(HttpServletResponse.SC_OK); HttpResponse response = EasyMock.createNiceMock(HttpResponse.class); EasyMock.expect(response.getEntity()).andReturn(entity); EasyMock.expect(response.getStatusLine()).andReturn(statusLine).anyTimes(); EasyMock.replay(response, entity, statusLine); EasyMock.expect(httpClient.execute((HttpUriRequest) EasyMock.anyObject())).andReturn(response); EasyMock.replay(httpClient); workspace.trustedHttpClient = httpClient; Assert.assertTrue(urlToSource.toString().length() > 255); try { Assert.assertNotNull(workspace.get(urlToSource.toURI())); } catch (NotFoundException e) { // This happens on some machines, so we catch and handle it. } }
From source file:es.upm.fiware.rss.expenditureLimit.processing.test.ProcessingLimitUtilTest.java
/** * Check the valid next period to start. */// w w w.j a va 2 s .co m public void updateNextPeriodToStart() throws RSSException { DbeExpendControl control = new DbeExpendControl(); DbeExpendLimitPK id = new DbeExpendLimitPK(); id.setTxElType(ProcessingLimitService.DAY_PERIOD_TYPE); control.setId(id); Date currentDate = new Date(); control.setDtNextPeriodStart(currentDate); ProcessingLimitUtilTest.logger.debug("Current date: {}", control.getDtNextPeriodStart().toString()); utils.updateNextPeriodToStart(control); ProcessingLimitUtilTest.logger.debug("New date: {}", control.getDtNextPeriodStart().toString()); Assert.assertTrue(currentDate.compareTo(control.getDtNextPeriodStart()) < 0); // Week id.setTxElType(ProcessingLimitService.WEEK_TYPE); control.setId(id); currentDate = new Date(); control.setDtNextPeriodStart(currentDate); ProcessingLimitUtilTest.logger.debug("Current date: {}", control.getDtNextPeriodStart().toString()); utils.updateNextPeriodToStart(control); ProcessingLimitUtilTest.logger.debug("New date: {}", control.getDtNextPeriodStart().toString()); Assert.assertTrue(currentDate.compareTo(control.getDtNextPeriodStart()) < 0); // Month id.setTxElType(ProcessingLimitService.MONTH_PERIOD_TYPE); control.setId(id); currentDate = new Date(); control.setDtNextPeriodStart(currentDate); ProcessingLimitUtilTest.logger.debug("Current date: {}", control.getDtNextPeriodStart().toString()); utils.updateNextPeriodToStart(control); ProcessingLimitUtilTest.logger.debug("New date: {}", control.getDtNextPeriodStart().toString()); Assert.assertTrue(currentDate.compareTo(control.getDtNextPeriodStart()) < 0); }