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:io.cloudslang.lang.runtime.steps.ExecutableStepsTest.java

@Test
public void testFinishExecutableEvents() {
    List<Output> possibleOutputs = Arrays.asList(new Output("name", "name"));
    List<Result> possibleResults = Arrays.asList(new Result(ScoreLangConstants.SUCCESS_RESULT, "true"));
    RunEnvironment runEnv = new RunEnvironment();
    runEnv.putReturnValues(new ReturnValues(new HashMap<String, Serializable>(), null));
    runEnv.getExecutionPath().down();//  w  w  w  .  ja v  a 2 s. c o m

    Map<String, Serializable> boundOutputs = new HashMap<>();
    boundOutputs.put("name", "John");
    String boundResult = ScoreLangConstants.SUCCESS_RESULT;

    when(outputsBinding.bindOutputs(isNull(Map.class), anyMapOf(String.class, Serializable.class),
            eq(runEnv.getSystemProperties()), eq(possibleOutputs))).thenReturn(boundOutputs);
    when(resultsBinding.resolveResult(isNull(Map.class), anyMapOf(String.class, Serializable.class),
            eq(runEnv.getSystemProperties()), eq(possibleResults), isNull(String.class)))
                    .thenReturn(boundResult);

    ExecutionRuntimeServices runtimeServices = new ExecutionRuntimeServices();
    executableSteps.finishExecutable(runEnv, possibleOutputs, possibleResults, runtimeServices, "task1",
            ExecutableType.FLOW);

    Collection<ScoreEvent> events = runtimeServices.getEvents();

    Assert.assertFalse(events.isEmpty());
    ScoreEvent boundOutputEvent = null;
    ScoreEvent startOutputEvent = null;
    ScoreEvent executableFinishedEvent = null;
    for (ScoreEvent event : events) {
        if (event.getEventType().equals(ScoreLangConstants.EVENT_OUTPUT_END)) {
            boundOutputEvent = event;
        } else if (event.getEventType().equals(ScoreLangConstants.EVENT_OUTPUT_START)) {
            startOutputEvent = event;
        } else if (event.getEventType().equals(ScoreLangConstants.EVENT_EXECUTION_FINISHED)) {
            executableFinishedEvent = event;
        }
    }
    Assert.assertNotNull(startOutputEvent);
    LanguageEventData eventData = (LanguageEventData) startOutputEvent.getData();
    Assert.assertTrue(eventData.containsKey(ScoreLangConstants.EXECUTABLE_OUTPUTS_KEY));
    Assert.assertTrue(eventData.containsKey(ScoreLangConstants.EXECUTABLE_RESULTS_KEY));
    List<Output> outputs = (List<Output>) eventData.get(ScoreLangConstants.EXECUTABLE_OUTPUTS_KEY);
    List<Result> results = (List<Result>) eventData.get(ScoreLangConstants.EXECUTABLE_RESULTS_KEY);
    Assert.assertEquals(possibleOutputs, outputs);
    Assert.assertEquals(possibleResults, results);

    Assert.assertNotNull(boundOutputEvent);
    eventData = (LanguageEventData) boundOutputEvent.getData();
    Assert.assertTrue(eventData.containsKey(LanguageEventData.OUTPUTS));
    Map<String, Serializable> returnOutputs = eventData.getOutputs();
    String returnResult = (String) eventData.get(LanguageEventData.RESULT);
    Assert.assertEquals("task1", eventData.getStepName());
    Assert.assertEquals(LanguageEventData.StepType.EXECUTABLE, eventData.getStepType());
    Assert.assertEquals(1, returnOutputs.size());
    Assert.assertEquals("John", returnOutputs.get("name"));
    Assert.assertTrue(returnResult.equals(ScoreLangConstants.SUCCESS_RESULT));

    Assert.assertNotNull(executableFinishedEvent);
    eventData = (LanguageEventData) executableFinishedEvent.getData();
    String result = (String) eventData.get(LanguageEventData.RESULT);
    Map<String, String> eventOutputs = (Map<String, String>) eventData.get(LanguageEventData.OUTPUTS);
    Assert.assertEquals(ScoreLangConstants.SUCCESS_RESULT, result);
    Assert.assertEquals(boundOutputs, eventOutputs);

}

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

