List of usage examples for junit.framework Assert assertNotNull
static public void assertNotNull(Object object)
From source file:at.tugraz.ist.akm.test.webservice.handler.FileRequestHandlerTest.java
public void testHandle() { HttpRequest httpRequest = new BasicHttpEntityEnclosingRequest("none", URI); HttpResponse httpResponse = new BasicHttpResponse( new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 200, "")); try {/*from w w w.j a va 2s. com*/ testInstance.handle(httpRequest, httpResponse, null); Assert.assertEquals(200, httpResponse.getStatusLine().getStatusCode()); Assert.assertNotNull(httpResponse.getEntity()); ByteArrayOutputStream baos = new ByteArrayOutputStream(); httpResponse.getEntity().writeTo(baos); FileReader reader = new FileReader(getInstrumentation().getContext(), DATA_FILE); Assert.assertEquals(reader.read(), new String(baos.toByteArray(), DEFAULT_ENCODING)); reader.close(); reader = null; } catch (HttpException httpException) { Assert.fail("Exception => " + httpException.getMessage()); httpException.printStackTrace(); } catch (IOException ioException) { Assert.fail("Exception => " + ioException.getMessage()); ioException.printStackTrace(); } }
From source file:com.tango.logstash.flume.redis.sink.serializer.TestLogstashSerializer.java
/** * Verifies that standard headers and body are parsed correctly * @throws RedisSerializerException//from www . j av a 2 s . com */ @Test public void parsingDefaultEventTest() throws RedisSerializerException { LogstashSerializer serializer = new LogstashSerializer(); byte[] body = new byte[] { '1', '2', '3', '4', '5' }; String testHost = "testhost"; String sourcePath = "/my/source/path"; String type = "mytype"; String source = "my source"; List<String> tags = new ArrayList<String>(); tags.add("one tag"); tags.add("another tag"); long now = System.currentTimeMillis(); Map<String, String> headers = new HashMap<String, String>(); headers.put(LogstashSerializer.TIMESTAMP, Long.toString(now)); headers.put(LogstashSerializer.HOST, testHost); headers.put(LogstashSerializer.SRC_PATH, sourcePath); headers.put(LogstashSerializer.TYPE, type); headers.put(LogstashSerializer.SOURCE, source); headers.put(LogstashSerializer.TAGS, StringUtils.join(tags, LogstashSerializer.DEFAULT_TAGS_SEPARATOR)); Event event = new SimpleEvent(); event.setBody(body); event.setHeaders(headers); LogstashEvent logstashEvent = serializer.convertToLogstashEvent(event); Assert.assertNotNull(logstashEvent.getMessage()); Assert.assertEquals(new String(body), logstashEvent.getMessage()); Assert.assertNotNull(logstashEvent.getTimestamp()); Assert.assertEquals(new Date(now), logstashEvent.getTimestamp()); Assert.assertNotNull(logstashEvent.getSourceHost()); Assert.assertEquals(testHost, logstashEvent.getSourceHost()); Assert.assertNotNull(logstashEvent.getSourcePath()); Assert.assertEquals(sourcePath, logstashEvent.getSourcePath()); Assert.assertNotNull(logstashEvent.getSource()); Assert.assertEquals(source, logstashEvent.getSource()); Assert.assertNotNull(logstashEvent.getType()); Assert.assertEquals(type, logstashEvent.getType()); Assert.assertNotNull(logstashEvent.getTags()); Assert.assertEquals(tags.size(), logstashEvent.getTags().size()); Assert.assertTrue(CollectionUtils.isEqualCollection(tags, logstashEvent.getTags())); Assert.assertNotNull(logstashEvent.getFields()); Assert.assertEquals(headers.size(), logstashEvent.getFields().size()); for (String key : headers.keySet()) { Assert.assertTrue(logstashEvent.getFields().containsKey(key)); Assert.assertEquals(headers.get(key), logstashEvent.getFields().get(key)); } }
From source file:SdkUnitTests.java
@Test public void LoginTest() { ApiClient apiClient = new ApiClient(); apiClient.setBasePath(BaseUrl);//from w w w.ja v a 2 s. com String creds = createAuthHeaderCreds(UserName, Password, IntegratorKey); apiClient.addDefaultHeader("X-DocuSign-Authentication", creds); Configuration.setDefaultApiClient(apiClient); try { AuthenticationApi authApi = new AuthenticationApi(); AuthenticationApi.LoginOptions loginOps = authApi.new LoginOptions(); loginOps.setApiPassword("true"); loginOps.setIncludeAccountIdGuid("true"); LoginInformation loginInfo = authApi.login(loginOps); Assert.assertNotSame(null, loginInfo); Assert.assertNotNull(loginInfo.getLoginAccounts()); Assert.assertTrue(loginInfo.getLoginAccounts().size() > 0); List<LoginAccount> loginAccounts = loginInfo.getLoginAccounts(); Assert.assertNotNull(loginAccounts.get(0).getAccountId()); System.out.println("LoginInformation: " + loginInfo); } catch (ApiException ex) { System.out.println("Exception: " + ex); } }
From source file:org.sakaiproject.crudplus.dao.test.CrudPlusDaoImplTest.java
/** * TODO - Remove this sample unit test/* w w w.j a v a 2 s.c o m*/ * Test method for {@link org.sakaiproject.crudplus.dao.impl.GenericHibernateDao#save(java.lang.Object)}. */ public void testSave() { CrudPlusItem item1 = new CrudPlusItem("New item1", ITEM_OWNER, ITEM_SITE, ITEM_HIDDEN, new Date()); dao.save(item1); Long itemId = item1.getId(); Assert.assertNotNull(itemId); Assert.assertEquals(dao.countAll(CrudPlusItem.class), 3); }
From source file:org.openxdata.server.service.impl.StudyManagerServiceTest.java
@Test public void deleteStudy_shouldDeleteGivenStudy() throws Exception { final String studyName = "Study Name"; List<StudyDef> studies = studyManagerService.getStudies(); Assert.assertEquals("There are 4 studies", 4, studies.size()); Assert.assertNull(getStudy(studyName, studies)); StudyDef study = new StudyDef(); study.setName(studyName);/*from w w w .j a va 2 s.c om*/ study.setCreator(userService.getUsers().get(0)); study.setDateCreated(new Date()); studyManagerService.saveStudy(study); studies = studyManagerService.getStudies(); Assert.assertEquals("Added 1 study, now there are 5", 5, studies.size()); study = getStudy(studyName, studies); Assert.assertNotNull(study); studyManagerService.deleteStudy(study); studies = studyManagerService.getStudies(); Assert.assertEquals("Deleted the study so there are 4 studies again", 4, studies.size()); Assert.assertNull(getStudy(studyName, studies)); }
From source file:com.liferay.mobile.push.DeviceRegistrationTest.java
@Test public void unregister() throws Exception { final String registrationId = "123"; register(registrationId);//from w w w .j av a2s .co m push.onSuccess(new Push.OnSuccess() { @Override public void onSuccess(JSONObject device) { try { Assert.assertNotNull(device); Assert.assertEquals(registrationId, device.getString("token")); } catch (JSONException je) { Assert.fail(); } } }).unregister(registrationId); Robolectric.runBackgroundTasks(); }
From source file:org.openmrs.module.webservices.rest19ext.web.v1_0.controller.VisitAttributeControllerTest.java
@Test public void shouldListAllAttributesForAVisit() throws Exception { request.addParameter(RestConstants.REQUEST_PROPERTY_FOR_INCLUDE_ALL, "true"); SimpleObject result = controller.getAll(Rest19ExtTestConstants.VISIT_UUID, request, response); Assert.assertNotNull(result); Assert.assertEquals(2, Util.getResultsSize(result)); }
From source file:amqp.spring.camel.component.SpringAMQPConsumerTest.java
@Test public void sendMessage() throws Exception { MockEndpoint mockEndpoint = getMockEndpoint("mock:test.a"); mockEndpoint.expectedMessageCount(1); context().createProducerTemplate().sendBodyAndHeader( "spring-amqp:directExchange:test.a?durable=false&autodelete=true&exclusive=false", "sendMessage", "HeaderKey", "HeaderValue"); mockEndpoint.assertIsSatisfied();/*from ww w. jav a 2 s .c o m*/ Message inMessage = mockEndpoint.getExchanges().get(0).getIn(); Assert.assertEquals("sendMessage", inMessage.getBody(String.class)); Assert.assertEquals("HeaderValue", inMessage.getHeader("HeaderKey")); Assert.assertNotNull(inMessage.getMessageId()); }
From source file:ejportal.webapp.action.UserActionTest.java
/** * Test save.// www .ja v a 2s . c o m * * @throws Exception * the exception */ public void testSave() throws Exception { final UserManager userManager = (UserManager) this.applicationContext.getBean("userManager"); final User user = userManager.getUserByUsername("user"); user.setPassword("user"); user.setConfirmPassword("user"); this.action.setUser(user); this.action.setFrom("list"); final MockHttpServletRequest request = new MockHttpServletRequest(); request.addParameter("encryptPass", "true"); ServletActionContext.setRequest(request); Assert.assertEquals("input", this.action.save()); Assert.assertNotNull(this.action.getUser()); Assert.assertFalse(this.action.hasActionErrors()); }
From source file:org.atemsource.atem.impl.meta.MetaAttributeServiceImplTest.java
@Test public void testSetMetaData() { // setup meta attribute EntityType<Attribute> holderType = entityTypeRepository.getEntityType(Attribute.class); EntityType<MetaDataExample> metaDataType = entityTypeRepository.getEntityType(MetaDataExample.class); SingleAttribute<MetaDataExample> testMetaAttribute = dynamicMetaAttributeService .addSingleMetaAttribute("test", holderType, metaDataType); // work with meta attribute EntityType<EntityB> entityType = entityTypeRepository.getEntityType(EntityB.class); Attribute attribute = entityType.getAttribute("singleA"); MetaDataExample ex = new MetaDataExample(); ex.setData("hallo"); Attribute metaAttribute = holderType.getMetaAttribute("test"); metaAttribute.setValue(attribute, ex); Assert.assertNotNull(metaAttribute); Assert.assertEquals(holderType, holderType); Object value = metaAttribute.getValue(attribute); Assert.assertEquals(ex, value);/*from w w w . j av a2s .c om*/ }