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

Source Link

Document

Asserts that a condition is false.

Usage

From source file:com.rackspacecloud.blueflood.io.serializers.astyanax.EnumRollupSerializationTest.java

@Test
public void testEnumV1RoundTrip() throws IOException {
    BluefloodEnumRollup e0 = new BluefloodEnumRollup().withEnumValue("enumValue1", 1L)
            .withEnumValue("enumValue2", 5L);
    BluefloodEnumRollup e1 = new BluefloodEnumRollup().withEnumValue(
            "t4.enum.abcdefg.hijklmnop.qrstuvw.xyz.ABCDEFG.HIJKLMNOP.QRSTUVW.XYZ.abcdefg.hijklmnop.qrstuvw.xyz.met",
            34454722343L)// w  ww  . j ava2  s.com
            .withEnumValue(
                    "t5.enum.abcdefg.hijklmnop.qrstuvw.xyz.ABCDEFG.HIJKLMNOP.QRSTUVW.XYZ.abcdefg.hijklmnop.qrstuvw.xyz.met",
                    34454722343L)
            .withEnumValue("enumValue2", 10L);
    BluefloodEnumRollup e2 = new BluefloodEnumRollup().withEnumValue("enumValue1", 1L)
            .withEnumValue("enumValue1", 1L);
    BluefloodEnumRollup er = BluefloodEnumRollup
            .buildRollupFromEnumRollups(Rollups.asPoints(BluefloodEnumRollup.class, 0, 300, e0, e1, e2));
    Assert.assertEquals(4, er.getCount());
    Map<Long, Long> map = er.getHashedEnumValuesWithCounts();
    Assert.assertTrue(map.get((long) "enumValue1".hashCode()) == 3L);
    Assert.assertTrue(map.get((long) "enumValue2".hashCode()) == 15L);

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    baos.write(Base64.encodeBase64(Serializers.enumRollupInstance.toByteBuffer(e0).array()));
    baos.write("\n".getBytes());
    baos.write(Base64.encodeBase64(Serializers.enumRollupInstance.toByteBuffer(e1).array()));
    baos.write("\n".getBytes());
    baos.write(Base64.encodeBase64(Serializers.enumRollupInstance.toByteBuffer(e2).array()));
    baos.write("\n".getBytes());
    baos.write(Base64.encodeBase64(Serializers.enumRollupInstance.toByteBuffer(er).array()));
    baos.write("\n".getBytes());
    baos.close();

    BufferedReader reader = new BufferedReader(
            new InputStreamReader(new ByteArrayInputStream(baos.toByteArray())));

    ByteBuffer bb = ByteBuffer.wrap(Base64.decodeBase64(reader.readLine().getBytes()));
    BluefloodEnumRollup ee0 = Serializers.serializerFor(BluefloodEnumRollup.class).fromByteBuffer(bb);
    Assert.assertEquals(e0, ee0);

    bb = ByteBuffer.wrap(Base64.decodeBase64(reader.readLine().getBytes()));
    BluefloodEnumRollup ee1 = Serializers.serializerFor(BluefloodEnumRollup.class).fromByteBuffer(bb);
    Assert.assertEquals(e1, ee1);

    bb = ByteBuffer.wrap(Base64.decodeBase64(reader.readLine().getBytes()));
    BluefloodEnumRollup ee2 = Serializers.serializerFor(BluefloodEnumRollup.class).fromByteBuffer(bb);
    Assert.assertEquals(e2, ee2);

    bb = ByteBuffer.wrap(Base64.decodeBase64(reader.readLine().getBytes()));
    BluefloodEnumRollup ee3 = Serializers.serializerFor(BluefloodEnumRollup.class).fromByteBuffer(bb);
    Assert.assertEquals(er, ee3);

    Assert.assertFalse(ee0.equals(ee1));
}

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

public void testPostWithLongLog() {
    Log.init(getContext());/*from   w  ww.j av a  2  s  . c  o m*/
    String message = "This is a INFO test";
    String tag = "my.log.info";
    Log.d(tag, message);
    Log.i(tag, message);
    Log.w(tag, message);
    for (int i = 0; i < 200; i++) {
        Log.w("" + i);
    }
    List<String> list = Log.getReportedEntries();
    Assert.assertNotNull(list);
    Assert.assertFalse(list.isEmpty());
    Assert.assertEquals(25, list.size());

    Log.report();
    Log.report("this is a user message", null);
    Exception error = new MalformedChallengeException("error message", new NumberFormatException());
    Log.report(null, error);
}

From source file:org.openmrs.module.webservices.rest.web.v1_0.controller.PersonAttributeControllerTest.java

