factoryobjectintegrationtests.java
来自「一些很有用的spring的书籍」· Java 代码 · 共 32 行
JAVA
32 行
package com.apress.springbook.chapter02;
import junit.framework.TestCase;
import org.springframework.core.io.ClassPathResource;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
public class FactoryObjectIntegrationTests extends TestCase {
public void testPreInstantiateSingletons() {
ConfigurableListableBeanFactory beanFactory =
new XmlBeanFactory(
new ClassPathResource(
"com/apress/springbook/chapter02/socket-factory.xml"
)
);
java.net.Socket localhost =
(java.net.Socket)beanFactory.getBean("localhost");
java.net.Socket apressDotCom =
(java.net.Socket)beanFactory.getBean("apress.com");
assertTrue(localhost.isConnected());
assertTrue(apressDotCom.isConnected());
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?