/**
 * Test method for/*from  www.jav a 2s  .  c  o m*/
 * {@link framework.repository.RepositoryObject#notify(utils.RepositoryEvent)}
 * .
 * 
 * @throws IOException
 * 
 * @throws NoRepositoryFoundException
 * @throws GoldStandardNotFoundException
 * @throws GoldStandardConfigurationException
 * @throws DataSetConfigurationException
 * @throws DataSetNotFoundException
 * @throws UnknownDataSetFormatException
 * @throws DataSetConfigNotFoundException
 * @throws GoldStandardConfigNotFoundException
 * @throws UnknownDistanceMeasureException
 * @throws RegisterException
 * @throws UnknownDataSetTypeException
 * @throws NoDataSetException
 * @throws UnknownDataPreprocessorException
 * @throws NumberFormatException
 * @throws IncompatibleDataSetConfigPreprocessorException
 */
@SuppressWarnings("unused")
@Test
public void testNotifyRepositoryEvent() throws IOException, NoRepositoryFoundException,
        GoldStandardNotFoundException, GoldStandardConfigurationException, DataSetNotFoundException,
        DataSetConfigurationException, UnknownDataSetFormatException, DataSetConfigNotFoundException,
        GoldStandardConfigNotFoundException, UnknownDistanceMeasureException, RegisterException,
        UnknownDataSetTypeException, NoDataSetException, NumberFormatException,
        UnknownDataPreprocessorException, IncompatibleDataSetConfigPreprocessorException {

    /*
     * Create two stub repository objects
     */
    this.repositoryObject = new StubRepositoryObject(this.getRepository(), false, System.currentTimeMillis(),
            new File("test"));

    StubRepositoryObject other = new StubRepositoryObject(this.getRepository(), false,
            System.currentTimeMillis(), new File("test2"));

    /*
     * Add the "other" object as listener to the first one
     */
    this.repositoryObject.addListener(other);

    Assert.assertFalse(other.notified);

    this.repositoryObject.notify(new RepositoryReplaceEvent(this.repositoryObject, other));

    Assert.assertTrue(other.notified);
    other.notified = false;

    this.repositoryObject.notify(new RepositoryReplaceEvent(other, this.repositoryObject));

    Assert.assertFalse(other.notified);
    other.notified = false;
}

From source file:me.buom.shiro.test.AppTest.java

@Test
@Repeat(times = 3, warmUp = 1)/*from   w  w  w.  java  2  s.  co m*/
public void test_superviser_delete() throws Exception {

    URL url = new URL(baseUrl.toExternalForm() + "superviser_delete");
    HttpGet method = new HttpGet(url.toURI());

    String contentType = "application/json; charset=utf-8";
    Header[] headers = buildHeader(ApiKey.SUPERVISER, method, contentType, null);

    method.setHeaders(headers);

    HttpResponse execute = client.execute(method);
    StatusLine statusLine = execute.getStatusLine();

    printResponse(execute);
    printHeader(execute);

    Assert.assertFalse(statusLine.getStatusCode() != 401);
}

From source file:com.smartitengineering.util.rest.client.jersey.cache.CustomResolverBasedCacheableClientTest.java

@Test
public void testPostNoConsumeProduce() {
    WebResource r = getClient().resource(getUri().path(Resources.METHOD_PATH).build());
    Assert.assertEquals(204, r.path("noconsumeproduce").post(ClientResponse.class).getStatus());

    ClientResponse cr = r.path("noconsumeproduce").post(ClientResponse.class, "POST");
    Assert.assertFalse(cr.hasEntity());
    cr.close();/* w ww  .  j  a  va2s  . c  o m*/
}

From source file:de.itsvs.cwtrpc.controller.AutowiredRemoteServiceGroupConfigTest.java

@Test
public void testIsAcceptedServiceInterface5() {
    final AutowiredRemoteServiceGroupConfig config;

    config = new AutowiredRemoteServiceGroupConfig();
    config.setBasePackages(Arrays.asList(new String[] { "de.itsvs.cwtrpc.controller.config." }));
    config.setIncludeFilters(Arrays.asList(new Pattern[] {
            PatternFactory.compile(PatternType.REGEX, MatcherType.PACKAGE, "de\\..+\\.TestService[13]"),
            PatternFactory.compile(PatternType.REGEX, MatcherType.PACKAGE, "de\\..+\\.TestService5") }));

    Assert.assertTrue(config.isAcceptedServiceInterface(TestService1.class));
    Assert.assertFalse(config.isAcceptedServiceInterface(TestService2.class));
    Assert.assertTrue(config.isAcceptedServiceInterface(TestService3.class));
    Assert.assertTrue(config.isAcceptedServiceInterface(TestService5.class));
}

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

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

    String token = null;/*from w  ww.j a  v  a2s  .c  om*/
    KtekQuestionnaireResultEntity resultData = null;
    QuestionnaireMngServer manager = new QuestionnaireMngServer();
    int boolOK = 0;

    try {

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

        boolOK = manager.saveQuestionnaireModel(token, resultData);

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

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

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

}

From source file:com.ebay.cloud.cms.query.service.QueryPaginationTest.java

@Test
public void testQueryIterSkip01() {
    String query = "ApplicationService.services[@name=~\"srp.*\"].runsOn";
    QueryContext context = newQueryContext(RAPTOR_REPO, RAPTOR_MAIN_BRANCH_ID);
    context.setAllowFullTableScan(true);
    context.setSkips(new int[] { 1, 0, 0 });
    IQueryResult result = queryService.query(query, context);
    Assert.assertFalse(result.hasMoreResults());
    Assert.assertEquals(0, result.getEntities().size());
}

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

@Test
public void testShouldReturnFalseIfAnotherPrinterModelDoesntHaveSameName() {

    PrinterModel differentPrinterModel = new PrinterModel();
    differentPrinterModel.setName("Different Printer Model Name");
    differentPrinterModel.setType(PrinterType.LABEL);
    differentPrinterModel.setPrintHandler(PrinterConstants.SOCKET_PRINT_HANDLER_BEAN_NAME);

    Assert.assertFalse(printerService.isNameAllocatedToAnotherPrinterModel(differentPrinterModel));
}

From source file:de.hybris.platform.b2badmin.services.impl.B2BUnitServiceTest.java

@Test
public void shouldDisableBranchofParentUnit() {
    sessionService.executeInLocalView(new SessionExecutionBody() {
        @Override//  ww  w.  j  av  a  2s . co m
        public void executeWithoutResult() {
            final String userId = "GC CEO";
            login(userId);

            final B2BUnitModel unitUK = b2bUnitService.getUnitForUid("GC Sales UK");

            b2bUnitService.disableBranch(unitUK);

            LOG.debug("Test all units are disabled for : " + unitUK.getUid());

            final Set<B2BUnitModel> allUnitsOfOrganization = b2bUnitService.getBranch(unitUK);

            for (final B2BUnitModel unit : allUnitsOfOrganization) {
                Assert.assertFalse(unit.getActive().booleanValue());
            }
        }
    }, userService.getAdminUser());
}

From source file:com.ebay.cloud.cms.query.service.QueryPaginationTest.java

@Test
public void testQueryIterSkip02() {
    // first round : skip = 7
    String query = "ApplicationService.services[@name=~\"srp.*\"].runsOn";
    raptorContext.setSkips(new int[] { 0, 7 });
    raptorContext.setAllowFullTableScan(true);
    raptorContext.setLimits(new int[] { 0, 0 });
    IQueryResult result0 = queryService.query(query, raptorContext);
    Assert.assertFalse(result0.hasMoreResults());
    Assert.assertEquals(3, result0.getEntities().size());

    // second round : add limit
    raptorContext.setSkips(new int[] { 0, 7 });
    raptorContext.setLimits(new int[] { 0, 2 });
    result0 = queryService.query(query, raptorContext);
    Assert.assertTrue(result0.hasMoreResults());
    Assert.assertEquals(2, result0.getEntities().size());

    // third round : increase skip/limit based on the suggestion
    int[] nextSkips = result0.getNextCursor().getSkips();
    int[] nextLimits = result0.getNextCursor().getLimits();
    int nextHint = result0.getNextCursor().getHint();
    Assert.assertEquals(3, result0.getNextCursor().getSkips().length);
    Assert.assertEquals(9, result0.getNextCursor().getSkips()[1]);
    Assert.assertEquals(1, nextHint);// w w w.  j  a v a  2 s  .  c o m
    raptorContext.setSkips(nextSkips);
    raptorContext.setLimits(nextLimits);
    raptorContext.setHint(nextHint);
    result0 = queryService.query(query, raptorContext);
    Assert.assertFalse(result0.hasMoreResults());
    Assert.assertEquals(1, result0.getEntities().size());

    // fourth round : increase skip/limits to bigger than the available counts
    raptorContext.setSkips(new int[] { 0, 11, 0 });
    raptorContext.setLimits(new int[] { 0, 0, 0 });
    raptorContext.setHint(1);
    IQueryResult result = queryService.query(query, raptorContext);
    Assert.assertFalse(result.hasMoreResults());
    Assert.assertEquals(0, result.getEntities().size());
}