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:org.atemsource.atem.impl.common.attribute.SingleAssociationAttributeTest.java

@Test
public void testSetter() {
    EntityA entity = new EntityA();
    final EntityB entityB = createEntity("Hallo", 2);

    SingleAttribute<EntityB> attribute = (SingleAttribute<EntityB>) getAttribute(PROPERTY);
    Assert.assertNotNull(attribute);
    attribute.setValue(entity, entityB);
    EntityB value = entity.getEntityB();
    assertEquals(entityB, value);/*from ww  w .  j  a  va 2s  . c o m*/
    Assert.assertTrue(entityB == value);
}

From source file:org.openmrs.module.formfilter.web.controller.AddFormFilterPropertyControllerTest.java

/**
 * @see {@link AddFormFilterPropertyController#addFormFilter(ModelMap, Integer, int)}
 *///  w w  w .  ja v a 2  s.co  m
@Test
@Verifies(value = "should support edit filter functionality", method = "addFormFilter(ModelMap,Integer,int)")
public void addFormFilter_shouldSupportEditFilterFunctionality() {

    AddFormFilterPropertyController controller = new AddFormFilterPropertyController();
    ModelMap model = new ModelMap();
    controller.addFormFilter(model, 1, "1");
    Assert.assertNotNull(((FormFilter) model.get("formFilter")));
    Assert.assertNotNull(((FormFilterProperty) model.get("formFilterProperty")));
}

From source file:org.jboss.spring.quickstarts.kitchensink.kitchensink_spring.test.MemberDaoTest.java

@Test
public void testRegister() {
    Member member = new Member();
    member.setEmail("jane.doe@mailinator.com");
    member.setName("Jane Doe");
    member.setPhoneNumber("2125552121");

    memberDao.register(member);//www  . j  ava  2  s.c o m
    Long id = member.getId();
    Assert.assertNotNull(id);

    Assert.assertEquals(2, memberDao.findAllOrderedByName().size());
    Member newMember = memberDao.findById(id);

    Assert.assertEquals("Jane Doe", newMember.getName());
    Assert.assertEquals("jane.doe@mailinator.com", newMember.getEmail());
    Assert.assertEquals("2125552121", newMember.getPhoneNumber());
    return;
}

From source file:de.hybris.platform.commerceservices.security.impl.DefaultSecureTokenServiceTest.java

@Test
public void testCycle() {
    final SecureToken data = new SecureToken(TEST_DATA, TEST_TS);
    final String token = service.encryptData(data);
    Assert.assertNotNull(token);
    final SecureToken result = service.decryptData(token);
    Assert.assertNotSame(result, data);/*  w w w  .j  ava2s  .c o m*/
    Assert.assertEquals(TEST_DATA, result.getData());
    Assert.assertEquals(TEST_TS, result.getTimeStamp());
}

From source file:io.cloudslang.engine.queue.repositories.ExecutionQueueRepositoryTest.java

@Test
public void testInsert() {
    List<ExecutionMessage> msg = new ArrayList<>();
    msg.add(generateMessage("group1", "msg1", 1));
    executionQueueRepository.insertExecutionQueue(msg, 1L);

    List<ExecutionMessage> result = executionQueueRepository.pollMessagesWithoutAck(100, 2);
    Assert.assertNotNull(result);
    Assert.assertEquals(1, result.size());

    ExecutionMessage resultMsg = result.get(0);
    Assert.assertEquals(ExecStatus.SENT, resultMsg.getStatus());
    Assert.assertEquals("group1", resultMsg.getWorkerGroup());
}

From source file:alpha.portal.webapp.filter.LocaleFilterTest.java

/**
 * Test set locale in session when session is null.
 * /*from  ww  w .  java  2 s  .c o m*/
 * @throws Exception
 *             the exception
 */
public void testSetLocaleInSessionWhenSessionIsNull() throws Exception {
    final MockHttpServletRequest request = new MockHttpServletRequest();
    request.addParameter("locale", "es");

    final MockHttpServletResponse response = new MockHttpServletResponse();
    this.filter.doFilter(request, response, new MockFilterChain());

    // no session, should result in null
    Assert.assertNull(request.getSession().getAttribute(Constants.PREFERRED_LOCALE_KEY));
    // thread locale should always have it, regardless of session
    Assert.assertNotNull(LocaleContextHolder.getLocale());
}

From source file:ejportal.webapp.action.InteresseActionTest.java

/**
 * Test edit.//w  w  w .jav a 2 s . c o m
 * 
 * @throws Exception
 *             the exception
 */
public void testEdit() throws Exception {
    this.log.debug("testing edit...");
    this.action.setInteresseId(1L);
    Assert.assertNull(this.action.getInteresse());
    Assert.assertEquals("edit", this.action.edit());
    Assert.assertNotNull(this.action.getInteresseBaseTO());
    Assert.assertFalse(this.action.hasActionErrors());
}

From source file:com.couchbase.lite.DocumentTest.java

/**
 * https://github.com/couchbase/couchbase-lite-android/issues/301
 *///  w w  w  .ja  va 2 s .  c  o m
