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:fr.free.movierenamer.utils.JSONUtilsTest.java

@Test
public void selectObject() {
    List<JSONObject> objects = JSONUtils.selectList("feed/movie", json);
    for (JSONObject object : objects) {
        Assert.assertEquals("Avatar", JSONUtils.selectString("title", object));
        break;/* w ww  . j av a 2  s. c  om*/
    }
}

From source file:org.duracloud.id.generator.ldap.impl.LdapImplTest.java

@Test
public void testMaxUserId() throws Exception {
    String base = "ou=people";
    String filter = "objectClass=x-idp-person";
    int max = createMockTemplate(base, filter);

    ldap.setLdapTemplate(template);/* www. j av a2s .co  m*/
    replayMocks();

    int id = ldap.maxUserId();
    Assert.assertEquals(max, id);

}

From source file:org.openxdata.server.service.impl.LocaleServiceTest.java

@Test
public void getForms_shouldReturnAllForms() throws Exception {
    List<Locale> locales = localeService.getLocales();

    Assert.assertNotNull(locales);/*from w  w w .ja  v a  2s  . c  o m*/
    Assert.assertEquals(1, locales.size());
    Assert.assertEquals("English", locales.get(0).getName());
}

From source file:com.ibm.mobilefirstplatform.clientsdk.android.security.mca.internal.security.AuthorizationPreferencesTests.java

public void testStringSaving() throws Exception {
    preferences.clientId.set(SAVE_STRING);

    AuthorizationManagerPreferences preferences2 = new AuthorizationManagerPreferences(
            getInstrumentation().getTargetContext());
    Assert.assertEquals(SAVE_STRING, preferences2.clientId.get());
}

From source file:org.ocpsoft.rewrite.servlet.config.RequestNullBindingTest.java

@Test
public void testNotNullBinding() throws Exception {
    HttpAction<HttpGet> action = get("/foo/123");
    Assert.assertEquals(200, action.getResponse().getStatusLine().getStatusCode());
}

From source file:com.mirth.connect.model.converters.tests.HL7SerializerTest.java

@Test
public void testFromXmlDefault() throws Exception {
    String input = FileUtils.readFileToString(new File("tests/test-hl7-output.xml"));
    String output = FileUtils.readFileToString(new File("tests/test-hl7-input.txt"));
    ER7Serializer serializer = new ER7Serializer(defaultProperties);
    Assert.assertEquals(output, TestUtil.convertCRToCRLF(serializer.fromXML(input)));
}

From source file:DvdLibraryDaoTest.java

@Test
public void addGetDeleteDvd() throws ParseException {

    Dvd d = new Dvd();
    d.setTitle("Whiplash");
    d.setReleaseDate(sdf.parse("10/15/2014"));
    d.setMpaaRating("R");
    d.setDirectorName("Damien Chazelle");
    d.setStudio("Sony Pictures");
    d.setUserNote("Provocative and emotional");

    dao.addDVD(d);//  ww  w . j ava2s  .  co  m

    Dvd fromDb = dao.findDVDByID(d.getDvdId());

    Assert.assertEquals(fromDb, d);

    dao.removeDVD(d.getDvdId());

    Assert.assertNull(dao.findDVDByID(d.getDvdId()));

}

From source file:com.couchbase.cblite.testapp.tests.Attachments.java

