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:org.slc.sli.dashboard.unit.controller.ConfigControllerTest.java

@Test
public void testSave() throws Exception {
    ConfigMap configMap = loadFile(Config.class.getClassLoader().getResource(CONFIG_MAP_LOCATION).getFile(),
            ConfigMap.class);
    try {/*from w w  w  . java  2s . c  o  m*/
        String response = configController.saveConfig(configMap);
        Assert.assertEquals("Success", response);
    } catch (Exception e) {
        Assert.fail("Should pass validation but getting " + e.getMessage());
    }
}

From source file:com.googlecode.fascinator.storage.ram.RamStorageTest.java

@Test
public void createObject() throws Exception {
    // Create a test object
    DigitalObject newObject = ram.createObject("oai:eprints.usq.edu.au:318");
    Payload dcPayload = newObject.createStoredPayload("oai_dc",
            IOUtils.toInputStream("<dc><title>test</title></dc>"));
    dcPayload.setLabel("Dublin Core Metadata");

    // Makes sure the object reports only 1 payload
    Set<String> payloads = newObject.getPayloadIdList();
    Assert.assertEquals(1, payloads.size());

    // Make sure our payload retrieves and is labelled correctly
    Payload payload = newObject.getPayload("oai_dc");
    Assert.assertEquals("Dublin Core Metadata", payload.getLabel());

    // Remove the payload and recheck object payload size
    newObject.removePayload(payload.getId());
    payloads = newObject.getPayloadIdList();
    Assert.assertEquals(0, payloads.size());

    // Remove the object from storage
    try {/*from w w w.j a  va  2s. c o  m*/
        ram.removeObject(newObject.getId());
    } catch (StorageException ex) {
        Assert.fail("Error deleting newObject : " + ex.getMessage());
    }
}

From source file:de.akquinet.gomobile.androlog.test.MailReporterTest.java

public void setUp() {
    try {/*ww  w.  j  ava  2  s . c om*/
        Assert.assertTrue("No SDCard or not the permission to write",
                Environment.getExternalStorageDirectory().canWrite());
        // Create files
        Properties propsDefault = new Properties();
        propsDefault.setProperty(Constants.ANDROLOG_ACTIVE, "true");
        propsDefault.setProperty(Constants.ANDROLOG_REPORT_ACTIVE, "true");
        propsDefault.setProperty(Constants.ANDROLOG_REPORT_REPORTERS,
                "de.akquinet.android.androlog.reporter.NoopReporter");

        Properties propsActive = new Properties();
        propsActive.setProperty(Constants.ANDROLOG_ACTIVE, "true");
        propsActive.setProperty(Constants.ANDROLOG_REPORT_ACTIVE, "true");
        propsActive.setProperty(Constants.ANDROLOG_REPORT_REPORTERS,
                "de.akquinet.android.androlog.reporter.MailReporter");
        propsActive.setProperty(MailReporter.ANDROLOG_REPORTER_MAIL_ADDRESS, "clement.escoffier@gmail.com");

        testContext = new File(Environment.getExternalStorageDirectory(),
                getContext().getPackageName() + ".properties");
        testContext.createNewFile();
        (new File(Environment.getExternalStorageDirectory(), "tmp")).mkdir();

        FileOutputStream out = new FileOutputStream(testContext);
        propsActive.store(out, "Enable Androlog file");
        out.close();
    } catch (Exception e) {
        e.printStackTrace();
        Assert.fail(e.getMessage());
    }
}

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

@Before
public void init() {
    try {/*  ww  w.  j a  v  a 2  s . c o m*/
        reportBuilder = DynamicReports.report();
        configureReport(reportBuilder);
        if (serializableTest()) {
            reportBuilder = serializableTest(reportBuilder);
        }
        JRDataSource dataSource = createDataSource();
        if (dataSource != null) {
            reportBuilder.setDataSource(dataSource);
        }
        build();
    } catch (Exception e) {
        e.printStackTrace();
        Assert.fail(e.getMessage());
    }
}

From source file:com.fabrefrederic.integrationTest.ITCommitService.java

@Test
@Transactional//from   w  ww . j  av  a2  s  .  com
public void get_Commits_From_The_Last_Retrieved_To_The_Last_Commit() {
    // given
    final int numberOfCommits = 8;
    final String repositoryPath = "/trunk/bundle/license.txt";

    // when
    List<Commit> commits = new ArrayList<Commit>();
    try {
        final Commit lastSavedCommit = commitService.getTheLastSavedCommit();
        System.out.println(lastSavedCommit.getNumber());
        final Long lastSavedCommitNumber = Long.valueOf(lastSavedCommit.getNumber());
        commits = commitService.getCommitsToTheLastRevision(repositoryPath, lastSavedCommitNumber);
    } catch (final Exception exception) {
        LOGGER.error("Error during getting commits from the svn repository", exception);
        Assert.fail("Error during getting commits from the svn repository");
    }
    try {
        commitService.saveCommits(commits);
    } catch (final Exception exception) {
        LOGGER.error("Error during saving commits into the database", exception);
        Assert.fail("Error during saving commits into the database");
    }

    // then
    Assert.assertEquals(commits.size(), numberOfCommits);

}

From source file:com.googlecode.ehcache.annotations.integration.ConfigurationFailureTest.java

/**
 * Test verifies behavior when no {@link CacheKeyGenerator} is defined for
 * the cacheKeyGenerator attribute on the {@link Cacheable} annotated method.
 *///from   w  w  w .j a va2s. c  om
