Example usage for junit.framework Assert assertEquals

List of usage examples for junit.framework Assert assertEquals

Introduction

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

Prototype

static public void assertEquals(int expected, int actual) 

Source Link

Document

Asserts that two ints are equal.

Usage

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

/**
 * Verify the custom generator is applied to the testDao.
 * // w w  w.j ava 2  s. c  o  m
 * @throws Exception
 */
@Test
public void testOverrideDefaultCacheKeyGenerator() throws Exception {
    this.testDao.call("foo");
    Assert.assertEquals(1, testDao.getCallCount());
    Assert.assertEquals(1, cacheKeyGenerator.getCallCount());

    this.testDao.call("foo");
    Assert.assertEquals(1, testDao.getCallCount());
    Assert.assertEquals(2, cacheKeyGenerator.getCallCount());

    this.testDao.call("foo");
    Assert.assertEquals(1, testDao.getCallCount());
    Assert.assertEquals(3, cacheKeyGenerator.getCallCount());
}

From source file:org.obiba.onyx.core.service.impl.AnyPasswordValidationStrategyImplTest.java

@Test
public void testGeneratePasswordReturnsConstant() {
    String password = anyPasswordStrategy.generatePassword(user);
    Assert.assertEquals(AnyPasswordValidationStrategyImpl.password, password);
}

From source file:at.uni_salzburg.cs.ckgroup.cscpp.mapper.registry.RegistryPersistenceTestCase.java

@Test
public void test() throws IOException, ParseException {
    URL storage = RegistryPersistenceTestCase.class.getResource("storage01.dat");
    File storagePath = new File(storage.getPath());

    Map<String, IRegistrationData> registrationData = new HashMap<String, IRegistrationData>();
    RegistryPersistence.loadRegistry(storagePath, registrationData);
    IRegistrationData d1 = registrationData.get("http://localhost:8080/engine");
    Assert.assertNotNull(d1);//from ww w.  jav  a 2 s  .  c  om
    String engineUri = d1.getEngineUrl();
    Assert.assertEquals("http://localhost:8080/engine", engineUri);

    String pilotUri = d1.getPilotUrl();
    Assert.assertEquals("http://localhost:8080/pilot", pilotUri);

    Set<String> sensors = d1.getSensors();
    Assert.assertEquals(7, sensors.size());
    Assert.assertTrue(sensors.contains("sonar"));
    Assert.assertTrue(sensors.contains("position"));
    Assert.assertTrue(sensors.contains("random"));
    Assert.assertTrue(sensors.contains("photo"));
    Assert.assertTrue(sensors.contains("video"));
    Assert.assertTrue(sensors.contains("airPressure"));
    Assert.assertTrue(sensors.contains("temperature"));

    List<IWayPoint> wayPoints = d1.getWaypoints();
    Assert.assertEquals(17, wayPoints.size());

    Assert.assertTrue(wayPoints.get(0) instanceof WayPoint);
    WayPoint wayPoint = (WayPoint) wayPoints.get(0);

    System.out.println("test() " + wayPoint.toJSONString());

    Assert.assertEquals(
            "{\"precision\":1.0,\"altitude\":1.0,\"velocity\":1.0,\"longitude\":13.04092571,\"latitude\":47.82204197}",
            wayPoint.toJSONString());
    Assert.assertEquals("(47.82204197, 13.04092571, 1.000) precision 1 velocity 1.0",
            wayPoints.get(0).toString());

    File tmpFile = File.createTempFile("mapper", ".dat");
    RegistryPersistence.storeRegistry(tmpFile, registrationData);

    String expected = FileUtils.loadFileAsString(storagePath);
    Assert.assertEquals(1860, expected.length());

    String actual = FileUtils.loadFileAsString(tmpFile);
    Assert.assertEquals(1860, actual.length());

    Assert.assertEquals(expected, actual);
    tmpFile.delete();
}

From source file:philaman.cput.cardealer.test.service.VehiclePriceRangeServiceTest.java