@SuppressWarnings("unchecked")
public void testAttachments() throws Exception {

    CBLBlobStore attachments = database.getAttachments();

    Assert.assertEquals(0, attachments.count());
    Assert.assertEquals(new HashSet<Object>(), attachments.allKeys());

    CBLStatus status = new CBLStatus();
    Map<String, Object> rev1Properties = new HashMap<String, Object>();
    rev1Properties.put("foo", 1);
    rev1Properties.put("bar", false);
    CBLRevision rev1 = database.putRevision(new CBLRevision(rev1Properties), null, false, status);

    Assert.assertEquals(CBLStatus.CREATED, status.getCode());

    byte[] attach1 = "This is the body of attach1".getBytes();
    status = database.insertAttachmentForSequenceWithNameAndType(new ByteArrayInputStream(attach1),
            rev1.getSequence(), "attach", "text/plain", rev1.getGeneration());
    Assert.assertEquals(CBLStatus.CREATED, status.getCode());

    CBLAttachment attachment = database.getAttachmentForSequence(rev1.getSequence(), "attach", status);
    Assert.assertEquals(CBLStatus.OK, status.getCode());
    Assert.assertEquals("text/plain", attachment.getContentType());
    byte[] data = IOUtils.toByteArray(attachment.getContentStream());
    Assert.assertTrue(Arrays.equals(attach1, data));

    Map<String, Object> innerDict = new HashMap<String, Object>();
    innerDict.put("content_type", "text/plain");
    innerDict.put("digest", "sha1-gOHUOBmIMoDCrMuGyaLWzf1hQTE=");
    innerDict.put("length", 27);
    innerDict.put("stub", true);
    innerDict.put("revpos", 1);
    Map<String, Object> attachmentDict = new HashMap<String, Object>();
    attachmentDict.put("attach", innerDict);

    Map<String, Object> attachmentDictForSequence = database
            .getAttachmentsDictForSequenceWithContent(rev1.getSequence(), false);
    Assert.assertEquals(attachmentDict, attachmentDictForSequence);

    CBLRevision gotRev1 = database.getDocumentWithIDAndRev(rev1.getDocId(), rev1.getRevId(),
            EnumSet.noneOf(CBLDatabase.TDContentOptions.class));
    Map<String, Object> gotAttachmentDict = (Map<String, Object>) gotRev1.getProperties().get("_attachments");
    Assert.assertEquals(attachmentDict, gotAttachmentDict);

    // Check the attachment dict, with attachments included:
    innerDict.remove("stub");
    innerDict.put("data", Base64.encodeBytes(attach1));
    attachmentDictForSequence = database.getAttachmentsDictForSequenceWithContent(rev1.getSequence(), true);
    Assert.assertEquals(attachmentDict, attachmentDictForSequence);

    gotRev1 = database.getDocumentWithIDAndRev(rev1.getDocId(), rev1.getRevId(),
            EnumSet.of(CBLDatabase.TDContentOptions.TDIncludeAttachments));
    gotAttachmentDict = (Map<String, Object>) gotRev1.getProperties().get("_attachments");
    Assert.assertEquals(attachmentDict, gotAttachmentDict);

    // Add a second revision that doesn't update the attachment:
    Map<String, Object> rev2Properties = new HashMap<String, Object>();
    rev2Properties.put("_id", rev1.getDocId());
    rev2Properties.put("foo", 2);
    rev2Properties.put("bazz", false);
    CBLRevision rev2 = database.putRevision(new CBLRevision(rev2Properties), rev1.getRevId(), false, status);
    Assert.assertEquals(CBLStatus.CREATED, status.getCode());

    status = database.copyAttachmentNamedFromSequenceToSequence("attach", rev1.getSequence(),
            rev2.getSequence());//from w  w  w  .  j  a va  2 s .c o m
    Assert.assertEquals(CBLStatus.OK, status.getCode());

    // Add a third revision of the same document:
    Map<String, Object> rev3Properties = new HashMap<String, Object>();
    rev3Properties.put("_id", rev2.getDocId());
    rev3Properties.put("foo", 2);
    rev3Properties.put("bazz", false);
    CBLRevision rev3 = database.putRevision(new CBLRevision(rev3Properties), rev2.getRevId(), false, status);
    Assert.assertEquals(CBLStatus.CREATED, status.getCode());

    byte[] attach2 = "<html>And this is attach2</html>".getBytes();
    status = database.insertAttachmentForSequenceWithNameAndType(new ByteArrayInputStream(attach2),
            rev3.getSequence(), "attach", "text/html", rev2.getGeneration());
    Assert.assertEquals(CBLStatus.CREATED, status.getCode());

    // Check the 2nd revision's attachment:
    CBLAttachment attachment2 = database.getAttachmentForSequence(rev2.getSequence(), "attach", status);
    Assert.assertEquals(CBLStatus.OK, status.getCode());
    Assert.assertEquals("text/plain", attachment2.getContentType());
    data = IOUtils.toByteArray(attachment2.getContentStream());
    Assert.assertTrue(Arrays.equals(attach1, data));

    // Check the 3rd revision's attachment:
    CBLAttachment attachment3 = database.getAttachmentForSequence(rev3.getSequence(), "attach", status);
    Assert.assertEquals(CBLStatus.OK, status.getCode());
    Assert.assertEquals("text/html", attachment3.getContentType());
    data = IOUtils.toByteArray(attachment3.getContentStream());
    Assert.assertTrue(Arrays.equals(attach2, data));

    // Examine the attachment store:
    Assert.assertEquals(2, attachments.count());
    Set<CBLBlobKey> expected = new HashSet<CBLBlobKey>();
    expected.add(CBLBlobStore.keyForBlob(attach1));
    expected.add(CBLBlobStore.keyForBlob(attach2));

    Assert.assertEquals(expected, attachments.allKeys());

    status = database.compact(); // This clears the body of the first revision
    Assert.assertEquals(CBLStatus.OK, status.getCode());
    Assert.assertEquals(1, attachments.count());

    Set<CBLBlobKey> expected2 = new HashSet<CBLBlobKey>();
    expected2.add(CBLBlobStore.keyForBlob(attach2));
    Assert.assertEquals(expected2, attachments.allKeys());
}