@Test
public void testNoCacheKeyGenerator() {
    try {
        new ClassPathXmlApplicationContext("/noCacheKeyGeneratorTestContext.xml");
        Assert.fail("Test should have failed with no CacheKeyGenerator defined");
    } catch (BeanCreationException bce) {
        Assert.assertEquals("cacheConfigurationTestImpl", bce.getBeanName());
    }
}

From source file:org.sonatype.nexus.kenai.internal.KenaiRealmTest.java

@Test
public void testAuthFailAuthFail() throws Exception {
    KenaiRealm kenaiRealm = this.getRealm();

    try {//from   w w  w.  ja  v a2s. c o  m
        Assert.assertNotNull(
                kenaiRealm.getAuthenticationInfo(new UsernamePasswordToken("unknown-user-foo-bar", "invalid")));
        Assert.fail("Expected: AccountException to be thrown");
    } catch (AccountException e) {
        // expected
    }

    try {
        kenaiRealm.getAuthenticationInfo(new UsernamePasswordToken("random", "JUNK-PASS"));
        Assert.fail("Expected: AccountException to be thrown");
    } catch (AccountException e) {
        // expected
    }

    Assert.assertNotNull(kenaiRealm.getAuthenticationInfo(new UsernamePasswordToken(username, password)));

    try {
        kenaiRealm.getAuthenticationInfo(new UsernamePasswordToken("random", "JUNK-PASS"));
        Assert.fail("Expected: AccountException to be thrown");
    } catch (AccountException e) {
        // expected
    }
}

From source file:com.aliyun.oss.integrationtests.ImageTest.java

@Test
public void testResizeImage() {
    String style = "image/resize,m_fixed,w_100,h_100"; // 

    try {/*from  w  ww  . ja  v  a  2 s . c  om*/
        GetObjectRequest request = new GetObjectRequest(bucketName, originalImage);
        request.addParameter("x-oss-process", style);

        OSSObject ossObject = ossClient.getObject(request);
        ossClient.putObject(bucketName, newImage, ossObject.getObjectContent());

        ImageInfo imageInfo = getImageInfo(bucketName, newImage);
        Assert.assertEquals(imageInfo.getHeight(), 100);
        Assert.assertEquals(imageInfo.getWidth(), 100); // 3587
        Assert.assertEquals(imageInfo.getFormat(), "jpg");

    } catch (Exception e) {
        e.printStackTrace();
        Assert.fail(e.getMessage());
    }
}

From source file:br.com.sicoob.cro.cop.batch.core.BatchProcessingTests.java

@Test
public void chunkExample() {
    try {//w  w  w  . j av a 2 s  . com
        Properties jobParameters = new Properties();
        jobParameters.put("nomeArquivo", "OpLm.csv");
        BatchProcess launcher = BatchApplication.createExecutionProcess("chunkExample", jobParameters);
        BatchExecution execution = launcher.start();
        while (execution.getStatus() != Status.COMPLETED) {
            Thread.sleep(5000);
            LOG.info(execution.toString());
        }
        LOG.info(execution.toString());
        assertEquals(Result.Type.SUCCESS, execution.getResult().getType());
    } catch (BatchStartException excecao) {
        Assert.fail(excecao.getMessage());
    } catch (InterruptedException ex) {
        Assert.fail(ex.getMessage());
        Logger.getLogger(BatchProcessingTests.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:eagle.log.entity.TestHBaseWriteEntitiesPerformance.java

private List<String> writeEntities(int count) {
    GenericEntityWriter writer = null;/*from  ww  w. j a v  a 2 s  .  com*/
    try {
        writer = new GenericEntityWriter(ed.getService());
    } catch (InstantiationException e1) {
        Assert.fail(e1.getMessage());
    } catch (IllegalAccessException e1) {
        Assert.fail(e1.getMessage());
    }

    if (LOG.isDebugEnabled())
        LOG.debug("Start to write " + count + " entities");
    int wroteCount = 0;
    List<String> rowkeys = new ArrayList<String>();
    List<TestLogAPIEntity> list = new ArrayList<TestLogAPIEntity>();
    for (int i = 0; i <= count; i++) {
        TestLogAPIEntity e = new TestLogAPIEntity();
        e.setTimestamp(new Date().getTime());
        e.setField1(i);
        e.setField2(i);
        e.setField3(i);
        e.setField4(new Long(i));
        e.setField5(new Double(i));
        e.setField6(new Double(i));
        e.setField7(String.valueOf(i));
        e.setTags(new HashMap<String, String>());
        e.getTags().put("jobID", "index_test_job_id");
        e.getTags().put("hostname", "testhost");
        e.getTags().put("index", String.valueOf(i));
        e.getTags().put("class", e.toString());
        list.add(e);

        if (list.size() >= 1000) {
            try {
                StopWatch watch = new StopWatch();
                watch.start();
                rowkeys.addAll(writer.write(list));
                watch.stop();
                wroteCount += list.size();
                if (LOG.isDebugEnabled())
                    LOG.debug("Wrote " + wroteCount + " / " + count + " entities" + " in " + watch.getTime()
                            + " ms");
                list.clear();
            } catch (Exception e1) {
                Assert.fail(e1.getMessage());
            }
        }
    }

    try {
        rowkeys.addAll(writer.write(list));
        wroteCount += list.size();
        if (LOG.isDebugEnabled())
            LOG.debug("wrote " + wroteCount + " / " + count + " entities");
    } catch (Exception e) {
        Assert.fail(e.getMessage());
    }
    if (LOG.isDebugEnabled())
        LOG.debug("done " + count + " entities");
    return rowkeys;
}