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(String message, boolean condition) 

Source Link

Document

Asserts that a condition is true.

Usage

From source file:net.sf.dynamicreports.test.jasper.chart.BarChartTest.java

@Override
public void test() {
    super.test();

    numberOfPagesTest(1);/*from   w ww.  ja va 2  s .c  om*/

    JFreeChart chart = getChart("summary.chart1", 0);
    CategoryPlot categoryPlot = chart.getCategoryPlot();
    Assert.assertEquals("renderer", BarRenderer.class, categoryPlot.getRenderer().getClass());
    Assert.assertTrue("show labels", categoryPlot.getRenderer().getBaseItemLabelsVisible());
    Assert.assertFalse("show tick labels", categoryPlot.getDomainAxis().isTickMarksVisible());
    Assert.assertFalse("show tick marks", categoryPlot.getDomainAxis().isTickLabelsVisible());

    chart = getChart("summary.chart2", 0);
    Axis axis = chart.getCategoryPlot().getDomainAxis();
    Assert.assertEquals("category label", "category", axis.getLabel());
    Assert.assertEquals("category label color", Color.BLUE, axis.getLabelPaint());
    Assert.assertEquals("category label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont());
    Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint());
    Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont());
    CategoryLabelPosition labelPosition = chart.getCategoryPlot().getDomainAxis().getCategoryLabelPositions()
            .getLabelPosition(RectangleEdge.LEFT);
    Assert.assertEquals("plot label rotation", (45d / 180) * Math.PI, labelPosition.getAngle());
    Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint());

    chart = getChart("summary.chart3", 0);
    axis = chart.getCategoryPlot().getRangeAxis();
    Assert.assertEquals("value label", "value", axis.getLabel());
    Assert.assertEquals("value label color", Color.BLUE, axis.getLabelPaint());
    Assert.assertEquals("value label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont());
    Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint());
    Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont());
    Assert.assertEquals("tick label mask", "10.00", ((NumberAxis) axis).getNumberFormatOverride().format(10));
    Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint());
    Assert.assertEquals("range min value", 1d, ((ValueAxis) axis).getLowerBound());
    Assert.assertEquals("range max value", 15d, ((ValueAxis) axis).getUpperBound());
}

From source file:net.sf.dynamicreports.test.jasper.chart.StackedBarChartTest.java

@Override
public void test() {
    super.test();

    numberOfPagesTest(1);/*from   w w  w .  j  a v  a 2  s .com*/

    JFreeChart chart = getChart("summary.chart1", 0);
    CategoryPlot categoryPlot = chart.getCategoryPlot();
    Assert.assertEquals("renderer", StackedBarRenderer.class, categoryPlot.getRenderer().getClass());
    Assert.assertTrue("show labels", categoryPlot.getRenderer().getBaseItemLabelsVisible());
    Assert.assertFalse("show tick labels", categoryPlot.getDomainAxis().isTickMarksVisible());
    Assert.assertFalse("show tick marks", categoryPlot.getDomainAxis().isTickLabelsVisible());

    chart = getChart("summary.chart2", 0);
    Axis axis = chart.getCategoryPlot().getDomainAxis();
    Assert.assertEquals("category label", "category", axis.getLabel());
    Assert.assertEquals("category label color", Color.BLUE, axis.getLabelPaint());
    Assert.assertEquals("category label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont());
    Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint());
    Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont());
    CategoryLabelPosition labelPosition = chart.getCategoryPlot().getDomainAxis().getCategoryLabelPositions()
            .getLabelPosition(RectangleEdge.LEFT);
    Assert.assertEquals("plot label rotation", (45d / 180) * Math.PI, labelPosition.getAngle());
    Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint());

    chart = getChart("summary.chart3", 0);
    axis = chart.getCategoryPlot().getRangeAxis();
    Assert.assertEquals("value label", "value", axis.getLabel());
    Assert.assertEquals("value label color", Color.BLUE, axis.getLabelPaint());
    Assert.assertEquals("value label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont());
    Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint());
    Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont());
    Assert.assertEquals("tick label mask", "10.00", ((NumberAxis) axis).getNumberFormatOverride().format(10));
    Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint());
    Assert.assertEquals("range min value", 1d, ((ValueAxis) axis).getLowerBound());
    Assert.assertEquals("range max value", 15d, ((ValueAxis) axis).getUpperBound());
}

