Package org.spw.controller

Source Code of org.spw.controller.DonationControllerTest

/*
* DonationControllerTest.java
* JUnit based test
*
* Created on 17 August 2007, 19:05
*/

package org.spw.controller;

import junit.framework.*;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;
import org.spw.model.Donation;

/**
*
* @author PSe
*/
public class DonationControllerTest extends TestCase {
    private static final Long TEST_ID = 9999999L;
    private static final DonationController ctrl = new DonationController();   
   
    public DonationControllerTest(String testName) {
        super(testName);
    }

    protected void setUp() throws Exception {
        Donation test = new Donation();
        test.setIdDonation(TEST_ID);
        test.setProposalTitle(getName());
        ctrl.create(test);       
    }

    protected void tearDown() throws Exception {
        ctrl.delete(ctrl.read(TEST_ID));
    }

    /**
     * Test of getDonations method, of class org.spw.controller.DonationController.
     */
    public void testGetDonations() {
        boolean found = false;
        System.out.println("getDonations");
       
        List<Donation> result = ctrl.getDonations();
        assertNotNull(result);
        assertTrue(result.size() > 0);
        for (Donation donation : result) {
            if (donation.getIdDonation() == TEST_ID) {
                found = true;
                break;
            }
        }
        assertTrue("Cannot find the test entity.", found);
    }
 
}
TOP

Related Classes of org.spw.controller.DonationControllerTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.