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:com.impetus.client.crud.compositeType.CQLTranslatorTest.java

@Test
public void testPrepareColumns() {
    logger.info("On prepare columns.");
    CQLTranslator translator = new CQLTranslator();
    UUID timeLineId = UUID.randomUUID();
    Date currentDate = new Date();
    CassandraCompoundKey key = new CassandraCompoundKey("mevivs", 1, timeLineId);
    CassandraPrimeUser user = new CassandraPrimeUser(key);
    user.setTweetBody("my first tweet");
    user.setTweetDate(currentDate);/*w w  w .j a v a 2  s.  c om*/
    EntityMetadata entityMetadata = KunderaMetadataManager.getEntityMetadata(
            ((EntityManagerFactoryImpl) emf).getKunderaMetadataInstance(), CassandraPrimeUser.class);
    Map<String, StringBuilder> translatedSql = translator.prepareColumnOrColumnValues(user, entityMetadata,
            TranslationType.VALUE, null, ((EntityManagerFactoryImpl) emf).getKunderaMetadataInstance())
            .get(TranslationType.VALUE);
    String columnAsCsv = "'mevivs',1,"
            + timeLineId /*+ ",'my first tweet','" + currentDate.getTime() + */ /*+ "'"*/;

    Assert.assertTrue(
            StringUtils.contains(translatedSql.get(entityMetadata.getTableName()).toString(), columnAsCsv));
    //        Assert.assertEquals(columnAsCsv, translatedSql);
}

From source file:com.impetus.kundera.client.cassandra.composite.DSCQLTranslatorTest.java

@Test
public void testPrepareColumns() {
    logger.info("On prepare columns.");
    CQLTranslator translator = new CQLTranslator();
    UUID timeLineId = UUID.randomUUID();
    Date currentDate = new Date();
    UserTimeLine key = new UserTimeLine("mevivs", 1, timeLineId);
    PrimeUser user = new PrimeUser(key);
    user.setTweetBody("my first tweet");
    user.setTweetDate(currentDate);/*from   w  w w  .j ava  2 s .c o  m*/
    EntityMetadata entityMetadata = KunderaMetadataManager
            .getEntityMetadata(((EntityManagerFactoryImpl) emf).getKunderaMetadataInstance(), PrimeUser.class);
    Map<String, StringBuilder> translatedSql = translator.prepareColumnOrColumnValues(user, entityMetadata,
            TranslationType.VALUE, null, ((EntityManagerFactoryImpl) emf).getKunderaMetadataInstance())
            .get(TranslationType.VALUE);
    String columnAsCsv = "'mevivs',1,"
            + timeLineId /*+ ",'my first tweet','" + currentDate.getTime() + */ /*+ "'"*/;

    Assert.assertTrue(
            StringUtils.contains(translatedSql.get(entityMetadata.getTableName()).toString(), columnAsCsv));
    //        Assert.assertEquals(columnAsCsv, translatedSql);
}

From source file:org.ocpsoft.redoculous.tests.markdown.MarkdownRenderTest.java

@Test
public void testServeMarkdown() throws Exception {
    WebTest test = new WebTest(baseUrl);
    String repositoryURL = "file://" + repository.getAbsolutePath();
    HttpAction<HttpPost> action = test.post("/api/v1/manage?repo=" + repositoryURL);
    Assert.assertEquals(201, action.getResponse().getStatusLine().getStatusCode());
    String location = URLDecoder.decode(action.getResponseHeaderValue("location"), "UTF8");
    Assert.assertEquals(test.getBaseURL() + test.getContextPath() + "/api/v1/serve?repo=" + repositoryURL,
            location);/*from w  ww .  ja va  2s.c  om*/

    HttpAction<HttpGet> document = test
            .get("/api/v1/serve?repo=" + repositoryURL + "&ref=master&path=document");
    Assert.assertTrue(document.getResponseContent().contains("<h1"));
    Assert.assertTrue(document.getResponseContent().contains("A First Level Header"));
}

From source file:edu.uci.ics.jung.io.TestGraphMLReader.java