From source file:com.couchbase.touchdb.testapp.tests.Attachments.java

@SuppressWarnings("unchecked")
public void testAttachments() throws Exception {

    TDBlobStore attachments = database.getAttachments();

    Assert.assertEquals(0, attachments.count());
    Assert.assertEquals(new HashSet<Object>(), attachments.allKeys());

    TDStatus status = new TDStatus();
    Map<String, Object> rev1Properties = new HashMap<String, Object>();
    rev1Properties.put("foo", 1);
    rev1Properties.put("bar", false);
    TDRevision rev1 = database.putRevision(new TDRevision(rev1Properties), null, false, status);

    Assert.assertEquals(TDStatus.CREATED, status.getCode());

    byte[] attach1 = "This is the body of attach1".getBytes();
    status = database.insertAttachmentForSequenceWithNameAndType(new ByteArrayInputStream(attach1),
            rev1.getSequence(), "attach", "text/plain", rev1.getGeneration());
    Assert.assertEquals(TDStatus.CREATED, status.getCode());

    TDAttachment attachment = database.getAttachmentForSequence(rev1.getSequence(), "attach", status);
    Assert.assertEquals(TDStatus.OK, status.getCode());
    Assert.assertEquals("text/plain", attachment.getContentType());
    byte[] data = IOUtils.toByteArray(attachment.getContentStream());
    Assert.assertTrue(Arrays.equals(attach1, data));

    Map<String, Object> innerDict = new HashMap<String, Object>();
    innerDict.put("content_type", "text/plain");
    innerDict.put("digest", "sha1-gOHUOBmIMoDCrMuGyaLWzf1hQTE=");
    innerDict.put("length", 27);
    innerDict.put("stub", true);
    innerDict.put("revpos", 1);
    Map<String, Object> attachmentDict = new HashMap<String, Object>();
    attachmentDict.put("attach", innerDict);

    Map<String, Object> attachmentDictForSequence = database
            .getAttachmentsDictForSequenceWithContent(rev1.getSequence(), false);
    Assert.assertEquals(attachmentDict, attachmentDictForSequence);

    TDRevision gotRev1 = database.getDocumentWithIDAndRev(rev1.getDocId(), rev1.getRevId(),
            EnumSet.noneOf(TDDatabase.TDContentOptions.class));
    Map<String, Object> gotAttachmentDict = (Map<String, Object>) gotRev1.getProperties().get("_attachments");
    Assert.assertEquals(attachmentDict, gotAttachmentDict);

    // Check the attachment dict, with attachments included:
    innerDict.remove("stub");
    innerDict.put("data", Base64.encodeBytes(attach1));
    attachmentDictForSequence = database.getAttachmentsDictForSequenceWithContent(rev1.getSequence(), true);
    Assert.assertEquals(attachmentDict, attachmentDictForSequence);

    gotRev1 = database.getDocumentWithIDAndRev(rev1.getDocId(), rev1.getRevId(),
            EnumSet.of(TDDatabase.TDContentOptions.TDIncludeAttachments));
    gotAttachmentDict = (Map<String, Object>) gotRev1.getProperties().get("_attachments");
    Assert.assertEquals(attachmentDict, gotAttachmentDict);

    // Add a second revision that doesn't update the attachment:
    Map<String, Object> rev2Properties = new HashMap<String, Object>();
    rev2Properties.put("_id", rev1.getDocId());
    rev2Properties.put("foo", 2);
    rev2Properties.put("bazz", false);
    TDRevision rev2 = database.putRevision(new TDRevision(rev2Properties), rev1.getRevId(), false, status);
    Assert.assertEquals(TDStatus.CREATED, status.getCode());

    status = database.copyAttachmentNamedFromSequenceToSequence("attach", rev1.getSequence(),
            rev2.getSequence());// w  ww .j a va 2 s . c  o  m
    Assert.assertEquals(TDStatus.OK, status.getCode());

    // Add a third revision of the same document:
    Map<String, Object> rev3Properties = new HashMap<String, Object>();
    rev3Properties.put("_id", rev2.getDocId());
    rev3Properties.put("foo", 2);
    rev3Properties.put("bazz", false);
    TDRevision rev3 = database.putRevision(new TDRevision(rev3Properties), rev2.getRevId(), false, status);
    Assert.assertEquals(TDStatus.CREATED, status.getCode());

    byte[] attach2 = "<html>And this is attach2</html>".getBytes();
    status = database.insertAttachmentForSequenceWithNameAndType(new ByteArrayInputStream(attach2),
            rev3.getSequence(), "attach", "text/html", rev2.getGeneration());
    Assert.assertEquals(TDStatus.CREATED, status.getCode());

    // Check the 2nd revision's attachment:
    TDAttachment attachment2 = database.getAttachmentForSequence(rev2.getSequence(), "attach", status);
    Assert.assertEquals(TDStatus.OK, status.getCode());
    Assert.assertEquals("text/plain", attachment2.getContentType());
    data = IOUtils.toByteArray(attachment2.getContentStream());
    Assert.assertTrue(Arrays.equals(attach1, data));

    // Check the 3rd revision's attachment:
    TDAttachment attachment3 = database.getAttachmentForSequence(rev3.getSequence(), "attach", status);
    Assert.assertEquals(TDStatus.OK, status.getCode());
    Assert.assertEquals("text/html", attachment3.getContentType());
    data = IOUtils.toByteArray(attachment3.getContentStream());
    Assert.assertTrue(Arrays.equals(attach2, data));

    // Examine the attachment store:
    Assert.assertEquals(2, attachments.count());
    Set<TDBlobKey> expected = new HashSet<TDBlobKey>();
    expected.add(TDBlobStore.keyForBlob(attach1));
    expected.add(TDBlobStore.keyForBlob(attach2));

    Assert.assertEquals(expected, attachments.allKeys());

    status = database.compact(); // This clears the body of the first revision
    Assert.assertEquals(TDStatus.OK, status.getCode());
    Assert.assertEquals(1, attachments.count());

    Set<TDBlobKey> expected2 = new HashSet<TDBlobKey>();
    expected2.add(TDBlobStore.keyForBlob(attach2));
    Assert.assertEquals(expected2, attachments.allKeys());
}

From source file:it.geosolutions.geostore.services.rest.auditing.AuditingConfigurationTest.java

@Test
public void testSimpleConfiguration() {
    AuditingConfiguration auditingConfiguration = new AuditingConfiguration();
    Assert.assertEquals(auditingConfiguration.isAuditEnable(), true);
    Assert.assertEquals(auditingConfiguration.getMaxRequestPerFile(), 3);
    Assert.assertEquals(auditingConfiguration.getTemplatesVersion(), 1);
    Assert.assertEquals(auditingConfiguration.getOutputDirectory(),
            AuditingTestsUtils.OUTPUT_DIRECTORY.getAbsolutePath());
    Assert.assertEquals(auditingConfiguration.getOutputFilesExtension(), "txt");
    Assert.assertEquals(auditingConfiguration.getTemplatesDirectory(),
            AuditingTestsUtils.TEMPLATES_DIRECTORY.getAbsolutePath());
}