/*
 * Copyright 2002-2008 the original author or authors.
 *
 * 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 integration.anyframe.services.transaction;

import integration.anyframe.services.transaction.sample.TransactionTestSampleService;

import org.springframework.transaction.PlatformTransactionManager;

/**
 * HibernateTransactionManagerService가 제공하는 기능을 테스트하기 위한 샘플 테스트 코드
 */
public class TransactionServiceTestHibernate extends AbstractTransactionServiceTest {

	/**
	 * 테스트 수행을 위한 main
	 */	
	public static void main(String[] args) throws Exception {
		TransactionServiceTestHibernate txHibernate = new TransactionServiceTestHibernate();

		// 1. initialize context
		txHibernate.setup();
		// 2. test	
		txHibernate.testInsertCommit();
		txHibernate.testInsertRollback();
		txHibernate.testUpdateCommit();
		txHibernate.testUpdateRollback();
		txHibernate.testRemoveCommit(); 
		
		// 3. close context
		txHibernate.teardown();
		
		System.out.println("Successful!!!!!!");
	}

	protected void setup() {
		super.setup();
		
		this.service = (TransactionTestSampleService)context.getBean("transactionSampleHibernate");
		this.transactionManager = (PlatformTransactionManager)context.getBean("transactionManagerHibernate");
	}

	protected String[] getConfigLocations() {
		return new String[]{"classpath*:/common/applicationContext-*.xml", 
				"classpath*:/applications/transactionsample/applicationContext-tx-sample-hibernate.xml", 
				"classpath*:/services/datasource/applicationContext-datasource-common.xml",
				"classpath*:/services/transaction/applicationContext-transaction-hibernate.xml", 
				"classpath*:/services/hibernate/applicationContext-hibernate.xml",
				"classpath*:/services/query/applicationContext-query-common.xml",
				"classpath*:/services/query/applicationContext-query-sqlloader.xml"};
	}

}

