Example usage for junit.framework Assert fail

List of usage examples for junit.framework Assert fail

Introduction

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

Prototype

static public void fail(String message) 

Source Link

Document

Fails a test with the given message.

Usage

From source file:com.mnxfst.testing.server.cfg.TestPTestServerConfigurationParser.java

@Test
public void testEvaluateStringWithValidDocumentAndInvalidExpression() throws ParserConfigurationException {
    try {/*  w  w  w.  jav  a 2 s.c  o m*/
        PTestServerConfigurationParser p = new PTestServerConfigurationParser();
        p.evaluateString(null, DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument());
        Assert.fail("Invalid expression, valid document");
    } catch (XPathExpressionException e) {
        //
    }
}

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

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

    numberOfPagesTest(1);/*from w  w  w.j  ava  2s  .  c  o m*/

    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:com.googlecode.ehcache.annotations.integration.TriggersRemoveAfterMethodInvocationTest.java

/**
 * /*  w w  w .j a v  a 2  s  .  co  m*/
 */
@Test
public void testHarness() {
    Cache cache = cacheManager.getCache("triggersRemoveAfterInvocationTestCache");

    Assert.assertEquals(0, cache.getSize());
    // place an element in the cache so we can tell when removeAll was called
    cache.put(new Element("key", "value"));
    Assert.assertEquals(1, cache.getSize());

    ThreadGroupRunner groupRunner = new ThreadGroupRunner("triggersRemoveAfterMethodInvocationTest", true);
    groupRunner.addTask(new Runnable() {
        public void run() {
            //2 
            triggersRemoveTestImpl.afterMethodInvocation("foo");
            try {
                // 6
                triggersRemoveTestImpl.getCyclicBarrier().await();
            } catch (InterruptedException e) {
                Assert.fail(e.getMessage());
                e.printStackTrace();
            } catch (BrokenBarrierException e) {
                Assert.fail(e.getMessage());
                e.printStackTrace();
            }
        }
    });

    // 1
    groupRunner.start();
    try {
        // 2
        triggersRemoveTestImpl.getCyclicBarrier().await();
    } catch (InterruptedException e) {
        Assert.fail(e.getMessage());
        e.printStackTrace();
    } catch (BrokenBarrierException e) {
        Assert.fail(e.getMessage());
        e.printStackTrace();
    }

    // 4: child thread inside TriggersRemove annotated method
    Assert.assertEquals(1, cache.getSize());
    // 5a
    triggersRemoveTestImpl.getProceedLatch().countDown();
    // TriggersRemove annotated method invocation complete
    try {
        // 6 
        triggersRemoveTestImpl.getCyclicBarrier().await();
    } catch (InterruptedException e) {
        Assert.fail(e.getMessage());
        e.printStackTrace();
    } catch (BrokenBarrierException e) {
        Assert.fail(e.getMessage());
        e.printStackTrace();
    }

    // at this point the removeAll has been called, verify cache is empty
    Assert.assertEquals(0, cache.getSize());
    try {
        groupRunner.join();
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}

From source file:eagle.dataproc.util.TestConfigOptionParser.java

@Test
public void testInvalidCommandArgument1() {
    String[] arguments = new String[] { "-D", "key1" };

    try {//from   ww  w.  j a  va2s . c  o  m
        new ConfigOptionParser().parseConfig(arguments);
        Assert.fail("Should throw ParseException");
    } catch (ParseException e) {
        LOG.info("Expected exception: " + e.getMessage());
    }
}

From source file:org.openmrs.module.feedback.web.SubmitFeedbackControllerTest.java

@Test
public void testpopulateModel() throws Exception {
    System.out.println("poplulateModel");

    SubmitFeedbackController instance = new SubmitFeedbackController();
    Map<String, Object> reqmap = new HashMap<String, Object>();

    instance.populateModel(request, reqmap);

    /* to check wheather the data is sent or not binded into the key feedback */
    if (!reqmap.containsKey("predefinedsubjects") || !reqmap.containsKey("severities")) {
        Assert.fail("Do not contain the object predefined subjects and severities");
    }//from w  ww .  j  ava2  s . com
}

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

@Test
public void testBlock1CrossTask() {
    int keyCnt1 = 10;
    int valCnt1 = 1;

    int keyCnt2 = 100;
    int valCnt2 = 4;

    super.initEnvironment(1 * 1024 * 1024);
    super.addInput(new UniformPactRecordGenerator(keyCnt1, valCnt1, false), 1);
    super.addInput(new UniformPactRecordGenerator(keyCnt2, valCnt2, false), 2);
    super.addOutput(this.outList);

    CrossTask<PactRecord, PactRecord, PactRecord> testTask = new CrossTask<PactRecord, PactRecord, PactRecord>();
    super.getTaskConfig().setLocalStrategy(LocalStrategy.NESTEDLOOP_BLOCKED_OUTER_FIRST);
    super.getTaskConfig().setMemorySize(1 * 1024 * 1024);

    super.registerTask(testTask, MockCrossStub.class);

    try {//  w w  w.  j  a  v a  2 s.c  o  m
        testTask.invoke();
    } catch (Exception e) {
        LOG.debug(e);
        Assert.fail("Invoke method caused exception.");
    }

    int expCnt = keyCnt1 * valCnt1 * keyCnt2 * valCnt2;

    Assert.assertTrue("Resultset size was " + this.outList.size() + ". Expected was " + expCnt,
            this.outList.size() == expCnt);

    this.outList.clear();

}

From source file:cz.PA165.vozovyPark.dao.VehicleDAOTest.java

/**
 * Test of getById method, of class VehicleDAO.
 *///from w w  w .j av  a  2s . c om
@Test
public void testCreateAndGetById() {
    try {
        Vehicle mercedes = VehicleDAOTest.getVehicle("Mercedes", 20000, "R4 Diesel", "E",
                UserClassEnum.PRESIDENT, "2a-447i-882a45", 2009, "UEW6828");
        vehicleDao.createVehicle(mercedes);

        Vehicle loaded = vehicleDao.getById(mercedes.getId());
        Assert.assertEquals("Insserted and loaded vehicles should be same.", mercedes, loaded);
    } catch (Exception ex) {
        Assert.fail("Unexpected exception was throwed: " + ex + " " + ex.getMessage());
    }
}

From source file:org.slc.sli.dashboard.unit.controller.ConfigControllerTest.java

@Test
public void testBadSave() throws Exception {
    Map<String, Config> mapOfConfigs = new HashMap<String, Config>();
    Config bad = new Config("+++", null, null, Type.FIELD, null, null, null, null, null);
    mapOfConfigs.put("something", bad);
    ConfigMap map = new ConfigMap();
    map.setConfig(mapOfConfigs);/*from   ww w .j ava 2s .co  m*/
    try {
        configController.saveConfig(map);
        Assert.fail("Should not be able to save");
    } catch (Exception e) {
        Assert.assertEquals("Invalid input parameter configMap", e.getMessage().substring(0, 33));
    }
}

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

@Test
public void testCancelTempTask() {

    super.initEnvironment(1024 * 1024 * 1);
    super.addInput(new DelayingInfinitiveInputIterator(100), 1);
    super.addOutput(new NirvanaOutputList());

    final TempTask<PactRecord> testTask = new TempTask<PactRecord>();
    super.getTaskConfig().setMemorySize(1 * 1024 * 1024);

    super.registerTask(testTask, PrevStub.class);

    Thread taskRunner = new Thread() {
        @Override//from  www .  j  a  v a 2  s .  c  o m
        public void run() {
            try {
                testTask.invoke();
            } catch (Exception ie) {
                ie.printStackTrace();
                Assert.fail("Task threw exception although it was properly canceled");
            }
        }
    };
    taskRunner.start();

    TaskCancelThread tct = new TaskCancelThread(1, taskRunner, testTask);
    tct.start();

    try {
        tct.join();
        taskRunner.join();
    } catch (InterruptedException ie) {
        Assert.fail("Joining threads failed");
    }

}

From source file:azkaban.crypto.DecryptionTest.java

@Test
public void testInvalidParams() throws IOException {
    BasicConfigurator.configure();//from   ww  w. ja v  a2s .  co  m
    Logger.getRootLogger().setLevel(Level.DEBUG);

    String expected = "test";
    String[] cipheredtexts = { "eyJ2ZXIiOiIxLjAiLCJ2YWwiOiJOd1hRejdOMjBXUU05SXEzaE94RVZnPT0ifQ==", null, "" };
    String[] passphrases = { "test1234", null, "" };

    for (String cipheredtext : cipheredtexts) {
        for (String passphrase : passphrases) {
            Crypto crypto = new Crypto();
            if (!StringUtils.isEmpty(cipheredtext) && !StringUtils.isEmpty(passphrase)) {
                String actual = crypto.decrypt(cipheredtext, passphrase);
                Assert.assertEquals(expected, actual);
            } else {
                try {
                    crypto.decrypt(cipheredtext, passphrase);
                    Assert.fail("Encyption should have failed with invalid parameters. cipheredtext: "
                            + cipheredtext + " , passphrase: " + passphrase);
                } catch (Exception e) {
                    Assert.assertTrue(e instanceof IllegalArgumentException);
                }
            }
        }
    }
}