Example usage for junit.framework Assert assertNull

List of usage examples for junit.framework Assert assertNull

Introduction

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

Prototype

static public void assertNull(Object object) 

Source Link

Document

Asserts that an object is null.

Usage

From source file:de.hybris.platform.catalog.jalo.synchronization.ItemCopyCreatorTest.java

@Test
public void testExceptionDuringCreation() throws InterruptedException {

    final CatalogVersionSyncCopyContext ctx = new CatalogVersionSyncCopyContext(syncJob, syncCronJob, worker) {
        @Override/*from  w w w  .  j  av a 2  s.  co  m*/
        SynchronizationPersistenceAdapter getPersistenceAdapter() {
            return new LegacySynchronizationPersistenceAdapter(this) {
                @Override
                public Item create(final ComposedType expectedType, final Map<String, Object> attributes)
                        throws SynchronizationPersistenceException {
                    throw new IllegalStateException("expected exception during creation ");
                }
            };
        }

    };

    final Product source = ProductManager.getInstance().createProduct(PRODUCT_FAILING_ON_CREATE);
    final Product target = null;

    final Collection<String> whiteList = Arrays
            .asList(Product.CODE/* , Product.NAME, Product.TYPE, Product.PK */);
    final Collection<String> blackList = Arrays.asList(Product.MODIFIED_TIME, Product.CREATION_TIME);

    final Map<String, Object> presets = Collections.EMPTY_MAP;
    final ItemCopyCreator copyCreator = new ItemCopyCreator(ctx, null, source, target, blackList, whiteList,
            presets);

    Assert.assertNull(copyCreator.copy());

}

From source file:org.openmrs.module.idgen.service.IdentifierSourceServiceTest.java

/**
 * @see {@link IdentifierSourceService#purgeIdentifierSource(IdentifierSource)}
 * /*  w w w  .  j av  a 2  s  . c  o  m*/
 */
@Test
@Verifies(value = "should delete an IdentifierSource from the system", method = "purgeIdentifierSource(IdentifierSource)")
public void purgeIdentifierSource_shouldDeleteAnIdentifierSourceFromTheSystem() throws Exception {
    IdentifierSource s = iss.getIdentifierSource(2);
    iss.purgeIdentifierSource(s);
    Assert.assertNull(iss.getIdentifierSource(2));
}

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

@Test
public void shouldPurgeAttribute() throws Exception {
    // I'm using sql queries and a flush-session because if I try to test this the natural way, hibernate
    // complains that the attribute will be re-created since the person is in the session.
    Number before = (Number) Context.getAdministrationService()
            .executeSQL("select count(*) from person_attribute where person_id = 2", true).get(0).get(0);

    controller.purge(personUuid, attributeUuid, request, response);
    Context.flushSession();//  www.ja va 2  s  . c  om
    Number after = (Number) Context.getAdministrationService()
            .executeSQL("select count(*) from person_attribute where person_id = 2", true).get(0).get(0);
    Assert.assertEquals(before.intValue() - 1, after.intValue());
    Assert.assertNull(service.getPersonAttributeByUuid(attributeUuid));
}

From source file:com.vmware.identity.sts.auth.impl.UserCertAuthenticatorTest.java

@Test(expected = InvalidCredentialsException.class)
public void testNullSignatureAlgorithm() throws Exception {
    com.vmware.identity.sts.idm.Authenticator idmAuth = EasyMock
            .createMock(com.vmware.identity.sts.idm.Authenticator.class);
    final Authenticator authenticator = new UserCertAuthenticator(idmAuth);

    final SecurityHeaderType header = new SecurityHeaderType();
    final UserCertificateTokenType userCertiticateToken = new UserCertificateTokenType();
    userCertiticateToken.setSignatureAlgorithm(null);
    ObjectFactory objectFactory = new ObjectFactory();
    header.getAny().add(objectFactory.createUserCertificateToken(userCertiticateToken));

    final Result authResult = authenticator.authenticate(newReq(header));
    Assert.assertNull(authResult);
}