From source file:eu.stratosphere.pact.runtime.task.CombineTaskExternalITCase.java

@Test
public void testSingleLevelMergeCombineTask() {

    int keyCnt = 8192;
    int valCnt = 8;

    super.initEnvironment(3 * 1024 * 1024);
    super.addInput(new UniformPactRecordGenerator(keyCnt, valCnt, false), 1);
    super.addOutput(this.outList);

    CombineTask<PactRecord> testTask = new CombineTask<PactRecord>();
    super.getTaskConfig().setLocalStrategy(LocalStrategy.COMBININGSORT);
    super.getTaskConfig().setMemorySize(3 * 1024 * 1024);
    super.getTaskConfig().setNumFilehandles(2);

    final int[] keyPos = new int[] { 0 };
    @SuppressWarnings("unchecked")
    final Class<? extends Key>[] keyClasses = (Class<? extends Key>[]) new Class[] { PactInteger.class };
    PactRecordComparatorFactory.writeComparatorSetupToConfig(super.getTaskConfig().getConfiguration(),
            super.getTaskConfig().getPrefixForInputParameters(0), keyPos, keyClasses);

    super.registerTask(testTask, MockCombiningReduceStub.class);

    try {// w  ww .j  a  v  a2  s . com
        testTask.invoke();
    } catch (Exception e) {
        LOG.debug(e);
        Assert.fail("Invoke method caused exception.");
    }

    int expSum = 0;
    for (int i = 1; i < valCnt; i++) {
        expSum += i;
    }

    // wee need to do the final aggregation manually in the test, because the
    // combiner is not guaranteed to do that
    HashMap<PactInteger, PactInteger> aggMap = new HashMap<PactInteger, PactInteger>();
    for (PactRecord record : this.outList) {
        PactInteger key = new PactInteger();
        PactInteger value = new PactInteger();
        key = record.getField(0, key);
        value = record.getField(1, value);
        PactInteger prevVal = aggMap.get(key);
        if (prevVal != null) {
            aggMap.put(key, new PactInteger(prevVal.getValue() + value.getValue()));
        } else {
            aggMap.put(key, value);
        }
    }

    Assert.assertTrue("Resultset size was " + aggMap.size() + ". Expected was " + keyCnt,
            aggMap.size() == keyCnt);

    for (PactInteger integer : aggMap.values()) {
        Assert.assertTrue("Incorrect result", integer.getValue() == expSum);
    }

    this.outList.clear();

}

From source file:net.sf.dynamicreports.test.jasper.chart.WaterfallBarChartTest.java

@Override
public void test() {
    super.test();

    numberOfPagesTest(1);/*from ww w . j  ava  2s  .  com*/

    JFreeChart chart = getChart("summary.chart1", 0);
    CategoryPlot categoryPlot = chart.getCategoryPlot();
    Assert.assertEquals("renderer", WaterfallBarRenderer.class, categoryPlot.getRenderer().getClass());
    Assert.assertTrue("show labels", categoryPlot.getRenderer().getBaseItemLabelsVisible());
    Assert.assertFalse("show tick labels", categoryPlot.getDomainAxis().isTickMarksVisible());
    Assert.assertFalse("show tick marks", categoryPlot.getDomainAxis().isTickLabelsVisible());

    chart = getChart("summary.chart2", 0);
    Axis axis = chart.getCategoryPlot().getDomainAxis();
    Assert.assertEquals("category label", "category", axis.getLabel());
    Assert.assertEquals("category label color", Color.BLUE, axis.getLabelPaint());
    Assert.assertEquals("category label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont());
    Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint());
    Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont());
    CategoryLabelPosition labelPosition = chart.getCategoryPlot().getDomainAxis().getCategoryLabelPositions()
            .getLabelPosition(RectangleEdge.LEFT);
    Assert.assertEquals("plot label rotation", (45d / 180) * Math.PI, labelPosition.getAngle());
    Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint());

    chart = getChart("summary.chart3", 0);
    axis = chart.getCategoryPlot().getRangeAxis();
    Assert.assertEquals("value label", "value", axis.getLabel());
    Assert.assertEquals("value label color", Color.BLUE, axis.getLabelPaint());
    Assert.assertEquals("value label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont());
    Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint());
    Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont());
    Assert.assertEquals("tick label mask", "10.00", ((NumberAxis) axis).getNumberFormatOverride().format(10));
    Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint());
    Assert.assertEquals("range min value", 1d, ((ValueAxis) axis).getLowerBound());
    Assert.assertEquals("range max value", 15d, ((ValueAxis) axis).getUpperBound());
}

