finished moving .ejb.* unit tests from .testsuite -> .context
This commit is contained in:
parent
0b0c8f1506
commit
2952609672
|
@ -19,6 +19,8 @@
|
|||
<classpathentry kind="var" path="IVY_CACHE/javax.ejb/com.springsource.javax.ejb/3.0.0/com.springsource.javax.ejb-3.0.0.jar" sourcepath="/IVY_CACHE/javax.ejb/com.springsource.javax.ejb/3.0.0/com.springsource.javax.ejb-sources-3.0.0.jar"/>
|
||||
<classpathentry kind="var" path="IVY_CACHE/javax.jms/com.springsource.javax.jms/1.1.0/com.springsource.javax.jms-1.1.0.jar" sourcepath="/IVY_CACHE/javax.jms/com.springsource.javax.jms/1.1.0/com.springsource.javax.jms-sources-1.1.0.jar"/>
|
||||
<classpathentry kind="var" path="IVY_CACHE/javax.persistence/com.springsource.javax.persistence/1.0.0/com.springsource.javax.persistence-1.0.0.jar" sourcepath="/IVY_CACHE/javax.persistence/com.springsource.javax.persistence/1.0.0/com.springsource.javax.persistence-sources-1.0.0.jar"/>
|
||||
<classpathentry kind="var" path="IVY_CACHE/javax.transaction/com.springsource.javax.transaction/1.1.0/com.springsource.javax.transaction-1.1.0.jar" sourcepath="/IVY_CACHE/javax.transaction/com.springsource.javax.transaction/1.1.0/com.springsource.javax.transaction-sources-1.1.0.jar"/>
|
||||
<classpathentry kind="var" path="IVY_CACHE/javax.xml.rpc/com.springsource.javax.xml.rpc/1.1.0/com.springsource.javax.xml.rpc-1.1.0.jar"/>
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.apache.log4j/com.springsource.org.apache.log4j/1.2.15/com.springsource.org.apache.log4j-1.2.15.jar" sourcepath="/IVY_CACHE/org.apache.log4j/com.springsource.org.apache.log4j/1.2.15/com.springsource.org.apache.log4j-sources-1.2.15.jar"/>
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.junit/com.springsource.org.junit/4.5.0/com.springsource.org.junit-4.5.0.jar" sourcepath="/IVY_CACHE/org.junit/com.springsource.org.junit/4.5.0/com.springsource.org.junit-sources-4.5.0.jar"/>
|
||||
<classpathentry kind="var" path="IVY_CACHE/org.apache.commons/com.springsource.org.apache.commons.logging/1.1.1/com.springsource.org.apache.commons.logging-1.1.1.jar" sourcepath="/IVY_CACHE/org.apache.commons/com.springsource.org.apache.commons.logging/1.1.1/com.springsource.org.apache.commons.logging-sources-1.1.1.jar"/>
|
||||
|
|
|
@ -51,6 +51,8 @@
|
|||
<dependency org="org.springframework" name="org.springframework.expression" rev="latest.integration" conf="compile->compile"/>
|
||||
<dependency org="org.springframework" name="org.springframework.instrument" rev="latest.integration" conf="optional, instrumentation->compile"/>
|
||||
<!-- test dependencies -->
|
||||
<dependency org="javax.transaction" name="com.springsource.javax.transaction" rev="1.1.0" conf="test->compile"/>
|
||||
<dependency org="javax.xml.rpc" name="com.springsource.javax.xml.rpc" rev="1.1.0" conf="test->compile"/>
|
||||
<dependency org="org.apache.log4j" name="com.springsource.org.apache.log4j" rev="1.2.15" conf="test->runtime"/>
|
||||
<dependency org="org.junit" name="com.springsource.org.junit" rev="4.5.0" conf="test->runtime"/>
|
||||
<dependency org="org.easymock" name="com.springsource.org.easymock" rev="2.3.0" conf="test->compile"/>
|
||||
|
|
|
@ -0,0 +1,86 @@
|
|||
/*
|
||||
* Copyright 2002-2007 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 org.springframework.beans.factory.parsing;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.core.CollectionFactory;
|
||||
|
||||
/**
|
||||
* @author Rob Harrop
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class CollectingReaderEventListener implements ReaderEventListener {
|
||||
|
||||
private final List defaults = new LinkedList();
|
||||
|
||||
private final Map componentDefinitions = CollectionFactory.createLinkedMapIfPossible(8);
|
||||
|
||||
private final Map aliasMap = CollectionFactory.createLinkedMapIfPossible(8);
|
||||
|
||||
private final List imports = new LinkedList();
|
||||
|
||||
|
||||
public void defaultsRegistered(DefaultsDefinition defaultsDefinition) {
|
||||
this.defaults.add(defaultsDefinition);
|
||||
}
|
||||
|
||||
public List getDefaults() {
|
||||
return Collections.unmodifiableList(this.defaults);
|
||||
}
|
||||
|
||||
public void componentRegistered(ComponentDefinition componentDefinition) {
|
||||
this.componentDefinitions.put(componentDefinition.getName(), componentDefinition);
|
||||
}
|
||||
|
||||
public ComponentDefinition getComponentDefinition(String name) {
|
||||
return (ComponentDefinition) this.componentDefinitions.get(name);
|
||||
}
|
||||
|
||||
public ComponentDefinition[] getComponentDefinitions() {
|
||||
Collection collection = this.componentDefinitions.values();
|
||||
return (ComponentDefinition[]) collection.toArray(new ComponentDefinition[collection.size()]);
|
||||
}
|
||||
|
||||
public void aliasRegistered(AliasDefinition aliasDefinition) {
|
||||
List aliases = (List) this.aliasMap.get(aliasDefinition.getBeanName());
|
||||
if(aliases == null) {
|
||||
aliases = new ArrayList();
|
||||
this.aliasMap.put(aliasDefinition.getBeanName(), aliases);
|
||||
}
|
||||
aliases.add(aliasDefinition);
|
||||
}
|
||||
|
||||
public List getAliases(String beanName) {
|
||||
List aliases = (List) this.aliasMap.get(beanName);
|
||||
return aliases == null ? null : Collections.unmodifiableList(aliases);
|
||||
}
|
||||
|
||||
public void importProcessed(ImportDefinition importDefinition) {
|
||||
this.imports.add(importDefinition);
|
||||
}
|
||||
|
||||
public List getImports() {
|
||||
return Collections.unmodifiableList(this.imports);
|
||||
}
|
||||
|
||||
}
|
|
@ -16,8 +16,10 @@
|
|||
|
||||
package org.springframework.ejb.config;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.parsing.BeanComponentDefinition;
|
||||
import org.springframework.beans.factory.parsing.CollectingReaderEventListener;
|
||||
import org.springframework.beans.factory.parsing.ComponentDefinition;
|
||||
|
@ -28,8 +30,9 @@ import org.springframework.core.io.ClassPathResource;
|
|||
/**
|
||||
* @author Torsten Juergeleit
|
||||
* @author Juergen Hoeller
|
||||
* @author Chris Beams
|
||||
*/
|
||||
public class JeeNamespaceHandlerEventTests extends TestCase {
|
||||
public class JeeNamespaceHandlerEventTests {
|
||||
|
||||
private CollectingReaderEventListener eventListener = new CollectingReaderEventListener();
|
||||
|
||||
|
@ -38,22 +41,26 @@ public class JeeNamespaceHandlerEventTests extends TestCase {
|
|||
private DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
this.reader = new XmlBeanDefinitionReader(this.beanFactory);
|
||||
this.reader.setEventListener(this.eventListener);
|
||||
this.reader.loadBeanDefinitions(new ClassPathResource("jeeNamespaceHandlerTests.xml", getClass()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJndiLookupComponentEventReceived() {
|
||||
ComponentDefinition component = this.eventListener.getComponentDefinition("simple");
|
||||
assertTrue(component instanceof BeanComponentDefinition);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLocalSlsbComponentEventReceived() {
|
||||
ComponentDefinition component = this.eventListener.getComponentDefinition("simpleLocalEjb");
|
||||
assertTrue(component instanceof BeanComponentDefinition);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoteSlsbComponentEventReceived() {
|
||||
ComponentDefinition component = this.eventListener.getComponentDefinition("simpleRemoteEjb");
|
||||
assertTrue(component instanceof BeanComponentDefinition);
|
|
@ -16,8 +16,10 @@
|
|||
|
||||
package org.springframework.ejb.config;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.ITestBean;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
|
@ -32,12 +34,14 @@ import org.springframework.jndi.JndiObjectFactoryBean;
|
|||
/**
|
||||
* @author Rob Harrop
|
||||
* @author Juergen Hoeller
|
||||
* @author Chris Beams
|
||||
*/
|
||||
public class JeeNamespaceHandlerTests extends TestCase {
|
||||
public class JeeNamespaceHandlerTests {
|
||||
|
||||
private ConfigurableListableBeanFactory beanFactory;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
GenericApplicationContext ctx = new GenericApplicationContext();
|
||||
new XmlBeanDefinitionReader(ctx).loadBeanDefinitions(
|
||||
new ClassPathResource("jeeNamespaceHandlerTests.xml", getClass()));
|
||||
|
@ -46,6 +50,7 @@ public class JeeNamespaceHandlerTests extends TestCase {
|
|||
this.beanFactory.getBeanNamesForType(ITestBean.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleDefinition() throws Exception {
|
||||
BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("simple");
|
||||
assertEquals(JndiObjectFactoryBean.class.getName(), beanDefinition.getBeanClassName());
|
||||
|
@ -53,6 +58,7 @@ public class JeeNamespaceHandlerTests extends TestCase {
|
|||
assertPropertyValue(beanDefinition, "resourceRef", "true");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testComplexDefinition() throws Exception {
|
||||
BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("complex");
|
||||
assertEquals(JndiObjectFactoryBean.class.getName(), beanDefinition.getBeanClassName());
|
||||
|
@ -66,18 +72,21 @@ public class JeeNamespaceHandlerTests extends TestCase {
|
|||
assertPropertyValue(beanDefinition, "defaultObject", "myValue");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithEnvironment() throws Exception {
|
||||
BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("withEnvironment");
|
||||
assertPropertyValue(beanDefinition, "jndiEnvironment", "foo=bar");
|
||||
assertPropertyValue(beanDefinition, "defaultObject", new RuntimeBeanReference("myBean"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithReferencedEnvironment() throws Exception {
|
||||
BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("withReferencedEnvironment");
|
||||
assertPropertyValue(beanDefinition, "jndiEnvironment", new RuntimeBeanReference("myEnvironment"));
|
||||
assertFalse(beanDefinition.getPropertyValues().contains("environmentRef"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleLocalSlsb() throws Exception {
|
||||
BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("simpleLocalEjb");
|
||||
assertEquals(LocalStatelessSessionProxyFactoryBean.class.getName(), beanDefinition.getBeanClassName());
|
||||
|
@ -85,6 +94,7 @@ public class JeeNamespaceHandlerTests extends TestCase {
|
|||
assertPropertyValue(beanDefinition, "jndiName", "ejb/MyLocalBean");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleRemoteSlsb() throws Exception {
|
||||
BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("simpleRemoteEjb");
|
||||
assertEquals(SimpleRemoteStatelessSessionProxyFactoryBean.class.getName(), beanDefinition.getBeanClassName());
|
||||
|
@ -92,6 +102,7 @@ public class JeeNamespaceHandlerTests extends TestCase {
|
|||
assertPropertyValue(beanDefinition, "jndiName", "ejb/MyRemoteBean");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testComplexLocalSlsb() throws Exception {
|
||||
BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("complexLocalEjb");
|
||||
assertEquals(LocalStatelessSessionProxyFactoryBean.class.getName(), beanDefinition.getBeanClassName());
|
||||
|
@ -103,6 +114,7 @@ public class JeeNamespaceHandlerTests extends TestCase {
|
|||
assertPropertyValue(beanDefinition, "jndiEnvironment", "foo=bar");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testComplexRemoteSlsb() throws Exception {
|
||||
BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("complexRemoteEjb");
|
||||
assertEquals(SimpleRemoteStatelessSessionProxyFactoryBean.class.getName(), beanDefinition.getBeanClassName());
|
|
@ -16,6 +16,8 @@
|
|||
|
||||
package org.springframework.ejb.support;
|
||||
|
||||
import static org.easymock.EasyMock.*;
|
||||
|
||||
import java.rmi.RemoteException;
|
||||
|
||||
import javax.ejb.CreateException;
|
||||
|
@ -26,7 +28,6 @@ import javax.jms.Message;
|
|||
import javax.naming.NamingException;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.easymock.MockControl;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.FatalBeanException;
|
||||
|
@ -40,14 +41,14 @@ import org.springframework.mock.jndi.SimpleNamingContextBuilder;
|
|||
/**
|
||||
* @author Rod Johnson
|
||||
* @author Juergen Hoeller
|
||||
* @author Chris Beams
|
||||
* @since 21.05.2003
|
||||
*/
|
||||
public class EjbSupportTests extends TestCase {
|
||||
|
||||
public void testSfsb() throws CreateException {
|
||||
MockControl mc = MockControl.createControl(SessionContext.class);
|
||||
SessionContext sc = (SessionContext) mc.getMock();
|
||||
mc.replay();
|
||||
SessionContext sc = createMock(SessionContext.class);
|
||||
replay(sc);
|
||||
|
||||
final BeanFactory bf = new StaticListableBeanFactory();
|
||||
BeanFactoryLocator bfl = new BeanFactoryLocator() {
|
||||
|
@ -65,6 +66,7 @@ public class EjbSupportTests extends TestCase {
|
|||
};
|
||||
|
||||
// Basically the test is what needed to be implemented here!
|
||||
@SuppressWarnings("serial")
|
||||
class MySfsb extends AbstractStatefulSessionBean {
|
||||
public void ejbCreate() throws CreateException {
|
||||
loadBeanFactory();
|
||||
|
@ -92,13 +94,13 @@ public class EjbSupportTests extends TestCase {
|
|||
public void testHelpfulNamingLookupMessage() throws NamingException, CreateException {
|
||||
SimpleNamingContextBuilder.emptyActivatedContextBuilder();
|
||||
|
||||
MockControl mc = MockControl.createControl(SessionContext.class);
|
||||
SessionContext sc = (SessionContext) mc.getMock();
|
||||
mc.replay();
|
||||
SessionContext sc = createMock(SessionContext.class);
|
||||
replay(sc);
|
||||
|
||||
// Leave with default XmlBeanFactoryLoader
|
||||
|
||||
// Basically the test is what needed to be implemented here!
|
||||
@SuppressWarnings("serial")
|
||||
AbstractStatelessSessionBean slsb = new AbstractStatelessSessionBean() {
|
||||
public void onEjbCreate() {
|
||||
}
|
||||
|
@ -116,9 +118,8 @@ public class EjbSupportTests extends TestCase {
|
|||
}
|
||||
|
||||
public void testSlsb() throws Exception {
|
||||
MockControl mc = MockControl.createControl(SessionContext.class);
|
||||
SessionContext sc = (SessionContext) mc.getMock();
|
||||
mc.replay();
|
||||
SessionContext sc = createMock(SessionContext.class);
|
||||
replay(sc);
|
||||
|
||||
final BeanFactory bf = new StaticListableBeanFactory();
|
||||
BeanFactoryLocator bfl = new BeanFactoryLocator() {
|
||||
|
@ -134,6 +135,7 @@ public class EjbSupportTests extends TestCase {
|
|||
}
|
||||
};
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
AbstractStatelessSessionBean slsb = new AbstractStatelessSessionBean() {
|
||||
protected void onEjbCreate() throws CreateException {
|
||||
assertTrue(getBeanFactory() == bf);
|
||||
|
@ -161,9 +163,8 @@ public class EjbSupportTests extends TestCase {
|
|||
}
|
||||
|
||||
public void testJmsMdb() throws Exception {
|
||||
MockControl mc = MockControl.createControl(MessageDrivenContext.class);
|
||||
MessageDrivenContext sc = (MessageDrivenContext) mc.getMock();
|
||||
mc.replay();
|
||||
MessageDrivenContext sc = createMock(MessageDrivenContext.class);
|
||||
replay(sc);
|
||||
|
||||
final BeanFactory bf = new StaticListableBeanFactory();
|
||||
BeanFactoryLocator bfl = new BeanFactoryLocator() {
|
||||
|
@ -179,6 +180,7 @@ public class EjbSupportTests extends TestCase {
|
|||
}
|
||||
};
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
AbstractJmsMessageDrivenBean mdb = new AbstractJmsMessageDrivenBean() {
|
||||
protected void onEjbCreate() {
|
||||
assertTrue(getBeanFactory() == bf);
|
||||
|
@ -195,15 +197,15 @@ public class EjbSupportTests extends TestCase {
|
|||
}
|
||||
|
||||
public void testCannotLoadBeanFactory() throws Exception {
|
||||
MockControl mc = MockControl.createControl(SessionContext.class);
|
||||
SessionContext sc = (SessionContext) mc.getMock();
|
||||
mc.replay();
|
||||
SessionContext sc = createMock(SessionContext.class);
|
||||
replay(sc);
|
||||
|
||||
BeanFactoryLocator bfl = new BeanFactoryLocator() {
|
||||
public BeanFactoryReference useBeanFactory(String factoryKey) throws FatalBeanException {
|
||||
throw new BootstrapException("", null);
|
||||
}};
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
AbstractStatelessSessionBean slsb = new AbstractStatelessSessionBean() {
|
||||
protected void onEjbCreate() throws CreateException {
|
||||
}
|
Loading…
Reference in New Issue