From source file:com.auditbucket.engine.service.WhatServiceTest.java

private void testKVStore() throws Exception {
    SecurityContextHolder.getContext().setAuthentication(authA);
    regService.registerSystemUser(new RegistrationBean("Company", email, "bah"));
    Fortress fortressA = fortressService.registerFortress(new FortressInputBean("Audit Test", true));
    String docType = "TestAuditX";
    String callerRef = "ABC123R";
    MetaInputBean inputBean = new MetaInputBean(fortressA.getName(), "wally", docType, new DateTime(),
            callerRef);//  w  w  w. jav  a2 s  .c  o m

    String ahKey = auditManager.createHeader(inputBean, null).getMetaKey();
    assertNotNull(ahKey);
    MetaHeader header = trackService.getHeader(ahKey);
    Map<String, Object> what = getWhatMap();
    String whatString = getJsonFromObject(what);
    try {
        auditManager.processLog(new LogInputBean(ahKey, "wally", new DateTime(), whatString));
    } catch (DataAccessException e) {
        logger.error(
                "KV Stores are configured in config.properties. This test is failing to find the {} server.",
                engineConfig.getKvStore());
        return;
    }
    TrackLog trackLog = trackDAO.getLastLog(header.getId());
    assertNotNull(trackLog);

    //When
    LogWhat logWhat = whatService.getWhat(header, trackLog.getChange());

    Assert.assertNotNull(logWhat);
    validateWhat(what, logWhat);

    Assert.assertTrue(whatService.isSame(header, trackLog.getChange(), whatString));
    // Testing that cancel works
    trackService.cancelLastLogSync(ahKey);
    Assert.assertNull(trackService.getLastLog(header));
    Assert.assertNull(whatService.getWhat(header, trackLog.getChange()).getWhat());
}

From source file:io.smartspaces.master.server.services.internal.comm.StandardMasterRosContextTest.java

/**
 * Test starting up the context./*  w  ww.  java 2 s.  c om*/
 *
 * <p>
 * This test has a remote ROS master.
 */
//@Test
public void testStartupRemoteRosMaster() {
    Mockito.when(systemConfiguration.getPropertyBoolean(MasterRosContext.CONFIGURATION_NAME_ROS_MASTER_ENABLE,
            MasterRosContext.CONFIGURATION_VALUE_DEFAULT_ROS_MASTER_ENABLE)).thenReturn(false);

    context.startup();

    Assert.assertNull(rosMasterController.getRosEnvironment());
    Mockito.verify(nodeConfiguration).setNodeName(MasterRosContext.ROS_NODENAME_SMARTSPACES_MASTER);
    Mockito.verify(rosEnvironment).newNode(nodeConfiguration,
            Lists.newArrayList(context.getMasterNodeListener()));
    Assert.assertEquals(masterNode, context.getMasterNode());
}

From source file:com.impetus.client.cassandra.config.CassandraPropertyReaderTest.java

