Example usage for junit.framework Assert assertFalse

List of usage examples for junit.framework Assert assertFalse

Introduction

In this page you can find the example usage for junit.framework Assert assertFalse.

Prototype

static public void assertFalse(boolean condition) 

Source Link

Document

Asserts that a condition is false.

Usage

From source file:org.openmrs.module.printer.PrinterServiceComponentTest.java

@Test
public void testAllowDuplicateIpAddressesIfAddressIsLocalHost() {

    Printer localPrinter = new Printer();
    localPrinter.setName("Local printer");
    localPrinter.setIpAddress("127.0.0.1");
    localPrinter.setType(PrinterType.LABEL);
    printerService.savePrinter(localPrinter);

    Printer anotherPrinter = new Printer();
    anotherPrinter.setName("Another printer");
    anotherPrinter.setIpAddress("127.0.0.1");
    anotherPrinter.setType(PrinterType.ID_CARD);

    Assert.assertFalse(printerService.isIpAddressAllocatedToAnotherPrinter(anotherPrinter));

}

From source file:org.alfresco.mobile.android.test.api.services.ActivityStreamServiceTest.java

/**
 * All Tests forActivityStreamService public methods which don't create an
 * error./*from   ww  w . j a va 2 s .  c  o  m*/
 * 
 * @Requirement 1S3, 1S4, 2F1,2F2, 2F3, 2F4, 2S1, 2S6, 2S7, 2S8, 2S9, 3S3,
 *              3S4, 4F1, 4F2, 4F3, 4F4, 4S6, 4S7, 4S8, 4S9, 5S3, 6F4, 6F6,
 *              6F7, 6S6, 6S7, 6S8, 6S9
 */
public void testActivityStreamService() {
    try {
        prepareScriptData();

        // ///////////////////////////////////////////////////////////////////////////
        // Method getActivityStream()
        // ///////////////////////////////////////////////////////////////////////////
        List<ActivityEntry> feed = activityStreamService.getActivityStream();
        if (feed == null || feed.isEmpty()) {
            // Log.d("ActivityStreamService",
            // "No stream activities available. Test aborted.");
            return;
        }
        int totalItems = feed.size();
        Assert.assertNotNull(feed);
        Assert.assertFalse(feed.isEmpty());

        // Sorting with listinContext and sort property : Sort is not
        // supported
        // by ActivityStreamService
        wait(10000);
        ListingContext lc = new ListingContext();
        lc.setSortProperty(DocumentFolderService.SORT_PROPERTY_DESCRIPTION);
        PagingResult<ActivityEntry> feedUnSorted = activityStreamService.getActivityStream(lc);
        Assert.assertEquals(lc.getMaxItems(), feedUnSorted.getList().size());
        Assert.assertEquals(feed.get(0).getIdentifier(), feed.get(0).getIdentifier());
        // ///////////////////////////////////////////////////////////////////////////
        // Paging ALL Activity Entry
        // ///////////////////////////////////////////////////////////////////////////
        lc = new ListingContext();
        lc.setMaxItems(5);
        lc.setSkipCount(0);

        // Check 1 activity
        PagingResult<ActivityEntry> pagingFeed = activityStreamService.getActivityStream(lc);
        Assert.assertNotNull(pagingFeed);
        Assert.assertEquals(5, pagingFeed.getList().size());
        Assert.assertEquals(getTotalItems(feed.size()), pagingFeed.getTotalItems());
        Assert.assertTrue(pagingFeed.hasMoreItems());

        // Check 0 activity if outside of total item
        lc.setMaxItems(10);
        lc.setSkipCount(feed.size());
        pagingFeed = activityStreamService.getActivityStream(lc);
        Assert.assertNotNull(pagingFeed);
        Assert.assertEquals(getTotalItems(feed.size()), pagingFeed.getTotalItems());
        Assert.assertEquals(hasMoreItem(), pagingFeed.hasMoreItems());

        // OnPremise max is 100 and not the case for cloud.
        if (isOnPremise()) {
            Assert.assertEquals(0, pagingFeed.getList().size());
        } else {
            Assert.assertEquals(10, pagingFeed.getList().size());
        }

        // Check feed.size() activity
        lc.setMaxItems(feed.size());
        lc.setSkipCount(0);
        pagingFeed = activityStreamService.getActivityStream(lc);
        Assert.assertNotNull(pagingFeed);
        Assert.assertEquals(feed.size(), pagingFeed.getList().size());
        Assert.assertEquals(getTotalItems(feed.size()), pagingFeed.getTotalItems());
        Assert.assertEquals(hasMoreItem(), pagingFeed.hasMoreItems());

        // ////////////////////////////////////////////////////
        // Incorrect Listing Context Value
        // ////////////////////////////////////////////////////
        // Incorrect settings in listingContext: Such as inappropriate
        // maxItems
        // (0)
        lc.setSkipCount(0);
        lc.setMaxItems(-1);
        pagingFeed = activityStreamService.getActivityStream(lc);
        Assert.assertNotNull(pagingFeed);
        Assert.assertEquals(getTotalItems(totalItems), pagingFeed.getTotalItems());
        Assert.assertEquals(
                (totalItems > ListingContext.DEFAULT_MAX_ITEMS) ? ListingContext.DEFAULT_MAX_ITEMS : totalItems,
                pagingFeed.getList().size());
        Assert.assertEquals(Boolean.TRUE, pagingFeed.hasMoreItems());

        // Incorrect settings in listingContext: Such as inappropriate
        // maxItems
        // (-1)
        lc.setSkipCount(0);
        lc.setMaxItems(-1);
        pagingFeed = activityStreamService.getActivityStream(lc);
        Assert.assertNotNull(pagingFeed);
        Assert.assertEquals(getTotalItems(totalItems), pagingFeed.getTotalItems());
        Assert.assertEquals(
                (totalItems > ListingContext.DEFAULT_MAX_ITEMS) ? ListingContext.DEFAULT_MAX_ITEMS : totalItems,
                pagingFeed.getList().size());
        Assert.assertEquals(Boolean.TRUE, pagingFeed.hasMoreItems());

        // Incorrect settings in listingContext: Such as inappropriate
        // skipcount
        // (-12)
        lc.setSkipCount(-12);
        lc.setMaxItems(5);
        pagingFeed = activityStreamService.getActivityStream(lc);
        Assert.assertNotNull(pagingFeed);
        Assert.assertEquals(getTotalItems(totalItems), pagingFeed.getTotalItems());
        Assert.assertEquals(5, pagingFeed.getList().size());
        Assert.assertTrue(pagingFeed.hasMoreItems());

        // List by User
        List<ActivityEntry> feed2 = activityStreamService.getActivityStream(alfsession.getPersonIdentifier());
        Assert.assertNotNull(feed2);

        // List with fake user
        Assert.assertNotNull(activityStreamService.getActivityStream(FAKE_USERNAME));
        Assert.assertEquals(0, activityStreamService.getActivityStream(FAKE_USERNAME).size());

        // List by site
        List<ActivityEntry> feed3 = activityStreamService.getSiteActivityStream(getSiteName(alfsession));
        Assert.assertNotNull(feed3);

        // ///////////////////////////////////////////////////////////////////////////
        // Activity Entry
        // ///////////////////////////////////////////////////////////////////////////
        ActivityEntry entry = feed.get(0);
        Assert.assertNotNull(entry.getIdentifier());
        Assert.assertNotNull(entry.getType());
        Assert.assertNotNull(entry.getCreatedBy());
        Assert.assertNotNull(entry.getCreatedAt());
        Assert.assertNotNull(entry.getSiteShortName());
        Assert.assertNotNull(entry.getData());

        // ///////////////////////////////////////////////////////////////////////////
        // Paging User Activity Entry
        // ///////////////////////////////////////////////////////////////////////////
        wait(10000);

        // Check consistency between Cloud and OnPremise
        if (!isOnPremise()) {
            // Check 1 activity
            lc.setMaxItems(1);
            lc.setSkipCount(0);
            pagingFeed = activityStreamService.getActivityStream(alfsession.getPersonIdentifier(), lc);
            Assert.assertNotNull(pagingFeed);
            Assert.assertEquals(1, pagingFeed.getList().size());
            // Assert.assertTrue(feed2.size() == pagingFeed.getTotalItems()
            // ||
            // feed2.size() - 1 == pagingFeed.getTotalItems());
            Assert.assertTrue(pagingFeed.hasMoreItems());
        }

        // ///////////////////////////////////////////////////////////////////////////
        // Paging Site Activity Entry
        // ///////////////////////////////////////////////////////////////////////////
        // Check 1 activity
        lc.setMaxItems(1);
        lc.setSkipCount(0);
        pagingFeed = activityStreamService.getSiteActivityStream(getSiteName(alfsession), lc);
        Assert.assertNotNull(pagingFeed);
        Assert.assertEquals(1, pagingFeed.getList().size());
        // Assert.assertTrue(feed3.size() == pagingFeed.getTotalItems() ||
        // feed3.size() - 1 == pagingFeed.getTotalItems());
        if (feed3.size() > 1) {
            Assert.assertTrue(pagingFeed.hasMoreItems());
        } else {
            Assert.assertFalse(pagingFeed.hasMoreItems());
        }
    } catch (Exception e) {
        Log.e(TAG, "Error during Activity Tests");
        Log.e("TAG", Log.getStackTraceString(e));
    }
}

