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:org.jboss.jsfunit.example.hellojsf.FacadeAPITest.java

@Test
public void testNoCreationOfBeanDuringELExpressionReference() throws IOException {
    HttpSession session = (HttpSession) server.getFacesContext().getExternalContext().getSession(true);
    Assert.assertNull(session.getAttribute("unreferencedsessionbean"));

    MyBean bean = (MyBean) server.getManagedBeanValue("#{unreferencedsessionbean}");
    Assert.assertNull(bean); // <--------- JSFUNIT-164

    bean = (MyBean) server.getManagedBeanValue("#{unreferencedrequestbean}");
    Assert.assertNull(bean); // <--------- JSFUNIT-164

    bean = (MyBean) server.getManagedBeanValue("#{unreferencedapplicationbean}");
    Assert.assertNull(bean); // <--------- JSFUNIT-164
}

From source file:org.kuali.kfs.sys.document.AccountingDocumentTestUtils.java

/**
 * @ShouldCommitTransactions needed for this test
 * @see ShouldCommitTransactions/*  w  w w .  j a va 2 s .  c o m*/
 */

public static void testConvertIntoErrorCorrection(AccountingDocument document, int expectedPrePECount,
        DocumentService documentService, TransactionalDocumentDictionaryService dictionaryService)
        throws Exception {
    if (((FinancialSystemTransactionalDocumentEntry) SpringContext.getBean(DataDictionaryService.class)
            .getDataDictionary().getDocumentEntry(document.getClass().getName())).getAllowsErrorCorrection()) {
        String documentNumber = document.getDocumentNumber();
        LOG.info("Submitting and blanket approving documentNumber to final to test error correction: "
                + documentNumber);
        // route the original doc, wait for status change
        blanketApproveDocument(document, "blanket approving errorCorrection source document", null,
                documentService);
        WorkflowTestUtils.waitForDocumentApproval(document.getDocumentNumber());
        // re-pull the document to get any updates made by KEW and the post-processor
        document = (AccountingDocument) documentService.getByDocumentHeaderId(documentNumber);

        // collect some preCorrect data
        String preCorrectId = document.getDocumentNumber();
        String preCorrectCorrectsId = document.getFinancialSystemDocumentHeader()
                .getFinancialDocumentInErrorNumber();

        int preCorrectPECount = document.getGeneralLedgerPendingEntries().size();
        // int preCorrectNoteCount = document.getDocumentHeader().getNotes().size();

        List<? extends SourceAccountingLine> preCorrectSourceLines = (List<? extends SourceAccountingLine>) ObjectUtils
                .deepCopy(new ArrayList<SourceAccountingLine>(document.getSourceAccountingLines()));
        List<? extends TargetAccountingLine> preCorrectTargetLines = (List<? extends TargetAccountingLine>) ObjectUtils
                .deepCopy(new ArrayList<TargetAccountingLine>(document.getTargetAccountingLines()));
        // validate preCorrect state
        Assert.assertNotNull(preCorrectId);
        Assert.assertNull(preCorrectCorrectsId);

        Assert.assertEquals(expectedPrePECount, preCorrectPECount);
        // assertEquals(0, preCorrectNoteCount);

        // do the error correction
        ((Correctable) document).toErrorCorrection();
        // compare to preCorrect state
        String postCorrectId = document.getDocumentNumber();
        LOG.info("postcorrect documentHeaderId = " + postCorrectId);
        Assert.assertFalse(postCorrectId.equals(preCorrectId));
        // pending entries should be cleared
        int postCorrectPECount = document.getGeneralLedgerPendingEntries().size();
        LOG.info("postcorrect PE count = " + postCorrectPECount);
        Assert.assertEquals(0, postCorrectPECount);
        // TODO: revisit this is it still needed
        // // count 1 note, compare to "correction" text
        // int postCorrectNoteCount = document.getDocumentHeader().getNotes().size();
        // assertEquals(1, postCorrectNoteCount);
        // DocumentNote note = document.getDocumentHeader().getNote(0);
        // LOG.debug("postcorrect note text = " + note.getFinancialDocumentNoteText());
        // assertTrue(note.getFinancialDocumentNoteText().indexOf("correction") != -1);
        // correctsId should be equal to old id
        String correctsId = document.getFinancialSystemDocumentHeader().getFinancialDocumentInErrorNumber();
        LOG.info("postcorrect correctsId = " + correctsId);
        Assert.assertEquals(preCorrectId, correctsId);
        // accounting lines should have sign reversed on amounts
        List<SourceAccountingLine> postCorrectSourceLines = document.getSourceAccountingLines();
        Assert.assertEquals(preCorrectSourceLines.size(), postCorrectSourceLines.size());
        for (int i = 0; i < preCorrectSourceLines.size(); ++i) {
            SourceAccountingLine preCorrectLine = preCorrectSourceLines.get(i);
            SourceAccountingLine postCorrectLine = postCorrectSourceLines.get(i);

            LOG.info("postcorrect line(docId,amount) = " + i + "(" + postCorrectId + ","
                    + postCorrectLine.getAmount());
            assertEquality(postCorrectId, postCorrectLine.getDocumentNumber());
            assertEquality(preCorrectLine.getAmount().negated(), postCorrectLine.getAmount());
        }

        List<? extends TargetAccountingLine> postCorrectTargetLines = document.getTargetAccountingLines();
        Assert.assertEquals(preCorrectTargetLines.size(), postCorrectTargetLines.size());
        for (int i = 0; i < preCorrectTargetLines.size(); ++i) {
            TargetAccountingLine preCorrectLine = preCorrectTargetLines.get(i);
            TargetAccountingLine postCorrectLine = postCorrectTargetLines.get(i);

            LOG.info("postcorrect line(docId,amount) = " + i + "(" + postCorrectId + ","
                    + postCorrectLine.getAmount());
            assertEquality(postCorrectId, postCorrectLine.getDocumentNumber());
            assertEquality(preCorrectLine.getAmount().negated(), postCorrectLine.getAmount());
        }
    }
}

