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

Source Link

Document

Asserts that a condition is false.

Usage

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

@Test
public void testSkipofRefused() {
    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);
    Mockito.when(model.getItemsRefused()).thenReturn(Integer.valueOf(10));

    iterator.init(model);// www .  j a  v  a 2 s  . c om

    Assert.assertFalse("All iterations should be skipped ", iterator.hasNext());
}

From source file:my.adam.smo.EncryptionTest.java

@Test
public void symetricEncryptionLongMessage() {
    ApplicationContext clientContext = new ClassPathXmlApplicationContext("Context.xml");
    SymmetricEncryptionBox box = clientContext.getBean(SymmetricEncryptionBox.class);
    int plainTextLength = 17;

    byte[] plainText = new byte[plainTextLength];
    random.nextBytes(plainText);// w  ww  . j a va2s. c o  m

    byte[] cryptogram = box.encrypt(plainText);
    Assert.assertFalse("plain text leaked!!!", Arrays.equals(plainText,
            Arrays.copyOfRange(cryptogram, SymmetricEncryptionBox.ivLength, cryptogram.length)));

    byte[] decrypted = box.decrypt(cryptogram);
    Assert.assertTrue("unable to decrypt", Arrays.equals(plainText, decrypted));
}

From source file:com.sap.prd.mobile.ios.mios.SpecificTargetTest.java

private void assertCorrectTargetBuild(File logFile) throws IOException {
    BufferedReader reader = new BufferedReader(new FileReader(logFile));
    try {// w  w w . j  a  v  a2 s .  co  m
        String line;
        boolean target1Built = false;
        boolean target2Built = false;
        while ((line = reader.readLine()) != null) {
            target1Built |= line.matches(
                    "=== BUILD.*TARGET Target1 OF PROJECT MultipleTargets WITH CONFIGURATION Release ===");
            target2Built |= line.matches(
                    "=== BUILD.*TARGET Target2 OF PROJECT MultipleTargets WITH CONFIGURATION Release ===");
        }
        Assert.assertFalse("Target1 must not be built", target1Built);
        Assert.assertTrue("Target2 must be built", target2Built);
    } finally {
        IOUtils.closeQuietly(reader);
    }
}

From source file:net.sf.dynamicreports.test.jasper.report.JasperExpressionTest.java

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

    numberOfPagesTest(1);//from  w  w  w  .  jav a2 s.com

    columnTitleCountTest(column1, 1);
    columnTitleValueTest(column1, "Column1\n\"Column1\"");

    columnTitleCountTest(column2, 1);
    columnTitleValueTest(column2, "Column2");

    columnDetailValueTest(column3, "0", "8", "3");

    try {
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        getReportBuilder().toJrXml(bos);
        String jrxml = new String(bos.toByteArray());
        Assert.assertFalse("jrxml contains dependency to dynamicreports",
                StringUtils.contains(jrxml, "net.sf.dynamicreports"));
    } catch (DRException e) {
        Assert.fail(e.getMessage());
    }
}

From source file:net.padaf.preflight.TestIsartorValidationFromClasspath.java

@Test()
public void validate() throws Exception {
    ValidationResult result = null;/*from w  ww  . j  ava 2  s . c  o m*/
    try {
        InputStream input = this.getClass().getResourceAsStream(path);
        ByteArrayDataSource bds = new ByteArrayDataSource(input);
        result = validator.validate(bds);
        Assert.assertFalse(path + " : Isartor file should be invalid (" + path + ")", result.isValid());
        Assert.assertTrue(path + " : Should find at least one error", result.getErrorsList().size() > 0);
        // could contain more than one error
        boolean found = false;
        for (ValidationError error : result.getErrorsList()) {
            if (error.getErrorCode().equals(this.expectedError)) {
                found = true;
            }
            if (isartorResultFile != null) {
                String log = path.replace(".pdf", "") + "#" + error.getErrorCode() + "#" + error.getDetails()
                        + "\n";
                isartorResultFile.write(log.getBytes());
            }
        }

        if (result.getErrorsList().size() > 1) {
            if (!found) {
                StringBuilder message = new StringBuilder(100);
                message.append(path).append(" : Invalid error code returned. Expected ");
                message.append(this.expectedError).append(", found ");
                for (ValidationError error : result.getErrorsList()) {
                    message.append(error.getErrorCode()).append(" ");
                }
                Assert.fail(message.toString());
            }
        } else {
            Assert.assertEquals(path + " : Invalid error code returned.", this.expectedError,
                    result.getErrorsList().get(0).getErrorCode());
        }
    } catch (ValidationException e) {
        throw new Exception(path + " :" + e.getMessage(), e);
    } finally {
        if (result != null) {
            result.closePdf();
        }
    }
}

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

