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.opencastproject.episode.filesystem.FileSystemElementStoreTest.java

@Test
public void testCopyBad() throws Exception {
    StoragePath from = new StoragePath(ORG_ID, MP_ID, VERSION_1, MP_ELEM_ID);
    StoragePath to = new StoragePath(ORG_ID, MP_ID, VERSION_2, MP_ELEM_ID);
    Assert.assertFalse(repo.copy(from, to));
}

From source file:org.apache.gobblin.writer.AsyncHttpWriterTest.java

/**
 * Test failure triggered by client error. No retries
 *//*w w  w  . j a  v a 2  s  .  c om*/
public void testClientError() {
    MockHttpClient client = new MockHttpClient();
    MockRequestBuilder requestBuilder = new MockRequestBuilder();
    MockResponseHandler responseHandler = new MockResponseHandler();
    MockAsyncHttpWriterBuilder builder = new MockAsyncHttpWriterBuilder(client, requestBuilder,
            responseHandler);
    TestAsyncHttpWriter asyncHttpWriter = new TestAsyncHttpWriter(builder);

    responseHandler.type = StatusType.CLIENT_ERROR;
    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);
    // No retries are done
    Assert.assertTrue(client.attempts == 1);
    Assert.assertTrue(responseHandler.attempts == 1);
}

From source file:io.cloudslang.engine.queue.repositories.ExecutionQueueRepositoryTest.java

@Test
public void testPollForRecovery() {
    List<ExecutionMessage> msg = new ArrayList<>();
    ExecutionMessage execMsg = generateMessage("group1", "msg1", 1);
    execMsg.setWorkerId("worker1");
    execMsg.setStatus(ExecStatus.IN_PROGRESS);
    execMsg.incMsgSeqId();//from  w w w  . ja  v a2 s .co m
    msg.add(execMsg);
    executionQueueRepository.insertExecutionStates(msg);
    executionQueueRepository.insertExecutionQueue(msg, 1L);
    List<ExecutionMessage> result = executionQueueRepository.pollRecovery("worker1", 10,
            ExecStatus.IN_PROGRESS);

    Assert.assertNotNull(result);
    Assert.assertFalse(result.isEmpty());
}

From source file:com.streamreduce.util.JiraClientIT.java

/**
 * Tests {@link JiraClient#getActivity(java.util.Set)}.
 *
 * @throws Exception if anything goes wrong
 *///from  w  w  w.  j  av a 2  s . c o m