public void testLoad() throws IOException {
    String testFilename = "toy_graph.ml";

    Graph<Number, Number> graph = loadGraph(testFilename);

    Assert.assertEquals(graph.getVertexCount(), 3);
    Assert.assertEquals(graph.getEdgeCount(), 3);

    BidiMap<Number, String> vertex_ids = gmlreader.getVertexIDs();

    Number joe = vertex_ids.getKey("1");
    Number bob = vertex_ids.getKey("2");
    Number sue = vertex_ids.getKey("3");

    Assert.assertNotNull(joe);/*  w w  w.j a  v a2  s.c  om*/
    Assert.assertNotNull(bob);
    Assert.assertNotNull(sue);

    Map<String, GraphMLMetadata<Number>> vertex_metadata = gmlreader.getVertexMetadata();
    Transformer<Number, String> name = vertex_metadata.get("name").transformer;
    Assert.assertEquals(name.transform(joe), "Joe");
    Assert.assertEquals(name.transform(bob), "Bob");
    Assert.assertEquals(name.transform(sue), "Sue");

    Assert.assertTrue(graph.isPredecessor(joe, bob));
    Assert.assertTrue(graph.isPredecessor(bob, joe));
    Assert.assertTrue(graph.isPredecessor(sue, joe));
    Assert.assertFalse(graph.isPredecessor(joe, sue));
    Assert.assertFalse(graph.isPredecessor(sue, bob));
    Assert.assertFalse(graph.isPredecessor(bob, sue));

    File testFile = new File(testFilename);
    testFile.delete();
}

From source file:com.netflix.curator.TestSessionFailRetryLoop.java

@Test
public void testRetry() throws Exception {
    Timing timing = new Timing();
    final CuratorZookeeperClient client = new CuratorZookeeperClient(server.getConnectString(),
            timing.session(), timing.connection(), null, new RetryOneTime(1));
    SessionFailRetryLoop retryLoop = client.newSessionFailRetryLoop(SessionFailRetryLoop.Mode.RETRY);
    retryLoop.start();//from  ww w .  j  a  v  a  2  s .  c o  m
    try {
        client.start();
        final AtomicBoolean secondWasDone = new AtomicBoolean(false);
        final AtomicBoolean firstTime = new AtomicBoolean(true);
        while (retryLoop.shouldContinue()) {
            try {
                RetryLoop.callWithRetry(client, new Callable<Void>() {
                    @Override
                    public Void call() throws Exception {
                        if (firstTime.compareAndSet(true, false)) {
                            Assert.assertNull(client.getZooKeeper().exists("/foo/bar", false));
                            KillSession.kill(client.getZooKeeper(), server.getConnectString());
                            client.getZooKeeper();
                            client.blockUntilConnectedOrTimedOut();
                        }

                        Assert.assertNull(client.getZooKeeper().exists("/foo/bar", false));
                        return null;
                    }
                });

                RetryLoop.callWithRetry(client, new Callable<Void>() {
                    @Override
                    public Void call() throws Exception {
                        Assert.assertFalse(firstTime.get());
                        Assert.assertNull(client.getZooKeeper().exists("/foo/bar", false));
                        secondWasDone.set(true);
                        return null;
                    }
                });
            } catch (Exception e) {
                retryLoop.takeException(e);
            }
        }

        Assert.assertTrue(secondWasDone.get());
    } finally {
        retryLoop.close();
        IOUtils.closeQuietly(client);
    }
}

From source file:org.geomajas.gwt2.client.map.layer.VectorLayerTest.java

@Test
public void testSelection() {
    VectorServerLayerImpl layer = new VectorServerLayerImpl(mapConfig, layerInfo, viewPort, eventBus);
    Assert.assertFalse(layer.isSelected());
    layer.setSelected(true);/*  w  w  w. ja v  a2 s.  c om*/
    Assert.assertTrue(layer.isSelected());
    layer.setSelected(false);
    Assert.assertFalse(layer.isSelected());
}

From source file:com.couchbase.lite.BlobStoreTest.java

public void testBasic() throws Exception {
    if (!isSQLiteDB())
        return;//from   www  .  j  ava 2  s.  c  om

    byte[] item = "this is an item".getBytes("UTF8");
    BlobKey key = new BlobKey();
    BlobKey key2 = new BlobKey();
    store.storeBlob(item, key);
    store.storeBlob(item, key2);
    Assert.assertTrue(Arrays.equals(key.getBytes(), key2.getBytes()));

    byte[] readItem = store.blobForKey(key);
    Assert.assertTrue(Arrays.equals(readItem, item));
    verifyRawBlob(key, item);

    String path = store.getBlobPathForKey(key);
    Assert.assertEquals((path == null), encrypt); // path is returned if not encrypted
}

From source file:org.openmrs.web.controller.maintenance.SystemInformationControllerTest.java

/**
 * @see SystemInformationController#showPage(ModelMap)
 *///from  ww w. j  a v  a  2s.  c om
@Test
@Verifies(value = "should add memory information attribute to the model map", method = "getMemoryInformation()")
public void getMemoryInformation_shouldReturnMemoryInformation() {
    Assert.assertTrue(((Map<String, Map<String, String>>) model.get("systemInfo"))
            .containsKey("SystemInfo.title.memoryInformation"));
}

From source file:de.hybris.platform.integration.cis.tax.strategies.impl.DefaultCisCalculateExternalTaxesFallbackStrategyTest.java

@Test
public void shouldCalculateTaxesWithFallbackForOrderWithZeroDeliveryCost() {
    given(abstractOrder.getDeliveryCost()).willReturn(null);
    final ExternalTaxDocument taxDocument = defaultCisCalculateExternalTaxesFallbackStrategy
            .calculateExternalTaxes(abstractOrder);
    Assert.assertNotNull(taxDocument);/*from www . j  a va 2  s .c o  m*/
    Assert.assertTrue(taxDocument.getAllTaxes().size() > 0);
    Assert.assertTrue(taxDocument.getShippingCostTaxes().size() == 0);
}

From source file:com.couchbase.lite.performance2.Test06_PullReplication.java

public double runOne(final int numberOfDocuments, final int sizeOfDocuments) throws Exception {
    String[] bigObj = new String[sizeOfDocuments];
    for (int i = 0; i < sizeOfDocuments; i++) {
        bigObj[i] = _propertyValue;/*from  w  w  w  .j av a2s  .c o  m*/
    }
    final Map<String, Object> props = new HashMap<String, Object>();
    props.put("bigArray", bigObj);

    String docIdTimestamp = Long.toString(System.currentTimeMillis());

    for (int i = 0; i < numberOfDocuments; i++) {
        String docId = String.format("doc%d-%s", i, docIdTimestamp);

        try {
            addDocWithId(docId, props, "attachment.png", false);
            //addDocWithId(docId, null, false);
        } catch (IOException ioex) {
            Log.v("PerformanceStats", TAG + ", Add document directly to sync gateway failed", ioex);
            fail();
        }
    }

    URL remote = getReplicationURL();
    final Replication replPush = database.createPushReplication(remote);
    replPush.setContinuous(false);
    if (!isSyncGateway(remote)) {
        replPush.setCreateTarget(true);
        Assert.assertTrue(replPush.shouldCreateTarget());
    }
    Log.v("PerformanceStats", TAG + ", Starting pushing operation with: " + replPush);
    runReplication(replPush);
    Log.v("PerformanceStats", TAG + ", Finished pushing operation with: " + replPush);

    long startMillis = System.currentTimeMillis();
    final Replication replPull = (Replication) database.createPullReplication(remote);
    replPull.setContinuous(false);
    Log.v("PerformanceStats", TAG + ", Starting pull replication with: " + replPull);
    runReplication(replPull);
    double executionTime = Long.valueOf(System.currentTimeMillis() - startMillis);
    Log.v("PerformanceStats", TAG + ", " + executionTime + "," + numberOfDocuments + "," + sizeOfDocuments);
    assertNotNull(database);
    Log.v("PerformanceStats", TAG + ", Finished pull replication with: " + replPull);
    return executionTime;
}