Example usage for junit.framework Assert assertNotSame

List of usage examples for junit.framework Assert assertNotSame

Introduction

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

Prototype

static public void assertNotSame(String message, Object expected, Object actual) 

Source Link

Document

Asserts that two objects do not refer to the same object.

Usage

From source file:com.javiermoreno.springboot.mvc.users.UserManagementServiceImplIT.java

@Test
public void checkNewUserIsSavedAndContainsCorrectPasswordHash() {
    DailyUser user = new DailyUser();
    user.setEmail("alice@wonderland.com");
    user.setBirthday(//from   ww w .j  a  v a  2 s .  co  m
            Date.from(LocalDate.of(1976, Month.DECEMBER, 12).atStartOfDay(ZoneId.systemDefault()).toInstant()));
    service.registerNewUser(user, "secret", true);

    Assert.assertNotSame("Id correctly assigned", 0, user.getId());
    Assert.assertEquals("Password md5 is correctely encoded.", "5ebe2294ecd0e0f08eab7690d2a6ee69",
            user.getPassword());
}

From source file:org.apache.synapse.transport.passthru.config.BaseConfigurationTest.java

@Test
public void testBuild() throws Exception {
    Assert.assertNotNull("Building base configuration isn't successful.", baseConfiguration);
    Assert.assertNotNull("Worker pool hasn't been initialized.", baseConfiguration.getWorkerPool());
    Assert.assertNotSame("Worker thread count hasn't been taken from passthru-http.properties file",
            conf.getWorkerPoolCoreSize(), DEFAULT_WORKER_POOL_SIZE_CORE);

}

From source file:org.apache.synapse.transport.passthru.config.BaseConfigurationTest.java

@Test
public void testGetIOBufferSize() throws Exception {
    Assert.assertNotNull("IO Buffer hasn't been initialized.", baseConfiguration.getIOBufferSize());
    Assert.assertNotSame("IO buffer size hasn't been taken from passthru-http.properties file",
            conf.getIOBufferSize(), DEFAULT_IO_BUFFER_SIZE);
}

From source file:org.apache.synapse.transport.passthru.config.SourceConfigurationTest.java

@Test
public void testBuild() throws Exception {
    Assert.assertNotNull("Building base configuration isn't successful.", sourceConfiguration);
    Assert.assertNotNull("Worker pool hasn't been initialized.", sourceConfiguration.getWorkerPool());
    Assert.assertNotSame("Worker thread count hasn't been taken from passthru-http.properties file",
            passThroughConfiguration.getWorkerPoolCoreSize(), DEFAULT_WORKER_POOL_SIZE_CORE);
}

From source file:cz.PA165.vozovyPark.dao.VehicleDAOTest.java

/**
 * Test of update method, of class VehicleDAO.
 *///  ww w.  java2  s. co m
@Test
public void testUpdate() {
    try {
        Vehicle mercedes = VehicleDAOTest.getVehicle("Mercedes", 20000, "R4 Diesel", "E",
                UserClassEnum.PRESIDENT, "2a-447i-882a45", 2009, "UEW6828");
        this.vehicleDao.createVehicle(mercedes);
        Long id = mercedes.getId();

        mercedes.setType("C");
        this.vehicleDao.updateVehicle(mercedes);

        Vehicle loaded = this.vehicleDao.getById(id);
        Assert.assertNotSame("Vehicle was not upadted!", "E", loaded.getType());
    } catch (Exception ex) {
        Assert.fail("Unexpected exception was throwed: " + ex + " " + ex.getMessage());
    }
}

From source file:eu.cloud4soa.soa.git.GitProxyTest.java

@Test
public void testRegisterPublicKeyForUser() {

    User user = new User();
    user.setFullname("Test");
    user.setUriID(userInstanceUriId);/*from  w w  w .  j  a v a2s  .  co  m*/
    user.setUsername("testUsername");
    List<Object> arrayList = new ArrayList<Object>();
    arrayList.add(user);
    when(userdao.findBy("uriID", userInstanceUriId)).thenReturn(arrayList);

    String rsa_pub_key = "aabbcc";
    when(pubkeydao.findByUserAndPubkey(user, rsa_pub_key)).thenReturn(new ArrayList<PubKey>());

    String[] array = gitservices.registerPublicKeyForUser(userInstanceUriId, rsa_pub_key);
    Assert.assertEquals("0", array[0]);
    Assert.assertEquals("OK", array[1]);

    ArrayList<PubKey> arrayList1 = new ArrayList<PubKey>();
    arrayList1.add(new PubKey());
    when(pubkeydao.findByUserAndPubkey(user, rsa_pub_key)).thenReturn(arrayList1);

    array = gitservices.registerPublicKeyForUser(userInstanceUriId, rsa_pub_key);
    Assert.assertEquals("1", array[0]);

    try {
        String originalContent = FileUtils.readFileToString(new File(originalAuthFile));
        String contentModified = FileUtils.readFileToString(authTempFile);
        int compareResult = originalContent.compareTo(contentModified);
        Assert.assertNotSame("File contents are equals!", 0, compareResult);
    } catch (IOException ex) {
        logger.error("Error in reading the file: " + ex.getMessage());
        Assert.fail("Error in reading the file: " + ex.getMessage());
    }
}

