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:net.idea.opentox.cli.test.DatasetClientTest.java

@Override
public void testCreate() throws Exception {
    //in case the TEST_SERVER uses HTTP BASIC
    otclient.setHTTPBasicCredentials("localhost", 8080, "admin", "changeit");

    DatasetClient<POLICY_RULE> cli = getOTClient();
    URL url = getClass().getClassLoader().getResource("net/idea/opentox/cli/test/sdf/1000-90-4.sdf");
    File fileToImport = new File(url.getFile());
    Assert.assertTrue(fileToImport.exists());
    Dataset dataset = new Dataset();
    dataset.getMetadata().setTitle("Test dataset");
    dataset.getMetadata().setSeeAlso("Test see also uri");
    dataset.getMetadata()//from   www . j av a2s . co m
            .setRights(new Rights("CC-BY-SA", "http://creativecommons.org/licenses/by-sa/2.0/", _type.license));
    dataset.setInputData(new InputData(fileToImport, DatasetClient._MATCH.InChI));
    RemoteTask task = cli.postAsync(dataset,
            new Identifier(String.format("%s%s", TEST_SERVER, Resources.dataset)));
    task.waitUntilCompleted(1000);
    //verify if ok
    Assert.assertEquals(HttpStatus.SC_OK, task.getStatus());
    Assert.assertNull(task.getError());
    List<Dataset> theDataset = cli.getMetadata(task.getResult());
    Assert.assertEquals(1, theDataset.size());
    Assert.assertEquals(dataset.getMetadata().getTitle(), theDataset.get(0).getMetadata().getTitle());
    Assert.assertEquals(dataset.getMetadata().getSeeAlso(), theDataset.get(0).getMetadata().getSeeAlso());
    Assert.assertEquals(task.getResult(), theDataset.get(0).getResourceIdentifier());

    CompoundClient<POLICY_RULE> ccli = otclient.getCompoundClient();
    List<Compound> compounds = cli.getCompounds(theDataset.get(0), ccli);
    Assert.assertNotNull(compounds);
    for (Compound compound : compounds) {
        System.out.println(compound);
    }

    //finally delete the dataset
    cli.delete(theDataset.get(0));
}

From source file:com.logsniffer.model.file.WildcardLogSourceTest.java

@Test
public void testLogsResolving() throws IOException {
    File tmp = File.createTempFile("sdkj", "jk");
    tmp.deleteOnExit();//from  w w w. j  a v a  2  s  .com
    File tmpFolder1 = new File(tmp.getPath() + "d", "f1");
    tmpFolder1.mkdirs();
    tmpFolder1.deleteOnExit();
    File tmpFolder2 = new File(tmp.getPath() + "d", "f2");
    tmpFolder2.mkdirs();
    tmpFolder2.deleteOnExit();
    FileUtils.write(new File(tmpFolder1, "1.txt"), "txt");
    FileUtils.write(new File(tmpFolder1, "2.txt"), "txt");
    FileUtils.write(new File(tmpFolder1, "3.log"), "log");
    FileUtils.write(new File(tmpFolder2, "22.txt"), "txt");
    File tmpDir = new File(tmpFolder2, "folder.txt");
    tmpDir.mkdir();
    tmpDir.deleteOnExit();

    // Check now
    WildcardLogsSource source = new WildcardLogsSource();
    source.setPattern(tmp.getPath() + "d/*.txt");
    Assert.assertEquals(0, source.getLogs().size());
    source.setPattern(tmp.getPath() + "d/**/*.txt");
    Log[] logs = source.getLogs().toArray(new Log[0]);
    Assert.assertEquals(3, logs.length);
    Arrays.sort(logs, new Comparator<Log>() {
        @Override
        public int compare(final Log o1, final Log o2) {
            return o1.getPath().compareTo(o2.getPath());
        }
    });
    Assert.assertTrue(logs[0].getPath().endsWith("1.txt"));
    Assert.assertTrue(logs[1].getPath().endsWith("2.txt"));
    Assert.assertTrue(logs[2].getPath().endsWith("22.txt"));
}