@Test
public void testJiraGetActivityParts() throws Exception {
    int maxResults = 100;
    List<Entry> testProjectActivity = jiraClient.getActivity(monitoredProjects, maxResults);

    Assert.assertTrue(testProjectActivity.size() > 0 && testProjectActivity.size() <= maxResults);

    for (Entry activity : testProjectActivity) {
        org.apache.abdera.model.Element activityObjectElement = activity
                .getFirstChild(new QName("http://activitystrea.ms/spec/1.0/", "object", "activity"));
        String projectKey = jiraClient.getProjectKeyOfEntry(activityObjectElement, monitoredProjects);

        // Prepare the inventory item
        inventoryItem.setExternalId(projectKey);

        Map<String, Object> activityParts = jiraClient.getPartsForActivity(inventoryItem, activity);

        Assert.assertNotNull(activityParts);

        String title = (String) activityParts.get("title");
        String content = (String) activityParts.get("content");
        Set<String> hashtags = (Set<String>) activityParts.get("hashtags");
        int expectedHashtagCount = 2; // #jira and #[project.key] is always expected

        try {
            Assert.assertNotNull(title);
            Assert.assertTrue(hashtags.contains("#" + projectKey.toLowerCase()));
            Assert.assertTrue(hashtags.contains("#jira"));

            // No good way to test content since it can be null a few different ways

            if (hashtags.contains("#issue")) {
                // Issue related tests
                expectedHashtagCount += 4; // #issue #[issue-type] #[issue-priority] #[issue-status]

                // There is no good way to test the actual issue hashtags because they could outdated
            } else if (hashtags.contains("#source")) {
                // Source related tests
                expectedHashtagCount += 2; // #source #[activity]

                Assert.assertFalse(hashtags.contains("#file")); // This is an ignored hashtag
                Assert.assertTrue(hashtags.contains("#changeset") || hashtags.contains("#review"));
            } else if (hashtags.contains("#wiki")) {
                // Wiki related tests
                if (!hashtags.contains("#blog") && !hashtags.contains("#page")) {
                    expectedHashtagCount += 1; // #wiki
                } else {
                    expectedHashtagCount += 2; // #wiki #[target]
                }

                Assert.assertFalse(hashtags.contains("#space")); // This is an ignored hashtag
                Assert.assertFalse(hashtags.contains("#article")); // This is an ignored hashtag
                Assert.assertFalse(hashtags.contains("#file")); // This is an ignored hashtag
            } else {
                Assert.fail("All Jira activity hashtags should contain at least one of he following: "
                        + "#issue, #source or #wiki");
            }

            // For comments and attachments, expected hashtags is one extra
            if (hashtags.contains("#comment") || hashtags.contains("#attachment")) {
                expectedHashtagCount += 1;
            }

            if (hashtags.contains("#issue") || (hashtags.contains("#wiki") && !hashtags.contains("#blog"))) {
                Assert.assertTrue(hashtags.size() >= expectedHashtagCount);
            } else {
                Assert.assertEquals(expectedHashtagCount, hashtags.size());
            }
        } catch (AssertionFailedError e) {
            // Add some extra output to make debugging easier
            System.out.println("Problematic title: " + activity.getTitle());
            System.out.println("Hashtags (Expected: " + expectedHashtagCount + "):");
            for (String hashtag : hashtags) {
                System.out.println("  " + hashtag);
            }
            throw e;
        }
    }
}

From source file:com.ibm.team.build.internal.hjplugin.tests.BuildConfigurationIT.java

public void testComponentLoading() throws Exception {
    // Test relative location for fetch destination
    // Test create folders for components
    // Test include/exclude components from the load

    // setup build request & verify BuildConfiguration
    // checkout & verify contents on disk
    if (Config.DEFAULT.isConfigured()) {

        String testName = getTestName() + System.currentTimeMillis();
        String fetchLocation = "path\\relative";
        RTCLoginInfo loginInfo = Config.DEFAULT.getLoginInfo();

        @SuppressWarnings("unchecked")
        Map<String, String> setupArtifacts = (Map<String, String>) testingFacade.invoke("testComponentLoading",
                new Class[] { String.class, // serverURL,
                        String.class, // userId,
                        String.class, // password,
                        int.class, // timeout,
                        String.class, // workspaceName,
                        String.class, // componentName,
                        String.class, // hjPath,
                        String.class }, // buildPath
                loginInfo.getServerUri(), loginInfo.getUserId(), loginInfo.getPassword(),
                loginInfo.getTimeout(), testName, getTestName(), sandboxDir.getPath(), fetchLocation);

        try {/*from w ww .ja v  a2 s .co m*/
            TaskListener listener = new StreamTaskListener(System.out, null);

            File changeLogFile = new File(sandboxDir, "RTCChangeLogFile");
            FileOutputStream changeLog = new FileOutputStream(changeLogFile);

            // checkout the changes
            @SuppressWarnings("unchecked")
            Map<String, String> buildProperties = (Map<String, String>) testingFacade.invoke("checkout",
                    new Class[] { String.class, // serverURL,
                            String.class, // userId,
                            String.class, // password,
                            int.class, // timeout,
                            String.class, // buildResultUUID,
                            String.class, // workspaceName,
                            String.class, // hjWorkspacePath,
                            OutputStream.class, // changeLog,
                            String.class, // baselineSetName,
                            Object.class, // listener
                            Locale.class }, // clientLocale
                    loginInfo.getServerUri(), loginInfo.getUserId(), loginInfo.getPassword(),
                    loginInfo.getTimeout(), setupArtifacts.get("buildResultItemId"), null,
                    sandboxDir.getCanonicalPath(), changeLog, "Snapshot", listener, Locale.getDefault());

            String[] children = sandboxDir.list();
            Assert.assertEquals(2, children.length); // changelog plus what we loaded
            File actualRoot = new File(sandboxDir, "path\\relative");
            Assert.assertTrue(actualRoot.exists());
            children = actualRoot.list();
            assertEquals(2, children.length); // metadata plus component root folder
            File shareRoot = new File(actualRoot, getTestName());
            Assert.assertTrue(shareRoot.exists());
            Assert.assertTrue(new File(shareRoot, "f").exists());
            Assert.assertTrue(new File(shareRoot, "f/a.txt").exists());

            RTCChangeLogParser parser = new RTCChangeLogParser();
            FileReader changeLogReader = new FileReader(changeLogFile);
            RTCChangeLogSet result = (RTCChangeLogSet) parser.parse(null, null, changeLogReader);

            // verify the result
            int changeCount = result.getComponentChangeCount() + result.getChangeSetsAcceptedCount()
                    + result.getChangeSetsDiscardedCount();
            Assert.assertFalse(result.isPersonalBuild());

            validateBuildProperties(setupArtifacts.get(ARTIFACT_WORKSPACE_ITEM_ID), fetchLocation, false, true,
                    "", true, setupArtifacts.get(ARTIFACT_COMPONENT1_ITEM_ID), result.getBaselineSetItemId(),
                    changeCount, true, buildProperties);

        } finally {
            // clean up
            testingFacade.invoke("tearDown", new Class[] { String.class, // serverURL,
                    String.class, // userId,
                    String.class, // password,
                    int.class, // timeout,
                    Map.class }, // setupArtifacts
                    loginInfo.getServerUri(), loginInfo.getUserId(), loginInfo.getPassword(),
                    loginInfo.getTimeout(), setupArtifacts);
        }
    }
}

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

