package com.tarena.oss.rights.dao;

import junit.framework.TestCase;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.tarena.oss.rights.pojo.Rights;
import com.tarena.oss.rights.pojo.Role;

public class RoleMgmtDAOByHibernateTest extends TestCase {
	private RightsMgmtDAO rightDAO;
	private RoleMgmtDAO roleDAO;
	
	public RoleMgmtDAOByHibernateTest(String name) {
		super(name);
	}

	protected void setUp() throws Exception {
		ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml");
		rightDAO = (RightsMgmtDAO)ac.getBean("rightdao");
		roleDAO = (RoleMgmtDAO)ac.getBean("roledao");
	}

	protected void tearDown() throws Exception {
	}

	public void testInsertRote() {
		Role role = new Role();
		role.setName("ÆÕÍ¨¹ÜÀíÔ±");
		Rights right1 = rightDAO.queryRight(1) ;
		Rights right2 = rightDAO.queryRight(2) ;
		role.getRights().add(right1);
		role.getRights().add(right2);
		roleDAO.insertRote(role);
	}

}