/**
 * Test method for/*w ww.ja  va  2 s . c om*/
 * {@link com.impetus.client.cassandra.config.CassandraPropertyReader#readProperty()}
 * .
 * 
 * @throws IOException
 */
@Test
public void testReadProperty() throws IOException {
    log.info("running CassandraPropertyReaderTest");
    // reader = new CassandraPropertyReader();
    // reader.read("CassandraCounterTest");
    EntityManagerFactory emf = Persistence.createEntityManagerFactory(pu);
    PersistenceUnitMetadata puMetadata = KunderaMetadataManager.getPersistenceUnitMetadata(pu);
    // metadata = CassandraPropertyReader.csmd;
    Properties properties = new Properties();
    InputStream inStream = ClassLoader
            .getSystemResourceAsStream(puMetadata.getProperty(PersistenceProperties.KUNDERA_CLIENT_PROPERTY));

    if (inStream != null) {
        properties.load(inStream);
        replication = properties.getProperty(Constants.REPLICATION_FACTOR);
        strategy = properties.getProperty(Constants.PLACEMENT_STRATEGY);
        String dataCenters = properties.getProperty(Constants.DATA_CENTERS);
        if (dataCenters != null) {
            StringTokenizer stk = new StringTokenizer(dataCenters, ",");
            while (stk.hasMoreTokens()) {
                StringTokenizer tokenizer = new StringTokenizer(stk.nextToken(), ":");
                if (tokenizer.countTokens() == 2) {
                    dataCenterToNode.put(tokenizer.nextToken(), tokenizer.nextToken());
                }
            }
        }

        String cf_defs = properties.getProperty(Constants.CF_DEFS);
        if (cf_defs != null) {
            StringTokenizer stk = new StringTokenizer(cf_defs, ",");
            while (stk.hasMoreTokens()) {
                CassandraColumnFamilyProperties familyProperties = new CassandraColumnFamilyProperties();
                StringTokenizer tokenizer = new StringTokenizer(stk.nextToken(), "|");
                if (tokenizer.countTokens() != 0 && tokenizer.countTokens() >= 2) {
                    String columnFamilyName = tokenizer.nextToken();
                    String defaultValidationClass = tokenizer.nextToken();
                    familyProperties.setDefault_validation_class(defaultValidationClass);

                    if (tokenizer.countTokens() != 0) {
                        String comparator = tokenizer.nextToken();

                        familyProperties.setComparator(comparator);

                    }
                    familyToProperties.put(columnFamilyName, familyProperties);
                }
            }
        }

        metadata = CassandraPropertyReader.csmd;
        if (replication != null) {
            Assert.assertNotNull(replication);
            Assert.assertNotNull(metadata.getReplication_factor());

        } else {
            Assert.assertNull(replication);
            Assert.assertNull(metadata.getReplication_factor());
        }
        Assert.assertEquals(replication, metadata.getReplication_factor());

        if (strategy != null) {
            Assert.assertNotNull(strategy);
            Assert.assertNotNull(metadata.getPlacement_strategy());

        } else {
            Assert.assertNull(strategy);
            Assert.assertNull(metadata.getPlacement_strategy());
        }
        Assert.assertEquals(strategy, metadata.getPlacement_strategy());

        if (!familyToProperties.isEmpty()) {
            Assert.assertNotNull(familyToProperties);
            Assert.assertNotNull(metadata.getColumnFamilyProperties());
            Assert.assertFalse(metadata.getColumnFamilyProperties().isEmpty());
        } else {
            Assert.assertTrue(metadata.getColumnFamilyProperties().isEmpty());
        }
        Assert.assertEquals(familyToProperties.size(), metadata.getColumnFamilyProperties().size());

        if (!dataCenterToNode.isEmpty()) {
            Assert.assertNotNull(dataCenterToNode);
            Assert.assertNotNull(metadata.getDataCenters());
            Assert.assertFalse(metadata.getDataCenters().isEmpty());
        } else {
            Assert.assertTrue(metadata.getDataCenters().isEmpty());
        }
        Assert.assertEquals(dataCenterToNode.size(), metadata.getDataCenters().size());
    } else {
        Assert.assertEquals("1", metadata.getReplication_factor());
        Assert.assertEquals(SimpleStrategy.class.getName(), metadata.getPlacement_strategy());
        Assert.assertEquals(0, metadata.getDataCenters().size());
        Assert.assertEquals(0, metadata.getColumnFamilyProperties().size());
    }
}

From source file:eu.trentorise.smartcampus.ac.provider.repository.persistence.AcDaoPersistenceImplTest.java

public void testCreateUser() {

    User user = new User();
    user.setAuthToken("token_test");
    user.setExpTime((long) 3600);
    user.setSocialId((long) 1004);

    // test user definition

    Authority auth1 = new Authority();
    auth1.setName("auth1");
    auth1.setRedirectUrl("url_auth1");

    Attribute attr = new Attribute();
    attr.setKey("projectName");
    attr.setValue("SC");

    attr.setAuthority(auth1);//from  ww  w  .  j  a  v  a  2  s  .  c o  m

    List<Attribute> attrs = new ArrayList<Attribute>();
    attrs.add(attr);
    user.setAttributes(attrs);

    Assert.assertNull(dao.readUser("token_test"));
    dao.create(user);
    Assert.assertNotNull(dao.readUser("token_test"));

    user = new User();
    user.setAuthToken("token_test1");
    user.setExpTime((long) 3600);
    user.setSocialId((long) 1004);

    try {
        dao.create(user);
        Assert.fail("Eception not throw");
    } catch (IllegalArgumentException e) {

    }

}

From source file:es.tekniker.framework.ktek.commons.mng.server.test.TestCommonsMngServer.java

@org.junit.Test
public void testLoginExists() {

    log.info("*************************************************************");
    log.info("testLoginExists: START ");
    String result = TestDefines.RESULT_OK;

    KtekUserEntity instance = null;/*from w  w  w  .j av a2 s.  c o  m*/

    CommonsMngServer manager = new CommonsMngServer();

    KtekLoginEntity login = getLoginExists();

    try {
        instance = manager.login(login);

        if (instance != null) {
            log.info("testLoginExists: instance is NOT NULL " + instance.getToken());
            Assert.assertNotNull(instance);
        } else {
            log.error("testLoginExists: instance is NULL ");
            result = TestDefines.RESULT_ERROR;
            Assert.assertNull(instance);
        }

    } catch (KtekExceptionEntity e) {
        System.out.println("TestUsersMngServer.loginExists:  exception " + e.getMessage());
        e.printStackTrace();
        Assert.assertFalse(false);
    }

    log.info("testLoginExists: RESULT " + result);
    log.info("testLoginExists: END ");
    log.info("*************************************************************");
    log.info("");
}

From source file:org.slc.sli.dashboard.unit.controller.ConfigControllerTest.java

@Test
public void testGetConfig() throws Exception {
    configController.setUserEdOrgManager(new UserEdOrgManager() {

        @Override// www  .j  a v a  2s  .  c o  m
        public GenericEntity getUserInstHierarchy(String token, Object key, Data config) {
            // TODO Auto-generated method stub
            return null;
        }

        @Override
        public GenericEntity getUserCoursesAndSections(String token, Object key, Data config) {
            // TODO Auto-generated method stub
            return null;
        }

        @Override
        public GenericEntity getUserSectionList(String token, Object key, Data config) {
            // TODO Auto-generated method stub
            return null;
        }

        @Override
        public GenericEntity getSchoolInfo(String token, Object key, Data config) {
            // TODO Auto-generated method stub
            return null;
        }

        @Override
        public EdOrgKey getUserEdOrg(String token) {
            // TODO Auto-generated method stub
            return null;
        }

        @Override
        public GenericEntity getStaffInfo(String token) {
            GenericEntity entity = new GenericEntity();
            GenericEntity edOrg = new GenericEntity();
            List<String> list = new ArrayList<String>();
            list.add(Constants.LOCAL_EDUCATION_AGENCY);
            edOrg.put(Constants.ATTR_ORG_CATEGORIES, list);
            entity.put(Constants.ATTR_ED_ORG, edOrg);
            return entity;
        }
    });
    configController.setPortalWSManager(new PortalWSManagerImpl() {
        @Override
        public String getHeader(boolean isAdmin) {
            return null;
        }
    });
    MockHttpServletRequest request = new MockHttpServletRequest();
    ModelAndView model = null;
    try {
        model = configController.getConfig(request);
    } catch (IllegalAccessException e) {
        // this exception is thrown because not admin
        model = null;
    }
    Assert.assertNull(model);
}