Example usage for junit.framework Assert assertTrue

List of usage examples for junit.framework Assert assertTrue

Introduction

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

Prototype

static public void assertTrue(boolean condition) 

Source Link

Document

Asserts that a condition is true.

Usage

From source file:org.geomajas.gwt2.client.map.layer.VectorLayerTest.java

@Test
public void testShowing() {
    VectorServerLayerImpl layer = new VectorServerLayerImpl(mapConfig, layerInfo, viewPort, eventBus);

    // Scale between 6 and 20 is OK:
    viewPort.applyResolution(viewPort.getResolution(5)); // 32 -> NOK
    Assert.assertFalse(layer.isShowing());

    viewPort.applyResolution(viewPort.getResolution(4)); // 16 -> OK
    Assert.assertTrue(layer.isShowing());

    viewPort.applyResolution(viewPort.getResolution(3)); // 8 -> OK
    Assert.assertTrue(layer.isShowing());

    viewPort.applyResolution(viewPort.getResolution(2)); // 4 -> NOK
    Assert.assertFalse(layer.isShowing());

    viewPort.applyResolution(viewPort.getResolution(1)); // 2 -> NOK
    Assert.assertFalse(layer.isShowing());

    viewPort.applyResolution(viewPort.getResolution(0)); // 1 -> NOK
    Assert.assertFalse(layer.isShowing());

    // Mark as invisible:
    layer.setMarkedAsVisible(false);/* ww  w.j a va2  s .co m*/
    viewPort.applyResolution(viewPort.getResolution(5)); // 32 -> NOK
    Assert.assertFalse(layer.isShowing());

    viewPort.applyResolution(viewPort.getResolution(4)); // 16 -> NOK
    Assert.assertFalse(layer.isShowing());
}

From source file:org.openmrs.module.webservices.rest.web.v1_0.controller.PersonAttributeControllerTest.java

@Test
public void shouldVoidAttribute() throws Exception {
    PersonAttribute personAttribute = service.getPersonAttributeByUuid(attributeUuid);
    Assert.assertFalse(personAttribute.isVoided());
    controller.delete(personUuid, attributeUuid, "unit test", request, response);
    personAttribute = service.getPersonAttributeByUuid(attributeUuid);
    Assert.assertTrue(personAttribute.isVoided());
    Assert.assertEquals("unit test", personAttribute.getVoidReason());
}

From source file:ml.shifu.shifu.core.binning.EqualPopulationBinningTest.java

@Test
public void testBingMerge() {
    List<EqualPopulationBinning> binningList = new ArrayList<EqualPopulationBinning>();
    long start, end;

    for (int i = 0; i < 10; i++) {
        start = System.currentTimeMillis();
        binningList.add(createBinning());
        end = System.currentTimeMillis();
        System.out.println("Spend " + (end - start) + " milli-seconds to create " + i + "-th binning.");
    }//from  w ww  .j  a  v  a2  s .c  o  m

    EqualPopulationBinning binning = createBinning();
    for (int i = 0; i < 10; i++) {
        EqualPopulationBinning another = binningList.get(i);

        start = System.currentTimeMillis();
        binning.mergeBin(another);
        end = System.currentTimeMillis();
        Assert.assertTrue((end - start) < 1000);
    }

    System.out.println(binning.getDataBin().toString());
}

From source file:io.cloudslang.lang.runtime.bindings.OutputsBindingTest.java

@Test
public void testOperationOutputsNoExpressionAtAll() {
    Map<String, Serializable> operationContext = prepareOperationContext();
    Map<String, Serializable> actionReturnValues = new HashMap<>();
    List<Output> outputs = Arrays.asList(createNoExpressionOutput("actionOutputKey1"));

    Map<String, Serializable> boundOutputs = outputsBinding.bindOutputs(operationContext, actionReturnValues,
            EMPTY_SET, outputs);/*  ww w  .  j  a  va  2  s. com*/
    Assert.assertTrue(boundOutputs.containsKey("actionOutputKey1"));
    Assert.assertEquals(null, boundOutputs.get("actionOutputKey1"));
}

From source file:org.ualerts.fixed.web.controller.fixture.ManualEnrollmentControllerTest.java

/**
 * Validate the data returned during a completely clean submission
 */// w  ww.j  a  v  a 2  s  .  c o m
@Test
public void validateGoodSubmission() throws Exception {
    final HttpServletRequest request = context.mock(HttpServletRequest.class);
    final HttpServletResponse resp = context.mock(HttpServletResponse.class);
    final FixtureModel fixture = new FixtureModel();
    final FixtureModel returningFixture = new FixtureModel();
    final BindingResult result = context.mock(BindingResult.class);

    fixture.setId(1L);
    returningFixture.setId(2L);

    context.checking(new Expectations() {
        {
            oneOf(result).hasErrors();
            will(returnValue(false));
            oneOf(fixtureService).createFixture(fixture);
            will(returnValue(returningFixture));
        }
    });

    Map<String, Object> response = controller.handleFormSubmission(request, resp, fixture, result);

    context.assertIsSatisfied();
    Assert.assertNotNull(response);
    Assert.assertTrue((Boolean) response.get("success"));
    Assert.assertNotNull(response.get("fixture"));
    Assert.assertEquals(FixtureModel.class, response.get("fixture").getClass());
    Assert.assertEquals(returningFixture, response.get("fixture"));
}

