List of usage examples for junit.framework Assert assertFalse
static public void assertFalse(boolean condition)
From source file:io.cloudslang.engine.node.services.WorkerNodeServiceTest.java
@Test public void readNonRespondingWorkers() throws Exception { List<String> workers = workerNodeService.readNonRespondingWorkers(); Assert.assertEquals(0, workers.size()); workerNodeService.create("H3", "H3", "dima.rassin", "c:/dir"); workers = workerNodeService.readNonRespondingWorkers(); Assert.assertEquals(0, workers.size()); // only activate workers can be non responding workerNodeService.activate("H3"); workers = workerNodeService.readNonRespondingWorkers(); Assert.assertEquals(0, workers.size());//still it not "non responding" because it yet to login(first login) // after login version is current system version. workerNodeService.up("H3"); workers = workerNodeService.readNonRespondingWorkers(); Assert.assertEquals(0, workers.size()); //when the worker version is too far from the system version its NonResponding when(versionService.getCurrentVersion(anyString())).thenReturn(100L); workers = workerNodeService.readNonRespondingWorkers(); Assert.assertEquals(3, workers.size()); //after up the worker version will be aligned with current system version. workerNodeService.up("H3"); workers = workerNodeService.readNonRespondingWorkers(); Assert.assertEquals(2, workers.size()); Assert.assertFalse(workers.contains("H3")); }
From source file:org.apache.sling.etcd.client.impl.EtcdClientImplTest.java
@Test public void testGetMissingKey() throws Exception { server1 = startServer(new StaticHandler(404, "/error-4.json"), "/v2/keys/test"); buildEtcdClient(serverPort(server1)); KeyResponse response = etcdClient.getKey("/test", EtcdParams.noParams()); Assert.assertNotNull(response);//w ww . j a va2 s . c o m Assert.assertFalse(response.isAction()); KeyError error = response.error(); Assert.assertNotNull(error); Assert.assertEquals(100, error.errorCode()); }
From source file:org.opencastproject.episode.filesystem.FileSystemElementStoreTest.java
@Test public void testGetBad() throws Exception { StoragePath storagePath = new StoragePath(ORG_ID, MP_ID, VERSION_1, MP_ELEM_ID); Option<InputStream> option = repo.get(storagePath); Assert.assertFalse(option.isSome()); }
From source file:com.ebay.cloud.cms.query.service.QueryPaginationTest.java
@Test public void testService02() { QueryContext tempContext = newQueryContext(RAPTOR_REPO, RAPTOR_MAIN_BRANCH_ID); tempContext.setAllowFullTableScan(true); tempContext.setLimits(new int[] { 0, 12, 0 }); tempContext.setSkips(new int[] { 0, 0, 0 }); tempContext.setRegistration(TestUtils.getDefaultDalImplementation(dataSource)); IQueryResult result = queryService.query("ApplicationService.services{@name}.runsOn{@name}", tempContext); List<IEntity> services = (List<IEntity>) result.getEntities(); Assert.assertEquals(10, services.size()); Assert.assertEquals("srp-app:Raptor-00002", services.get(0).getFieldValues("name").get(0)); Assert.assertEquals("srp-app:Raptor-00003", services.get(1).getFieldValues("name").get(0)); Assert.assertFalse(result.hasMoreResults()); }
From source file:com.feedzai.fos.impl.weka.WekaManagerTest.java
@Test public void reconfigureModelByByteArrayTest() throws FOSException, IOException, ClassNotFoundException { ModelDescriptor descriptor = new ModelDescriptor(ModelDescriptor.Format.BINARY, "target/test-classes/models/test.model"); UUID id = wekaManager.addModel(new Cloner<>(wekaManager.listModels().get(testUID)).get(), new ModelBinary(new Cloner<Classifier>(descriptor).getSerialized())); String previousFiles = wekaManager.listModels().get(id).getProperties().get(WekaModelConfig.MODEL_FILE); wekaManager.reconfigureModel(id, modelConfig, new ModelBinary(new Cloner<Classifier>(descriptor).getSerialized())); Assert.assertEquals(2, wekaManager.listModels().size()); Assert.assertEquals(modelConfig.getAttributes(), wekaManager.listModels().get(id).getAttributes()); Assert.assertTrue(new File(wekaManager.listModels().get(id).getProperties().get(WekaModelConfig.MODEL_FILE)) .exists());//from ww w .j a v a 2 s .c om Assert.assertFalse(new File(previousFiles).getAbsolutePath() .equals(wekaManager.listModels().get(id).getProperties().get(WekaModelConfig.MODEL_FILE))); }
From source file:org.apache.gobblin.writer.AsyncHttpWriterTest.java
/** * Test max attempts triggered by failing to send. Attempt 3 times *//* ww w . j a va 2 s . c o m*/ public void testMaxAttempts() { MockHttpClient client = new MockHttpClient(); MockRequestBuilder requestBuilder = new MockRequestBuilder(); MockResponseHandler responseHandler = new MockResponseHandler(); MockAsyncHttpWriterBuilder builder = new MockAsyncHttpWriterBuilder(client, requestBuilder, responseHandler); TestAsyncHttpWriter asyncHttpWriter = new TestAsyncHttpWriter(builder); client.shouldSendSucceed = false; MockWriteCallback callback = new MockWriteCallback(); asyncHttpWriter.write(new Object(), callback); boolean hasAnException = false; try { asyncHttpWriter.close(); } catch (Exception e) { hasAnException = true; } Assert.assertTrue(hasAnException); Assert.assertFalse(callback.isSuccess); Assert.assertTrue(client.isCloseCalled); Assert.assertTrue(client.attempts == AsyncHttpWriter.DEFAULT_MAX_ATTEMPTS); Assert.assertTrue(responseHandler.attempts == 0); }
From source file:io.druid.indexer.HdfsClasspathSetupTest.java
@Test public void testConcurrentUpload() throws IOException, InterruptedException, ExecutionException, TimeoutException { final int concurrency = 10; ListeningExecutorService pool = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(concurrency)); // barrier ensures that all jobs try to add files to classpath at same time. final CyclicBarrier barrier = new CyclicBarrier(concurrency); final DistributedFileSystem fs = miniCluster.getFileSystem(); final Path expectedJarPath = new Path(finalClasspath, dummyJarFile.getName()); List<ListenableFuture<Boolean>> futures = new ArrayList<>(); for (int i = 0; i < concurrency; i++) { futures.add(pool.submit(new Callable() { @Override// w w w . j av a2 s . c om public Boolean call() throws Exception { int id = barrier.await(); Job job = Job.getInstance(conf, "test-job-" + id); Path intermediatePathForJob = new Path(intermediatePath, "job-" + id); JobHelper.addJarToClassPath(dummyJarFile, finalClasspath, intermediatePathForJob, fs, job); // check file gets uploaded to final HDFS path Assert.assertTrue(fs.exists(expectedJarPath)); // check that the intermediate file is not present Assert.assertFalse(fs.exists(new Path(intermediatePathForJob, dummyJarFile.getName()))); // check file gets added to the classpath Assert.assertEquals(expectedJarPath.toString(), job.getConfiguration().get(MRJobConfig.CLASSPATH_FILES)); return true; } })); } Futures.allAsList(futures).get(30, TimeUnit.SECONDS); pool.shutdownNow(); }
From source file:com.sludev.commons.vfs2.provider.azure.AzFileProviderTest.java
@Test public void A003_exist() throws Exception { String currAccountStr = testProperties.getProperty("azure.account.name"); String currKey = testProperties.getProperty("azure.account.key"); String currContainerStr = testProperties.getProperty("azure.test0001.container.name"); String currHost = testProperties.getProperty("azure.host"); // <account>.blob.core.windows.net String currFileNameStr;//www .ja v a 2s. c o m DefaultFileSystemManager currMan = new DefaultFileSystemManager(); currMan.addProvider(AzConstants.AZSBSCHEME, new AzFileProvider()); currMan.init(); StaticUserAuthenticator auth = new StaticUserAuthenticator("", currAccountStr, currKey); FileSystemOptions opts = new FileSystemOptions(); DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, auth); currFileNameStr = "test01.tmp"; String currUriStr = String.format("%s://%s/%s/%s", AzConstants.AZSBSCHEME, currHost, currContainerStr, currFileNameStr); FileObject currFile = currMan.resolveFile(currUriStr, opts); log.info(String.format("exist() file '%s'", currUriStr)); Boolean existRes = currFile.exists(); Assert.assertTrue(existRes); currFileNameStr = "non-existant-file-8632857264.tmp"; currUriStr = String.format("%s://%s/%s/%s", AzConstants.AZSBSCHEME, currAccountStr, currContainerStr, currFileNameStr); currFile = currMan.resolveFile(currUriStr, opts); log.info(String.format("exist() file '%s'", currUriStr)); existRes = currFile.exists(); Assert.assertFalse(existRes); }
From source file:org.openmrs.module.emrapi.account.AccountComponentTest.java
@Test public void shouldUnretireExistingUser() { Person person = personService.getPerson(501); // existing person with retired user account in test dataset AccountDomainWrapper account = accountService.getAccountByPerson(person); account.setUserEnabled(true);/*from w w w .j a va2s. c o m*/ account.save(); Context.flushSession(); Context.clearSession(); User user = userService.getUser(501); Assert.assertFalse(user.isRetired()); Assert.assertNull(user.getDateRetired()); Assert.assertNull(user.getRetiredBy()); Assert.assertNull(user.getRetireReason()); }
From source file:de.clusteval.utils.TestRepositoryObject.java
/** * Test method for// w w w . ja v a 2 s .co m * {@link framework.repository.RepositoryObject#addListener(utils.RepositoryListener)} * . * * @throws RegisterException * */ @Test public void testAddListener() throws RegisterException { /* * Dont add the object itself as a listener */ Assert.assertFalse(this.repositoryObject.addListener(this.repositoryObject)); RepositoryObject other = new StubRepositoryObject(this.getRepository(), false, System.currentTimeMillis(), new File("test2")); Assert.assertTrue(this.repositoryObject.addListener(other)); /* * Already in there */ Assert.assertFalse(this.repositoryObject.addListener(other)); Assert.assertTrue(this.repositoryObject.removeListener(other)); /* * Not in there anymore */ Assert.assertFalse(this.repositoryObject.removeListener(other)); }