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:org.openxdata.server.service.impl.PermissionServiceTest.java

@Test
public void savePermission_shouldSavePermission() throws Exception {
    final String permissionName = "Permission Name";

    List<Permission> permissions = permissionService.getPermissions();
    Assert.assertEquals(75, permissions.size());
    Assert.assertNull(permissionService.getPermission(permissionName));

    permissionService.savePermission(new Permission(permissionName));

    permissions = permissionService.getPermissions();
    Assert.assertEquals(76, permissionService.getPermissions().size());
    Assert.assertNotNull(permissionService.getPermission(permissionName));
}

From source file:com.google.api.ads.adwords.awreporting.model.definitions.ReportDisplayKeywordDefinitionTest.java

/**
 * @see com.google.api.ads.adwords.awreporting.model.definitions.
 * AbstractReportDefinitionTest#testFirstEntry(
 * com.google.api.ads.adwords.awreporting.model.entities.Report)
 *///  w  w  w .  j a v  a  2s  .co m
@Override
protected void testFirstEntry(ReportDisplayKeyword first) {
    Assert.assertEquals(1056270861L, first.getAccountId().longValue());
    Assert.assertEquals("2014-06-09", first.getDay());
    Assert.assertEquals(0.00, first.getCost().doubleValue());
    Assert.assertEquals(0L, first.getClicks().longValue());
    Assert.assertEquals(59L, first.getImpressions().longValue());
    Assert.assertEquals(0L, first.getConversions().longValue());
    Assert.assertEquals(0.00, first.getCtrBigDecimal().doubleValue());
    Assert.assertEquals(0.00, first.getAvgCpm().doubleValue());
    Assert.assertEquals(0.00, first.getAvgCpc().doubleValue());

    Assert.assertEquals(208108586L, first.getCampaignId().longValue());
    Assert.assertEquals("Search IP", first.getCampaignName());
    Assert.assertEquals(11390393906L, first.getAdGroupId().longValue());
    Assert.assertEquals("Gen", first.getAdGroupName());
    Assert.assertEquals("", first.getDestinationUrl());
    Assert.assertEquals(10024300L, first.getKeywordId().longValue());
    Assert.assertEquals("restaurant", first.getKeywordText());
    Assert.assertFalse(first.isNegative());
}

From source file:net.awired.generic.jpa.impl.GenericDaoImplTest.java

@Test
public void should_update_entity() throws Exception {
    EntityTest entity = new EntityTest();
    entity.setName("genre2");
    EntityTest persisted = save(entity);
    persisted.setName("newgenre");
    save(persisted);//  w w  w.  ja v  a  2  s  .  c om

    EntityTest res = find(persisted.getId());
    Assert.assertEquals("newgenre", res.getName());
}

From source file:com.comcast.viper.flume2storm.location.StaticLocationServiceConfigurationTest.java

/**
 * Test {@link StaticLocationServiceConfiguration#from(Configuration)}
 *
 * @throws F2SConfigurationException//from   w  w  w  . j  ava  2 s.  c o m
 *           If the configuration is invalid
 */
@Test
public void testFromConfiguration() throws F2SConfigurationException {
    String configurationLoaderClassName = SimpleServiceProviderConfigurationLoader.class.getCanonicalName();
    String serviceProviderBase = "whatever";
    Configuration config = new BaseConfiguration();
    config.addProperty(StaticLocationServiceConfiguration.CONFIGURATION_LOADER_CLASS,
            configurationLoaderClassName);
    config.addProperty(StaticLocationServiceConfiguration.SERVICE_PROVIDER_BASE, serviceProviderBase);

    StaticLocationServiceConfiguration staticLocationServiceConfiguration = StaticLocationServiceConfiguration
            .from(config);
    Assert.assertEquals(configurationLoaderClassName,
            staticLocationServiceConfiguration.getConfigurationLoaderClassName());
    Assert.assertEquals(serviceProviderBase, staticLocationServiceConfiguration.getServiceProviderBase());
}

From source file:ch.vorburger.mariadb4j.MariaDB4jSampleTutorialTest.java

@Test
public void testEmbeddedMariaDB4j() throws Exception {
    DB db = DB.newEmbeddedDB(3308);/*from w ww .j av  a2 s.  c  o m*/
    db.start();

    Connection conn = null;
    try {
        conn = db.getConnection();
        QueryRunner qr = new QueryRunner();

        // Should be able to create a new table
        qr.update(conn, "CREATE TABLE hello(world VARCHAR(100))");

        // Should be able to insert into a table
        qr.update(conn, "INSERT INTO hello VALUES ('Hello, world')");

        // Should be able to select from a table
        List<String> results = qr.query(conn, "SELECT * FROM hello", new ColumnListHandler<String>());
        Assert.assertEquals(1, results.size());
        Assert.assertEquals("Hello, world", results.get(0));

        // Should be able to source a SQL file
        db.source("ch/vorburger/mariadb4j/testSourceFile.sql");
        results = qr.query(conn, "SELECT * FROM hello", new ColumnListHandler<String>());
        Assert.assertEquals(3, results.size());
        Assert.assertEquals("Hello, world", results.get(0));
        Assert.assertEquals("Bonjour, monde", results.get(1));
        Assert.assertEquals("Hola, mundo", results.get(2));
    } finally {
        DbUtils.closeQuietly(conn);
    }
}

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

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

    Model model = new Model.Builder("3-series").make("BMW").bodyType("Sedan").modelDescr("open sunroof")
            .build();// w w  w.jav a2s .com
    Model model1 = new Model.Builder("Mazda 5").make("Mazda").bodyType("hatch").build();
    Model model2 = new Model.Builder("Mazda 6").make("Mazda").bodyType("hatch").build();
    Model model3 = new Model.Builder("Tazz").make("Toyota").bodyType("Sedan").build();
    Model model4 = new Model.Builder("323").make("Mazda").bodyType("hatch").build();

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

    List<Model> mazdaCars = service.getMakeModels("Mazda");
    Assert.assertEquals(3, mazdaCars.size());
}