@Test
public void shouldVoidAttribute() throws Exception {
    PersonAttribute personAttribute = service.getPersonAttributeByUuid(attributeUuid);
    Assert.assertFalse(personAttribute.isVoided());
    controller.delete(personUuid, attributeUuid, "unit test", request, response);
    personAttribute = service.getPersonAttributeByUuid(attributeUuid);
    Assert.assertTrue(personAttribute.isVoided());
    Assert.assertEquals("unit test", personAttribute.getVoidReason());
}

From source file:com.impetus.kundera.EntityManagerImplTest.java

@Test
public void testSingleEntityCRUD_EmCleared() {
    // Persist/*from  w  w w . ja  v  a 2 s.  c  o m*/
    final SampleEntity entity = new SampleEntity();
    entity.setKey(1);
    entity.setName("Amry");
    entity.setCity("Delhi");
    em.persist(entity);

    Assert.assertTrue(em.contains(entity));
    em.clear();
    Assert.assertFalse(em.contains(entity));

    SampleEntity found = em.find(SampleEntity.class, 1, new HashMap<String, Object>());

    assertSampleEntity(found);

    found.setName("Xamry");
    found.setCity("Noida");
    em.clear();
    em.merge(found);

    SampleEntity foundAfterMerge = em.find(SampleEntity.class, 1);
    assertUpdatedSampleEntity(foundAfterMerge);

    // Modify record in dummy database directly
    SampleEntity se = (SampleEntity) DummyDatabase.INSTANCE.getSchema("KunderaTest").getTable("table")
            .getRecord(new Integer(1));
    se.setCity("Singapore");

    em.refresh(foundAfterMerge);
    SampleEntity found2 = em.find(SampleEntity.class, 1);
    Assert.assertEquals("Singapore", found2.getCity());

    em.detach(foundAfterMerge);
    em.clear();
    found = em.find(SampleEntity.class, 1);

    em.remove(found);
    em.clear();
    SampleEntity foundAfterDeletion = em.find(SampleEntity.class, 1);
    Assert.assertNull(foundAfterDeletion);
}

From source file:com.rackspacecloud.blueflood.io.serializers.astyanax.GaugeRollupSerializerTest.java

@Test
public void testSerializerDeserializerV1() throws Exception {
    BluefloodGaugeRollup gauge1 = BluefloodGaugeRollup.buildFromRawSamples(
            Rollups.asPoints(SimpleNumber.class, System.currentTimeMillis(), 300, new SimpleNumber(10L)));
    BluefloodGaugeRollup gauge2 = BluefloodGaugeRollup.buildFromRawSamples(Rollups.asPoints(SimpleNumber.class,
            System.currentTimeMillis() - 100, 300, new SimpleNumber(1234567L)));
    BluefloodGaugeRollup gauge3 = BluefloodGaugeRollup.buildFromRawSamples(Rollups.asPoints(SimpleNumber.class,
            System.currentTimeMillis() - 200, 300, new SimpleNumber(10.4D)));
    BluefloodGaugeRollup gaugesRollup = BluefloodGaugeRollup.buildFromGaugeRollups(Rollups
            .asPoints(BluefloodGaugeRollup.class, System.currentTimeMillis(), 300, gauge1, gauge2, gauge3));
    Assert.assertEquals(3, gaugesRollup.getCount());

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    baos.write(Base64.encodeBase64(Serializers.gaugeRollupInstance.toByteBuffer(gauge1).array()));
    baos.write("\n".getBytes());
    baos.write(Base64.encodeBase64(Serializers.gaugeRollupInstance.toByteBuffer(gauge2).array()));
    baos.write("\n".getBytes());
    baos.write(Base64.encodeBase64(Serializers.gaugeRollupInstance.toByteBuffer(gauge3).array()));
    baos.write("\n".getBytes());
    baos.write(Base64.encodeBase64(Serializers.gaugeRollupInstance.toByteBuffer(gaugesRollup).array()));
    baos.write("\n".getBytes());
    baos.close();/*from   w  ww  .j a v a2  s  .  c  o m*/

    BufferedReader reader = new BufferedReader(
            new InputStreamReader(new ByteArrayInputStream(baos.toByteArray())));

    ByteBuffer bb = ByteBuffer.wrap(Base64.decodeBase64(reader.readLine().getBytes()));
    BluefloodGaugeRollup deserializedGauge1 = Serializers.serializerFor(BluefloodGaugeRollup.class)
            .fromByteBuffer(bb);
    Assert.assertEquals(gauge1, deserializedGauge1);

    bb = ByteBuffer.wrap(Base64.decodeBase64(reader.readLine().getBytes()));
    BluefloodGaugeRollup deserializedGauge2 = Serializers.serializerFor(BluefloodGaugeRollup.class)
            .fromByteBuffer(bb);
    Assert.assertEquals(gauge2, deserializedGauge2);

    bb = ByteBuffer.wrap(Base64.decodeBase64(reader.readLine().getBytes()));
    BluefloodGaugeRollup deserializedGauge3 = Serializers.serializerFor(BluefloodGaugeRollup.class)
            .fromByteBuffer(bb);
    Assert.assertEquals(gauge3, deserializedGauge3);

    bb = ByteBuffer.wrap(Base64.decodeBase64(reader.readLine().getBytes()));
    BluefloodGaugeRollup deserializedGauge4 = Serializers.serializerFor(BluefloodGaugeRollup.class)
            .fromByteBuffer(bb);
    Assert.assertEquals(gaugesRollup, deserializedGauge4);

    Assert.assertFalse(deserializedGauge1.equals(deserializedGauge2));
}

