光头强不强

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

1.新建LoadPropertis类,内容如下:

import org.springframework.context.support.ClassPathXmlApplicationContext;

import junit.framework.TestCase;

public class LoadPropertis extends TestCase{
private static ClassPathXmlApplicationContext context= null;
private static String allproperties[] = {
"applicationContext-channel-test.xml","applicationContext-common-test.xml"
};
protected void setUp() throws Exception{
super.setUp();
if(context==null){
context = new ClassPathXmlApplicationContext(allproperties);
}
}
protected void tearDown() throws Exception{
super.tearDown();
}
protected Object getBean(String beanName){
if(beanName == null){
throw new IllegalArgumentException(beanName + "is null");
}
return context.getBean(beanName);
}
}

 

2.新建:Test01类,内容如下:

public class Test01 extends LoadPropertis {

private IZybCoreBS zybCoreBS;

protected void setUp() throws Exception{
super.setUp();
zybCoreBS = (IZybCoreBS)this.getBean("zybCoreBS");
}

protected void tearDown()throws Exception{
super.tearDown();
}

public void test01() {

CurrAccoInVo currAccoInVo = new CurrAccoInVo();

try {
zybCoreBS.currAccoQuery(currAccoInVo);
} catch (Exception e) {
System.out.println("失败");
}

}

}

 

3.配置文件:application-channel-test.xml文件内容如下:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>

<bean id="zybCoreBS" class="com.tansun.scf.zyb.intf.core.service.impl.ZybCoreBSImpl">
<property name="bussCommonBS">
<ref bean="bussCommonBS" />
</property>
</bean>

<bean id="zybCmsBS" class="com.tansun.scf.zyb.intf.cms.service.impl.ZybCmsBSImpl">
<property name="bussCommonBS">
<ref bean="bussCommonBS" />
</property>
</bean>

<bean id="bussCommonBS" class="com.tansun.scf.common.service.impl.BussCommonBSImpl">
<property name="sysparamBS">
<ref bean="sysparamBS" />
</property>
</bean>

</beans>

 

4.配置文件applicationContext-common-test.xml内容如下:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="jndiDataSource"
class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>OracleDataSource</value>
</property>
</bean>

<bean id="lobHandler"
class="org.springframework.jdbc.support.lob.DefaultLobHandler" lazy-init="true"/>

 

 

</beans>

 

其中applicationContext-common-test.xml是放数据库配置文件和数据库表xml文件目录的,

applicationContext-channel-test.xml是放调用java类的bean配置信息的

posted on 2016-05-28 15:45  光头强不强  阅读(293)  评论(0)    收藏  举报