From source file:com.hybris.datahub.service.impl.DefaultJsonServiceTest.java

/**
 * convertTmallTradesJson/*from   w  ww.jav  a2 s . c o  m*/
 *
 * @throws Exception
 */
@Test
public void convertTmallTradesJson() throws Exception {
    final Class<? extends DefaultJsonServiceTest> instance = getClass();
    if (instance != null) {
        final ClassLoader classLoader = instance.getClassLoader();
        if (classLoader != null) {

            String json = "";
            InputStream resourceAsStream = null;
            try {
                resourceAsStream = classLoader.getResourceAsStream(SAMPLE_TMALL_TRADES_JSON);
                json = IOUtils.toString(resourceAsStream);
            } catch (final IOException e) {
                LOG.error(e.getMessage(), e);
            } finally {
                if (resourceAsStream != null) {
                    try {
                        resourceAsStream.close();
                    } catch (final IOException e) {
                        LOG.error(e.getMessage(), e);
                    }
                }
            }
            final List<Map<String, String>> csv = service.parse(json);
            final Map<String, String> raw = csv.get(0);

            Assert.assertTrue(raw.containsKey("marketplaceStoreName"));
            Assert.assertTrue(raw.containsKey("currency"));
            Assert.assertTrue(raw.containsKey("productCatalogVersion"));
            Assert.assertTrue(raw.containsKey("trades"));

            Assert.assertEquals("CNY", raw.get("currency"));
            Assert.assertEquals("electronics-cnProductCatalog:Online", raw.get("productCatalogVersion"));

            final Map<String, String> rawTrade = service.parse(raw.get("trades")).get(0);

            Assert.assertEquals("2100703549093", rawTrade.get("numIid"));
            Assert.assertEquals("TRADE_CLOSED_BY_TAOBAO", rawTrade.get("status"));
        }
    } else {
        Assert.fail("Class not found.");
    }
}

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

@Test
public void testJiraGetIssueStatuses() throws Exception {
    Assert.assertTrue(jiraClient.getIssueStatuses().size() > 0);
}

From source file:example.crm.CrmIT.java

/**
 * HTTP GET http://localhost:9003/public/index.html
 * returns the index page./*from   w  ww . ja  va 2  s.  com*/
 */
@Test
public void getIndexTest() throws Exception {
    LOG.info("Sent HTTP GET request to get the index.html page");
    url = new URL(INDEX_TEST_URL);
    InputStream in = null;
    try {
        in = url.openStream();
    } catch (IOException e) {
        LOG.error("Error connecting to {}", INDEX_TEST_URL);
        LOG.error(
                "You should build the 'camel-netty4-http' quick start and deploy it to a local Fabric8 before running this test");
        LOG.error("Please read the README.md file in 'camel-netty4-http' quick start root");
        Assert.fail("Connection error");
    }
    String res = getStringFromInputStream(in);
    LOG.info(res);
    Assert.assertTrue(res.contains("Camel REST DSL Example"));
}

From source file:eagle.storage.jdbc.TestJdbcStorage.java

public void testWriteAndRead() throws IOException, QueryCompileException {
    // record insert init time
    long startTime = System.currentTimeMillis();
    // Write 1000 entities
    List<TestTimeSeriesAPIEntity> entityList = new ArrayList<TestTimeSeriesAPIEntity>();
    int i = 0;//from w  w w  .  j ava  2s.c  o m
    while (i++ < 1000) {
        entityList.add(newInstance());
    }
    ModifyResult<String> result = storage.create(entityList, entityDefinition);
    Assert.assertTrue(result.getSize() >= 1000);
    // record insertion finish time
    long endTime = System.currentTimeMillis();

    // init read in time range [startTime, endTime)
    RawQuery rawQuery = new RawQuery();
    rawQuery.setQuery("TestTimeSeriesAPIEntity[]{*}");
    rawQuery.setStartTime(DateTimeUtil.millisecondsToHumanDateWithSeconds(startTime));
    rawQuery.setEndTime(DateTimeUtil.millisecondsToHumanDateWithSeconds(endTime + 1));
    rawQuery.setPageSize(1000000);
    CompiledQuery query = new CompiledQuery(rawQuery);
    QueryResult queryResult = storage.query(query, entityDefinition);
    Assert.assertTrue(queryResult.getSize() >= 1000);
}

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

@Test
public void testAfterPropertiesSet3() {
    final StaticApplicationContext appContext;
    final AutowiredRemoteServiceGroupConfig config;

    appContext = new StaticApplicationContext();
    appContext.registerSingleton("testService1", TestService1Impl.class);

    config = new AutowiredRemoteServiceGroupConfig();
    config.setBasePackages(Arrays.asList(new String[] { "de.itsvs.cwtrpc.controller.config2." }));
    config.setApplicationContext(appContext);
    config.afterPropertiesSet();//from w  ww.j a v  a 2 s  .c o  m

    Assert.assertTrue(config.getChildGroupConfigs().isEmpty());
    Assert.assertEquals(0, config.getServiceConfigs().size());
}