From source file:com.rackspacecloud.blueflood.io.serializers.EnumRollupSerializationTest.java

@Test
public void testEnumV1RoundTrip() throws IOException {
    BluefloodEnumRollup e0 = new BluefloodEnumRollup().withEnumValue("enumValue1", 1L)
            .withEnumValue("enumValue2", 5L);
    BluefloodEnumRollup e1 = new BluefloodEnumRollup().withEnumValue(
            "t4.enum.abcdefg.hijklmnop.qrstuvw.xyz.ABCDEFG.HIJKLMNOP.QRSTUVW.XYZ.abcdefg.hijklmnop.qrstuvw.xyz.met",
            34454722343L)/*from   www  . j  a v a2  s .  co m*/
            .withEnumValue(
                    "t5.enum.abcdefg.hijklmnop.qrstuvw.xyz.ABCDEFG.HIJKLMNOP.QRSTUVW.XYZ.abcdefg.hijklmnop.qrstuvw.xyz.met",
                    34454722343L)
            .withEnumValue("enumValue2", 10L);
    BluefloodEnumRollup e2 = new BluefloodEnumRollup().withEnumValue("enumValue1", 1L)
            .withEnumValue("enumValue1", 1L);
    BluefloodEnumRollup er = BluefloodEnumRollup
            .buildRollupFromEnumRollups(Rollups.asPoints(BluefloodEnumRollup.class, 0, 300, e0, e1, e2));
    Assert.assertEquals(4, er.getCount());
    Map<Long, Long> map = er.getHashedEnumValuesWithCounts();
    Assert.assertTrue(map.get((long) "enumValue1".hashCode()) == 3L);
    Assert.assertTrue(map.get((long) "enumValue2".hashCode()) == 15L);

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    baos.write(Base64.encodeBase64(new NumericSerializer.EnumRollupSerializer().toByteBuffer(e0).array()));
    baos.write("\n".getBytes());
    baos.write(Base64.encodeBase64(new NumericSerializer.EnumRollupSerializer().toByteBuffer(e1).array()));
    baos.write("\n".getBytes());
    baos.write(Base64.encodeBase64(new NumericSerializer.EnumRollupSerializer().toByteBuffer(e2).array()));
    baos.write("\n".getBytes());
    baos.write(Base64.encodeBase64(new NumericSerializer.EnumRollupSerializer().toByteBuffer(er).array()));
    baos.write("\n".getBytes());
    baos.close();

    BufferedReader reader = new BufferedReader(
            new InputStreamReader(new ByteArrayInputStream(baos.toByteArray())));

    ByteBuffer bb = ByteBuffer.wrap(Base64.decodeBase64(reader.readLine().getBytes()));
    BluefloodEnumRollup ee0 = NumericSerializer.serializerFor(BluefloodEnumRollup.class).fromByteBuffer(bb);
    Assert.assertEquals(e0, ee0);

    bb = ByteBuffer.wrap(Base64.decodeBase64(reader.readLine().getBytes()));
    BluefloodEnumRollup ee1 = NumericSerializer.serializerFor(BluefloodEnumRollup.class).fromByteBuffer(bb);
    Assert.assertEquals(e1, ee1);

    bb = ByteBuffer.wrap(Base64.decodeBase64(reader.readLine().getBytes()));
    BluefloodEnumRollup ee2 = NumericSerializer.serializerFor(BluefloodEnumRollup.class).fromByteBuffer(bb);
    Assert.assertEquals(e2, ee2);

    bb = ByteBuffer.wrap(Base64.decodeBase64(reader.readLine().getBytes()));
    BluefloodEnumRollup ee3 = NumericSerializer.serializerFor(BluefloodEnumRollup.class).fromByteBuffer(bb);
    Assert.assertEquals(er, ee3);

    Assert.assertFalse(ee0.equals(ee1));
}