@Test
public void testSkipofDeletedAndRefused() {
    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);
    Mockito.when(model.getItemsRefused()).thenReturn(Integer.valueOf(2));
    Mockito.when(model.getItemsDeleted()).thenReturn(Integer.valueOf(2));

    iterator.init(model);//from w ww  . ja  v  a2 s. co m

    Assert.assertFalse("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  w  w w  . j a  va2 s .c om*/

    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:my.adam.smo.EncryptionTest.java

@Test
public void symmetricEncryptionGaveDifferentCryptogramForSamePlainText() {
    ApplicationContext clientContext = new ClassPathXmlApplicationContext("Context.xml");
    SymmetricEncryptionBox box = clientContext.getBean(SymmetricEncryptionBox.class);
    int plainTextLength = 17;
    Random random = new Random();

    byte[] plainText = new byte[plainTextLength];
    random.nextBytes(plainText);// ww  w. j a  v  a  2s  . c  o  m

    byte[] cryptogram1 = box.encrypt(plainText);
    byte[] cryptogram2 = box.encrypt(plainText);

    Assert.assertFalse("cryptograms are same", Arrays.equals(cryptogram1, cryptogram2));

    byte[] decrypted1 = box.decrypt(cryptogram1);
    Assert.assertTrue("unable to decrypt", Arrays.equals(plainText, decrypted1));

    byte[] decrypted2 = box.decrypt(cryptogram2);
    Assert.assertTrue("unable to decrypt", Arrays.equals(plainText, decrypted2));
}

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

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

    numberOfPagesTest(1);//from   www.  j ava2  s  .co m

    JFreeChart chart = getChart("summary.chart1", 0);
    XYItemRenderer renderer = chart.getXYPlot().getRenderer();
    Assert.assertEquals("renderer", XYLineAndShapeRenderer.class, renderer.getClass());
    Assert.assertFalse("show shapes", ((XYLineAndShapeRenderer) renderer).getBaseShapesVisible());
    Assert.assertFalse("show lines", ((XYLineAndShapeRenderer) renderer).getBaseLinesVisible());
    xyChartDataTest(chart, 0, "Column2", new Number[][] { { 1d, 2d }, { 2d, 3d }, { 3d, 4d }, { 4d, 5d } });
    xyChartDataTest(chart, 1, "Column1", new Number[][] { { 2d, 1d }, { 3d, 2d }, { 4d, 3d }, { 5d, 4d } });

    chart = getChart("summary.chart2", 0);
    Axis axis = chart.getXYPlot().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());
    Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint());

    chart = getChart("summary.chart3", 0);
    axis = chart.getXYPlot().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());
}

From source file:org.jboss.as.test.clustering.cluster.web.passivation.SessionPassivationAbstractCase.java

/**
 * Tests the ability to passivate session when max-idle-time for session is reached.
 *
 * @throws Exception//  ww w . j av  a  2s  . c  o m
 */
@Test
public void testSessionPassivationWithMaxIdleTime(
        @ArquillianResource @OperateOnDeployment(DEPLOYMENT_1) URL baseURL1) throws Exception {

    // Create an instance of HttpClient
    HttpClient client = HttpClientUtils.relaxedCookieHttpClient();
    try {
        // Setup the session
        HttpResponse response = ClusterHttpClientUtil.tryGet(client, baseURL1 + SimpleServlet.URL);
        Assert.assertFalse("Session should not be serialized",
                Boolean.valueOf(response.getFirstHeader(SimpleServlet.HEADER_SERIALIZED).getValue()));
        response.getEntity().getContent().close();

        // Get the attribute set
        response = ClusterHttpClientUtil.tryGet(client, baseURL1 + SimpleServlet.URL);
        Assert.assertFalse("Session still should not be serialized",
                Boolean.valueOf(response.getFirstHeader(SimpleServlet.HEADER_SERIALIZED).getValue()));
        response.getEntity().getContent().close();

        // Sleep up to 20 secs to allow max-idle to be reached and JBoss Web background process to run
        // knowing that max-idle in jboss-web.xml is 10 seconds and tomcat JBoss Web process is using the
        // default 10 seconds and processExpiresFrequency is 1 so kicks in every time.
        Thread.sleep((PASSIVATION_MAX_IDLE_TIME + 10) * 1000);

        // Activate the session by requesti ng the attribute
        response = ClusterHttpClientUtil.tryGet(client, baseURL1 + SimpleServlet.URL);
        Assert.assertTrue("Session should have activated and have been deserialized",
                Boolean.valueOf(response.getFirstHeader(SimpleServlet.HEADER_SERIALIZED).getValue()));
        Assert.assertEquals(3, Integer.parseInt(response.getFirstHeader("value").getValue()));
        response.getEntity().getContent().close();
    } finally {
        client.getConnectionManager().shutdown();
    }
}