List of usage examples for junit.framework Assert assertNotNull
static public void assertNotNull(Object object)
From source file:ejportal.webapp.action.UserActionTest.java
/** * Test search.//from w w w. ja va2 s . com * * @throws Exception * the exception */ public void testSearch() throws Exception { Assert.assertNull(this.action.getUsers()); Assert.assertEquals("success", this.action.list()); Assert.assertNotNull(this.action.getUsers()); Assert.assertFalse(this.action.hasActionErrors()); }
From source file:com.hybris.backoffice.cockpitng.dataaccess.facades.DefaultPlatformPermissionFacadeStrategyTest.java
@Test public void testGetWritableLocalesForInstance() { final Set<Locale> expectedLocales = permissionFacade.getWritableLocalesForInstance(product); Assert.assertNotNull(expectedLocales); Assert.assertTrue(expectedLocales.contains(englishLocale)); }
From source file:io.cloudslang.lang.compiler.CompileDecisionTest.java
@Test public void testDecision1PreCompile() throws Exception { URL decision = getClass().getResource("/decision/decision_1.sl"); Executable executable = compiler.preCompile(fromFile(decision.toURI())); Assert.assertNotNull(executable); Assert.assertTrue(executable instanceof Decision); Decision expectedDecision = new Decision(emptyActionData, emptyActionData, "user.decisions", "decision_1", inputs1, outputs1, results1, Collections.<String>emptySet(), emptySetSystemProperties); Assert.assertEquals(expectedDecision, executable); }
From source file:com.auditbucket.engine.service.WhatServiceTest.java
private void testKVStore() throws Exception { SecurityContextHolder.getContext().setAuthentication(authA); regService.registerSystemUser(new RegistrationBean("Company", email, "bah")); Fortress fortressA = fortressService.registerFortress(new FortressInputBean("Audit Test", true)); String docType = "TestAuditX"; String callerRef = "ABC123R"; MetaInputBean inputBean = new MetaInputBean(fortressA.getName(), "wally", docType, new DateTime(), callerRef);//from ww w .j av a 2 s . c o m String ahKey = auditManager.createHeader(inputBean, null).getMetaKey(); assertNotNull(ahKey); MetaHeader header = trackService.getHeader(ahKey); Map<String, Object> what = getWhatMap(); String whatString = getJsonFromObject(what); try { auditManager.processLog(new LogInputBean(ahKey, "wally", new DateTime(), whatString)); } catch (DataAccessException e) { logger.error( "KV Stores are configured in config.properties. This test is failing to find the {} server.", engineConfig.getKvStore()); return; } TrackLog trackLog = trackDAO.getLastLog(header.getId()); assertNotNull(trackLog); //When LogWhat logWhat = whatService.getWhat(header, trackLog.getChange()); Assert.assertNotNull(logWhat); validateWhat(what, logWhat); Assert.assertTrue(whatService.isSame(header, trackLog.getChange(), whatString)); // Testing that cancel works trackService.cancelLastLogSync(ahKey); Assert.assertNull(trackService.getLastLog(header)); Assert.assertNull(whatService.getWhat(header, trackLog.getChange()).getWhat()); }
From source file:com.vmware.identity.sts.auth.impl.BETAuthenticatorTest.java
@Test public void testAuthNotCompleted() { final RequestSecurityTokenType rst = newValidRst(); final byte[] initRawLeg = Base64.decodeBase64(rst.getBinaryExchange().getValue()); com.vmware.identity.sts.idm.Authenticator idmAuth = EasyMock .createMock(com.vmware.identity.sts.idm.Authenticator.class); final byte[] serverLeg = new byte[] { -3, 9 }; final GSSResult gssResult = new GSSResult(rst.getContext(), serverLeg); EasyMock.expect(idmAuth.authenticate(EasyMock.eq(rst.getContext()), EasyMock.aryEq(initRawLeg))) .andReturn(gssResult);/*from www. jav a2 s . c o m*/ EasyMock.replay(idmAuth); final Authenticator authenticator = new BETAuthenticator(idmAuth); final Result result = authenticator.authenticate(newReq(rst)); Assert.assertNotNull(result); Assert.assertFalse(result.completed()); Assert.assertTrue(Arrays.equals(serverLeg, result.getServerLeg())); EasyMock.verify(idmAuth); }
From source file:com.google.gct.idea.appengine.synchronization.SampleSyncTaskTest.java
@Ignore @Test//from ww w .j av a 2s. c om public void testSync_singleCommit() throws GitAPIException, IOException, URISyntaxException { // Sync files from mock Git Hub repo to mock local Android sample template repo SampleSyncTask sampleSyncTask = new SampleSyncTask(mockAndroidRepoPath, mockGitHubRepoPath); sampleSyncTask.run(); // Add a file to mock github repo RevCommit commit = addFileToMockGitHubRepo("a.txt", "Adding a.txt"); // Sync files from mock Git Hub repo to mock local Android sample template repo sampleSyncTask.run(); // Check that the last commit in the mock Android repo is the commit made to add a new file Git mockAndroidRepo = Git.open(new File(mockAndroidRepoPath)); Iterable<RevCommit> logs = mockAndroidRepo.log().call(); Assert.assertNotNull(logs); // Check that commits exist boolean hasCommits = false; for (RevCommit aLog : logs) { hasCommits = true; Assert.assertEquals(commit.getCommitTime(), aLog.getCommitTime()); Assert.assertEquals(commit.getFullMessage(), aLog.getFullMessage()); break; } Assert.assertTrue(hasCommits); }
From source file:net.padaf.xmpbox.parser.XMLValueTypeDescriptionManagerTest.java
@Test public void testPropDescWithField() throws Exception { String type = "type1"; String uri = "nsURI1"; String prefix = "pref1"; String descProp = "descProp1"; List<String> fieldNames = new ArrayList<String>(); fieldNames.add("fieldName1"); fieldNames.add("fieldName2"); List<String> fieldValueTypes = new ArrayList<String>(); fieldValueTypes.add("fieldVT1"); fieldValueTypes.add("fieldVT2"); List<String> fieldDescription = new ArrayList<String>(); fieldDescription.add("FieldDesc1"); fieldDescription.add("FieldDesc2"); List<FieldDescription> fieldList = new ArrayList<FieldDescription>(); fieldList.add(new FieldDescription(fieldNames.get(0), fieldValueTypes.get(0), fieldDescription.get(0))); fieldList.add(new FieldDescription(fieldNames.get(1), fieldValueTypes.get(1), fieldDescription.get(1))); XMLValueTypeDescriptionManager xmlParser = new XMLValueTypeDescriptionManager(); xmlParser.addValueTypeDescription(type, uri, prefix, descProp, fieldList); ByteArrayOutputStream bos = new ByteArrayOutputStream(); xmlParser.toXML(bos);/*from ww w . j a v a2s . c o m*/ IOUtils.closeQuietly(bos); XMLValueTypeDescriptionManager propRetrieve = new XMLValueTypeDescriptionManager(); InputStream is = new ByteArrayInputStream(bos.toByteArray()); propRetrieve.loadListFromXML(is); List<ValueTypeDescription> vtList = propRetrieve.getValueTypesDescriptionList(); Assert.assertEquals(1, vtList.size()); ValueTypeDescription vt = vtList.get(0); Assert.assertEquals(type, vt.getType()); Assert.assertEquals(uri, vt.getNamespaceURI()); Assert.assertEquals(prefix, vt.getPrefix()); Assert.assertEquals(descProp, vt.getDescription()); List<FieldDescription> fieldsFound = vt.getFields(); Assert.assertNotNull(fieldsFound); for (int i = 0; i < fieldsFound.size(); i++) { Assert.assertTrue(fieldNames.contains(fieldsFound.get(i).getName())); Assert.assertTrue(fieldValueTypes.contains(fieldsFound.get(i).getValueType())); Assert.assertTrue(fieldDescription.contains(fieldsFound.get(i).getDescription())); } }
From source file:com.impetus.kundera.rest.resources.MongoQueryTest.java
@Test public void testCompositeUserCRUD() throws JsonParseException, JsonMappingException, IOException { WebResource webResource = resource(); restClient = new RESTClientImpl(); restClient.initialize(webResource, mediaType); // Get Application Token applicationToken = restClient.getApplicationToken(_PU, null); Assert.assertNotNull(applicationToken); applicationToken = applicationToken.replaceAll("^\"|\"$", ""); Assert.assertTrue(applicationToken.startsWith("AT_")); // Get Session Token sessionToken = restClient.getSessionToken(applicationToken); Assert.assertNotNull(sessionToken);// w ww . jav a 2 s . c o m sessionToken = sessionToken.replaceAll("^\"|\"$", ""); Assert.assertTrue(sessionToken.startsWith("ST_")); UUID timeLineId = UUID.randomUUID(); Date currentDate = new Date(); MongoCompoundKey key = new MongoCompoundKey("mevivs", 1, timeLineId); MongoPrimeUser timeLine = new MongoPrimeUser(key); timeLine.setKey(key); timeLine.setTweetBody("my first tweet"); timeLine.setTweetDate(currentDate); MongoCompoundKey key1 = new MongoCompoundKey("john", 2, timeLineId); MongoPrimeUser timeLine2 = new MongoPrimeUser(key1); timeLine2.setKey(key1); timeLine2.setTweetBody("my second tweet"); timeLine2.setTweetDate(currentDate); String mongoUser = JAXBUtils.toString(timeLine, MediaType.APPLICATION_JSON); Assert.assertNotNull(mongoUser); String mongoUser1 = JAXBUtils.toString(timeLine2, MediaType.APPLICATION_JSON); Assert.assertNotNull(mongoUser1); // Insert Record String insertResponse1 = restClient.insertEntity(sessionToken, mongoUser, "MongoPrimeUser"); String insertResponse2 = restClient.insertEntity(sessionToken, mongoUser1, "MongoPrimeUser"); Assert.assertNotNull(insertResponse1); Assert.assertNotNull(insertResponse2); Assert.assertTrue(insertResponse1.indexOf("200") > 0); Assert.assertTrue(insertResponse2.indexOf("200") > 0); String encodepk1 = null; pk1 = JAXBUtils.toString(key, MediaType.APPLICATION_JSON); pk2 = JAXBUtils.toString(key1, MediaType.APPLICATION_JSON); try { encodepk1 = java.net.URLEncoder.encode(pk1, "UTF-8"); } catch (UnsupportedEncodingException e) { log.error(e.getMessage()); } // Find Record String foundUser = restClient.findEntity(sessionToken, encodepk1, "MongoPrimeUser"); Assert.assertNotNull(foundUser); Assert.assertNotNull(foundUser); Assert.assertTrue(foundUser.indexOf("mevivs") > 0); foundUser = foundUser.substring(1, foundUser.length() - 1); Map<String, Object> userDetails = new HashMap<String, Object>(); ObjectMapper mapper = new ObjectMapper(); userDetails = mapper.readValue(foundUser, userDetails.getClass()); foundUser = mapper.writeValueAsString(userDetails.get("mongoprimeuser")); // Update Record foundUser = foundUser.replaceAll("first", "hundreth"); String updatedUser = restClient.updateEntity(sessionToken, foundUser, MongoPrimeUser.class.getSimpleName()); Assert.assertNotNull(updatedUser); Assert.assertTrue(updatedUser.indexOf("hundreth") > 0); /** JPA Query - Select */ // Get All users String jpaQuery = "select p from " + MongoPrimeUser.class.getSimpleName() + " p"; String queryResult = restClient.runJPAQuery(sessionToken, jpaQuery, new HashMap<String, Object>()); log.debug("Query Result:" + queryResult); Assert.assertNotNull(queryResult); Assert.assertFalse(StringUtils.isEmpty(queryResult)); Assert.assertTrue(queryResult.indexOf("mongoprimeuser") > 0); Assert.assertTrue(queryResult.indexOf(pk1) > 0); Assert.assertTrue(queryResult.indexOf(pk2) > 0); Assert.assertTrue(queryResult.indexOf("Motif") < 0); jpaQuery = "select p from " + MongoPrimeUser.class.getSimpleName() + " p WHERE p.key = :key"; Map<String, Object> params = new HashMap<String, Object>(); params.put("key", pk1); queryResult = restClient.runObjectJPAQuery(sessionToken, jpaQuery, params); log.debug("Query Result:" + queryResult); Assert.assertNotNull(queryResult); Assert.assertFalse(StringUtils.isEmpty(queryResult)); Assert.assertTrue(queryResult.indexOf("mongoprimeuser") > 0); Assert.assertTrue(queryResult.indexOf(timeLineId.toString()) > 0); Assert.assertTrue(queryResult.indexOf(pk2) < 0); Assert.assertTrue(queryResult.indexOf("Motif") < 0); jpaQuery = "select p from " + MongoPrimeUser.class.getSimpleName() + " p"; params = new HashMap<String, Object>(); params.put("firstResult", 0); params.put("maxResult", 1); queryResult = restClient.runObjectJPAQuery(sessionToken, jpaQuery, params); log.debug("Query Result:" + queryResult); String userList = queryResult.substring(1, queryResult.length() - 1); mapper = new ObjectMapper(); userDetails = new HashMap<String, Object>(); userDetails = mapper.readValue(userList, userDetails.getClass()); userList = mapper.writeValueAsString(userDetails.get("mongoprimeuser")); List<MongoPrimeUser> navigation = mapper.readValue(userList, mapper.getTypeFactory().constructCollectionType(List.class, MongoPrimeUser.class)); Assert.assertNotNull(queryResult); Assert.assertFalse(StringUtils.isEmpty(queryResult)); Assert.assertTrue(queryResult.indexOf("mongoprimeuser") > 0); Assert.assertTrue(queryResult.indexOf(timeLineId.toString()) > 0); Assert.assertEquals(1, navigation.size()); /** JPA Query - Select All */ // Get All Users String allUsers = restClient.getAllEntities(sessionToken, MongoPrimeUser.class.getSimpleName()); log.debug(allUsers); Assert.assertNotNull(allUsers); // Close Session restClient.closeSession(sessionToken); // Close Application restClient.closeApplication(applicationToken); }
From source file:io.cloudslang.engine.node.services.WorkerNodeServiceTest.java
@Test public void readByUUID() throws Exception { WorkerNode worker = workerNodeService.readByUUID("H1"); Assert.assertNotNull(worker); }