From source file:net.sf.dynamicreports.test.jasper.chart.Bar3DChartTest.java

@Override
public void test() {
    super.test();

    numberOfPagesTest(1);/*from  w ww.j  a v  a 2 s . com*/

    JFreeChart chart = getChart("summary.chart1", 0);
    CategoryPlot categoryPlot = chart.getCategoryPlot();
    Assert.assertEquals("renderer", BarRenderer3D.class, categoryPlot.getRenderer().getClass());
    BarRenderer3D renderer = (BarRenderer3D) categoryPlot.getRenderer();
    Assert.assertTrue("show labels", renderer.getBaseItemLabelsVisible());
    Assert.assertEquals("x offset", 2d, renderer.getXOffset());
    Assert.assertEquals("y offset", 3d, renderer.getYOffset());

    chart = getChart("summary.chart2", 0);
    Axis axis = chart.getCategoryPlot().getDomainAxis();
    Assert.assertEquals("category label", "category", axis.getLabel());
    Assert.assertEquals("category label color", Color.BLUE, axis.getLabelPaint());
    Assert.assertEquals("category label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont());
    Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint());
    Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont());
    CategoryLabelPosition labelPosition = chart.getCategoryPlot().getDomainAxis().getCategoryLabelPositions()
            .getLabelPosition(RectangleEdge.LEFT);
    Assert.assertEquals("plot label rotation", (45d / 180) * Math.PI, labelPosition.getAngle());
    Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint());

    chart = getChart("summary.chart3", 0);
    axis = chart.getCategoryPlot().getRangeAxis();
    Assert.assertEquals("value label", "value", axis.getLabel());
    Assert.assertEquals("value label color", Color.BLUE, axis.getLabelPaint());
    Assert.assertEquals("value label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont());
    Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint());
    Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont());
    Assert.assertEquals("tick label mask", "10.00", ((NumberAxis) axis).getNumberFormatOverride().format(10));
    Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint());
    Assert.assertEquals("range min value", 1d, ((ValueAxis) axis).getLowerBound());
    Assert.assertEquals("range max value", 15d, ((ValueAxis) axis).getUpperBound());
}

From source file:net.sf.dynamicreports.test.jasper.tableofcontents.TableOfContents1Test.java