From source file:cz.PA165.vozovyPark.dao.ServiceIntervalDAOTest.java

/**
 *
 *//*from   w w  w  .j a v a 2s . c  o  m*/
@Test
public void testValidUpdate() {
    try {
        Vehicle mercedes = ServiceIntervalDAOTest.getVehicle("Mercedes", 20000, "R4 Diesel", "E",
                UserClassEnum.PRESIDENT, "2a-447i-882a45", 2009);
        vehicleDao.createVehicle(mercedes);
        ServiceInterval interval1 = ServiceIntervalDAOTest.getServiceInterval(new ArrayList<Date>(),
                "Prehodeni koles", 7, mercedes);
        serviceIntervalDAO.createSI(interval1);

        interval1.setDescription("Vymeneni oleje");
        serviceIntervalDAO.updateSI(interval1);

        ServiceInterval loaded = serviceIntervalDAO.getById(interval1.getId());
        Assert.assertNotSame("Description has not been updated.", "Prehodeni koles", loaded.getDescription());
    } catch (Exception ex) {
        Assert.fail("Unexpected exception was throwed: " + ex + " " + ex.getMessage());
    }
}

From source file:eu.cloud4soa.soa.git.GitProxyTest.java

@Test
public void testDeletePublicKeyForUser() {

    User user = new User();
    user.setId(new Long(0));
    user.setFullname("Test");
    user.setUriID(userInstanceUriId);/*from   w w w.  j a v  a 2s  .  co  m*/
    user.setUsername("testUsername");
    List<Object> arrayList = new ArrayList<Object>();
    arrayList.add(user);
    when(userdao.findBy("uriID", userInstanceUriId)).thenReturn(arrayList);

    String rsa_pub_key = "aabbcc";
    when(pubkeydao.findByUserAndPubkey(user, rsa_pub_key)).thenReturn(new ArrayList<PubKey>());

    String[] array = gitservices.registerPublicKeyForUser(userInstanceUriId, rsa_pub_key);
    Assert.assertEquals("0", array[0]);
    Assert.assertEquals("OK", array[1]);

    ArrayList<PubKey> arrayList1 = new ArrayList<PubKey>();
    PubKey pubKey = new PubKey();
    pubKey.setId(new Long(0));
    arrayList1.add(pubKey);
    when(pubkeydao.findByPubkey(rsa_pub_key)).thenReturn(arrayList1);

    when(userdao.findBy("uriID", userInstanceUriId)).thenReturn(arrayList);
    when(pubkeydao.findByUserAndPubkey(user, rsa_pub_key)).thenReturn(arrayList1);
    array = gitservices.deletePublicKeyFromUser(userInstanceUriId, rsa_pub_key);
    Assert.assertEquals("0", array[0]);
    Assert.assertEquals("OK", array[1]);
    try {
        String originalContent = FileUtils.readFileToString(new File(originalAuthFile));
        String contentModified = FileUtils.readFileToString(authTempFile);
        int compareResult = originalContent.compareTo(contentModified);
        logger.info("Compare:" + compareResult);
        Assert.assertNotSame("File contents are different!", 0, compareResult);
    } catch (IOException ex) {
        logger.error("Error in reading the file: " + ex.getMessage());
        Assert.fail("Error in reading the file: " + ex.getMessage());
    }
}

From source file:net.sourceforge.seqware.common.metadata.MetadataWSTest.java

public void testGetWorkflowAccession() {
    logger.info("getWorkflowAccession");
    int accession = instance.getWorkflowAccession("FastqQualityReportAndFilter", "0.10.1");
    Assert.assertNotSame("Accession not found", -1, accession);
    Assert.assertEquals("Incorrect accession found", 2860, accession);
}

From source file:org.dataconservancy.dcs.util.ChecksumGeneratorVerifierTest.java

/**
 * Verify that we can generate a correct MD5 checksum hex string for a file, and that if the file is modified the checksum changes
 *///from ww  w  .j  a  v a 2s .co m
@Test
public void testGenerateMD5checksum() {
    String checksum = ChecksumGeneratorVerifier.generateMD5checksum(file1);
    Assert.assertEquals(file1MD5checksum, checksum);
    String modifiedChecksum = ChecksumGeneratorVerifier.generateMD5checksum(modifiedFile1);
    Assert.assertNotSame("The modified file should not have the same checksum.", file1MD5checksum,
            modifiedChecksum);
}