List of usage examples for junit.framework Assert assertTrue
static public void assertTrue(boolean condition)
From source file:com.buddycloud.mediaserver.download.DownloadImageTest.java
@Test public void downloadImage() throws Exception { ClientResource client = new ClientResource(URL); client.setChallengeResponse(ChallengeScheme.HTTP_BASIC, BASE_USER, BASE_TOKEN); File file = new File(TEST_OUTPUT_DIR + File.separator + "downloaded.jpg"); FileOutputStream outputStream = FileUtils.openOutputStream(file); client.get().write(outputStream);/*from ww w .ja va 2 s . c o m*/ Assert.assertTrue(file.exists()); // Delete downloaded file FileUtils.deleteDirectory(new File(TEST_OUTPUT_DIR)); outputStream.close(); }
From source file:com.buddycloud.mediaserver.download.DownloadVideoTest.java
@Test public void downloadVideo() throws Exception { ClientResource client = new ClientResource(URL); client.setChallengeResponse(ChallengeScheme.HTTP_BASIC, BASE_USER, BASE_TOKEN); File file = new File(TEST_OUTPUT_DIR + File.separator + "downloaded.avi"); FileOutputStream outputStream = FileUtils.openOutputStream(file); client.get().write(outputStream);//from w w w. j av a2 s.co m Assert.assertTrue(file.exists()); // Delete downloaded file FileUtils.deleteDirectory(new File(TEST_OUTPUT_DIR)); outputStream.close(); }
From source file:com.connectsdk.service.WebOSTVServiceTest.java
@Test public void testCapabilitiesForVersion4() { Mockito.when(serviceDescription.getVersion()).thenReturn("4.0.0"); Assert.assertTrue(service.hasCapabilities(MediaControl.Play, MediaControl.Pause, MediaControl.Stop, MediaControl.Seek, MediaControl.Position, MediaControl.Duration, MediaControl.PlayState, WebAppLauncher.Close, WebAppLauncher.Launch, WebAppLauncher.Launch_Params)); }
From source file:com.googlecode.t7mp.TomcatArtifactDispatcherTest.java
@Test public void testArtifactDispatcher() throws MojoExecutionException, IOException { TomcatArtifactDispatcher dispatcher = new TomcatArtifactDispatcher(myArtifactResolver, catalinaBaseDir, Mockito.mock(SetupUtil.class), Mockito.mock(Log.class)); Artifact artifact = Mockito.mock(Artifact.class); Mockito.when(artifact.getArtifactId()).thenReturn(ArtifactConstants.ARTIFACTID); Mockito.when(artifact.getGroupId()).thenReturn(ArtifactConstants.GROUPID); Mockito.when(artifact.getVersion()).thenReturn(ArtifactConstants.VERSION); Mockito.when(artifact.getClassifier()).thenReturn(ArtifactConstants.CLASSIFIER); Mockito.when(artifact.getType()).thenReturn(ArtifactConstants.JAR_TYPE); Mockito.when(artifact.getFile()).thenReturn(sourceFile); Mockito.when(myArtifactResolver.resolve(Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString())).thenReturn(artifact); List<? extends AbstractArtifact> artifactList = getArtifacList(); dispatcher.resolveArtifacts(artifactList); Assert.assertNotNull(dispatcher.resolvedArtifacts); Assert.assertTrue(artifactList.size() == dispatcher.resolvedArtifacts.size()); for (AbstractArtifact a : dispatcher.resolvedArtifacts) { Assert.assertEquals(a.getArtifactId(), a.getArtifact().getArtifactId()); Assert.assertEquals(a.getGroupId(), a.getArtifact().getGroupId()); Assert.assertEquals(a.getVersion(), a.getArtifact().getVersion()); }/*from w ww.j av a2 s . c om*/ File targetDir = new File(catalinaBaseDir, "lib"); targetDir.mkdirs(); Assert.assertTrue(targetDir.exists()); dispatcher.copyTo(targetDir.getName()); File[] targetFiles = targetDir.listFiles(new FilesOnlyFileFilter()); Assert.assertTrue(targetFiles.length == 2); for (File f : targetFiles) { System.out.println(f.getAbsolutePath()); Assert.assertTrue( f.getName().equals(ArtifactConstants.ARTIFACTID + "-" + ArtifactConstants.VERSION + ".jar") || f.getName().equals(ArtifactConstants.ARTIFACTID + ".war")); } dispatcher.clear(); Assert.assertTrue(dispatcher.resolvedArtifacts.size() == 0); }
From source file:de.hybris.basecommerce.SimpleSmtpServerUtilsTest.java
@Test public void testFindNextPort() { SimpleSmtpServer server1 = null;/*from w w w. j a va 2 s. co m*/ SimpleSmtpServer server2 = null; SimpleSmtpServer server3 = null; SimpleSmtpServer server4 = null; try { server1 = SimpleSmtpServerUtils.startServer(TEST_START_PORT, true); Assert.assertFalse(server1.isStopped()); Assert.assertTrue(server1.getPort() > 0); server2 = SimpleSmtpServerUtils.startServer(TEST_START_PORT, true); Assert.assertFalse(server2.isStopped()); Assert.assertTrue(server2.getPort() > 0); Assert.assertFalse(server1.getPort() == server2.getPort()); server3 = SimpleSmtpServerUtils.startServer(TEST_START_PORT, true); Assert.assertFalse(server3.isStopped()); Assert.assertTrue(server3.getPort() > 0); Assert.assertFalse(server1.getPort() == server3.getPort()); Assert.assertFalse(server2.getPort() == server3.getPort()); // stop server 1 final int server1Port = server1.getPort(); server1.stop(); Assert.assertTrue(server1.isStopped()); server1 = null; // now port from server 1 should be free again server4 = SimpleSmtpServerUtils.startServer(TEST_START_PORT, true); Assert.assertFalse(server4.isStopped()); if (server1Port != server4.getPort()) { LOG.warn("unable to re-use port server1 port " + server1Port + " even though server1 was stopped"); } } finally { if (server4 != null) { server4.stop(); } if (server3 != null) { server3.stop(); } if (server2 != null) { server2.stop(); } if (server1 != null) { server1.stop(); } } }
From source file:com.netflix.curator.framework.recipes.queue.TestQueueSharder.java
@Test public void testDistribution() throws Exception { final int threshold = 100; final int factor = 10; Timing timing = new Timing(); CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(), timing.connection(), new RetryOneTime(1)); QueueSharder<String, DistributedQueue<String>> sharder = null; try {/* w w w. ja v a 2 s . c o m*/ client.start(); final CountDownLatch latch = new CountDownLatch(1); QueueConsumer<String> consumer = new QueueConsumer<String>() { @Override public void consumeMessage(String message) throws Exception { latch.await(); } @Override public void stateChanged(CuratorFramework client, ConnectionState newState) { } }; QueueAllocator<String, DistributedQueue<String>> distributedQueueAllocator = makeAllocator(consumer); QueueSharderPolicies policies = QueueSharderPolicies.builder().newQueueThreshold(threshold) .thresholdCheckMs(1).build(); sharder = new QueueSharder<String, DistributedQueue<String>>(client, distributedQueueAllocator, "/queues", "/leader", policies); sharder.start(); for (int i = 0; i < (factor * threshold); ++i) { sharder.getQueue().put(Integer.toString(i)); Thread.sleep(5); } timing.forWaiting().sleepABit(); SummaryStatistics statistics = new SummaryStatistics(); for (String path : sharder.getQueuePaths()) { int numChildren = client.checkExists().forPath(path).getNumChildren(); Assert.assertTrue(numChildren > 0); Assert.assertTrue(numChildren >= (threshold * .1)); statistics.addValue(numChildren); } latch.countDown(); Assert.assertTrue(statistics.getMean() >= (threshold * .9)); } finally { timing.sleepABit(); // let queue clear Closeables.closeQuietly(sharder); Closeables.closeQuietly(client); } }
From source file:nl.han.dare2date.service.UserNotificationTest.java
@Test public void testOnMessage() { userNotification.onMessage(message); Assert.assertEquals("theus.de.tester@test.nl", mail.getValue().getTo()[0]); Assert.assertEquals("r@dare2date.com", mail.getValue().getFrom()); Assert.assertTrue(mail.getValue().getText().indexOf("Theus") != -1); }
From source file:com.github.neoio.net.message.staging.file.TestFileMessageStaging.java
@Test public void test() throws Exception { ByteBuffer buffer = ByteBuffer.allocate(1024); buffer.put("Hello World".getBytes("US-ASCII")); buffer.flip();/* ww w .j av a 2 s . co m*/ Assert.assertEquals(11, staging.writeTempReadBytes(buffer)); Assert.assertTrue(staging.hasTempReadBytes()); buffer.clear(); Assert.assertEquals(11, staging.readTempReadBytes(buffer)); buffer.put("Hello World".getBytes("US-ASCII")); buffer.flip(); staging.writePrimaryStaging(buffer, 22); buffer.clear(); staging.getPrimaryStage().read(buffer); Assert.assertEquals("Hello WorldHello World", new String(buffer.array(), 0, 22)); }
From source file:org.wso2.carbon.ganalytics.publisher.GoogleAnalyticsDataPublisherTest.java
@Test public void testPublishPOSTHTTP() throws Exception { GoogleAnalyticsData data = new GoogleAnalyticsData.DataBuilder("UA-50303033-1", "1", "35009a79-1a05-49d7-b876-2b884d0fsadfa", GoogleAnalyticsConstants.HIT_TYPE_PAGEVIEW) .setDocumentPath("/testpagePOST").setDocumentHostName("localhost.com") .setDocumentTitle("HTTP POST").build(); List<NameValuePair> payload = GoogleAnalyticsDataPublisher.buildPayload(data); Assert.assertTrue(GoogleAnalyticsDataPublisher.publishPOST(payload, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1944.0 Safari/537.36", false));//from w w w . j av a 2s .co m }
From source file:io.cloudslang.lang.compiler.modeller.transformers.ResultsTransformerTest.java
@Test public void testTransform() throws Exception { List<Result> results = resultsTransformer.transform(resultsMapOpWithData).getTransformedData(); Assert.assertTrue(CollectionUtils.isNotEmpty(results)); Assert.assertEquals(3, results.size()); }