@Override
public void test() {
    super.test();

    numberOfPagesTest(3);/*  www  .  j ava 2 s  . c  om*/

    elementValueTest("title.textField1", "Table of contents");

    elementCountTest("detail.textField1", 6);
    int index = 0;
    for (int i = 0; i < 3; i++) {
        String anchorName = group1.getGroup().getName() + "_" + i * 24;

        elementValueTest("detail.textField1", index, "value" + (i + 1));
        JRPrintText text = (JRPrintText) getElementAt("detail.textField1", index);
        Assert.assertEquals("text anchor", anchorName, text.getHyperlinkAnchor());

        JRPrintText dots = (JRPrintText) getElementAt("detail.textField2", index);
        String value = JRStyledTextUtil.getInstance(DefaultJasperReportsContext.getInstance())
                .getTruncatedText(dots);
        Assert.assertTrue("dots", StringUtils.containsOnly(value, "."));
        Assert.assertEquals("dots anchor", anchorName, dots.getHyperlinkAnchor());

        JRPrintText pageIndex = (JRPrintText) getElementAt("detail.textField3", index);
        Assert.assertEquals("pageIndex anchor", anchorName, pageIndex.getHyperlinkAnchor());
        index++;

        anchorName = labelExpression.getName() + "_" + (i + 1) * 24;

        elementValueTest("detail.textField1", index, "group footer" + (i + 1));
        text = (JRPrintText) getElementAt("detail.textField1", index);
        Assert.assertEquals("text anchor", anchorName, text.getHyperlinkAnchor());

        dots = (JRPrintText) getElementAt("detail.textField2", index);
        value = JRStyledTextUtil.getInstance(DefaultJasperReportsContext.getInstance()).getTruncatedText(dots);
        Assert.assertTrue("dots", StringUtils.containsOnly(value, "."));
        Assert.assertEquals("dots anchor", anchorName, dots.getHyperlinkAnchor());

        pageIndex = (JRPrintText) getElementAt("detail.textField3", index);
        Assert.assertEquals("pageIndex anchor", anchorName, pageIndex.getHyperlinkAnchor());
        index++;
    }
    elementValueTest("detail.textField3", "1", "1", "1", "2", "2", "2");

    elementCountTest("detail.textField4", 9);
    for (int i = 0; i < 9; i++) {
        String anchorName = group2.getGroup().getName() + "_" + i * 8;

        JRPrintText text = (JRPrintText) getElementAt("detail.textField4", i);
        Assert.assertEquals("text anchor", anchorName, text.getHyperlinkAnchor());

        JRPrintText dots = (JRPrintText) getElementAt("detail.textField5", i);
        String value = JRStyledTextUtil.getInstance(DefaultJasperReportsContext.getInstance())
                .getTruncatedText(dots);
        Assert.assertTrue("dots", StringUtils.containsOnly(value, "."));
        Assert.assertEquals("dots anchor", anchorName, dots.getHyperlinkAnchor());

        JRPrintText pageIndex = (JRPrintText) getElementAt("detail.textField6", i);
        Assert.assertEquals("pageIndex anchor", anchorName, pageIndex.getHyperlinkAnchor());
    }
    elementValueTest("detail.textField4", "value1", "value2", "value3", "value1", "value2", "value3", "value1",
            "value2", "value3");
    elementValueTest("detail.textField6", "1", "1", "1", "1", "1", "1", "2", "2", "2");

    String name1 = "groupHeaderTitleAndValue.group_" + group1.getGroup().getName() + ".tocReference1";
    String name2 = "groupHeaderTitleAndValue.group_" + group1.getGroup().getName() + "1";
    elementCountTest(name1, 3);
    for (int i = 0; i < 3; i++) {
        String anchorName = group1.getGroup().getName() + "_" + i * 24;

        elementValueTest(name1, i, "");
        JRPrintText reference = (JRPrintText) getElementAt(name1, i);
        Assert.assertEquals("reference anchorName " + name1, anchorName, reference.getAnchorName());

        groupHeaderValueTest(group1, i, "value" + (i + 1));
        reference = (JRPrintText) getElementAt(name2, i);
        Assert.assertEquals("reference anchorName " + name2, anchorName, reference.getAnchorName());
    }

    name1 = labelExpression.getName() + ".tocReference";
    name2 = "groupFooter.textField1";
    elementCountTest(name1, 3);
    for (int i = 0; i < 3; i++) {
        String anchorName = labelExpression.getName() + "_" + (i + 1) * 24;

        elementValueTest(name1, i, "");
        JRPrintText reference = (JRPrintText) getElementAt(name1, i);
        Assert.assertEquals("reference anchorName " + name1, anchorName, reference.getAnchorName());

        groupHeaderValueTest(group1, i, "value" + (i + 1));
        reference = (JRPrintText) getElementAt(name2, i);
        Assert.assertEquals("reference anchorName " + name2, anchorName, reference.getAnchorName());
    }

    name1 = "groupHeaderTitleAndValue.group_" + group2.getGroup().getName() + ".tocReference1";
    name2 = "groupHeaderTitleAndValue.group_" + group2.getGroup().getName() + "1";
    elementCountTest(name1, 9);
    for (int i = 0; i < 9; i++) {
        String anchorName = group2.getGroup().getName() + "_" + i * 8;

        elementValueTest(name1, i, "");
        JRPrintText reference = (JRPrintText) getElementAt(name1, i);
        Assert.assertEquals("reference anchorName " + name1, anchorName, reference.getAnchorName());

        reference = (JRPrintText) getElementAt(name2, i);
        Assert.assertEquals("reference anchorName " + name2, anchorName, reference.getAnchorName());
    }
    groupHeaderValueTest(group2, "value1", "value2", "value3", "value1", "value2", "value3", "value1", "value2",
            "value3");

    columnTitleCountTest(column3, 2);
    columnTitleValueTest(column3, "Column3", "Column3");
    columnDetailCountTest(column3, 72);
    columnDetailValueTest(column3, 71, "text");
}

