List of usage examples for junit.framework Assert assertFalse
static public void assertFalse(boolean condition)
From source file:ar.com.zauber.commons.moderation.HibernateRepositoryModerationTest.java
/** Salvar una entidad y su estado de moderacin */ @Test/* www .ja v a 2 s.co m*/ public final void testModerationEntitySave() { final Moderateable entity = new MockRepositoryModerateableEntity(open, moderationEntryRepository); repository.saveOrUpdate(entity); final Reference<?> ref = entity.generateReference(); repository.getHibernateTemplate().flush(); repository.getHibernateTemplate().clear(); final Moderateable entityFromDb = (Moderateable) repository.retrieve(ref); Assert.assertEquals(open, entityFromDb.getModerationState()); Assert.assertNotNull(entityFromDb.getModerationHistory()); Assert.assertEquals(0, entityFromDb.getModerationHistory().size()); Assert.assertEquals(EnumModerationState.OPEN.getName(), entityFromDb.getModerationState().getName()); Assert.assertEquals(1, entityFromDb.getModerationState().getValidDestinations().size()); Assert.assertFalse(entityFromDb.getModerationState().canChangeTo(closed)); }
From source file:es.tekniker.framework.ktek.questionnaire.mng.server.test.TestQuestionnaireMngServer.java
@org.junit.Test public void testGetQuestionnaireModelByToken() { log.info("*************************************************************"); log.info("testGetQuestionnaireModelByToken: START "); String result = TestDefines.RESULT_OK; QuestionnaireMngServer manager = new QuestionnaireMngServer(); String token = null;//from w w w .j a va2 s.c o m int idlang = 1; int idquestionnaire = 1; KtekQuestionnaireModelEntity instance = null; String codtelecareprogram = "TBP1"; try { token = TestData.getLoginToken(); instance = manager.getQuestionnaireModelByToken(token, idlang, codtelecareprogram, idquestionnaire); if (instance != null) { log.info("testGetQuestionnaireModelByToken: instanc is NOT NULL "); Assert.assertTrue(true); } else { log.error("testGetQuestionnaireModelByToken: instance is NULL "); result = TestDefines.RESULT_ERROR; Assert.assertTrue(false); } } catch (KtekExceptionEntity e) { System.out.println("testGetQuestionnaireModelByToken: exception " + e.getMessage()); e.printStackTrace(); Assert.assertFalse(false); } log.info("testGetQuestionnaireModelByToken: RESULT " + result); log.info("testGetQuestionnaireModelByToken: END "); log.info("*************************************************************"); log.info(""); }
From source file:org.openmrs.module.paperrecord.PaperRecordServiceComponentTest.java
@Test public void testPaperMedicalRecordExistsReturnsFalseIfIdentifierIsInUseButWrongIdentifierType() { // from the standard test dataset Location medicalRecordLocation = locationService.getLocation(1); // this identifier exists in the standard test data set Assert.assertFalse(paperRecordService.paperRecordExistsWithIdentifier("6TS-4", medicalRecordLocation)); }
From source file:com.github.ipaas.ideploy.agent.handler.RollbackCodeHandlerTest.java
/** * , USING_VERSION,? ROLLBACKTO_VERSION * //from ww w. jav a 2 s . c om * @throws Exception */ @Test public void rollbackCodeTest() throws Exception { String deployRoot = "/www/app" + APP_NAME; File usingfile = new File(deployRoot); RollbackCodeHandler rollback = new RollbackCodeHandler(); String localBkPath = "/www/appbk" + APP_NAME + "/firstVer0"; Map<String, Object> cantRollBackParams = new HashMap<String, Object>(); cantRollBackParams.put("localBkPath", localBkPath); cantRollBackParams.put("deployPath", deployRoot); try { rollback.execute(null, null, cantRollBackParams, null); // : // ,?,?! fail("Created fraction 1/0! That's undefined!"); } catch (Exception e) { assertEquals("?,?!", e.getMessage()); } File localBkFile = new File(localBkPath); if (!localBkFile.exists()) { localBkFile.mkdirs(); } rollback.execute(null, null, cantRollBackParams, null); Integer hostStatus4New = 1; String savePath = "/www/apptemp/" + USING_VERSION; Map<String, Object> firstRollbackParams = new HashMap<String, Object>(); firstRollbackParams.put("usingCodeVerPath", TEST_GROUP + TAGS + "/" + USING_VERSION); firstRollbackParams.put("hostStatus", hostStatus4New); firstRollbackParams.put("savePath", savePath); firstRollbackParams.put("deployPath", deployRoot); rollback.execute(null, null, firstRollbackParams, null); // ,,? DownloadCodeHandler downLoadHandler = new DownloadCodeHandler(); Integer notUpdateAll = 2; Integer hostStatus4Old = 2; Map<String, Object> secondDownLoadParams = new HashMap<String, Object>(); secondDownLoadParams.put("doingCodeVerPath", TEST_GROUP + TAGS + "/" + ROLLBACKTO_VERSION); secondDownLoadParams.put("usingCodeVerPath", TEST_GROUP + TAGS + "/" + USING_VERSION); secondDownLoadParams.put("hostStatus", hostStatus4Old); secondDownLoadParams.put("savePath", "/www/apptemp/rollback_test_vaild");// ?? secondDownLoadParams.put("updateAll", notUpdateAll); downLoadHandler.execute(null, null, secondDownLoadParams, null); File updateFile = new File("/www/apptemp/rollback_test_vaild/update.txt"); List<String> updateList = FileUtils.readLines(updateFile);// ??,? String savePath2 = "/www/apptemp/" + ROLLBACKTO_VERSION; Map<String, Object> secondRollbackParams = new HashMap<String, Object>(); secondRollbackParams.put("usingCodeVerPath", TEST_GROUP + TAGS + "/" + ROLLBACKTO_VERSION); secondRollbackParams.put("doingCodeVerPath", TEST_GROUP + TAGS + "/" + USING_VERSION); secondRollbackParams.put("hostStatus", hostStatus4Old); secondRollbackParams.put("savePath", savePath2); secondRollbackParams.put("deployPath", deployRoot); rollback.execute(null, null, secondRollbackParams, null); // , // ? for (String str : updateList) { if (str.startsWith("+")) { // Assert.assertTrue(new File(deployRoot + StringUtils.removeStart(str, "+").trim()).exists()); } else if (str.startsWith("-")) { // String f = deployRoot + StringUtils.removeStart(str, "-").trim(); Assert.assertFalse(new File(f).exists()); } } FileUtils.cleanDirectory(usingfile); FileUtils.forceDelete(localBkFile); FileUtils.cleanDirectory(new File("/www/apptemp")); }
From source file:org.ualerts.fixed.web.controller.fixture.ManualEnrollmentControllerTest.java
/** * Validate the controller method for handling POST data when there are * initial BindingResult errors.//w ww .j av a 2s .co m * @throws Exception */ @Test public void validateErrorHandling() throws Exception { final HttpServletRequest request = context.mock(HttpServletRequest.class); final HttpServletResponse resp = context.mock(HttpServletResponse.class); final FixtureModel fixture = new FixtureModel(); final BindingResult result = context.mock(BindingResult.class); context.checking(new Expectations() { { oneOf(result).hasErrors(); will(returnValue(true)); oneOf(result).hasErrors(); will(returnValue(true)); exactly(2).of(result).hasFieldErrors(); will(returnValue(true)); oneOf(result).getFieldErrors(); will(returnValue(new ArrayList<FieldError>())); exactly(2).of(result).hasGlobalErrors(); will(returnValue(true)); oneOf(result).getGlobalErrors(); will(returnValue(new ArrayList<ObjectError>())); } }); Map<String, Object> response = controller.handleFormSubmission(request, resp, fixture, result); context.assertIsSatisfied(); Assert.assertNotNull(response); Assert.assertFalse((Boolean) response.get("success")); Assert.assertNotNull(response.get("errors")); }
From source file:org.opencastproject.workspace.impl.WorkspaceImplTest.java
@Test public void testPutCachingWithFilesystemMapping() throws Exception { WorkingFileRepository repo = EasyMock.createNiceMock(WorkingFileRepository.class); EasyMock.expect(repo.getURI((String) EasyMock.anyObject(), (String) EasyMock.anyObject(), (String) EasyMock.anyObject())) .andReturn(new URI("http://localhost:8080/files" + WorkingFileRepository.MEDIAPACKAGE_PATH_PREFIX + "foo/bar/header.gif")); EasyMock.expect(repo.put((String) EasyMock.anyObject(), (String) EasyMock.anyObject(), (String) EasyMock.anyObject(), (InputStream) EasyMock.anyObject())) .andReturn(new URI("http://localhost:8080/files" + WorkingFileRepository.MEDIAPACKAGE_PATH_PREFIX + "foo/bar/header.gif")); EasyMock.expect(repo.getBaseUri()).andReturn(new URI("http://localhost:8080/files")).anyTimes(); EasyMock.replay(repo);//from ww w. ja va 2 s. c o m workspace.setRepository(repo); // Put a stream into the workspace (and hence, the repository) InputStream in = null; try { in = getClass().getResourceAsStream("/opencast_header.gif"); Assert.assertNotNull(in); workspace.put("foo", "bar", "header.gif", in); } finally { IOUtils.closeQuietly(in); } // Ensure that the file was put into the working file repository EasyMock.verify(repo); // Ensure that the file was not cached in the workspace (since there is a configured filesystem mapping) File file = new File(workspaceRoot, "http___localhost_8080_files_foo_bar_header.gif"); Assert.assertFalse(file.exists()); }
From source file:functionalTests.vfsprovider.TestProActiveProvider.java
private void setUpTestDir() throws URISyntaxException, IOException { // create dir if (testDir.exists()) { removeTestDir();/*from w w w .j a va 2 s . c o m*/ } Assert.assertFalse(testDir.exists()); Assert.assertTrue(testDir.mkdirs()); // extract files from archive with VFS provider test data final ZipInputStream zipInputStream = new ZipInputStream( new BufferedInputStream(TEST_DATA_SRC_ZIP_URL.openStream())); try { extractZip(zipInputStream, testDir); } finally { zipInputStream.close(); } // set VFS tests property System.setProperty("test.basedir", testDir.getAbsolutePath()); }
From source file:de.hybris.platform.util.database.TableNameDatabaseMetaDataCallbackTest.java
@Test public void testOmmitAdminTables() throws MetaDataAccessException { ///*from w ww.j av a2s . c o m*/ final TableNameDatabaseMetaDataCallback tablesFilterCallback = new TableNameDatabaseMetaDataCallback( defaultQueryProvider, Registry.getCurrentTenantNoFallback()) { @Override Collection<SlaveTenant> getSlaveTenants() { return allSlaves; } }; final List<String> tables = (List<String>) JdbcUtils.extractDatabaseMetaData(dataSource, tablesFilterCallback); Assert.assertFalse(tables.contains("JGROUPSPING")); Assert.assertFalse(tables.contains(QueryProviderFactory.LOCK_TABLE)); }
From source file:com.smartitengineering.util.rest.client.jersey.cache.HttpCache4jResolverBasedCacheableClientTest.java
@Test public void testHead() { WebResource r = getClient().resource(getUri().path(Resources.METHOD_PATH).build()); ClientResponse cr = r.head(); Assert.assertFalse(cr.hasEntity()); }
From source file:at.tfr.securefs.process.ProcessFilesTest.java
@Test public void testCopyFilesByWalkFileHierarchy() throws Exception { // Given: NO target directory yet!!, the source file generateFileHierarchy(fromRoot, 0, MAX_DIR_DEPTH, cp, secret); Assert.assertFalse(Files.exists(toRoot.resolve(DATA_FILES))); Assert.assertFalse(Files.exists(targetToFile)); ProcessFiles pf = new ProcessFilesBean(new MockSecureFsCache()); ProcessFilesData cfd = new ProcessFilesData(); // Then we can generate a full hierarchy copy generateHierachyCopy(pf, cfd);//from ww w . java2 s .c o m }