@Test
public void testPaperMedicalRecordExistsForPatientShouldReturnFalseIfWrongIdentifierType() {

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

    // this identifier exists in the standard test data set, but it is paper record identifier, not a patient identifier
    Assert.assertFalse(paperRecordService.paperRecordExistsForPatientWithPrimaryIdentifier("CATBALL",
            medicalRecordLocation));/*from   w ww.  j  a v  a  2s . c  o  m*/
}

From source file:de.clusteval.data.goldstandard.TestGoldStandardConfig.java

/**
 * Test method for {@link data.goldstandard.GoldStandardConfig#register()}.
 * //from ww w  .  j  a  v a2 s  .c o m
 * @throws GoldStandardNotFoundException
 * @throws NoRepositoryFoundException
 * @throws IOException
 * @throws GoldStandardConfigurationException
 * @throws RegisterException
 * @throws UnknownRunDataStatisticException
 * @throws UnknownRunStatisticException
 * @throws UnknownDataStatisticException
 * @throws NoOptimizableProgramParameterException
 * @throws UnknownParameterOptimizationMethodException
 * @throws IncompatibleParameterOptimizationMethodException
 * @throws IncompatibleDataSetConfigPreprocessorException
 * @throws UnknownDataPreprocessorException
 * @throws UnknownDataSetTypeException
 * @throws UnknownDistanceMeasureException
 * @throws UnknownRProgramException
 * @throws UnknownProgramTypeException
 * @throws UnknownProgramParameterException
 * @throws InvalidOptimizationParameterException
 * @throws UnknownRunResultFormatException
 * @throws IncompatibleContextException
 * @throws RunException
 * @throws UnknownClusteringQualityMeasureException
 * @throws UnknownParameterType
 * @throws UnknownContextException
 * @throws ConfigurationException
 * @throws NumberFormatException
 * @throws DataConfigNotFoundException
 * @throws DataConfigurationException
 * @throws NoDataSetException
 * @throws DataSetConfigNotFoundException
 * @throws DataSetNotFoundException
 * @throws DataSetConfigurationException
 * @throws UnknownDataSetFormatException
 */