From source file:de.hybris.platform.jobs.RemovedItemPKProcessorTest.java

@Test
public void testAllIterated() {
    final PK one = PK.createFixedUUIDPK(102, 1);
    final PK two = PK.createFixedUUIDPK(102, 2);
    final PK three = PK.createFixedUUIDPK(102, 3);

    final MediaModel mediaPk = new MediaModel();
    final DataInputStream dis = new DataInputStream(buildUpStream(one, two, three));

    Mockito.when(model.getItemPKs()).thenReturn(mediaPk);
    Mockito.when(mediaService.getStreamFromMedia(mediaPk)).thenReturn(dis);

    iterator.init(model);//w w  w. j a va2s .  c o  m

    Assert.assertTrue("Not all iterations should be skipped ", iterator.hasNext());
    Assert.assertEquals("Should  return first element ", one, iterator.next());
    Assert.assertTrue("Not all iterations should be skipped ", iterator.hasNext());
    Assert.assertEquals("Should  return second element ", two, iterator.next());
    Assert.assertTrue("Not all iterations should be skipped ", iterator.hasNext());
    Assert.assertEquals("Should  return third element ", three, iterator.next());
    Assert.assertFalse("Now all iterations should be skipped ", iterator.hasNext());
}

From source file:net.sf.dynamicreports.test.jasper.chart.SpiderChartTest.java

@Override
public void test() {
    super.test();

    numberOfPagesTest(1);//from   ww  w .ja va 2s  .co  m

    JRPrintFrame printFrame = (JRPrintFrame) getElementAt("summary.list1", 0);

    JRPrintImage image = (JRPrintImage) printFrame.getElements().get(0);
    JFreeChart chart = getChart(image);
    SpiderWebPlot plot = (SpiderWebPlot) chart.getPlot();
    Assert.assertEquals("max value", 10d, plot.getMaxValue());
    Assert.assertEquals("rotation", Rotation.ANTICLOCKWISE, plot.getDirection());
    Assert.assertEquals("table order", org.jfree.util.TableOrder.BY_COLUMN, plot.getDataExtractOrder());
    Assert.assertFalse("web filled", plot.isWebFilled());
    Assert.assertEquals("start angle", 20d, plot.getStartAngle());
    Assert.assertEquals("head percent", 30d, plot.getHeadPercent());
    Assert.assertEquals("interior gap", 0.15d, plot.getInteriorGap());
    Assert.assertEquals("axis line color", Color.RED, plot.getAxisLinePaint());
    Assert.assertEquals("interior gap", 2f, ((BasicStroke) plot.getAxisLineStroke()).getLineWidth());
    Assert.assertEquals("label color", Color.BLUE, plot.getLabelPaint());
    Assert.assertEquals("label gap", 2d, plot.getAxisLabelGap());
    Assert.assertTrue("label font", plot.getLabelFont().isBold());

    image = (JRPrintImage) printFrame.getElements().get(1);
    chart = getChart(image);
    plot = (SpiderWebPlot) chart.getPlot();
    Assert.assertEquals("title", "title", chart.getTitle().getText());
    Assert.assertEquals("subtitle", "subtitle", ((TextTitle) chart.getSubtitle(1)).getText());
}

From source file:org.esco.portlet.changeetab.service.impl.CachingEtablissementServiceTest.java

@Test
public void testRetrieveOneExistingEtab() throws Exception {
    final Collection<String> uais = new ArrayList<String>();
    uais.add(CachingEtablissementServiceTest.UAI_2);

    final Map<String, Etablissement> etabs = this.service.retrieveEtablissementsByCodes(uais);

    Assert.assertNotNull("Should return an empty collection !", etabs);
    Assert.assertEquals("Should return only one etab !", 1, etabs.size());
    Assert.assertTrue("Bad etab returned !", etabs.containsValue(CachingEtablissementServiceTest.ETAB_2));
}

From source file:net.sf.dynamicreports.googlecharts.test.AbstractJasperTest.java

protected void containsHtml(String message, String text) {
    Assert.assertTrue(message, StringUtils.contains(html, text));
}