List of usage examples for junit.framework Assert assertFalse
static public void assertFalse(boolean condition)
From source file:com.scaleunlimited.cascading.FlowMonitorTest.java
@SuppressWarnings({ "unchecked", "rawtypes" }) @Test/* ww w . j a va 2s . c o m*/ public void testHtmlGeneration() throws Throwable { final Fields groupField = new Fields("user"); final Fields testFields = new Fields("user", "value"); final int perRequestDelay = 0; final int numDatums = 100; final String testDir = "build/test/FlowMonitorTest/testHtmlGeneration/"; String in = testDir + "in"; String out = testDir + "out"; Lfs sourceTap = new Lfs(new SequenceFile(testFields), in, SinkMode.REPLACE); TupleEntryCollector write = sourceTap.openForWrite(new HadoopFlowProcess()); for (int i = 0; i < numDatums; i++) { String username = "user-" + (i % 3); write.add(new Tuple(username, i)); } write.close(); Pipe pipe = new Pipe("test"); pipe = new Each(pipe, new Debug()); pipe = new GroupBy("group by user", pipe, groupField); pipe = new Every(pipe, new Fields("value"), new Sum()); pipe = new Each(pipe, new MyFilter(perRequestDelay)); pipe = new GroupBy("group by sum", pipe, new Fields("sum")); Lfs sinkTap = new Lfs(new SequenceFile(new Fields("user", "sum")), out, SinkMode.REPLACE); Flow<JobConf> flow = new HadoopFlowConnector().connect("FlowMonitorTest", sourceTap, sinkTap, pipe); for (FlowStep<JobConf> step : flow.getFlowSteps()) { StepUtils.nameFlowStep((BaseFlowStep<JobConf>) step); } FlowMonitor monitor = new FlowMonitor(flow); monitor.setUpdateInterval(100); monitor.setHtmlDirectory(testDir); monitor.addMonitorTask(new MyTask()); monitor.setIncludeCascadingCounters(true); Assert.assertTrue(monitor.run(MyCounters.FILTER_REQUESTS)); File htmlFile = new File(testDir + FlowMonitor.FILENAME); Assert.assertTrue(htmlFile.exists()); String content = IOUtils.toString(new FileReader(htmlFile)); Assert.assertTrue(content.contains("FlowMonitorTest")); Assert.assertTrue(content.contains(MyCounters.FILTER_REQUESTS.toString())); Assert.assertTrue(content.contains("<td>MyTask</td>")); Assert.assertTrue(content.contains("200 bytes/sec & faster!")); Assert.assertTrue(content.contains("<td>" + numDatums + "</td>")); // Make sure we're not getting negative durations Assert.assertFalse(content.contains("<td>-")); }
From source file:org.openmrs.module.paperrecord.PaperRecordServiceComponentTest.java
@Test public void testPaperMedicalRecordExistsReturnsFalseIfIdentifierIsInUseButWrongLocation() { // from the standard test dataset Location medicalRecordLocation = locationService.getLocation(2); // this identifier exists in the standard test data set Assert.assertFalse(paperRecordService.paperRecordExistsWithIdentifier("CATBALL", medicalRecordLocation)); }
From source file:ejportal.webapp.action.UserActionTest.java
/** * Test remove./*from w w w. java 2s .c o m*/ * * @throws Exception * the exception */ public void testRemove() throws Exception { final User user = new User("admin"); user.setId(-2L); this.action.setUser(user); Assert.assertEquals("success", this.action.delete()); Assert.assertFalse(this.action.hasActionErrors()); }
From source file:com.onesite.sdk.test.api.SessionApiTest.java
@Test public void testLoginCrossDomain() { SessionApi api = new SessionApi(); try {//from w ww . j av a2 s.c o m User testUser = new User(); testUser.setId(userID); URL redirectUrl = api.loginCrossDomain(testUser, password, callbackUrl, ip, expiresFromNow); System.out.println("Login Cross Domain Redirect Url"); System.out.println(redirectUrl.toString()); Assert.assertFalse(StringUtils.isEmpty(redirectUrl.toString())); } catch (Exception e) { Assert.fail(); } }
From source file:cz.PA165.vozovyPark.dao.UserDAOTest.java
/** * *///ww w. j a v a 2s . c o m @Test public void testValidRemove() { //UserDAO dao = createUserDAOFactory(); User user = newDefaultUser(); User result = null; try { userDao.createUser(user); Long id = user.getId(); em.getTransaction().begin(); userDao.removeUser(user); em.getTransaction().commit(); result = userDao.getById(id); } catch (Exception e) { fail("Unexpected exception was threw: " + e + " " + e.getMessage()); } Assert.assertFalse(em.contains(user)); }
From source file:com.ibm.jaggr.service.impl.config.BundleVersionsHashTest.java
@Test public void testBundleVersionsHash() throws Exception { URI tmpDir = new File(System.getProperty("user.dir")).toURI(); IAggregator mockAggregator = TestUtils.createMockAggregator(); InitParams initParams = new InitParams(Arrays .asList(new InitParam[] { new InitParam("propName", "getBundleVersionsHash", mockAggregator) })); BundleVersionsHash bvh = new BundleVersionsHash(); IServiceReference mockServiceReference = EasyMock.createNiceMock(IServiceReference.class); IServiceReference[] serviceReferences = new IServiceReference[] { mockServiceReference }; IPlatformServices mockPlatformServices = EasyMock.createNiceMock(IPlatformServices.class); IAggregatorExtension mockExtension = EasyMock.createMock(IAggregatorExtension.class); EasyMock.expect(mockAggregator.getPlatformServices()).andReturn(mockPlatformServices).anyTimes(); EasyMock.replay(mockAggregator);/* w w w . j a v a2s . c o m*/ Dictionary<String, String> dict = new Hashtable<String, String>(); dict.put("name", mockAggregator.getName()); EasyMock.expect(mockPlatformServices.getService(mockServiceReference)).andReturn(bvh).anyTimes(); EasyMock.expect(mockExtension.getInitParams()).andReturn(initParams).anyTimes(); EasyMock.expect(mockPlatformServices.getServiceReferences(IConfigScopeModifier.class.getName(), "(name=" + mockAggregator.getName() + ")")).andReturn(serviceReferences).anyTimes(); EasyMock.replay(mockServiceReference, mockPlatformServices, mockExtension); bvh.initialize(mockAggregator, mockExtension, null); EasyMock.verify(mockPlatformServices); Bundle mockBundle1 = EasyMock.createMock(Bundle.class); Bundle mockBundle2 = EasyMock.createMock(Bundle.class); PowerMock.mockStatic(Platform.class); EasyMock.expect(Platform.getBundle("com.test.bundle1")).andReturn(mockBundle1).anyTimes(); EasyMock.expect(Platform.getBundle("com.test.bundle2")).andReturn(mockBundle2).anyTimes(); EasyMock.expect(Platform.getBundle("com.test.bundle3")).andReturn(null).anyTimes(); final Dictionary<String, String> bundle1Headers = new Hashtable<String, String>(); final Dictionary<String, String> bundle2Headers = new Hashtable<String, String>(); EasyMock.expect(mockBundle1.getHeaders()).andAnswer(new IAnswer<Dictionary<String, String>>() { @Override public Dictionary<String, String> answer() throws Throwable { return bundle1Headers; } }).anyTimes(); EasyMock.expect(mockBundle2.getHeaders()).andAnswer(new IAnswer<Dictionary<String, String>>() { @Override public Dictionary<String, String> answer() throws Throwable { return bundle2Headers; } }).anyTimes(); PowerMock.replay(Platform.class, mockBundle1, mockBundle2); bundle1Headers.put("Bnd-LastModified", "123456789"); bundle2Headers.put("Bnd-LastModified", "234567890"); bundle1Headers.put("Bundle-Version", "1.2.3.20140414"); bundle2Headers.put("Bundle-Version", "1.2.3.20140412"); String config = "{cacheBust:getBundleVersionsHash(['Bundle-Version', 'Bnd-LastModified'], 'com.test.bundle1', 'com.test.bundle2')}"; ConfigImpl cfg = new ConfigImpl(mockAggregator, tmpDir, config, true); String cacheBust = cfg.getCacheBust(); bundle1Headers.put("Bnd-LastModified", "123456780"); cfg = new ConfigImpl(mockAggregator, tmpDir, config, true); Assert.assertFalse(cacheBust.equals(cfg.getCacheBust())); bundle1Headers.put("Bnd-LastModified", "123456789"); cfg = new ConfigImpl(mockAggregator, tmpDir, config, true); Assert.assertEquals(cacheBust, cfg.getCacheBust()); bundle2Headers.put("Bundle-Version", "1.2.4"); cfg = new ConfigImpl(mockAggregator, tmpDir, config, true); Assert.assertFalse(cacheBust.equals(cfg.getCacheBust())); bundle2Headers.put("Bundle-Version", "1.2.3.20140412"); cfg = new ConfigImpl(mockAggregator, tmpDir, config, true); Assert.assertEquals(cacheBust, cfg.getCacheBust()); // Test that when header names are not specified, it defaults to 'Bundle-Version'. config = "{cacheBust:getBundleVersionsHash('com.test.bundle1', 'com.test.bundle2')}"; cfg = new ConfigImpl(mockAggregator, tmpDir, config, true); cacheBust = cfg.getCacheBust(); bundle1Headers.put("Bnd-LastModified", "123456780"); cfg = new ConfigImpl(mockAggregator, tmpDir, config, true); Assert.assertEquals(cacheBust, cfg.getCacheBust()); bundle2Headers.put("Bundle-Version", "1.2.4"); cfg = new ConfigImpl(mockAggregator, tmpDir, config, true); Assert.assertFalse(cacheBust.equals(cfg.getCacheBust())); bundle2Headers.put("Bundle-Version", "1.2.3.20140412"); cfg = new ConfigImpl(mockAggregator, tmpDir, config, true); Assert.assertEquals(cacheBust, cfg.getCacheBust()); // Ensure exception thrown if a specified bundle is not found config = "{cacheBust:getBundleVersionsHash('com.test.bundle1', 'com.test.bundle2', 'com.test.bundle3')}"; try { cfg = new ConfigImpl(mockAggregator, tmpDir, config, true); Assert.fail("Expected exception"); } catch (WrappedException ex) { Assert.assertTrue(NotFoundException.class.isInstance(ex.getCause())); } // ensure exception thrown if argument is wrong type config = "{cacheBust:getBundleVersionsHash({})}"; try { cfg = new ConfigImpl(mockAggregator, tmpDir, config, true); Assert.fail("Expected exception"); } catch (WrappedException ex) { Assert.assertTrue(IllegalArgumentException.class.isInstance(ex.getCause())); } // ensure value is null if no bundle names specified config = "{cacheBust:getBundleVersionsHash()}"; cfg = new ConfigImpl(mockAggregator, tmpDir, config, true); Assert.assertNull(cfg.getCacheBust()); config = "{cacheBust:getBundleVersionsHash(['Bundle-Version'])}"; cfg = new ConfigImpl(mockAggregator, tmpDir, config, true); Assert.assertNull(cfg.getCacheBust()); config = "{}"; cfg = new ConfigImpl(mockAggregator, tmpDir, config, true); Assert.assertNull(cfg.getCacheBust()); // Ensure that cacheBust is a base64 encoded array of 16 bytes. byte[] bytes = Base64.decodeBase64(cacheBust); Assert.assertEquals(16, bytes.length); }
From source file:de.hybris.platform.servicelayer.media.impl.DefaultMediaPermissionServiceIntegrationTest.java
/** * Test method for/*w ww. j a v a2 s . com*/ * {@link de.hybris.platform.servicelayer.media.impl.DefaultMediaPermissionService#isReadAccessGranted(de.hybris.platform.core.model.media.MediaModel, de.hybris.platform.core.model.security.PrincipalModel)} * . */ @Test public void testIsReadAccessGrantedFalse() { final PermissionAssignment permissionAssignment_deny = new PermissionAssignment(PermissionsConstants.READ, userService.getCurrentUser(), true); permissionManagementService.addItemPermission(testMediaItem, permissionAssignment_deny); //this will overwrite the grant permission into deny final boolean result = mediaPermissionService.isReadAccessGranted(testMediaItem, userService.getCurrentUser()); Assert.assertFalse(result); }
From source file:io.druid.indexer.HdfsClasspathSetupTest.java
@Test public void testAddNonSnapshotJarToClasspath() throws IOException { Job job = Job.getInstance(conf, "test-job"); DistributedFileSystem fs = miniCluster.getFileSystem(); JobHelper.addJarToClassPath(dummyJarFile, finalClasspath, intermediatePath, fs, job); Path expectedJarPath = new Path(finalClasspath, dummyJarFile.getName()); // check file gets uploaded to final HDFS path Assert.assertTrue(fs.exists(expectedJarPath)); // check that the intermediate file gets deleted Assert.assertFalse(fs.exists(new Path(intermediatePath, dummyJarFile.getName()))); // check file gets added to the classpath Assert.assertEquals(expectedJarPath.toString(), job.getConfiguration().get(MRJobConfig.CLASSPATH_FILES)); Assert.assertEquals(dummyJarString, StringUtils.fromUtf8(IOUtils.toByteArray(fs.open(expectedJarPath)))); }
From source file:org.openscore.lang.compiler.modeller.transformers.InputsTransformerTest.java
@Test public void testOverrideInput() throws Exception { @SuppressWarnings("unchecked") List<Input> inputs = inputTransformer.transform(inputsMap); Input input = inputs.get(8);/*from w ww. j a va2 s . c om*/ Assert.assertEquals("input9", input.getName()); Assert.assertEquals("input6", input.getExpression()); Assert.assertFalse(input.isOverridable()); Assert.assertFalse(input.isEncrypted()); Assert.assertTrue(input.isRequired()); }
From source file:es.tekniker.framework.ktek.commons.mng.server.test.TestCommonsMngServer.java
@org.junit.Test public void testLoginExists() { log.info("*************************************************************"); log.info("testLoginExists: START "); String result = TestDefines.RESULT_OK; KtekUserEntity instance = null;/* ww w .ja va2 s . c o m*/ CommonsMngServer manager = new CommonsMngServer(); KtekLoginEntity login = getLoginExists(); try { instance = manager.login(login); if (instance != null) { log.info("testLoginExists: instance is NOT NULL " + instance.getToken()); Assert.assertNotNull(instance); } else { log.error("testLoginExists: instance is NULL "); result = TestDefines.RESULT_ERROR; Assert.assertNull(instance); } } catch (KtekExceptionEntity e) { System.out.println("TestUsersMngServer.loginExists: exception " + e.getMessage()); e.printStackTrace(); Assert.assertFalse(false); } log.info("testLoginExists: RESULT " + result); log.info("testLoginExists: END "); log.info("*************************************************************"); log.info(""); }