public void testRegister() throws GoldStandardConfigurationException, IOException, NoRepositoryFoundException,
        GoldStandardNotFoundException, GoldStandardConfigNotFoundException, RegisterException,
        UnknownDataSetFormatException, DataSetConfigurationException, DataSetNotFoundException,
        DataSetConfigNotFoundException, NoDataSetException, DataConfigurationException,
        DataConfigNotFoundException, NumberFormatException, ConfigurationException, UnknownContextException,
        UnknownParameterType, UnknownClusteringQualityMeasureException, RunException,
        IncompatibleContextException, UnknownRunResultFormatException, InvalidOptimizationParameterException,
        UnknownProgramParameterException, UnknownProgramTypeException, UnknownRProgramException,
        UnknownDistanceMeasureException, UnknownDataSetTypeException, UnknownDataPreprocessorException,
        IncompatibleDataSetConfigPreprocessorException, IncompatibleParameterOptimizationMethodException,
        UnknownParameterOptimizationMethodException, NoOptimizableProgramParameterException,
        UnknownDataStatisticException, UnknownRunStatisticException, UnknownRunDataStatisticException {
    this.repositoryObject = Parser.parseFromFile(GoldStandardConfig.class,
            new File("testCaseRepository/data/goldstandards/configs/DS1_1.gsconfig").getAbsoluteFile());
    Assert.assertEquals(this.repositoryObject,
            this.getRepository().getRegisteredObject((GoldStandardConfig) this.repositoryObject));

    // adding a GoldStandardConfig equal to another one already registered
    // does
    // not register the second object.
    this.repositoryObject = new GoldStandardConfig((GoldStandardConfig) this.repositoryObject);
    Assert.assertEquals(this.getRepository().getRegisteredObject((GoldStandardConfig) this.repositoryObject),
            this.repositoryObject);
    Assert.assertFalse(this.getRepository()
            .getRegisteredObject((GoldStandardConfig) this.repositoryObject) == this.repositoryObject);
}

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

@Test
public void testDeleteChunkWillDeleteChunkFromStorage() {
    Location location1 = helpers.newLocation("world", 123, 321);
    ChunkData chunk1 = helpers.newChunkData("player", new ArrayList<String>(), location1);
    chunk1 = systemUnderTest.addChunk(chunk1);
    systemUnderTest.writeChunkToStorage(chunk1);

    Assert.assertTrue(chunk1.getFile().exists());
    systemUnderTest.deleteChunk(chunk1);
    Assert.assertFalse(chunk1.getFile().exists());
}

From source file:com.impetus.kundera.rest.resources.PolyglotQueryTest.java

