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