From source file:de.hybris.platform.b2b.services.impl.B2BCostCenterServiceTest.java

@Test
public void testFindCostCenters() throws Exception {
    final String userId = "IC CEO";
    final B2BCustomerModel customer = login(userId);
    final List<B2BCostCenterModel> costCenters = b2bCostCenterService.getCostCentersForUnitBranch(customer,
            commonI18NService.getCurrentCurrency());
    Assert.assertNotNull(costCenters);//from   w w  w  . ja v  a  2  s  .c  o m
    Assert.assertTrue(CollectionUtils.isNotEmpty(costCenters));
}

From source file:com.tasktop.c2c.server.configuration.service.tests.TemplateProcessingConfiguratorTest.java

@Test
public void testBasicTemplating() {
    Assert.assertFalse(targetDir.exists());

    ProjectServiceConfiguration conf = new ProjectServiceConfiguration();
    conf.setProperties(new HashMap<String, String>());
    conf.getProperties().put("a.key", "a.value");
    conf.getProperties().put("b.key", "b.value");
    conf.getProperties().put("c.key", "c.value");
    conf.setProjectIdentifier("testId");

    templateProcessingConfigurator.configure(conf);

    Assert.assertTrue(targetDir.exists());
    Assert.assertTrue(targetDir.isDirectory());
}

From source file:argendata.service.DatasetServiceImplTest.java

@Test
public void preDatasetStoreTest() {

    PreDataset dataset = DatasetTestFactory.getPreDataset();
    System.out.println(dataset.toString());
    datasetService.store(dataset);/*w w w . j  a  v  a  2s. c  om*/

    PreDataset theDataset = datasetService.asyncGetPreDataset(dataset.getTitleId());
    System.out.println(theDataset);

    Assert.assertTrue(dataset.getTitle().equals(theDataset.getTitle()));
    Assert.assertTrue(dataset.getTitleId().equals(theDataset.getTitleId()));
    Assert.assertTrue(dataset.getLicense().equals(theDataset.getLicense()));
    Assert.assertTrue(dataset.getAccessURL().equals(theDataset.getAccessURL()));
    Assert.assertTrue(dataset.getDataQuality().equals(theDataset.getDataQuality()));
    Assert.assertTrue(dataset.getLocation().equals(theDataset.getLocation()));
    Assert.assertTrue(dataset.getModified().equals(theDataset.getModified()));
    Assert.assertTrue(dataset.getDescription().equals(theDataset.getDescription()));
    Assert.assertTrue(dataset.getSpatial().equals(theDataset.getSpatial()));
    Assert.assertTrue(dataset.getTemporal().equals(theDataset.getTemporal()));
    Assert.assertTrue(dataset.getFormat().equals(theDataset.getFormat()));
    Assert.assertTrue(dataset.getPublisher().equals(theDataset.getPublisher()));

}

From source file:org.apache.vysper.xmpp.extension.xep0124.inttests.AllowedOriginIntegrationTest.java

@Test
public void flashCrossdomain() throws Exception {
    HttpResponse response = httpclient.execute(new HttpGet(getServerUrl() + "crossdomain.xml"));

    String declaration = "<?xml version='1.0'?><!DOCTYPE cross-domain-policy SYSTEM 'http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd'>";

    // XML parser does not support DOCTYPE declarations, so we hack around that here
    String xml = parseFully(response.getEntity().getContent());
    Assert.assertTrue(xml.startsWith(declaration));

    xml = xml.substring(declaration.length());

    XMLElement elm = new XMLUtil(xml).parse();
    Assert.assertEquals("cross-domain-policy", elm.getName());

    Assert.assertEquals(2, elm.getInnerElements().size());

    XMLElement firstChild = elm.getInnerElements().get(0);
    XMLElement secondChild = elm.getInnerElements().get(1);

    Assert.assertEquals("allow-access-from", firstChild.getName());
    Assert.assertEquals("example.com", firstChild.getAttributeValue("domain"));

    Assert.assertEquals("allow-access-from", secondChild.getName());
    Assert.assertEquals("foo.example.com", secondChild.getAttributeValue("domain"));
}

From source file:de.hybris.platform.servicelayer.cronjob.impl.DefaultJobLogConverterTest.java

@Test
public void testValidFormatEmptyLogs() {

    final String result = converter.convert(new ArrayList<JobLogModel>());

    Mockito.verify(formatFactory, Mockito.times(1)).createDateTimeFormat(DateFormat.DEFAULT, -1);

    Assert.assertTrue(StringUtils.isEmpty(result));
}

From source file:com.googlecode.t7mp.steps.ConfigFilesSequenceTest.java

@Test
public void testConfigFilesSequence() throws IOException {
    Mockito.when(configuration.getCatalinaBase()).thenReturn(catalinaBaseDir);
    //        Mockito.when(mojo.getLog()).thenReturn(log);
    Mockito.when(configuration.getTomcatShutdownCommand()).thenReturn("SHUTDOWN");
    Context context = new DefaultContext(new ChainedArtifactResolver(), configuration);
    ConfigFilesSequence sequence = new ConfigFilesSequence();
    sequence.execute(context);//from w  w w.jav a2  s. c  om
    File catalinaProperties = new File(confDirectory, "catalina.properties");
    Assert.assertTrue(catalinaProperties.exists());
    System.out.println(new String(getBytesFromFile(catalinaProperties)));
}

From source file:com.espertech.esper.multithread.StmtIterateCallable.java

public Object call() throws Exception {
    try {//  w  ww .  j  a  v a  2  s  .  c  o  m
        for (int loop = 0; loop < numRepeats; loop++) {
            log.info(".call Thread " + Thread.currentThread().getId() + " sending event " + loop);
            String id = Long.toString(threadNum * 100000000 + loop);
            SupportBean bean = new SupportBean(id, 0);
            engine.getEPRuntime().sendEvent(bean);

            for (int i = 0; i < stmt.length; i++) {
                log.info(".call Thread " + Thread.currentThread().getId() + " starting iterator " + loop);
                SafeIterator<EventBean> it = stmt[i].safeIterator();
                boolean found = false;
                for (; it.hasNext();) {
                    EventBean theEvent = it.next();
                    if (theEvent.get("theString").equals(id)) {
                        found = true;
                    }
                }
                it.close();
                Assert.assertTrue(found);
                log.info(".call Thread " + Thread.currentThread().getId() + " end iterator " + loop);
            }
        }
    } catch (AssertionFailedError ex) {
        log.fatal("Assertion error in thread " + Thread.currentThread().getId(), ex);
        return false;
    } catch (Throwable t) {
        log.fatal("Error in thread " + Thread.currentThread().getId(), t);
        return false;
    }
    return true;
}

From source file:org.wso2.carbon.ganalytics.publisher.GoogleAnalyticsDataPublisherTest.java

@Test
public void testPublishGETHTTPS() throws Exception {
    GoogleAnalyticsData data = new GoogleAnalyticsData.DataBuilder("UA-50303033-1", "1",
            "35009a79-1a05-49d7-b876-2b884d0fsadfa", GoogleAnalyticsConstants.HIT_TYPE_PAGEVIEW)
                    .setDocumentPath("/testpageGET").setDocumentHostName("localhost.com")
                    .setDocumentTitle("HTTPS GET").build();

    String payload = GoogleAnalyticsDataPublisher.buildPayloadString(data);
    Assert.assertTrue(GoogleAnalyticsDataPublisher.publishGET(payload,
            "Mozilla/5.0 (Windows NT 5.1; rv:31.0) Gecko/20100101 Firefox/31.0", true));
}