@Test
public void testUserCRUD() throws JsonParseException, JsonMappingException, IOException {
    WebResource webResource = resource();
    restClient = new RESTClientImpl();
    restClient.initialize(webResource, mediaType);

    buildUser1Str();/*ww w .  j  ava2s . co m*/
    // Get Application Token
    applicationToken = restClient.getApplicationToken(_PU, null);
    Assert.assertNotNull(applicationToken);
    applicationToken = applicationToken.replaceAll("^\"|\"$", "");
    Assert.assertTrue(applicationToken.startsWith("AT_"));

    // Get Session Token
    sessionToken = restClient.getSessionToken(applicationToken);
    Assert.assertNotNull(sessionToken);
    sessionToken = sessionToken.replaceAll("^\"|\"$", "");
    Assert.assertTrue(sessionToken.startsWith("ST_"));

    // Insert Record
    String insertResponse1 = restClient.insertEntity(sessionToken, userString,
            UserCassandra.class.getSimpleName());

    Assert.assertNotNull(insertResponse1);
    Assert.assertTrue(insertResponse1.indexOf("200") > 0);

    // Find Record
    String foundUser = restClient.findEntity(sessionToken, "0001", UserCassandra.class.getSimpleName());
    Assert.assertNotNull(foundUser);
    Assert.assertTrue(foundUser.indexOf("0001") > 0);

    foundUser = foundUser.substring(1, foundUser.length() - 1);
    Map<String, Object> userDetails = new HashMap<String, Object>();
    ObjectMapper mapper = new ObjectMapper();
    userDetails = mapper.readValue(foundUser, userDetails.getClass());
    foundUser = mapper.writeValueAsString(userDetails.get("usercassandra"));

    // Update Record
    foundUser = foundUser.replaceAll("163.12", "165.21");

    String updatedUser = restClient.updateEntity(sessionToken, foundUser, UserCassandra.class.getSimpleName());

    Assert.assertNotNull(updatedUser);
    Assert.assertTrue(updatedUser.indexOf("165.21") > 0);

    /** JPA Query - Select */
    // Get All Professionals
    String jpaQuery = "select p from " + UserCassandra.class.getSimpleName() + " p";
    String queryResult = restClient.runJPAQuery(sessionToken, jpaQuery, new HashMap<String, Object>());
    log.debug("Query Result:" + queryResult);

    Assert.assertNotNull(queryResult);
    Assert.assertFalse(StringUtils.isEmpty(queryResult));
    Assert.assertTrue(queryResult.indexOf("usercassandra") > 0);
    Assert.assertTrue(queryResult.indexOf("0001") > 0);
    Assert.assertTrue(queryResult.indexOf("0002") > 0);
    Assert.assertTrue(queryResult.indexOf("0003") > 0);

    Assert.assertTrue(queryResult.indexOf("Motif") < 0);

    jpaQuery = "select p from " + UserCassandra.class.getSimpleName() + " p WHERE p.userId = :userId";
    Map<String, Object> params = new HashMap<String, Object>();

    params.put("userId", "0001");

    queryResult = restClient.runObjectJPAQuery(sessionToken, jpaQuery, params);
    log.debug("Query Result:" + queryResult);

    Assert.assertNotNull(queryResult);
    Assert.assertFalse(StringUtils.isEmpty(queryResult));
    Assert.assertTrue(queryResult.indexOf("usercassandra") > 0);
    Assert.assertTrue(queryResult.indexOf("0001") > 0);

    Assert.assertTrue(queryResult.indexOf("Motif") < 0);

    /** JPA Query - Select All */
    // Get All Professionals
    String allUsers = restClient.getAllEntities(sessionToken, UserCassandra.class.getSimpleName());
    log.debug(allUsers);
    Assert.assertNotNull(allUsers);

    // Close Session
    restClient.closeSession(sessionToken);

    // Close Application
    restClient.closeApplication(applicationToken);
}

From source file:es.tekniker.framework.ktek.questionnaire.mng.server.test.TestQuestionnaireMngServer.java

public void testSaveKtekQuestionnaireAssesment1() {
    log.info("*************************************************************");
    log.info("testSaveKtekQuestionnaireAssesment1: START ");
    String result = TestDefines.RESULT_OK;

    String token = null;//from w  w  w  .  j  av  a2  s. c  o  m
    KtekQuestionnaireResultEntity resultData = null;
    QuestionnaireMngServer manager = new QuestionnaireMngServer();
    int boolOK = 0;

    try {

        token = TestData.getLoginToken();
        resultData = es.tekniker.framework.ktek.questionnaire.mng.db.TestData
                .getKtekQuestionnaireAssessmentResultEntity1();

        boolOK = manager.saveQuestionnaireModel(token, resultData);

        if (boolOK == 1) {
            log.info("testSaveKtekQuestionnaireAssesment1: SAVE OK ");
            Assert.assertTrue(true);
        } else {
            log.error("testSaveKtekQuestionnaireAssesment1: SAVE ERROR ");
            result = TestDefines.RESULT_ERROR;
            Assert.assertTrue(false);
        }

    } catch (KtekExceptionEntity e) {
        System.out.println("testSaveKtekQuestionnaireAssesment1:  exception " + e.getMessage());
        e.printStackTrace();
        Assert.assertFalse(false);
    }

    log.info("testSaveKtekQuestionnaireAssesment1: RESULT " + result);
    log.info("testSaveKtekQuestionnaireAssesment1: END ");
    log.info("*************************************************************");
    log.info("");

}