From source file:org.kuali.kfs.sys.document.AccountingDocumentTestUtils.java

/**
 * @ShouldCommitTransactions needed for this test
 * @see ShouldCommitTransactions//from  w w  w  . java2 s  . c o  m
 */
public static void testConvertIntoCopy(AccountingDocument document, DocumentService documentService,
        int expectedPrePECount) throws Exception {
    // save the original doc, wait for status change
    document.prepareForSave();
    routeDocument(document, "saving copy source document", null, documentService);
    if (!document.getDocumentHeader().getWorkflowDocument().isApproved()) {
        WorkflowTestUtils.waitForStatusChange(document.getDocumentNumber(), DocumentStatus.ENROUTE);
    }
    // collect some preCopy data
    String preCopyId = document.getDocumentNumber();
    String preCopyCopiedFromId = document.getDocumentHeader().getDocumentTemplateNumber();

    int preCopyPECount = document.getGeneralLedgerPendingEntries().size();
    // int preCopyNoteCount = document.getDocumentHeader().getNotes().size();
    DocumentStatus preCopyStatus = document.getDocumentHeader().getWorkflowDocument().getStatus();

    List<? extends SourceAccountingLine> preCopySourceLines = (List<? extends SourceAccountingLine>) ObjectUtils
            .deepCopy(new ArrayList(document.getSourceAccountingLines()));
    List<? extends TargetAccountingLine> preCopyTargetLines = (List<? extends TargetAccountingLine>) ObjectUtils
            .deepCopy(new ArrayList(document.getTargetAccountingLines()));
    // validate preCopy state
    Assert.assertNotNull(preCopyId);
    Assert.assertNull(preCopyCopiedFromId);

    Assert.assertEquals(expectedPrePECount, preCopyPECount);

    // do the copy
    ((Copyable) document).toCopy();
    // compare to preCopy state

    String postCopyId = document.getDocumentNumber();
    Assert.assertFalse(postCopyId.equals(preCopyId));
    // verify that docStatus has changed
    DocumentStatus postCopyStatus = document.getDocumentHeader().getWorkflowDocument().getStatus();
    Assert.assertFalse(postCopyStatus.equals(preCopyStatus));
    // pending entries should be cleared
    int postCopyPECount = document.getGeneralLedgerPendingEntries().size();
    Assert.assertEquals(0, postCopyPECount);

    // TODO: revisit this is it still needed
    // count 1 note, compare to "copied" text
    // int postCopyNoteCount = document.getDocumentHeader().getNotes().size();
    // assertEquals(1, postCopyNoteCount);
    // DocumentNote note = document.getDocumentHeader().getNote(0);
    // assertTrue(note.getFinancialDocumentNoteText().indexOf("copied from") != -1);
    // copiedFrom should be equal to old id
    String copiedFromId = document.getDocumentHeader().getDocumentTemplateNumber();
    Assert.assertEquals(preCopyId, copiedFromId);
    // accounting lines should be have different docHeaderIds but same
    // amounts
    List<? extends SourceAccountingLine> postCopySourceLines = document.getSourceAccountingLines();
    Assert.assertEquals(preCopySourceLines.size(), postCopySourceLines.size());
    for (int i = 0; i < preCopySourceLines.size(); ++i) {
        SourceAccountingLine preCopyLine = preCopySourceLines.get(i);
        SourceAccountingLine postCopyLine = postCopySourceLines.get(i);

        assertInequality(preCopyLine.getDocumentNumber(), postCopyLine.getDocumentNumber());
        assertEquality(preCopyLine.getAmount(), postCopyLine.getAmount());
    }

    List<? extends TargetAccountingLine> postCopyTargetLines = document.getTargetAccountingLines();
    Assert.assertEquals(preCopyTargetLines.size(), postCopyTargetLines.size());
    for (int i = 0; i < preCopyTargetLines.size(); ++i) {
        TargetAccountingLine preCopyLine = preCopyTargetLines.get(i);
        TargetAccountingLine postCopyLine = postCopyTargetLines.get(i);

        assertInequality(preCopyLine.getDocumentNumber(), postCopyLine.getDocumentNumber());
        assertEquality(preCopyLine.getAmount(), postCopyLine.getAmount());
    }
}