From source file:com.github.ipaas.ideploy.agent.handler.UpdateCodeHandlerTest.java

/**
 * ??,???,// w  w w.j a  va  2  s.c  o m
 * 
 * @throws Exception
 */
@Test
public void updateCodeTest() throws Exception {
    String usingRoot = "/www/apptemp/" + USING_VERSION;
    String doingRoot = "/www/apptemp/" + DOING_VERSION;
    DownloadCodeHandler downLoadHandler = new DownloadCodeHandler();
    File usingfile = new File(usingRoot);
    if (usingfile.exists()) {
        FileUtils.forceDelete(usingfile);
    }
    File doingFile = new File(doingRoot);
    if (doingFile.exists()) {
        FileUtils.forceDelete(doingFile);
    }

    String flowId = "flowIdNotNeed";
    String cmd = "cmdNotNeed";
    Integer hostStatus4New = 1;
    Integer updateAll = 1;
    Map<String, Object> firstDownLoadParams = new HashMap<String, Object>();
    firstDownLoadParams.put("doingCodeVerPath", TEST_GROUP + TAGS + "/" + USING_VERSION);
    firstDownLoadParams.put("hostStatus", hostStatus4New);
    firstDownLoadParams.put("savePath", usingRoot);// ??
    firstDownLoadParams.put("updateAll", updateAll);
    downLoadHandler.execute(flowId, cmd, firstDownLoadParams, null);

    Assert.assertTrue(new File(usingRoot + "/update.txt").exists());

    Integer notUpdateAll = 2;
    Integer hostStatus4Old = 2;
    Map<String, Object> secondDownLoadParams = new HashMap<String, Object>();
    secondDownLoadParams.put("doingCodeVerPath", TEST_GROUP + TAGS + "/" + DOING_VERSION);
    secondDownLoadParams.put("usingCodeVerPath", TEST_GROUP + TAGS + "/" + USING_VERSION);
    secondDownLoadParams.put("hostStatus", hostStatus4Old);
    secondDownLoadParams.put("savePath", doingRoot);// ??
    secondDownLoadParams.put("updateAll", notUpdateAll);
    downLoadHandler.execute(flowId, cmd, secondDownLoadParams, null);
    File updateFile = new File(doingRoot + "/update.txt");
    List<String> updateList = FileUtils.readLines(updateFile);
    UpdateCodeHandler updateHandler = new UpdateCodeHandler();
    Map<String, Object> updateParam = new HashMap<String, Object>();
    updateParam.put("targetPath", usingRoot + "/code");
    updateParam.put("srcPath", doingRoot);
    updateHandler.execute(null, null, updateParam, null);// ?doingRoot?usingRoot

    // ?
    // String do

    for (String str : updateList) {
        if (str.startsWith("+")) {
            Assert.assertTrue(
                    new File(usingRoot + "/code" + StringUtils.removeStart(str, "+").trim()).exists());
        } else if (str.startsWith("-")) {
            String f = usingRoot + "/code" + StringUtils.removeStart(str, "-").trim();
            Assert.assertFalse(new File(f).exists());
        }
    }

    if (usingfile.exists()) {
        FileUtils.forceDelete(usingfile);
    }

}

From source file:com.google.api.ads.adwords.jaxws.extensions.report.model.definitions.ReportKeywordDefinitionTest.java

/**
 * @see com.google.api.ads.adwords.jaxws.extensions.report.model.definitions.
 * AbstractReportDefinitionTest#testLastEntry(
 * com.google.api.ads.adwords.jaxws.extensions.report.model.entities.Report)
 *//*from   w  ww  .java2  s .c om*/