public void testPutDeletedDocument() throws CouchbaseLiteException {

    Document document = database.createDocument();
    Map<String, Object> properties = new HashMap<String, Object>();
    properties.put("foo", "foo");
    properties.put("bar", Boolean.FALSE);
    document.putProperties(properties);
    Assert.assertNotNull(document.getCurrentRevision());
    String docId = document.getId();

    properties.put("_rev", document.getCurrentRevisionId());
    properties.put("_deleted", true);
    properties.put("mykey", "myval");
    SavedRevision newRev = document.putProperties(properties);
    newRev.loadProperties();
    assertTrue(newRev.getProperties().containsKey("mykey"));

    Assert.assertTrue(document.isDeleted());
    Document fetchedDoc = database.getExistingDocument(docId);
    Assert.assertNull(fetchedDoc);

    // query all docs and make sure we don't see that document
    database.getAllDocs(new QueryOptions());
    Query queryAllDocs = database.createAllDocumentsQuery();
    QueryEnumerator queryEnumerator = queryAllDocs.run();
    for (Iterator<QueryRow> it = queryEnumerator; it.hasNext();) {
        QueryRow row = it.next();
        Assert.assertFalse(row.getDocument().getId().equals(docId));
    }
}

From source file:fr.msch.wissl.server.TestLogin.java

@Test
public void test() throws IOException, JSONException {
    HttpClient client = new HttpClient();

    // good username, bad password: error 401
    PostMethod post = new PostMethod(TServer.URL + "login");
    post.addParameter("username", admin_username);
    post.addParameter("password", "bad_password");
    client.executeMethod(post);/*w w  w . j a v  a 2  s .c o  m*/
    post.getResponseBodyAsString();
    Assert.assertEquals(401, post.getStatusCode());

    // empty password and username: error 401
    post = new PostMethod(TServer.URL + "login");
    post.addParameter("username", "");
    post.addParameter("password", "");
    client.executeMethod(post);
    post.getResponseBodyAsString();
    Assert.assertEquals(401, post.getStatusCode());

    // log in as admin
    post = new PostMethod(TServer.URL + "login");
    post.addParameter("username", admin_username);
    post.addParameter("password", admin_password);
    client.executeMethod(post);

    String ret = post.getResponseBodyAsString();
    JSONObject obj = new JSONObject(ret);
    int uid_admin = obj.getInt("userId");
    String sid_admin = obj.getString("sessionId");
    int auth = obj.getInt("auth");

    Assert.assertEquals(200, post.getStatusCode());
    Assert.assertEquals(uid_admin, this.admin_userId);
    Assert.assertNotNull(UUID.fromString(sid_admin));
    Assert.assertEquals(auth, 1);

    // call 'stats' with this session, should succeed
    GetMethod get = new GetMethod(TServer.URL + "stats");
    get.addRequestHeader("sessionId", sid_admin);
    client.executeMethod(get);
    Assert.assertEquals(200, get.getStatusCode());

    // the previous session that was setup by the test case 
    // for this user should NOT have been destroyed
    // both sessions are kept for the same user
    get = new GetMethod(TServer.URL + "stats");
    get.addRequestHeader("sessionId", this.admin_sessionId);
    client.executeMethod(get);
    Assert.assertEquals(200, get.getStatusCode());

    // the other user set up by the test case should still be logged in
    get = new GetMethod(TServer.URL + "stats");
    get.addRequestHeader("sessionId", this.user_sessionId);
    client.executeMethod(get);
    Assert.assertEquals(200, get.getStatusCode());

    // logout all users
    post = new PostMethod(TServer.URL + "logout");
    post.addRequestHeader("sessionId", sid_admin);
    client.executeMethod(post);
    Assert.assertEquals(204, post.getStatusCode());

    post = new PostMethod(TServer.URL + "logout");
    post.addRequestHeader("sessionId", this.user_sessionId);
    client.executeMethod(post);
    Assert.assertEquals(204, post.getStatusCode());

    post = new PostMethod(TServer.URL + "logout");
    post.addRequestHeader("sessionId", this.admin_sessionId);
    client.executeMethod(post);
    Assert.assertEquals(204, post.getStatusCode());

    // check that neither client can call 'stats'
    get = new GetMethod(TServer.URL + "stats");
    get.addRequestHeader("sessionId", sid_admin);
    client.executeMethod(get);
    Assert.assertEquals(401, get.getStatusCode());

    get = new GetMethod(TServer.URL + "stats");
    get.addRequestHeader("sessionId", this.user_sessionId);
    client.executeMethod(get);
    Assert.assertEquals(401, get.getStatusCode());
}

From source file:ejportal.webapp.action.RechnungActionTest.java

/**
 * Test edit.//from  ww  w.j  a v  a  2  s  . c  o m
 * 
 * @throws Exception
 *             the exception
 */
public void testEdit() throws Exception {
    this.log.debug("testing edit...");
    this.action.setRechnungId(1L);
    Assert.assertNull(this.action.getRechnung());
    Assert.assertEquals("edit", this.action.edit());
    Assert.assertNotNull(this.action.getRechnungBaseTO());
    Assert.assertFalse(this.action.hasActionErrors());
}