From source file:org.kuali.kra.proposaldevelopment.budget.service.impl.BudgetSubAwardServiceTest.java

protected void assertExpectedResults(List<Map<String, BudgetDecimal>> results) {
    int index = 0;
    for (BudgetPeriod period : budget.getBudgetPeriods()) {
        for (BudgetLineItem lineItem : period.getBudgetLineItems()) {
            Assert.assertEquals(subAward.getSubAwardNumber(), lineItem.getSubAwardNumber());
            Assert.assertEquals(results.get(index).get(lineItem.getCostElement()), lineItem.getLineItemCost());
        }//  w  w w  .  jav a2 s  . com
        for (Map.Entry<String, BudgetDecimal> entry : results.get(index).entrySet()) {
            if (entry.getValue().isZero()) {
                Assert.assertNull(findLineItemByCostElement(period.getBudgetLineItems(), entry.getKey()));
            } else {
                Assert.assertEquals(entry.getValue(),
                        findLineItemByCostElement(period.getBudgetLineItems(), entry.getKey())
                                .getLineItemCost());
            }
        }
        index++;
    }
}

From source file:org.lwes.listener.FilterListenerTest.java

@Test
public void testManuallySet() {
    FilterListener filterListener = new FilterListener();
    filterListener.processArguments(new String[] { "-m", "224.0.0.0", "-p", "0000" });
    Map<String, String> inattrs = new HashMap<String, String>();
    inattrs.put("eid", "1");
    filterListener.setEventAttrs(inattrs);

    // Verify the argument was parsed properly
    Map<String, String> attrs = filterListener.getEventAttrs();
    Assert.assertNotNull(attrs);// www . j a va  2 s . com
    Assert.assertEquals(1, attrs.size());
    Assert.assertEquals("1", attrs.get("eid"));

    filterListener.destroy();
    Assert.assertNull(filterListener.getEventAttrs());
    Assert.assertNull(filterListener.getEventNames());
}

From source file:org.lwes.listener.FilterListenerTest.java

@Test
public void testSingleEventFilter() {
    FilterListener filterListener = new FilterListener();
    filterListener.processArguments(new String[] { "-m", "224.0.0.0", "-p", "0000", "-e", "Test::One" });

    List<String> names = filterListener.getEventNames();
    Assert.assertNotNull(names);//from   www  .  j  av a2s.  com
    Assert.assertEquals(1, names.size());
    Assert.assertEquals("Test::One", names.get(0));

    MapEvent evt = new MapEvent("Test::One");
    Event matchedEvent = filterListener.match(evt);
    Assert.assertNotNull(matchedEvent);
    filterListener.handleEvent(evt);

    evt = new MapEvent("Test::Two");
    matchedEvent = filterListener.match(evt);
    Assert.assertNull(matchedEvent);
    filterListener.handleEvent(evt);
}

From source file:org.lwes.listener.FilterListenerTest.java

@Test
public void testMultipleEventFilter() {
    FilterListener filterListener = new FilterListener();
    filterListener//from w w w . jav a  2 s. c  om
            .processArguments(new String[] { "-m", "224.0.0.0", "-p", "0000", "-e", "Test::One,Test::Three" });

    List<String> names = filterListener.getEventNames();
    Assert.assertNotNull(names);
    Assert.assertEquals(2, names.size());

    MapEvent evt = new MapEvent("Test::One");
    Event matchedEvent = filterListener.match(evt);
    Assert.assertNotNull(matchedEvent);

    evt = new MapEvent("Test::Two");
    matchedEvent = filterListener.match(evt);
    Assert.assertNull(matchedEvent);
}

From source file:org.lwes.listener.FilterListenerTest.java

