/**
 * @(#)ProjectDAOImplTest.java
 * 
 * JFoxSOAF, Service-Oriented Application Framework
 * 
 * Copyright(c) JFoxSOAF Team
 * 
 * Licensed under the GNU LGPL, Version 2.1 (the "License"); 
 * you may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at  
 * 
 * http://www.gnu.org/copyleft/lesser.html
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 * See the License for the specific language governing permissions and 
 * limitations under the License. 
 * 
 * For more information, please visit:
 * http://www.jfox.cn/confluence/display/JFoxSOAF/Home
 * http://www.huihoo.org/jfox/jfoxsoaf
 */

package org.huihoo.jfox.soaf.samples.jdbc.dao;

import java.util.Iterator;
import java.util.List;

import junit.framework.TestCase;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.huihoo.jfox.soaf.container.ServiceLoader;
import org.huihoo.jfox.soaf.samples.jdbc.model.ProjectBean;

/**
 * @author peter
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class ProjectDAOImplTest extends TestCase {
	
	private final Log log = LogFactory.getLog(getClass());
	
	private ServiceLoader sl = ServiceLoader.getInstance();
	
	private ProjectDAOImpl projectDAOImpl;

	/*
	 * @see TestCase#setUp()
	 */
	protected void setUp() throws Exception {
		super.setUp();
		
		if (!sl.isServiceLoaded()) {
			sl.initService("jfoxsoaf-config.xml");
		}
		
		projectDAOImpl = new ProjectDAOImpl();
	}

	/*
	 * @see TestCase#tearDown()
	 */
	protected void tearDown() throws Exception {
		super.tearDown();
	}

	public void testGetProjectById() {
		ProjectBean pb = projectDAOImpl.getProjectById();
		log.info("id" + pb.getId());
		log.info("name" + pb.getName());
		log.info("type" + pb.getType());		
	}
	
	public void testGetProjects() {		
		List projectList = projectDAOImpl.getProjects();
		Iterator iter = projectList.iterator();
		while (iter.hasNext()) {
			ProjectBean pb = (ProjectBean)iter.next();
			log.info("id" + pb.getId());
			log.info("name" + pb.getName());
			log.info("type" + pb.getType());
		}
    }	
	
	public void testCountProject() {
		System.out.println("hell");
		int count = projectDAOImpl.countProject();
		System.out.println("count is: " + String.valueOf(count));
    }
}