@Override
protected void testLastEntry(ReportKeyword last) {

    Assert.assertEquals(8661954824L, last.getAccountId().longValue());
    Assert.assertEquals("2013-05-10", last.getDay());
    Assert.assertEquals(0.00, last.getCostBigDecimal().doubleValue());
    Assert.assertEquals(0L, last.getClicks().longValue());
    Assert.assertEquals(1L, last.getImpressions().longValue());
    Assert.assertEquals(0L, last.getConversions().longValue());
    Assert.assertEquals(0.00, last.getCtrBigDecimal().doubleValue());
    Assert.assertEquals(0.00, last.getAvgCpmBigDecimal().doubleValue());
    Assert.assertEquals(0.00, last.getAvgCpcBigDecimal().doubleValue());
    Assert.assertEquals(6.00, last.getAvgPositionBigDecimal().doubleValue());
    Assert.assertEquals("EUR", last.getCurrencyCode());

    Assert.assertEquals(86352677L, last.getCampaignId().longValue());
    Assert.assertEquals(3398915357L, last.getAdGroupId().longValue());
    Assert.assertEquals(44877775648L, last.getKeywordId().longValue());
    Assert.assertEquals("enabled", last.getStatus());
    Assert.assertEquals(10.00, last.getQualityScoreAsBigDecimal().doubleValue());
    Assert.assertEquals("Broad", last.getKeywordMatchType());
    Assert.assertEquals("propriete sologne a vendre", last.getKeywordText());
    Assert.assertEquals("", last.getDestinationUrl());
    Assert.assertFalse(last.isNegative());

}

From source file:org.apache.sling.etcd.testing.EtcdHandlerTest.java

@Test
public void testDoGetExistingFolderNonRecursiveSorted() throws Exception {
    server = startServer(new EtcdHandler(new Etcd(TestContent.build())), "/v2/keys/*");
    HttpGet get = new HttpGet("http://localhost:" + serverPort(server) + "/v2/keys/b?sorted=true");
    CloseableHttpResponse response = httpClient.execute(get);
    Assert.assertEquals(200, response.getStatusLine().getStatusCode());
    JSONObject body = body(response);//from w  w w  .  j a va 2s  .c  om
    assertAction(body, "get");
    JSONObject b = body.optJSONObject("node");
    Assert.assertEquals("/b", b.get("key"));
    JSONArray bChildren = b.getJSONArray("nodes");
    Assert.assertEquals(1, bChildren.length());
    JSONObject b1 = bChildren.getJSONObject(0);
    Assert.assertEquals("/b/b1", b1.getString("key"));
    Assert.assertFalse(b1.has("nodes"));
}

From source file:org.thingsplode.server.executors.ExecutorTest.java

@Test
public void testBootNotificationRequest() throws UnknownHostException, InterruptedException, ExecutionException,
        TimeoutException, MessageConversionException {
    Device d = TestFactory.createDevice("test_device_2", "987654321", "1");
    Future<Response> rspHandle = requestGw.execute(
            new BootNotificationRequest(d.getIdentification(), Calendar.getInstance().getTimeInMillis(), d));
    Response rsp = rspHandle.get(30, TimeUnit.SECONDS);
    Assert.assertNotNull("The resposne message cannot be null.", rsp);
    Assert.assertFalse(rsp.isErrorType());
    Assert.assertTrue(rsp.isAcknowledged());
    Assert.assertNotNull("The registration id cannot be null",
            rsp.expectMessageByType(BootNotificationResponse.class).getRegistrationID());
    System.out.println("\n\n RESPONSE");
    System.out.println(rsp.toString());
    System.out.println("\n\n ========");
}

From source file:de.clusteval.utils.TestRepositoryObject.java

