pricingmgmtservicetest.java

来自「当时就海底世界没客服热线mkxmykm,xkxtml, xrtlujlnszlt」· Java 代码 · 共 80 行

JAVA
80
字号
package com.tarena.oss.test;

import java.util.Collection;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.tarena.oss.pricing.pojo.Pricing;
import com.tarena.oss.pricing.pojo.PricingConditionDTO;
import com.tarena.oss.pricing.service.PricingMgmtService;

public class PricingMgmtServiceTest extends TestCase {
	private PricingMgmtService service;
	private ApplicationContext context;
	
	public PricingMgmtServiceTest(String name) {
		super(name);
	}

	protected void setUp() throws Exception {
		context = new ClassPathXmlApplicationContext("applicationContext.xml");
		service = (PricingMgmtService)context.getBean("pricingServiceProxy");
	}

	protected void tearDown() throws Exception {
		context = null;
		service = null;
	}

	public void testFindAll() {
		Collection<Pricing> ps = service.findAll();
		System.out.println(ps);
	}

	public void testFindAllByCondition() {
		PricingConditionDTO dto = new PricingConditionDTO();
		dto.setName("资");
		Collection<Pricing> ps = service.findAllByCondition(dto);
		System.out.println(ps);
	}

	public void testAddPricing() {
		Pricing p = new Pricing(null, "套餐一", 10, 0.8, "通过JUnit测试");
		service.addPricing(p);
	}

	public void testModifyPricing() {
		Pricing p = service.findPricingById(1);
		p.setName("资费二");
		service.modifyPricing(p);
	}

	public void testFindPricingById() {
		Pricing p = service.findPricingById(1);
		System.out.println(p);
	}

	public void testRemovePricing() {
		service.removePricing(2);
	}

	public static Test suite(){
		TestSuite suite = new TestSuite();

		suite.addTest(new PricingMgmtServiceTest("testAddPricing"));
		suite.addTest(new PricingMgmtServiceTest("testFindAll"));
		suite.addTest(new PricingMgmtServiceTest("testFindAllByCondition"));
		suite.addTest(new PricingMgmtServiceTest("testFindPricingById"));
		suite.addTest(new PricingMgmtServiceTest("testModifyPricing"));
		suite.addTest(new PricingMgmtServiceTest("testRemovePricing"));
		suite.addTest(new PricingMgmtServiceTest("testFindAll"));
		
		return suite;
	}
}

⌨️ 快捷键说明

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