@Test
public void hello() {
    repo = ctx.getBean(ModelRepository.class);
    service = ctx.getBean(VehiclePriceRangeService.class);

    Model model = new Model.Builder("3-series").make("BMW").bodyType("Sedan").modelDescr("open sunroof")
            .price(250000).build();//from ww w. java 2  s  . c om
    Model model1 = new Model.Builder("Mazda 5").make("Mazda").bodyType("hatch").price(180000).build();
    Model model2 = new Model.Builder("Tazz").make("Toyota").bodyType("Sedan").price(120000).build();
    Model model3 = new Model.Builder("Golf 3").make("VW").bodyType("hatch").price(190000).build();
    Model model4 = new Model.Builder("323").make("Mazda").bodyType("hatch").price(80000).build();

    repo.save(model);
    repo.save(model1);
    repo.save(model2);
    repo.save(model3);
    repo.save(model4);

    List<Model> carsInRange = service.getVehicleInPriceRange(90000.0, 200000.0);
    Assert.assertEquals(3, carsInRange.size());
}

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

public Object call() throws Exception {
    try {//from   www  . java2s  .c  o m
        long total = 0;
        for (int loop = 0; loop < numRepeats; loop++) {
            // Insert event into named window
            sendMarketBean(threadKey, loop);
            total++;

            String selectQuery = "select * from MyWindow where theString='" + threadKey + "' and longPrimitive="
                    + loop;
            EPOnDemandQueryResult queryResult = engine.executeQuery(selectQuery);
            Assert.assertEquals(1, queryResult.getArray().length);
            Assert.assertEquals(threadKey, queryResult.getArray()[0].get("theString"));
            Assert.assertEquals((long) loop, queryResult.getArray()[0].get("longPrimitive"));
        }
    } catch (Exception ex) {
        log.fatal("Error in thread " + Thread.currentThread().getId(), ex);
        return false;
    }
    return true;
}

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 w w .  j a  v a  2  s . co  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.jasig.ssp.util.importer.job.twodottwo.StageFailTest.java

@Test
public void testStageFail() throws Exception {

    //Test file has duplicate values and should fail on stage, where skip limit is set to 1
    BatchStatus exitStatus = jobLauncherTestUtils.launchJob().getStatus();

    Assert.assertEquals(BatchStatus.FAILED, exitStatus);

}

From source file:com.mirth.connect.plugins.datatypes.edi.test.EDISerializerTest.java

@Test
public void testIssue1597fromXML() throws Exception {
    String input = FileUtils.readFileToString(new File("tests/test-1597-input-missing-elements.xml"));
    String output = FileUtils.readFileToString(new File("tests/test-1597-output.txt"));
    EDISerializer serializer = new EDISerializer(new EDIDataTypeProperties().getSerializerProperties());
    Assert.assertEquals(output, serializer.fromXML(input));
}

From source file:org.ocpsoft.rewrite.annotation.visit.AnnotationConfigurationTest.java

@Test
public void testControl() throws Exception {
    HttpAction<HttpGet> action = get("/annotation/control");
    Assert.assertEquals(404, action.getResponse().getStatusLine().getStatusCode());
}

From source file:org.jasig.ssp.util.importer.job.twodottwo.ReportAccuracyTest.java

@SuppressWarnings("unchecked")
@Test/*from w w w  .j  a v  a 2s  .co m*/
public void testJob() throws Exception {

    JobExecution jobExecution = jobLauncherTestUtils.launchJob();

    Map<String, ReportEntry> report = (Map<String, ReportEntry>) jobExecution.getExecutionContext()
            .get("report");
    Assert.assertNotNull(report);
    Set<Entry<String, ReportEntry>> entrySet = report.entrySet();
    Assert.assertEquals(3, entrySet.size());
    for (Entry<String, ReportEntry> entry : entrySet) {
        Assert.assertEquals(new Integer(2), entry.getValue().getNumberInsertedUpdated());
    }

}