List of usage examples for junit.framework Assert assertFalse
static public void assertFalse(boolean condition)
From source file:at.tfr.securefs.ui.CopyFilesTest.java
@Test public void testCopyFilesByWalk() throws Exception { // Given: NO target directory yet!!, the source file final String data = "Hallo Echo"; try (OutputStream os = cp.getEncrypter(fromFile)) { IOUtils.write(data, os);/* w w w. ja va 2s .c o m*/ } Assert.assertFalse(Files.exists(toRoot.resolve(DATA_FILES))); Assert.assertFalse(Files.exists(targetToFile)); // When: copy of fromRoot to toRoot ProcessFiles pf = new ProcessFilesBean(new MockSecureFsCache()); CopyFilesServiceBean cfb = new CopyFilesServiceBean(config, cp, pf, new MockSecureFsCache(), async); cfb.setFromPathName(fromRoot.toString()); cfb.setToPathName(toRoot.toString()); cfb.setNewSecret(newSecret); cfb.runCopyFiles(); // Then: a target file is created in same subpath like sourceFile: Assert.assertTrue("subpath is not created", Files.exists(toRoot.resolve(DATA_FILES))); Assert.assertTrue("target file not created", Files.exists(targetToFile)); // Then: the content of target file is decryptable with newSecret // and equals content of source file byte[] buf = new byte[data.getBytes().length]; try (InputStream is = cp.getDecrypter(targetToFile, newSecret)) { IOUtils.read(is, buf); } Assert.assertEquals("failed to decrypt data", data, String.valueOf(data)); }
From source file:com.netflix.curator.TestSessionFailRetryLoop.java
@Test public void testRetry() throws Exception { Timing timing = new Timing(); final CuratorZookeeperClient client = new CuratorZookeeperClient(server.getConnectString(), timing.session(), timing.connection(), null, new RetryOneTime(1)); SessionFailRetryLoop retryLoop = client.newSessionFailRetryLoop(SessionFailRetryLoop.Mode.RETRY); retryLoop.start();/*from www. jav a 2 s . c o m*/ try { client.start(); final AtomicBoolean secondWasDone = new AtomicBoolean(false); final AtomicBoolean firstTime = new AtomicBoolean(true); while (retryLoop.shouldContinue()) { try { RetryLoop.callWithRetry(client, new Callable<Void>() { @Override public Void call() throws Exception { if (firstTime.compareAndSet(true, false)) { Assert.assertNull(client.getZooKeeper().exists("/foo/bar", false)); KillSession.kill(client.getZooKeeper(), server.getConnectString()); client.getZooKeeper(); client.blockUntilConnectedOrTimedOut(); } Assert.assertNull(client.getZooKeeper().exists("/foo/bar", false)); return null; } }); RetryLoop.callWithRetry(client, new Callable<Void>() { @Override public Void call() throws Exception { Assert.assertFalse(firstTime.get()); Assert.assertNull(client.getZooKeeper().exists("/foo/bar", false)); secondWasDone.set(true); return null; } }); } catch (Exception e) { retryLoop.takeException(e); } } Assert.assertTrue(secondWasDone.get()); } finally { retryLoop.close(); IOUtils.closeQuietly(client); } }
From source file:com.buddycloud.mediaserver.delete.DeleteMediaTest.java
@Test public void deleteMedia() throws Exception { ClientResource client = new ClientResource(URL); client.setChallengeResponse(ChallengeScheme.HTTP_BASIC, BASE_USER, BASE_TOKEN); client.delete();//from ww w . ja v a 2 s . c o m Assert.assertFalse(fileToDelete.exists()); }
From source file:io.cloudslang.lang.compiler.modeller.transformers.PublishTransformerTest.java
@Test(timeout = DEFAULT_TIMEOUT) public void testTransform() throws Exception { @SuppressWarnings("unchecked") List<Output> publishValues = publishTransformer.transform(publishMap); Assert.assertFalse(publishValues.isEmpty()); }
From source file:com.rackspacecloud.blueflood.io.serializers.CounterRollupSerializationTest.java
@Test public void testCounterV1RoundTrip() throws IOException { CounterRollup c0 = new CounterRollup().withCount(7442245).withSampleCount(1); CounterRollup c1 = new CounterRollup().withCount(34454722343L).withSampleCount(10); if (System.getProperty("GENERATE_COUNTER_SERIALIZATION") != null) { OutputStream os = new FileOutputStream("src/test/resources/serializations/counter_version_" + Constants.VERSION_1_COUNTER_ROLLUP + ".bin", false); os.write(Base64.encodeBase64(new NumericSerializer.CounterRollupSerializer().toByteBuffer(c0).array())); os.write("\n".getBytes()); os.write(Base64.encodeBase64(new NumericSerializer.CounterRollupSerializer().toByteBuffer(c1).array())); os.write("\n".getBytes()); os.close();/*from www .ja v a 2 s . c o m*/ } Assert.assertTrue(new File("src/test/resources/serializations").exists()); int count = 0; int version = 0; final int maxVersion = Constants.VERSION_1_COUNTER_ROLLUP; while (version <= maxVersion) { BufferedReader reader = new BufferedReader( new FileReader("src/test/resources/serializations/counter_version_" + version + ".bin")); ByteBuffer bb = ByteBuffer.wrap(Base64.decodeBase64(reader.readLine().getBytes())); CounterRollup cc0 = NumericSerializer.serializerFor(CounterRollup.class).fromByteBuffer(bb); Assert.assertEquals(c0, cc0); bb = ByteBuffer.wrap(Base64.decodeBase64(reader.readLine().getBytes())); CounterRollup cc1 = NumericSerializer.serializerFor(CounterRollup.class).fromByteBuffer(bb); Assert.assertEquals(c1, cc1); Assert.assertFalse(cc0.equals(cc1)); version++; count++; } Assert.assertTrue(count > 0); }
From source file:com.buddycloud.mediaserver.delete.DeleteAvatarTest.java
@Test public void deleteAvatar() throws Exception { ClientResource client = new ClientResource(URL); client.setChallengeResponse(ChallengeScheme.HTTP_BASIC, BASE_USER, BASE_TOKEN); client.delete();//from www . j a v a 2 s . co m Assert.assertFalse(fileToDelete.exists()); }
From source file:com.qcadoo.model.integration.FieldModuleIntegrationTest.java
License:asdf
@Test public void shouldCallAdditinanalFieldValidators() throws Exception { // given// w ww .j a va 2s . co m DataDefinition productDao = dataDefinitionService.get(PLUGIN_PRODUCTS_NAME, ENTITY_NAME_PRODUCT); DataDefinition machineDao = dataDefinitionService.get(PLUGIN_MACHINES_NAME, ENTITY_NAME_MACHINE); DataDefinition componentDao = dataDefinitionService.get(PLUGIN_PRODUCTS_NAME, ENTITY_NAME_COMPONENT); PluginStateResolver pluginStateResolver = mock(PluginStateResolver.class); PluginUtilsService pluginUtil = new PluginUtilsService(); ReflectionTestUtils.setField(pluginUtil, "pluginStateResolver", pluginStateResolver); pluginUtil.init(); given(pluginStateResolver.isEnabled(PLUGIN_MACHINES_NAME)).willReturn(true); Entity machine = machineDao.save(createMachine("asd")); Entity product = createProduct("asd", "asd"); product = productDao.save(product); Entity component = createComponent("name", product, machine); component.setField("machineDescription", "as"); // when component = componentDao.save(component); // then Assert.assertFalse(component.isValid()); }
From source file:com.google.api.ads.adwords.awreporting.model.definitions.ReportDisplayKeywordDefinitionTest.java
/** * @see com.google.api.ads.adwords.awreporting.model.definitions. * AbstractReportDefinitionTest#testFirstEntry( * com.google.api.ads.adwords.awreporting.model.entities.Report) *//*from w ww. jav a 2s .c o m*/ @Override protected void testFirstEntry(ReportDisplayKeyword first) { Assert.assertEquals(1056270861L, first.getAccountId().longValue()); Assert.assertEquals("2014-06-09", first.getDay()); Assert.assertEquals(0.00, first.getCost().doubleValue()); Assert.assertEquals(0L, first.getClicks().longValue()); Assert.assertEquals(59L, first.getImpressions().longValue()); Assert.assertEquals(0L, first.getConversions().longValue()); Assert.assertEquals(0.00, first.getCtrBigDecimal().doubleValue()); Assert.assertEquals(0.00, first.getAvgCpm().doubleValue()); Assert.assertEquals(0.00, first.getAvgCpc().doubleValue()); Assert.assertEquals(208108586L, first.getCampaignId().longValue()); Assert.assertEquals("Search IP", first.getCampaignName()); Assert.assertEquals(11390393906L, first.getAdGroupId().longValue()); Assert.assertEquals("Gen", first.getAdGroupName()); Assert.assertEquals("", first.getDestinationUrl()); Assert.assertEquals(10024300L, first.getKeywordId().longValue()); Assert.assertEquals("restaurant", first.getKeywordText()); Assert.assertFalse(first.isNegative()); }
From source file:loaders.LoadQueryTransformerTest.java
@Test public void testParamReordering() throws Exception { String query = "select id as id from user where id = ${param1} or id = ${param2} and id > ${param1}"; HashMap<String, Object> params = new HashMap<String, Object>(); AbstractDbDataLoader.QueryPack queryPack = prepareQuery(query, new BandData(""), params); System.out.println(queryPack.getQuery()); Assert.assertFalse(queryPack.getQuery().contains("${")); writeParams(queryPack);/*from ww w .j a v a 2s . c o m*/ params.put("param1", "param1"); params.put("param2", "param2"); queryPack = prepareQuery(query, new BandData(""), params); System.out.println(queryPack.getQuery()); Assert.assertEquals(3, StringUtils.countMatches(queryPack.getQuery(), "?")); writeParams(queryPack); Assert.assertEquals("param1", queryPack.getParams()[0].getValue()); Assert.assertEquals("param2", queryPack.getParams()[1].getValue()); Assert.assertEquals("param1", queryPack.getParams()[2].getValue()); }
From source file:org.openscore.lang.compiler.modeller.transformers.DoTransformerTest.java
@Test public void testTransformConst() throws Exception { @SuppressWarnings("unchecked") List<Input> inputs = doTransformer.transform(doInputsMap); Assert.assertFalse(inputs.isEmpty()); Input input = inputs.get(1);//from ww w .j av a 2 s.co m Assert.assertEquals("country", input.getName()); Assert.assertEquals("str('Israel')", input.getExpression()); }