@Test
public void testSingleAttribute() {
    FilterListener filterListener = new FilterListener();
    filterListener.processArguments(new String[] { "-m", "224.0.0.0", "-p", "0000", "-a", "eid=1" });

    // Verify the argument was parsed properly
    Map<String, String> attrs = filterListener.getEventAttrs();
    Assert.assertNotNull(attrs);//from  w w w.j  a  va  2  s .  co m
    Assert.assertEquals(1, attrs.size());
    Assert.assertEquals("1", attrs.get("eid"));

    // Verify matching functions properly
    MapEvent evt = new MapEvent("Test::One");
    evt.setString("eid", "1");
    Event matchedEvent = filterListener.match(evt);
    Assert.assertNotNull(matchedEvent);

    evt = new MapEvent("Test::One");
    evt.setString("eid", "2");
    matchedEvent = filterListener.match(evt);
    Assert.assertNull(matchedEvent);
}

From source file:org.lwes.listener.FilterListenerTest.java

@Test
public void testMultipleAttributes() {
    FilterListener filterListener = new FilterListener();
    filterListener.processArguments(new String[] { "-m", "224.0.0.0", "-p", "0000", "-a", "eid=1,pid=5" });

    // Verify the argument was parsed properly
    Map<String, String> attrs = filterListener.getEventAttrs();
    Assert.assertNotNull(attrs);//from w  w  w . j a v a2  s.c  o m
    Assert.assertEquals(2, attrs.size());
    Assert.assertEquals("1", attrs.get("eid"));
    Assert.assertEquals("5", attrs.get("pid"));

    // Verify multiple arguments get matched properly
    MapEvent evt = new MapEvent("Test::One");
    evt.setString("eid", "1");
    evt.setString("pid", "5");
    Event matchedEvent = filterListener.match(evt);
    Assert.assertNotNull(matchedEvent);

    evt = new MapEvent("Test::One");
    evt.setString("eid", "2");
    evt.setString("pid", "5");
    matchedEvent = filterListener.match(evt);
    Assert.assertNull(matchedEvent);
}

From source file:org.mifos.accounts.loan.business.LoanBOIntegrationTest.java

public void testHandleArrearsAging_Create() throws Exception {
    Calendar calendar = new GregorianCalendar();
    calendar.setTime(DateUtils.getCurrentDateWithoutTimeStamp());
    calendar.add(calendar.WEEK_OF_MONTH, -2);
    java.sql.Date secondWeekDate = new java.sql.Date(calendar.getTimeInMillis());

    accountBO = getLoanAccount();//from ww w.  ja  va 2s  . co m
    for (AccountActionDateEntity installment : accountBO.getAccountActionDates()) {
        if (installment.getInstallmentId().intValue() == 1) {
            ((LoanScheduleEntity) installment).setActionDate(secondWeekDate);
        }
    }
    TestObjectFactory.updateObject(accountBO);
    TestObjectFactory.flushandCloseSession();
    accountBO = TestObjectFactory.getObject(AccountBO.class, accountBO.getAccountId());
    Assert.assertNull(((LoanBO) accountBO).getLoanArrearsAgingEntity());

    ((LoanBO) accountBO).handleArrearsAging();
    StaticHibernateUtil.commitTransaction();
    StaticHibernateUtil.closeSession();

    accountBO = TestObjectFactory.getObject(AccountBO.class, accountBO.getAccountId());
    LoanArrearsAgingEntity agingEntity = ((LoanBO) accountBO).getLoanArrearsAgingEntity();

    Assert.assertNotNull(agingEntity);
    Assert.assertEquals(new Money(getCurrency(), "100"), agingEntity.getOverduePrincipal());
    Assert.assertEquals(new Money(getCurrency(), "12"), agingEntity.getOverdueInterest());
    Assert.assertEquals(new Money(getCurrency(), "112"), agingEntity.getOverdueBalance());
    Assert.assertEquals(Short.valueOf("14"), agingEntity.getDaysInArrears());

    Assert.assertEquals(((LoanBO) accountBO).getLoanSummary().getPrincipalDue(),
            agingEntity.getUnpaidPrincipal());
    Assert.assertEquals(((LoanBO) accountBO).getLoanSummary().getInterestDue(),
            agingEntity.getUnpaidInterest());
    Assert.assertEquals(((LoanBO) accountBO).getLoanSummary().getPrincipalDue()
            .add(((LoanBO) accountBO).getLoanSummary().getInterestDue()), agingEntity.getUnpaidBalance());

    Assert.assertEquals(((LoanBO) accountBO).getTotalPrincipalAmountInArrears(),
            agingEntity.getOverduePrincipal());
    Assert.assertEquals(((LoanBO) accountBO).getTotalInterestAmountInArrears(),
            agingEntity.getOverdueInterest());
    Assert.assertEquals(((LoanBO) accountBO).getTotalPrincipalAmountInArrears()
            .add(((LoanBO) accountBO).getTotalInterestAmountInArrears()), agingEntity.getOverdueBalance());
}