Example usage for junit.framework Assert assertNotNull

List of usage examples for junit.framework Assert assertNotNull

Introduction

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

Prototype

static public void assertNotNull(Object object) 

Source Link

Document

Asserts that an object isn't null.

Usage

From source file:com.netflix.curator.framework.recipes.locks.TestReaper.java

@Test
public void testUsingLeader() throws Exception {
    final Timing timing = new Timing();
    final CuratorFramework client = makeClient(timing, null);
    final CountDownLatch latch = new CountDownLatch(1);
    LeaderSelectorListener listener = new LeaderSelectorListener() {
        @Override//www. jav  a2s.c  o  m
        public void takeLeadership(CuratorFramework client) throws Exception {
            Reaper reaper = new Reaper(client, 1);
            try {
                reaper.addPath("/one/two/three", Reaper.Mode.REAP_UNTIL_DELETE);
                reaper.start();

                timing.sleepABit();
                latch.countDown();
            } finally {
                IOUtils.closeQuietly(reaper);
            }
        }

        @Override
        public void stateChanged(CuratorFramework client, ConnectionState newState) {
        }
    };
    LeaderSelector selector = new LeaderSelector(client, "/leader", listener);
    try {
        client.start();
        client.create().creatingParentsIfNeeded().forPath("/one/two/three");

        Assert.assertNotNull(client.checkExists().forPath("/one/two/three"));

        selector.start();
        timing.awaitLatch(latch);

        Assert.assertNull(client.checkExists().forPath("/one/two/three"));
    } finally {
        IOUtils.closeQuietly(selector);
        IOUtils.closeQuietly(client);
    }
}

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

/**
 * @see {@link IdentifierSourceService#getIdentifierSource(Integer)}
 *//*from   ww w  .  j  a  v a2 s .c  om*/
@Test
@Verifies(value = "should return a saved sequential identifier generator", method = "getIdentifierSource(Integer)")
public void getIdentifierSource_shouldReturnASavedSequentialIdentifierGenerator() throws Exception {
    SequentialIdentifierGenerator sig = (SequentialIdentifierGenerator) iss.getIdentifierSource(1);
    Assert.assertEquals(sig.getName(), "Test Sequential Generator");
    Assert.assertNotNull(sig.getBaseCharacterSet());
}

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

/**
 * @see ObsController#getObs(String,WebRequest)
 * @verifies get a full representation of a obs
 *///  www  .  j a  va  2 s. c  om
@Test
public void getObs_shouldGetAFullRepresentationOfAObs() throws Exception {
    MockHttpServletRequest req = new MockHttpServletRequest();
    req.addParameter(RestConstants.REQUEST_PROPERTY_FOR_REPRESENTATION, RestConstants.REPRESENTATION_FULL);
    Object result = new ObsController().retrieve("39fb7f47-e80a-4056-9285-bd798be13c63", req);
    Assert.assertNotNull(result);
    Util.log("Obs fetched (default)", result);
    Assert.assertEquals("39fb7f47-e80a-4056-9285-bd798be13c63", PropertyUtils.getProperty(result, "uuid"));
    Assert.assertNotNull(PropertyUtils.getProperty(result, "links"));
    Assert.assertNotNull(PropertyUtils.getProperty(result, "person"));
    Assert.assertNotNull(PropertyUtils.getProperty(result, "concept"));
    Assert.assertNotNull(PropertyUtils.getProperty(result, "auditInfo"));
}

From source file:org.codehaus.grepo.query.hibernate.repository.HibernateRepositoryTest.java

@Test
public void testDefaultPaging() {
    createTestEntities(10);
    Assert.assertNotNull(repo.getByTypeWithDefaultPaging(0));
}

From source file:org.springsource.examples.expenses.TestDatabaseExpenseReportingService.java