From source file:io.seldon.recommendation.VariationTestingClientStrategyTest.java

@Test
public void rangeTest() {
    BigDecimal ratioTotal = new BigDecimal(1.0);
    BigDecimal currentMax = new BigDecimal(0.0);
    BigDecimal r1 = new BigDecimal(0.9);
    BigDecimal r2 = new BigDecimal(0.1);
    NumberRange range1 = new NumberRange(currentMax,
            currentMax.add(r1.divide(ratioTotal, 5, BigDecimal.ROUND_UP)));
    currentMax = currentMax.add(r1);/*from   w ww. j  av  a2  s . co  m*/
    NumberRange range2 = new NumberRange(currentMax.add(new BigDecimal(0.0001)),
            currentMax.add(r2.divide(ratioTotal, 5, BigDecimal.ROUND_UP)));
    BigDecimal t = new BigDecimal(0.900001);
    Assert.assertTrue(range1.containsNumber(t));
    Assert.assertFalse(range2.containsNumber(t));
    BigDecimal t2 = new BigDecimal(0.901);
    Assert.assertFalse(range1.containsNumber(t2));
    Assert.assertTrue(range2.containsNumber(t2));

}

From source file:com.rackspacecloud.blueflood.io.serializers.GaugeRollupSerializerTest.java

@Test
public void testSerializerDeserializerV1() throws Exception {
    BluefloodGaugeRollup gauge1 = BluefloodGaugeRollup.buildFromRawSamples(
            Rollups.asPoints(SimpleNumber.class, System.currentTimeMillis(), 300, new SimpleNumber(10L)));
    BluefloodGaugeRollup gauge2 = BluefloodGaugeRollup.buildFromRawSamples(Rollups.asPoints(SimpleNumber.class,
            System.currentTimeMillis() - 100, 300, new SimpleNumber(1234567L)));
    BluefloodGaugeRollup gauge3 = BluefloodGaugeRollup.buildFromRawSamples(Rollups.asPoints(SimpleNumber.class,
            System.currentTimeMillis() - 200, 300, new SimpleNumber(10.4D)));
    BluefloodGaugeRollup gaugesRollup = BluefloodGaugeRollup.buildFromGaugeRollups(Rollups
            .asPoints(BluefloodGaugeRollup.class, System.currentTimeMillis(), 300, gauge1, gauge2, gauge3));
    Assert.assertEquals(3, gaugesRollup.getCount());

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    baos.write(Base64.encodeBase64(new NumericSerializer.GaugeRollupSerializer().toByteBuffer(gauge1).array()));
    baos.write("\n".getBytes());
    baos.write(Base64.encodeBase64(new NumericSerializer.GaugeRollupSerializer().toByteBuffer(gauge2).array()));
    baos.write("\n".getBytes());
    baos.write(Base64.encodeBase64(new NumericSerializer.GaugeRollupSerializer().toByteBuffer(gauge3).array()));
    baos.write("\n".getBytes());
    baos.write(Base64// w  ww. j av  a2s.c  o  m
            .encodeBase64(new NumericSerializer.GaugeRollupSerializer().toByteBuffer(gaugesRollup).array()));
    baos.write("\n".getBytes());
    baos.close();

    BufferedReader reader = new BufferedReader(
            new InputStreamReader(new ByteArrayInputStream(baos.toByteArray())));

    ByteBuffer bb = ByteBuffer.wrap(Base64.decodeBase64(reader.readLine().getBytes()));
    BluefloodGaugeRollup deserializedGauge1 = NumericSerializer.serializerFor(BluefloodGaugeRollup.class)
            .fromByteBuffer(bb);
    Assert.assertEquals(gauge1, deserializedGauge1);

    bb = ByteBuffer.wrap(Base64.decodeBase64(reader.readLine().getBytes()));
    BluefloodGaugeRollup deserializedGauge2 = NumericSerializer.serializerFor(BluefloodGaugeRollup.class)
            .fromByteBuffer(bb);
    Assert.assertEquals(gauge2, deserializedGauge2);

    bb = ByteBuffer.wrap(Base64.decodeBase64(reader.readLine().getBytes()));
    BluefloodGaugeRollup deserializedGauge3 = NumericSerializer.serializerFor(BluefloodGaugeRollup.class)
            .fromByteBuffer(bb);
    Assert.assertEquals(gauge3, deserializedGauge3);

    bb = ByteBuffer.wrap(Base64.decodeBase64(reader.readLine().getBytes()));
    BluefloodGaugeRollup deserializedGauge4 = NumericSerializer.serializerFor(BluefloodGaugeRollup.class)
            .fromByteBuffer(bb);
    Assert.assertEquals(gaugesRollup, deserializedGauge4);

    Assert.assertFalse(deserializedGauge1.equals(deserializedGauge2));
}

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

