Package com.vst.dao

Source Code of com.vst.dao.AuthentificationElementDaoTest

package com.vst.dao;

import java.util.List;

import com.vst.dao.BaseDaoTestCase;
import com.vst.model.AuthentificationElement;

import org.springframework.dao.InvalidDataAccessApiUsageException;
import org.springframework.orm.ObjectRetrievalFailureException;

public class AuthentificationElementDaoTest extends BaseDaoTestCase {
    private Integer authentificationElementId = new Integer("1");
    private AuthentificationElementDao dao = null;

    public void setAuthentificationElementDao(AuthentificationElementDao dao) {
        this.dao = dao;
    }

    public void testAddAuthentificationElement() throws Exception {
        AuthentificationElement authentificationElement = new AuthentificationElement();

        // set required fields

        dao.saveAuthentificationElement(authentificationElement);

        // verify a primary key was assigned
        assertNotNull(authentificationElement.getAuthentificationId());

        // verify set fields are same after save
    }

    public void testGetAuthentificationElement() throws Exception {
        AuthentificationElement authentificationElement = dao.getAuthentificationElement(authentificationElementId);
        assertNotNull(authentificationElement);
    }

    public void testGetAuthentificationElements() throws Exception {
        AuthentificationElement authentificationElement = new AuthentificationElement();

        List results = dao.getAuthentificationElements(authentificationElement);
        assertTrue(results.size() > 0);
    }

    public void testSaveAuthentificationElement() throws Exception {
        AuthentificationElement authentificationElement = dao.getAuthentificationElement(authentificationElementId);

        // update required fields

        dao.saveAuthentificationElement(authentificationElement);

    }

    public void testRemoveAuthentificationElement() throws Exception {
        Integer removeId = new Integer("3");
        dao.removeAuthentificationElement(removeId);
        try {
            dao.getAuthentificationElement(removeId);
            fail("authentificationElement found in database");
        } catch (ObjectRetrievalFailureException e) {
            assertNotNull(e.getMessage());
        } catch (InvalidDataAccessApiUsageException e) { // Spring 2.0 throws this one
            assertNotNull(e.getMessage());         
        }
    }
}
TOP

Related Classes of com.vst.dao.AuthentificationElementDaoTest

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.