/**
 * Test method for/*w ww  . j  av  a 2  s . c o  m*/
 * {@link framework.repository.RepositoryObject#equals(java.lang.Object)}.
 * 
 * @throws Exception
 */
@Test
public void testEqualsObject() throws Exception {
    File f = new File("testCaseRepository/data/goldstandards/DS1/Zachary_karate_club_gold_standard.txt")
            .getAbsoluteFile();
    this.repositoryObject = new StubRepositoryObject(this.getRepository(), false, f.lastModified(), f);

    /*
     * Identity
     */
    Assert.assertEquals(new StubRepositoryObject(this.getRepository(), false, f.lastModified(), f),
            this.repositoryObject);
    /*
     * Mod-date is ignored
     */
    Assert.assertEquals(new StubRepositoryObject(this.getRepository(), false, f.lastModified() - 1, f),
            this.repositoryObject);

    Repository repository2 = new Repository(new File("repository2").getAbsolutePath(), null);

    /*
     * Different repositories
     */
    Assert.assertFalse(
            new StubRepositoryObject(repository2, false, f.lastModified(), f).equals(this.repositoryObject));

    FileUtils.deleteDirectory(new File("repository2").getAbsoluteFile());

    File f2 = new File(
            "testCaseRepository/data/goldstandards/sfld/sfld_brown_et_al_amidohydrolases_families_gold_standard.txt");
    Assert.assertFalse(this.repositoryObject
            .equals(new StubRepositoryObject(this.getRepository(), false, f2.lastModified(), f2)));

    /*
     * Different classes
     */
    Assert.assertFalse(this.repositoryObject
            .equals(new StubRepositoryObject(this.getRepository(), false, f2.lastModified(), f2)));
}

From source file:org.openmrs.module.paperrecord.PaperRecordServiceComponentTest.java

@Test
public void testPaperMedicalRecordExistsReturnsFalseIfPaperMedicalRecordDoesNotExist() {

    // from the standard test dataset
    Location medicalRecordLocation = locationService.getLocation(1);

    // this identifier exists in the standard test data set, but there is no paper record associated with it
    Assert.assertFalse(paperRecordService.paperRecordExistsWithIdentifier("101", medicalRecordLocation));
}

From source file:de.hybris.platform.util.database.TableNameDatabaseMetaDataCallbackTest.java

@Test
public void testDropOnlyTablesWithMyPrefix() throws MetaDataAccessException {

    final String currentPrefix = "dr2_";

    final String otherPrefix = "other_";
    final String nonePrefix = "";

    createTable(dataSource, currentPrefix + "foo");
    createTable(dataSource, currentPrefix + "bar");
    createTable(dataSource, currentPrefix + "boo");

    createTable(dataSource, otherPrefix + "foo");
    createTable(dataSource, otherPrefix + "bar");
    createTable(dataSource, otherPrefix + "boo");

    createTable(dataSource, nonePrefix + "foo");
    createTable(dataSource, nonePrefix + "bar");
    createTable(dataSource, nonePrefix + "boo");

    final TableNameDatabaseMetaDataCallback tablesFilterCallback = new TableNameDatabaseMetaDataCallback(
            defaultQueryProvider, drop2Tenant) {
        @Override//w w w  .j ava2s .  c o  m
        Collection<SlaveTenant> getSlaveTenants() {
            return allSlaves;
        }

    };

    final List<String> tables = (List<String>) JdbcUtils.extractDatabaseMetaData(dataSource,
            tablesFilterCallback);

    Assert.assertTrue(containsIgnoreCase(currentPrefix + "foo", tables));
    Assert.assertTrue(containsIgnoreCase(currentPrefix + "bar", tables));
    Assert.assertTrue(containsIgnoreCase(currentPrefix + "boo", tables));

    Assert.assertFalse(containsIgnoreCase(otherPrefix + "foo", tables));
    Assert.assertFalse(containsIgnoreCase(otherPrefix + "bar", tables));
    Assert.assertFalse(containsIgnoreCase(otherPrefix + "boo", tables));

    Assert.assertFalse(containsIgnoreCase(nonePrefix + "foo", tables));
    Assert.assertFalse(containsIgnoreCase(nonePrefix + "bar", tables));
    Assert.assertFalse(containsIgnoreCase(nonePrefix + "boo", tables));

    testOmmitAdminTables();
}

From source file:com.kmaismith.chunkclaim.Data.DataManagerTest.java

@Test
public void testReadPlayerDataWillCreatePlayerDataWhenNoPlayerDataIsPresent() {
    File playerFile = new File(PlayerData.playerDataFolderPath + File.separator + "playerA.dat");

    Assert.assertFalse(playerFile.exists());

    PlayerData player = systemUnderTest.readPlayerData("playerA");
    systemUnderTest.savePlayerData(player);

    // There are already tests covering the contents being written correctly
    Assert.assertTrue(playerFile.exists());
}