⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 reservationtest.java

📁 hotel management system
💻 JAVA
字号:
/*
 * Copyright 2005-2007 Kevin A. Lee
 *
 * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
 *
 * 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.
 *
 */
package test.net.sourceforge.hoteldj.web;

import java.util.Collection;
import java.util.Date;

import javax.ejb.EJBException;
import javax.ejb.RemoveException;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import junit.framework.TestCase;
import net.sourceforge.hoteldj.ejb.CustomerLocal;
import net.sourceforge.hoteldj.ejb.HotelManagerFacadeLocal;
import net.sourceforge.hoteldj.ejb.HotelManagerFacadeLocalHome;
import net.sourceforge.hoteldj.ejb.ReservationLocal;
import net.sourceforge.hoteldj.web.ReservationIDHelper;

/**
 * JUnit test class for Reservation entity bean
 * 
 * @author Kevin A. Lee
 * @email kevin.lee@buildmeister.com
 * 
 */
public class ReservationTest extends TestCase {

	private static final long serialVersionUID = 1447523027071610257L;
	HotelManagerFacadeLocal hm = null;
	CustomerLocal customer = null;
	Integer customerId = null;
	ReservationLocal reservation = null;
	
	/*
	 * (non-Java-doc)
	 */
	public void setUp() {

		Context context = null;
		
		try {
			context = new InitialContext();
			HotelManagerFacadeLocalHome hmHome = (HotelManagerFacadeLocalHome) context
					.lookup(HotelManagerFacadeLocalHome.JNDI_NAME);
			hm = hmHome.create();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			try {
				context.close();
			} catch (NamingException e) {
				e.printStackTrace();
			}
		}
		
		customer = hm.newCustomer("Kevin", "Lee");
		customerId = customer.getId();
	}
	
	public void tearDown() {
		try {
			customer.remove();
		} catch (EJBException e) {
			e.printStackTrace();
		} catch (RemoveException e) {
			e.printStackTrace();
		}
	}

	/*
	 * (non-Java-doc) 
	 */
	public void testNewReservation() throws Exception {
		Date today = new Date();
		reservation = hm.newReservation(new Integer(2), today, new Integer(4), customerId);
		assertNotNull(reservation);
		Integer reservationId = reservation.getId();
		assertEquals(new Integer(2), reservation.getNum_guests());
		//assertEquals(today, reservation.getArrival_date());
		assertEquals(new Integer(4), reservation.getNum_nights());
		boolean deleted = hm.deleteReservation(reservationId);
		assertTrue(deleted);
		assertNull(reservation);
	}
	
	/*
	 * (non-Java-doc)
	 */
	public void testReservationHelper() throws Exception {
		//ReservationIDHelper ridHelper = new ReservationIDHelper();
		//ReservationLocal res = hm.getReservation(ridHelper.formattedtoId("HJD00000001"));
	}
	
	/*
	 * (non-Java-doc)
	 */
	public void testGetReservationsForCustomer() throws Exception {
		//Collection resList = hm.getReservationsInformation(customerCode);
	}
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -