/*
 * 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;

/**
 * JTATransactionService가 제공하는 기능을 테스트하기 위한 샘플 테스트 코드
 */
public class TransactionServiceTestJTA extends AbstractTransactionServiceTest {

	/**
	 * 테스트 수행을 위한 main
	 */	
	public static void main(String[] args) throws Exception {
		TransactionServiceTestJTA txJTA = new TransactionServiceTestJTA();

		// 1. initialize context
		txJTA.setup();
		// 2. test	
		txJTA.testInsertCommit();
		txJTA.testInsertRollback();
		txJTA.testUpdateCommit();
		txJTA.testUpdateRollback();
		txJTA.testRemoveCommit(); 
		
		// 3. close context
		txJTA.teardown();
		
		System.out.println("Successful!!!!!!");
	}

	protected void setup() {
		super.setup();
		
		this.service = (TransactionTestSampleService)context.getBean("transactionSampleJTA");
		this.transactionManager = (PlatformTransactionManager)context.getBean("transactionManagerJTA");
	}

	@Override
	protected String[] getConfigLocations() {
		return new String[]{"classpath*:/common/applicationContext-*.xml", 
				"classpath*:/applications/transactionsample/applicationContext-tx-sample-jta.xml", 
				"classpath*:/services/datasource/applicationContext-datasource-common.xml",
				"classpath*:/services/transaction/applicationContext-transaction-jta.xml", 
				"classpath*:/services/hibernate/applicationContext-hibernate.xml",
				"classpath*:/services/query/applicationContext-query-common.xml",
				"classpath*:/services/query/applicationContext-query-sqlloader.xml"};
	}

}