@Test
public void testShowing() {
    VectorServerLayerImpl layer = new VectorServerLayerImpl(mapConfig, layerInfo, viewPort, eventBus);

    // Scale between 6 and 20 is OK:
    viewPort.applyResolution(viewPort.getResolution(5)); // 32 -> NOK
    Assert.assertFalse(layer.isShowing());

    viewPort.applyResolution(viewPort.getResolution(4)); // 16 -> OK
    Assert.assertTrue(layer.isShowing());

    viewPort.applyResolution(viewPort.getResolution(3)); // 8 -> OK
    Assert.assertTrue(layer.isShowing());

    viewPort.applyResolution(viewPort.getResolution(2)); // 4 -> NOK
    Assert.assertFalse(layer.isShowing());

    viewPort.applyResolution(viewPort.getResolution(1)); // 2 -> NOK
    Assert.assertFalse(layer.isShowing());

    viewPort.applyResolution(viewPort.getResolution(0)); // 1 -> NOK
    Assert.assertFalse(layer.isShowing());

    // Mark as invisible:
    layer.setMarkedAsVisible(false);//from ww  w  .j a  va 2 s  . c  o  m
    viewPort.applyResolution(viewPort.getResolution(5)); // 32 -> NOK
    Assert.assertFalse(layer.isShowing());

    viewPort.applyResolution(viewPort.getResolution(4)); // 16 -> NOK
    Assert.assertFalse(layer.isShowing());
}

From source file:com.streamreduce.datasource.BootstrapDatabaseDataPopulatorITCase.java

/**
 * Make sure connections and inventory items that are public do not leak sensitive information.
 *
 * @throws Exception if anything goes wrong
 *///w ww  .j av a  2  s  .c  o  m
@Test
@Ignore
public void testForSecurityLeaks() throws Exception {
    // NOTE: This could be put elsewhere but since it was written as part of SOBA-1855, here it sits for now

    String authnToken = login(testUsername, testUsername);
    List<ConnectionResponseDTO> allConnections = jsonToObject(
            makeRequest(connectionsBaseUrl, "GET", null, authnToken),
            TypeFactory.defaultInstance().constructCollectionType(List.class, ConnectionResponseDTO.class));
    String awsAccessKeyId = cloudProperties.getString("nodeable.integrations.aws.accessKeyId");
    String awsSecretKey = cloudProperties.getString("nodeable.integrations.aws.secretKey");

    Assert.assertEquals(26, allConnections.size());

    for (ConnectionResponseDTO connection : allConnections) {
        // Make sure public connections do not have the connection credentials in them
        Assert.assertFalse(connection.isOwner());
        Assert.assertNull(connection.getIdentity());

        // Only cloud inventory items can be leaked so let's filter our inventory items
        if (connection.getType().equals(CloudProvider.TYPE)) {
            inventoryService.refreshInventoryItemCache(connectionService.getConnection(connection.getId()));

            List<InventoryItem> rawInventoryItems = inventoryService.getInventoryItems(connection.getId());
            int retry = 0;

            while (rawInventoryItems.size() == 0 && retry < 3) {
                Thread.sleep(30000);
                rawInventoryItems = inventoryService.getInventoryItems(connection.getId());
                retry++;
            }

            if (rawInventoryItems.size() == 0) {
                throw new Exception("Unable to prepare for the test so tests are unable to run.");
            }

            // Make sure public inventory items do not have anything sensitive in them
            String rawResponse = makeRequest(connectionsBaseUrl + "/" + connection.getId() + "/inventory",
                    "GET", null, authnToken);
            ConnectionInventoryResponseDTO responseDTO = jsonToObject(rawResponse,
                    TypeFactory.defaultInstance().constructType(ConnectionInventoryResponseDTO.class));

            for (InventoryItemResponseDTO inventoryItem : responseDTO.getInventoryItems()) {
                BasicDBObject payload = inventoryItem.getPayload();

                Assert.assertFalse(JSONObject.fromObject(payload).toString().contains(awsAccessKeyId));
                Assert.assertFalse(JSONObject.fromObject(payload).toString().contains(awsSecretKey));
                Assert.assertFalse(payload.containsField("adminPassword"));
                Assert.assertFalse(payload.containsField("credentials"));
            }

        }
    }
}