@Test
public void testFindingReports() throws Throwable {
    Long erId = reportingService.createNewReport(this.purpose);
    Assert.assertNotNull(erId);
    List<Expense> expenses = reportingService.addExpenses(erId, this.charges);
    Assert.assertEquals(expenses.size(), this.charges.size());
    List<ExpenseReport> er = reportingService.getOpenReports();
    Assert.assertEquals(er.size(), 1);//from w  w  w.jav  a 2 s . c o  m
    ExpenseReport firstReport = er.iterator().next();
    Assert.assertNotNull(firstReport.getId());
    Assert.assertEquals(firstReport.getExpenses().size(), this.charges.size());
}

From source file:com.cubusmail.user.test.UserAccountDaoTest.java

/**
 * Test moveContacts().//from w  w  w.j  a  v a2s.  c o  m
 */
// @Test
public void testMoveContacts() {

    UserAccount userAccount = (UserAccount) this.context.getBean("testUserAccount");
    UserAccount savedUserAccount = this.userAccountDao.getUserAccountByUsername(userAccount.getUsername());
    Assert.assertNotNull(savedUserAccount);
    List<ContactFolder> contactFolders = this.userAccountDao.retrieveContactFolders(userAccount);

    ContactFolder targetFolder = contactFolders.get(0);
    ContactFolder sourceFolder = contactFolders.get(1);
    List<Contact> contacts = this.userAccountDao.retrieveContactList(sourceFolder);
    Long[] contactIds = new Long[] { contacts.get(0).getId(), contacts.get(1).getId() };

    this.userAccountDao.moveContacts(contactIds, targetFolder);
}

From source file:org.web4thejob.orm.TypeSerailizationTest.java

@Test
public void simpleMarshallingTest() throws XmlMappingException, IOException {
    final Marshaller marshaller = ContextUtil.getBean(Marshaller.class);
    Assert.assertNotNull(marshaller);

    final ByteArrayOutputStream out = new ByteArrayOutputStream();
    final Result result = new StreamResult(out);
    final Master1 master1 = ContextUtil.getDRS().getOne(Master1.class);
    marshaller.marshal(master1, result);

    final Unmarshaller unmarshaller = ContextUtil.getBean(Unmarshaller.class);
    final Master1 master2 = (Master1) unmarshaller
            .unmarshal(new StreamSource(new ByteArrayInputStream(out.toByteArray())));

    Assert.assertEquals(master1, master2);
}

From source file:org.jrecruiter.service.UserServiceTest.java

@Test
public void testLoadUserByUsername() {

    final User user = getUser();

    try {/*from  www  .  java 2  s  . c o  m*/
        userService.addUser(user);
        entityManager.flush();
    } catch (DuplicateUserException e) {
        Assert.fail();
    }

    final UserDetails user2 = userService.loadUserByUsername(user.getUsername());

    Assert.assertNotNull(user2);
}

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

@Test
public void searchUserById() {
    User u = dao.readUser(2);
    Assert.assertNotNull(u);
    u = dao.readUser(1000);
    Assert.assertNull(u);
}

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

@Test
public void deleteLocale_shouldDeleteGivenLocale() throws Exception {
    final String localeName = "LocaleName";
    final String localeKey = "LocaleKey";

    List<Locale> locales = localeService.getLocales();
    Assert.assertEquals(1, locales.size());
    Assert.assertNull(getLocale(localeName, locales));

    Locale locale = new Locale();
    locale.setName(localeName);/*from   ww w  .j a  va  2  s  .c  o m*/
    locale.setKey(localeKey);
    locale.setCreator(userService.getUsers().get(0));
    locale.setDateCreated(new Date());

    locales = new ArrayList<Locale>();
    locales.add(locale);

    localeService.saveLocale(locales);
    locales = localeService.getLocales();
    Assert.assertEquals(2, locales.size());

    locale = getLocale(localeName, locales);
    Assert.assertNotNull(locale);

    localeService.deleteLocale(locale);

    locales = localeService.getLocales();
    Assert.assertEquals(1, locales.size());
    Assert.assertNull(getLocale(localeName, locales));
}