From source file:com.netflix.simianarmy.conformity.TestSameZonesInElbAndAsg.java

@Test
public void testZoneMismatch() {
    Cluster cluster = new Cluster("cluster1", "us-east-1", new AutoScalingGroup("asg1"));
    Conformity result = check(cluster);//w  w  w. j a  v a2 s .c  om
    Assert.assertEquals(result.getRuleId(), getName());
    Assert.assertEquals(result.getFailedComponents().size(), 1);
    Assert.assertEquals(result.getFailedComponents().iterator().next(), "elb2");
}

From source file:com.hybris.backoffice.cockpitng.dataaccess.facades.DefaultPlatformObjectFacadeStrategyTest.java

@Test
public void testLoad() throws ObjectNotFoundException {
    final ModelService modelService = Mockito.mock(ModelService.class);

    final UserModel user = new UserModel();
    user.setName("Test User");

    Mockito.when(modelService.get(PK.parse("1234"))).thenReturn(user);

    final LabelService labelService = Mockito.mock(LabelService.class);
    Mockito.when(labelService.getObjectLabel(Mockito.any())).thenReturn(StringUtils.EMPTY);

    final DefaultPlatformObjectFacadeStrategy strategy = new DefaultPlatformObjectFacadeStrategy();

    strategy.setModelService(modelService);
    strategy.setLabelService(labelService);

    // Test we get the same user
    Assert.assertEquals(user, strategy.load("1234", null));

    // Test that an unknown pk will return null
    Assert.assertNull(strategy.load("9999", null));
    Assert.assertNull(strategy.load(null, null));

    try {/*ww  w. j a  va  2 s.  c  o m*/
        strategy.load("", null);
        Assert.fail("load method should have thrown an exception");
    } catch (final ObjectNotFoundException ex) // NOPMD
    {
        // expected behavior
    }

}

From source file:com.google.api.ads.adwords.jaxws.extensions.report.model.definitions.ReportAdExtensionDefinitionTest.java

/**
 * @see com.google.api.ads.adwords.jaxws.extensions.report.model.definitions.
 * AbstractReportDefinitionTest#testFirstEntry(
 * com.google.api.ads.adwords.jaxws.extensions.report.model.entities.Report)
 *///www.j av  a2  s. c o m
@Override
protected void testFirstEntry(ReportAdExtension first) {

    Assert.assertEquals(319387457L, first.getAdExtensionId().longValue());
    Assert.assertEquals(119807057L, first.getCampaignId().longValue());
    Assert.assertEquals("active", first.getStatus());
    Assert.assertEquals("eligible", first.getApprovalStatus());
    Assert.assertEquals("location extension", first.getAdExtensionType());

    Assert.assertEquals("Computers", first.getDevice());
    Assert.assertEquals("Headline", first.getClickType());

    Assert.assertEquals("2013-05-01", first.getDay());
    Assert.assertEquals(0L, first.getClicks().longValue());
    Assert.assertEquals(47L, first.getImpressions().longValue());
    Assert.assertEquals(0L, first.getConversions().longValue());
    Assert.assertEquals(0.00, first.getCostBigDecimal().doubleValue());
    Assert.assertEquals(0.00, first.getCtrBigDecimal().doubleValue());
    Assert.assertEquals(0.00, first.getAvgCpcBigDecimal().doubleValue());
    Assert.assertEquals(0.00, first.getAvgCpmBigDecimal().doubleValue());
    Assert.assertEquals(4.51, first.getAvgPositionBigDecimal().doubleValue());

}

From source file:com.baidu.jprotobuf.rpc.client.IDLProxyFactoryBeanTest.java

protected ServiceExporter doCreateServiceExporter() {
    IDLServiceExporter exporter = new IDLServiceExporter();
    exporter.setInputIDL(resource);/*from   www . j a v a2 s .c  o  m*/
    exporter.setOutputIDL(resource);
    exporter.setServiceName("SimpleIDLTest");
    exporter.setInvoker(new ServerInvoker() {

        @Override
        public void invoke(IDLProxyObject input, IDLProxyObject output) throws Exception {
            Assert.assertNotNull(input);
            Assert.assertEquals("how are you!", input.get("list"));

            if (output != null) {
                output.put("list", "hello world");
            }
        }
    });
    try {
        exporter.afterPropertiesSet();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return exporter;
}