moving unit tests from .testsuite -> .jms
This commit is contained in:
parent
15860b1607
commit
5e0c5a42ad
|
|
@ -10,6 +10,8 @@
|
||||||
<classpathentry combineaccessrules="false" kind="src" path="/org.springframework.context"/>
|
<classpathentry combineaccessrules="false" kind="src" path="/org.springframework.context"/>
|
||||||
<classpathentry combineaccessrules="false" kind="src" path="/org.springframework.core"/>
|
<classpathentry combineaccessrules="false" kind="src" path="/org.springframework.core"/>
|
||||||
<classpathentry combineaccessrules="false" kind="src" path="/org.springframework.transaction"/>
|
<classpathentry combineaccessrules="false" kind="src" path="/org.springframework.transaction"/>
|
||||||
|
<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.easymock/com.springsource.org.easymock/2.3.0/com.springsource.org.easymock-2.3.0.jar" sourcepath="/IVY_CACHE/org.easymock/com.springsource.org.easymock/2.3.0/com.springsource.org.easymock-sources-2.3.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.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.resource/com.springsource.javax.resource/1.5.0/com.springsource.javax.resource-1.5.0.jar" sourcepath="/IVY_CACHE/javax.resource/com.springsource.javax.resource/1.5.0/com.springsource.javax.resource-sources-1.5.0.jar"/>
|
<classpathentry kind="var" path="IVY_CACHE/javax.resource/com.springsource.javax.resource/1.5.0/com.springsource.javax.resource-1.5.0.jar" sourcepath="/IVY_CACHE/javax.resource/com.springsource.javax.resource/1.5.0/com.springsource.javax.resource-sources-1.5.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.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"/>
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,8 @@
|
||||||
<dependency org="org.aopalliance" name="com.springsource.org.aopalliance" rev="1.0.0" conf="compile->compile"/>
|
<dependency org="org.aopalliance" name="com.springsource.org.aopalliance" rev="1.0.0" conf="compile->compile"/>
|
||||||
<dependency org="org.apache.commons" name="com.springsource.org.apache.commons.logging" rev="1.1.1" conf="compile->compile"/>
|
<dependency org="org.apache.commons" name="com.springsource.org.apache.commons.logging" rev="1.1.1" conf="compile->compile"/>
|
||||||
<dependency org="org.apache.commons" name="com.springsource.org.apache.commons.pool" rev="1.3.0" conf="optional, commons-pool->compile"/>
|
<dependency org="org.apache.commons" name="com.springsource.org.apache.commons.pool" rev="1.3.0" conf="optional, commons-pool->compile"/>
|
||||||
|
<dependency org="org.easymock" name="com.springsource.org.easymock" rev="2.3.0" conf="test->compile"/>
|
||||||
|
<dependency org="org.junit" name="com.springsource.org.junit" rev="4.5.0" conf="test->runtime"/>
|
||||||
<dependency org="org.springframework" name="org.springframework.aop" rev="latest.integration" conf="compile->compile"/>
|
<dependency org="org.springframework" name="org.springframework.aop" rev="latest.integration" conf="compile->compile"/>
|
||||||
<dependency org="org.springframework" name="org.springframework.beans" rev="latest.integration" conf="compile->compile"/>
|
<dependency org="org.springframework" name="org.springframework.beans" rev="latest.integration" conf="compile->compile"/>
|
||||||
<dependency org="org.springframework" name="org.springframework.context" rev="latest.integration" conf="compile->compile"/>
|
<dependency org="org.springframework" name="org.springframework.context" rev="latest.integration" conf="compile->compile"/>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
import org.springframework.core.enums.ShortCodedLabeledEnum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Rob Harrop
|
||||||
|
*/
|
||||||
|
public class Colour extends ShortCodedLabeledEnum {
|
||||||
|
|
||||||
|
public static final Colour RED = new Colour(0, "RED");
|
||||||
|
public static final Colour BLUE = new Colour(1, "BLUE");
|
||||||
|
public static final Colour GREEN = new Colour(2, "GREEN");
|
||||||
|
public static final Colour PURPLE = new Colour(3, "PURPLE");
|
||||||
|
|
||||||
|
private Colour(int code, String label) {
|
||||||
|
super(code, label);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2002-2005 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;
|
||||||
|
|
||||||
|
public interface INestedTestBean {
|
||||||
|
|
||||||
|
public String getCompany();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright 2002-2005 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;
|
||||||
|
|
||||||
|
public interface IOther {
|
||||||
|
|
||||||
|
void absquatulate();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,71 @@
|
||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface used for {@link org.springframework.beans.TestBean}.
|
||||||
|
*
|
||||||
|
* <p>Two methods are the same as on Person, but if this
|
||||||
|
* extends person it breaks quite a few tests..
|
||||||
|
*
|
||||||
|
* @author Rod Johnson
|
||||||
|
* @author Juergen Hoeller
|
||||||
|
*/
|
||||||
|
public interface ITestBean {
|
||||||
|
|
||||||
|
int getAge();
|
||||||
|
|
||||||
|
void setAge(int age);
|
||||||
|
|
||||||
|
String getName();
|
||||||
|
|
||||||
|
void setName(String name);
|
||||||
|
|
||||||
|
ITestBean getSpouse();
|
||||||
|
|
||||||
|
void setSpouse(ITestBean spouse);
|
||||||
|
|
||||||
|
ITestBean[] getSpouses();
|
||||||
|
|
||||||
|
String[] getStringArray();
|
||||||
|
|
||||||
|
void setStringArray(String[] stringArray);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Throws a given (non-null) exception.
|
||||||
|
*/
|
||||||
|
void exceptional(Throwable t) throws Throwable;
|
||||||
|
|
||||||
|
Object returnsThis();
|
||||||
|
|
||||||
|
INestedTestBean getDoctor();
|
||||||
|
|
||||||
|
INestedTestBean getLawyer();
|
||||||
|
|
||||||
|
IndexedTestBean getNestedIndexedBean();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Increment the age by one.
|
||||||
|
* @return the previous age
|
||||||
|
*/
|
||||||
|
int haveBirthday();
|
||||||
|
|
||||||
|
void unreliableFileOperation() throws IOException;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,145 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2002-2006 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;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.SortedMap;
|
||||||
|
import java.util.SortedSet;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Juergen Hoeller
|
||||||
|
* @since 11.11.2003
|
||||||
|
*/
|
||||||
|
public class IndexedTestBean {
|
||||||
|
|
||||||
|
private TestBean[] array;
|
||||||
|
|
||||||
|
private Collection collection;
|
||||||
|
|
||||||
|
private List list;
|
||||||
|
|
||||||
|
private Set set;
|
||||||
|
|
||||||
|
private SortedSet sortedSet;
|
||||||
|
|
||||||
|
private Map map;
|
||||||
|
|
||||||
|
private SortedMap sortedMap;
|
||||||
|
|
||||||
|
|
||||||
|
public IndexedTestBean() {
|
||||||
|
this(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IndexedTestBean(boolean populate) {
|
||||||
|
if (populate) {
|
||||||
|
populate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void populate() {
|
||||||
|
TestBean tb0 = new TestBean("name0", 0);
|
||||||
|
TestBean tb1 = new TestBean("name1", 0);
|
||||||
|
TestBean tb2 = new TestBean("name2", 0);
|
||||||
|
TestBean tb3 = new TestBean("name3", 0);
|
||||||
|
TestBean tb4 = new TestBean("name4", 0);
|
||||||
|
TestBean tb5 = new TestBean("name5", 0);
|
||||||
|
TestBean tb6 = new TestBean("name6", 0);
|
||||||
|
TestBean tb7 = new TestBean("name7", 0);
|
||||||
|
TestBean tbX = new TestBean("nameX", 0);
|
||||||
|
TestBean tbY = new TestBean("nameY", 0);
|
||||||
|
this.array = new TestBean[] {tb0, tb1};
|
||||||
|
this.list = new ArrayList();
|
||||||
|
this.list.add(tb2);
|
||||||
|
this.list.add(tb3);
|
||||||
|
this.set = new TreeSet();
|
||||||
|
this.set.add(tb6);
|
||||||
|
this.set.add(tb7);
|
||||||
|
this.map = new HashMap();
|
||||||
|
this.map.put("key1", tb4);
|
||||||
|
this.map.put("key2", tb5);
|
||||||
|
this.map.put("key.3", tb5);
|
||||||
|
List list = new ArrayList();
|
||||||
|
list.add(tbX);
|
||||||
|
list.add(tbY);
|
||||||
|
this.map.put("key4", list);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public TestBean[] getArray() {
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setArray(TestBean[] array) {
|
||||||
|
this.array = array;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Collection getCollection() {
|
||||||
|
return collection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCollection(Collection collection) {
|
||||||
|
this.collection = collection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List getList() {
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setList(List list) {
|
||||||
|
this.list = list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set getSet() {
|
||||||
|
return set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSet(Set set) {
|
||||||
|
this.set = set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SortedSet getSortedSet() {
|
||||||
|
return sortedSet;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSortedSet(SortedSet sortedSet) {
|
||||||
|
this.sortedSet = sortedSet;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map getMap() {
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMap(Map map) {
|
||||||
|
this.map = map;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SortedMap getSortedMap() {
|
||||||
|
return sortedMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSortedMap(SortedMap sortedMap) {
|
||||||
|
this.sortedMap = sortedMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,60 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2002-2005 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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simple nested test bean used for testing bean factories, AOP framework etc.
|
||||||
|
*
|
||||||
|
* @author Trevor D. Cook
|
||||||
|
* @since 30.09.2003
|
||||||
|
*/
|
||||||
|
public class NestedTestBean implements INestedTestBean {
|
||||||
|
|
||||||
|
private String company = "";
|
||||||
|
|
||||||
|
public NestedTestBean() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public NestedTestBean(String company) {
|
||||||
|
setCompany(company);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCompany(String company) {
|
||||||
|
this.company = (company != null ? company : "");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCompany() {
|
||||||
|
return company;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (!(obj instanceof NestedTestBean)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
NestedTestBean ntb = (NestedTestBean) obj;
|
||||||
|
return this.company.equals(ntb.company);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int hashCode() {
|
||||||
|
return this.company.hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "NestedTestBean: " + this.company;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,437 @@
|
||||||
|
/*
|
||||||
|
* 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 org.springframework.beans;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.BeanFactory;
|
||||||
|
import org.springframework.beans.factory.BeanFactoryAware;
|
||||||
|
import org.springframework.beans.factory.BeanNameAware;
|
||||||
|
import org.springframework.util.ObjectUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simple test bean used for testing bean factories, the AOP framework etc.
|
||||||
|
*
|
||||||
|
* @author Rod Johnson
|
||||||
|
* @author Juergen Hoeller
|
||||||
|
* @since 15 April 2001
|
||||||
|
*/
|
||||||
|
public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOther, Comparable {
|
||||||
|
|
||||||
|
private String beanName;
|
||||||
|
|
||||||
|
private String country;
|
||||||
|
|
||||||
|
private BeanFactory beanFactory;
|
||||||
|
|
||||||
|
private boolean postProcessed;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private String sex;
|
||||||
|
|
||||||
|
private int age;
|
||||||
|
|
||||||
|
private boolean jedi;
|
||||||
|
|
||||||
|
private ITestBean[] spouses;
|
||||||
|
|
||||||
|
private String touchy;
|
||||||
|
|
||||||
|
private String[] stringArray;
|
||||||
|
|
||||||
|
private Integer[] someIntegerArray;
|
||||||
|
|
||||||
|
private Date date = new Date();
|
||||||
|
|
||||||
|
private Float myFloat = new Float(0.0);
|
||||||
|
|
||||||
|
private Collection friends = new LinkedList();
|
||||||
|
|
||||||
|
private Set someSet = new HashSet();
|
||||||
|
|
||||||
|
private Map someMap = new HashMap();
|
||||||
|
|
||||||
|
private List someList = new ArrayList();
|
||||||
|
|
||||||
|
private Properties someProperties = new Properties();
|
||||||
|
|
||||||
|
private INestedTestBean doctor = new NestedTestBean();
|
||||||
|
|
||||||
|
private INestedTestBean lawyer = new NestedTestBean();
|
||||||
|
|
||||||
|
private IndexedTestBean nestedIndexedBean;
|
||||||
|
|
||||||
|
private boolean destroyed;
|
||||||
|
|
||||||
|
private Number someNumber;
|
||||||
|
|
||||||
|
private Colour favouriteColour;
|
||||||
|
|
||||||
|
private Boolean someBoolean;
|
||||||
|
|
||||||
|
private List otherColours;
|
||||||
|
|
||||||
|
private List pets;
|
||||||
|
|
||||||
|
|
||||||
|
public TestBean() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public TestBean(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TestBean(ITestBean spouse) {
|
||||||
|
this.spouses = new ITestBean[] {spouse};
|
||||||
|
}
|
||||||
|
|
||||||
|
public TestBean(String name, int age) {
|
||||||
|
this.name = name;
|
||||||
|
this.age = age;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TestBean(ITestBean spouse, Properties someProperties) {
|
||||||
|
this.spouses = new ITestBean[] {spouse};
|
||||||
|
this.someProperties = someProperties;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TestBean(List someList) {
|
||||||
|
this.someList = someList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TestBean(Set someSet) {
|
||||||
|
this.someSet = someSet;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TestBean(Map someMap) {
|
||||||
|
this.someMap = someMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TestBean(Properties someProperties) {
|
||||||
|
this.someProperties = someProperties;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setBeanName(String beanName) {
|
||||||
|
this.beanName = beanName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBeanName() {
|
||||||
|
return beanName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBeanFactory(BeanFactory beanFactory) {
|
||||||
|
this.beanFactory = beanFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BeanFactory getBeanFactory() {
|
||||||
|
return beanFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPostProcessed(boolean postProcessed) {
|
||||||
|
this.postProcessed = postProcessed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPostProcessed() {
|
||||||
|
return postProcessed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSex() {
|
||||||
|
return sex;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSex(String sex) {
|
||||||
|
this.sex = sex;
|
||||||
|
if (this.name == null) {
|
||||||
|
this.name = sex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAge() {
|
||||||
|
return age;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAge(int age) {
|
||||||
|
this.age = age;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isJedi() {
|
||||||
|
return jedi;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setJedi(boolean jedi) {
|
||||||
|
this.jedi = jedi;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ITestBean getSpouse() {
|
||||||
|
return (spouses != null ? spouses[0] : null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSpouse(ITestBean spouse) {
|
||||||
|
this.spouses = new ITestBean[] {spouse};
|
||||||
|
}
|
||||||
|
|
||||||
|
public ITestBean[] getSpouses() {
|
||||||
|
return spouses;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTouchy() {
|
||||||
|
return touchy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTouchy(String touchy) throws Exception {
|
||||||
|
if (touchy.indexOf('.') != -1) {
|
||||||
|
throw new Exception("Can't contain a .");
|
||||||
|
}
|
||||||
|
if (touchy.indexOf(',') != -1) {
|
||||||
|
throw new NumberFormatException("Number format exception: contains a ,");
|
||||||
|
}
|
||||||
|
this.touchy = touchy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCountry() {
|
||||||
|
return country;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCountry(String country) {
|
||||||
|
this.country = country;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String[] getStringArray() {
|
||||||
|
return stringArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStringArray(String[] stringArray) {
|
||||||
|
this.stringArray = stringArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer[] getSomeIntegerArray() {
|
||||||
|
return someIntegerArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSomeIntegerArray(Integer[] someIntegerArray) {
|
||||||
|
this.someIntegerArray = someIntegerArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getDate() {
|
||||||
|
return date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDate(Date date) {
|
||||||
|
this.date = date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Float getMyFloat() {
|
||||||
|
return myFloat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMyFloat(Float myFloat) {
|
||||||
|
this.myFloat = myFloat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Collection getFriends() {
|
||||||
|
return friends;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFriends(Collection friends) {
|
||||||
|
this.friends = friends;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set getSomeSet() {
|
||||||
|
return someSet;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSomeSet(Set someSet) {
|
||||||
|
this.someSet = someSet;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map getSomeMap() {
|
||||||
|
return someMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSomeMap(Map someMap) {
|
||||||
|
this.someMap = someMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List getSomeList() {
|
||||||
|
return someList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSomeList(List someList) {
|
||||||
|
this.someList = someList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Properties getSomeProperties() {
|
||||||
|
return someProperties;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSomeProperties(Properties someProperties) {
|
||||||
|
this.someProperties = someProperties;
|
||||||
|
}
|
||||||
|
|
||||||
|
public INestedTestBean getDoctor() {
|
||||||
|
return doctor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDoctor(INestedTestBean doctor) {
|
||||||
|
this.doctor = doctor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public INestedTestBean getLawyer() {
|
||||||
|
return lawyer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLawyer(INestedTestBean lawyer) {
|
||||||
|
this.lawyer = lawyer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Number getSomeNumber() {
|
||||||
|
return someNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSomeNumber(Number someNumber) {
|
||||||
|
this.someNumber = someNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Colour getFavouriteColour() {
|
||||||
|
return favouriteColour;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFavouriteColour(Colour favouriteColour) {
|
||||||
|
this.favouriteColour = favouriteColour;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getSomeBoolean() {
|
||||||
|
return someBoolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSomeBoolean(Boolean someBoolean) {
|
||||||
|
this.someBoolean = someBoolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IndexedTestBean getNestedIndexedBean() {
|
||||||
|
return nestedIndexedBean;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNestedIndexedBean(IndexedTestBean nestedIndexedBean) {
|
||||||
|
this.nestedIndexedBean = nestedIndexedBean;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List getOtherColours() {
|
||||||
|
return otherColours;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOtherColours(List otherColours) {
|
||||||
|
this.otherColours = otherColours;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List getPets() {
|
||||||
|
return pets;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPets(List pets) {
|
||||||
|
this.pets = pets;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ITestBean#exceptional(Throwable)
|
||||||
|
*/
|
||||||
|
public void exceptional(Throwable t) throws Throwable {
|
||||||
|
if (t != null) {
|
||||||
|
throw t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void unreliableFileOperation() throws IOException {
|
||||||
|
throw new IOException();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @see ITestBean#returnsThis()
|
||||||
|
*/
|
||||||
|
public Object returnsThis() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see IOther#absquatulate()
|
||||||
|
*/
|
||||||
|
public void absquatulate() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public int haveBirthday() {
|
||||||
|
return age++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void destroy() {
|
||||||
|
this.destroyed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean wasDestroyed() {
|
||||||
|
return destroyed;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean equals(Object other) {
|
||||||
|
if (this == other) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (other == null || !(other instanceof TestBean)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
TestBean tb2 = (TestBean) other;
|
||||||
|
return (ObjectUtils.nullSafeEquals(this.name, tb2.name) && this.age == tb2.age);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int hashCode() {
|
||||||
|
return this.age;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int compareTo(Object other) {
|
||||||
|
if (this.name != null && other instanceof TestBean) {
|
||||||
|
return this.name.compareTo(((TestBean) other).getName());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -16,34 +16,27 @@
|
||||||
|
|
||||||
package org.springframework.jms.listener;
|
package org.springframework.jms.listener;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import org.junit.Test;
|
||||||
|
|
||||||
import org.springframework.test.AssertThrows;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unit tests for the {@link AbstractMessageListenerContainer} class.
|
* Unit tests for the {@link AbstractMessageListenerContainer} class.
|
||||||
*
|
*
|
||||||
* @author Rick Evans
|
* @author Rick Evans
|
||||||
|
* @author Chris Beams
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractMessageListenerContainerTests extends TestCase {
|
public abstract class AbstractMessageListenerContainerTests {
|
||||||
|
|
||||||
protected abstract AbstractMessageListenerContainer getContainer();
|
protected abstract AbstractMessageListenerContainer getContainer();
|
||||||
|
|
||||||
|
|
||||||
|
@Test(expected=IllegalArgumentException.class)
|
||||||
public void testSettingMessageListenerToANullType() throws Exception {
|
public void testSettingMessageListenerToANullType() throws Exception {
|
||||||
new AssertThrows(IllegalArgumentException.class) {
|
getContainer().setMessageListener(null);
|
||||||
public void test() throws Exception {
|
|
||||||
getContainer().setMessageListener(null);
|
|
||||||
}
|
|
||||||
}.runTest();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(expected=IllegalArgumentException.class)
|
||||||
public void testSettingMessageListenerToAnUnsupportedType() throws Exception {
|
public void testSettingMessageListenerToAnUnsupportedType() throws Exception {
|
||||||
new AssertThrows(IllegalArgumentException.class) {
|
getContainer().setMessageListener("Bingo");
|
||||||
public void test() throws Exception {
|
|
||||||
getContainer().setMessageListener("Bingo");
|
|
||||||
}
|
|
||||||
}.runTest();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
package org.springframework.jms.listener;
|
package org.springframework.jms.listener;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
import javax.jms.Connection;
|
import javax.jms.Connection;
|
||||||
|
|
@ -29,14 +31,15 @@ import javax.jms.Session;
|
||||||
|
|
||||||
import org.easymock.MockControl;
|
import org.easymock.MockControl;
|
||||||
import org.easymock.internal.AlwaysMatcher;
|
import org.easymock.internal.AlwaysMatcher;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
import org.springframework.core.task.TaskExecutor;
|
import org.springframework.core.task.TaskExecutor;
|
||||||
import org.springframework.jms.StubQueue;
|
import org.springframework.jms.StubQueue;
|
||||||
import org.springframework.test.AssertThrows;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Rick Evans
|
* @author Rick Evans
|
||||||
* @author Juergen Hoeller
|
* @author Juergen Hoeller
|
||||||
|
* @author Chris Beams
|
||||||
*/
|
*/
|
||||||
public class SimpleMessageListenerContainerTests extends AbstractMessageListenerContainerTests {
|
public class SimpleMessageListenerContainerTests extends AbstractMessageListenerContainerTests {
|
||||||
|
|
||||||
|
|
@ -50,7 +53,8 @@ public class SimpleMessageListenerContainerTests extends AbstractMessageListener
|
||||||
private SimpleMessageListenerContainer container;
|
private SimpleMessageListenerContainer container;
|
||||||
|
|
||||||
|
|
||||||
protected void setUp() throws Exception {
|
@Before
|
||||||
|
public void setUp() throws Exception {
|
||||||
this.container = (SimpleMessageListenerContainer) getContainer();
|
this.container = (SimpleMessageListenerContainer) getContainer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -59,6 +63,7 @@ public class SimpleMessageListenerContainerTests extends AbstractMessageListener
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testSessionTransactedModeReallyDoesDefaultToFalse() throws Exception {
|
public void testSessionTransactedModeReallyDoesDefaultToFalse() throws Exception {
|
||||||
assertFalse("The [pubSubLocal] property of SimpleMessageListenerContainer " +
|
assertFalse("The [pubSubLocal] property of SimpleMessageListenerContainer " +
|
||||||
"must default to false. Change this test (and the " +
|
"must default to false. Change this test (and the " +
|
||||||
|
|
@ -66,24 +71,19 @@ public class SimpleMessageListenerContainerTests extends AbstractMessageListener
|
||||||
container.isPubSubNoLocal());
|
container.isPubSubNoLocal());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(expected=IllegalArgumentException.class)
|
||||||
public void testSettingConcurrentConsumersToZeroIsNotAllowed() throws Exception {
|
public void testSettingConcurrentConsumersToZeroIsNotAllowed() throws Exception {
|
||||||
new AssertThrows(IllegalArgumentException.class) {
|
container.setConcurrentConsumers(0);
|
||||||
public void test() throws Exception {
|
container.afterPropertiesSet();
|
||||||
container.setConcurrentConsumers(0);
|
|
||||||
container.afterPropertiesSet();
|
|
||||||
}
|
|
||||||
}.runTest();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(expected=IllegalArgumentException.class)
|
||||||
public void testSettingConcurrentConsumersToANegativeValueIsNotAllowed() throws Exception {
|
public void testSettingConcurrentConsumersToANegativeValueIsNotAllowed() throws Exception {
|
||||||
new AssertThrows(IllegalArgumentException.class) {
|
container.setConcurrentConsumers(-198);
|
||||||
public void test() throws Exception {
|
container.afterPropertiesSet();
|
||||||
container.setConcurrentConsumers(-198);
|
|
||||||
container.afterPropertiesSet();
|
|
||||||
}
|
|
||||||
}.runTest();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testInitDoesNotStartTheConnectionIfAutoStartIsSetToFalse() throws Exception {
|
public void testInitDoesNotStartTheConnectionIfAutoStartIsSetToFalse() throws Exception {
|
||||||
MockControl mockMessageConsumer = MockControl.createControl(MessageConsumer.class);
|
MockControl mockMessageConsumer = MockControl.createControl(MessageConsumer.class);
|
||||||
MessageConsumer messageConsumer = (MessageConsumer) mockMessageConsumer.getMock();
|
MessageConsumer messageConsumer = (MessageConsumer) mockMessageConsumer.getMock();
|
||||||
|
|
@ -131,6 +131,7 @@ public class SimpleMessageListenerContainerTests extends AbstractMessageListener
|
||||||
mockConnectionFactory.verify();
|
mockConnectionFactory.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testInitStartsTheConnectionByDefault() throws Exception {
|
public void testInitStartsTheConnectionByDefault() throws Exception {
|
||||||
MockControl mockMessageConsumer = MockControl.createControl(MessageConsumer.class);
|
MockControl mockMessageConsumer = MockControl.createControl(MessageConsumer.class);
|
||||||
MessageConsumer messageConsumer = (MessageConsumer) mockMessageConsumer.getMock();
|
MessageConsumer messageConsumer = (MessageConsumer) mockMessageConsumer.getMock();
|
||||||
|
|
@ -180,6 +181,7 @@ public class SimpleMessageListenerContainerTests extends AbstractMessageListener
|
||||||
mockConnectionFactory.verify();
|
mockConnectionFactory.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testCorrectSessionExposedForSessionAwareMessageListenerInvocation() throws Exception {
|
public void testCorrectSessionExposedForSessionAwareMessageListenerInvocation() throws Exception {
|
||||||
final SimpleMessageConsumer messageConsumer = new SimpleMessageConsumer();
|
final SimpleMessageConsumer messageConsumer = new SimpleMessageConsumer();
|
||||||
|
|
||||||
|
|
@ -249,6 +251,7 @@ public class SimpleMessageListenerContainerTests extends AbstractMessageListener
|
||||||
mockConnectionFactory.verify();
|
mockConnectionFactory.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testTaskExecutorCorrectlyInvokedWhenSpecified() throws Exception {
|
public void testTaskExecutorCorrectlyInvokedWhenSpecified() throws Exception {
|
||||||
final SimpleMessageConsumer messageConsumer = new SimpleMessageConsumer();
|
final SimpleMessageConsumer messageConsumer = new SimpleMessageConsumer();
|
||||||
|
|
||||||
|
|
@ -308,6 +311,7 @@ public class SimpleMessageListenerContainerTests extends AbstractMessageListener
|
||||||
mockConnectionFactory.verify();
|
mockConnectionFactory.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testRegisteredExceptionListenerIsInvokedOnException() throws Exception {
|
public void testRegisteredExceptionListenerIsInvokedOnException() throws Exception {
|
||||||
final SimpleMessageConsumer messageConsumer = new SimpleMessageConsumer();
|
final SimpleMessageConsumer messageConsumer = new SimpleMessageConsumer();
|
||||||
|
|
||||||
|
|
@ -376,6 +380,7 @@ public class SimpleMessageListenerContainerTests extends AbstractMessageListener
|
||||||
mockConnectionFactory.verify();
|
mockConnectionFactory.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testNoRollbackOccursIfSessionIsNotTransactedAndThatExceptionsDo_NOT_Propagate() throws Exception {
|
public void testNoRollbackOccursIfSessionIsNotTransactedAndThatExceptionsDo_NOT_Propagate() throws Exception {
|
||||||
final SimpleMessageConsumer messageConsumer = new SimpleMessageConsumer();
|
final SimpleMessageConsumer messageConsumer = new SimpleMessageConsumer();
|
||||||
|
|
||||||
|
|
@ -433,6 +438,7 @@ public class SimpleMessageListenerContainerTests extends AbstractMessageListener
|
||||||
mockConnectionFactory.verify();
|
mockConnectionFactory.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testTransactedSessionsGetRollbackLogicAppliedAndThatExceptionsStillDo_NOT_Propagate() throws Exception {
|
public void testTransactedSessionsGetRollbackLogicAppliedAndThatExceptionsStillDo_NOT_Propagate() throws Exception {
|
||||||
this.container.setSessionTransacted(true);
|
this.container.setSessionTransacted(true);
|
||||||
|
|
||||||
|
|
@ -495,6 +501,7 @@ public class SimpleMessageListenerContainerTests extends AbstractMessageListener
|
||||||
mockConnectionFactory.verify();
|
mockConnectionFactory.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testDestroyClosesConsumersSessionsAndConnectionInThatOrder() throws Exception {
|
public void testDestroyClosesConsumersSessionsAndConnectionInThatOrder() throws Exception {
|
||||||
MockControl mockMessageConsumer = MockControl.createControl(MessageConsumer.class);
|
MockControl mockMessageConsumer = MockControl.createControl(MessageConsumer.class);
|
||||||
MessageConsumer messageConsumer = (MessageConsumer) mockMessageConsumer.getMock();
|
MessageConsumer messageConsumer = (MessageConsumer) mockMessageConsumer.getMock();
|
||||||
|
|
@ -16,25 +16,38 @@
|
||||||
|
|
||||||
package org.springframework.jms.listener.adapter;
|
package org.springframework.jms.listener.adapter;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import static org.junit.Assert.*;
|
||||||
import org.easymock.MockControl;
|
|
||||||
import org.springframework.jms.support.converter.SimpleMessageConverter102;
|
|
||||||
import org.springframework.test.AssertThrows;
|
|
||||||
|
|
||||||
import javax.jms.*;
|
import javax.jms.BytesMessage;
|
||||||
|
import javax.jms.InvalidDestinationException;
|
||||||
|
import javax.jms.JMSException;
|
||||||
|
import javax.jms.Message;
|
||||||
|
import javax.jms.Queue;
|
||||||
|
import javax.jms.QueueSender;
|
||||||
|
import javax.jms.QueueSession;
|
||||||
|
import javax.jms.TextMessage;
|
||||||
|
import javax.jms.Topic;
|
||||||
|
import javax.jms.TopicPublisher;
|
||||||
|
import javax.jms.TopicSession;
|
||||||
|
|
||||||
|
import org.easymock.MockControl;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.springframework.jms.support.converter.SimpleMessageConverter102;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unit tests for the {@link MessageListenerAdapter102} class.
|
* Unit tests for the {@link MessageListenerAdapter102} class.
|
||||||
*
|
*
|
||||||
* @author Rick Evans
|
* @author Rick Evans
|
||||||
|
* @author Chris Beams
|
||||||
*/
|
*/
|
||||||
public final class MessageListenerAdapter102Tests extends TestCase {
|
public final class MessageListenerAdapter102Tests {
|
||||||
|
|
||||||
private static final String TEXT = "The Runaways";
|
private static final String TEXT = "The Runaways";
|
||||||
private static final String CORRELATION_ID = "100";
|
private static final String CORRELATION_ID = "100";
|
||||||
private static final String RESPONSE_TEXT = "Old Lace";
|
private static final String RESPONSE_TEXT = "Old Lace";
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testWithMessageContentsDelegateForBytesMessage() throws Exception {
|
public void testWithMessageContentsDelegateForBytesMessage() throws Exception {
|
||||||
|
|
||||||
MockControl mockBytesMessage = MockControl.createControl(BytesMessage.class);
|
MockControl mockBytesMessage = MockControl.createControl(BytesMessage.class);
|
||||||
|
|
@ -59,6 +72,7 @@ public final class MessageListenerAdapter102Tests extends TestCase {
|
||||||
mockBytesMessage.verify();
|
mockBytesMessage.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testWithMessageDelegate() throws Exception {
|
public void testWithMessageDelegate() throws Exception {
|
||||||
|
|
||||||
MockControl mockTextMessage = MockControl.createControl(TextMessage.class);
|
MockControl mockTextMessage = MockControl.createControl(TextMessage.class);
|
||||||
|
|
@ -80,12 +94,14 @@ public final class MessageListenerAdapter102Tests extends TestCase {
|
||||||
mockTextMessage.verify();
|
mockTextMessage.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testThatTheDefaultMessageConverterisIndeedTheSimpleMessageConverter102() throws Exception {
|
public void testThatTheDefaultMessageConverterisIndeedTheSimpleMessageConverter102() throws Exception {
|
||||||
MessageListenerAdapter102 adapter = new MessageListenerAdapter102();
|
MessageListenerAdapter102 adapter = new MessageListenerAdapter102();
|
||||||
assertNotNull("The default [MessageConverter] must never be null.", adapter.getMessageConverter());
|
assertNotNull("The default [MessageConverter] must never be null.", adapter.getMessageConverter());
|
||||||
assertTrue("The default [MessageConverter] must be of the type [SimpleMessageConverter102]; if you've just changed it, then change this test to reflect your change.", adapter.getMessageConverter() instanceof SimpleMessageConverter102);
|
assertTrue("The default [MessageConverter] must be of the type [SimpleMessageConverter102]; if you've just changed it, then change this test to reflect your change.", adapter.getMessageConverter() instanceof SimpleMessageConverter102);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testWithResponsiveMessageDelegate_DoesNotSendReturnTextMessageIfNoSessionSupplied() throws Exception {
|
public void testWithResponsiveMessageDelegate_DoesNotSendReturnTextMessageIfNoSessionSupplied() throws Exception {
|
||||||
|
|
||||||
MockControl mockTextMessage = MockControl.createControl(TextMessage.class);
|
MockControl mockTextMessage = MockControl.createControl(TextMessage.class);
|
||||||
|
|
@ -107,6 +123,7 @@ public final class MessageListenerAdapter102Tests extends TestCase {
|
||||||
mockTextMessage.verify();
|
mockTextMessage.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testWithResponsiveMessageDelegateWithDefaultDestination_SendsReturnTextMessageWhenSessionSuppliedForQueue() throws Exception {
|
public void testWithResponsiveMessageDelegateWithDefaultDestination_SendsReturnTextMessageWhenSessionSuppliedForQueue() throws Exception {
|
||||||
|
|
||||||
MockControl mockDestination = MockControl.createControl(Queue.class);
|
MockControl mockDestination = MockControl.createControl(Queue.class);
|
||||||
|
|
@ -167,6 +184,7 @@ public final class MessageListenerAdapter102Tests extends TestCase {
|
||||||
mockQueueSender.verify();
|
mockQueueSender.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testWithResponsiveMessageDelegateWithDefaultDestination_SendsReturnTextMessageWhenSessionSuppliedForTopic() throws Exception {
|
public void testWithResponsiveMessageDelegateWithDefaultDestination_SendsReturnTextMessageWhenSessionSuppliedForTopic() throws Exception {
|
||||||
|
|
||||||
MockControl mockDestination = MockControl.createControl(Topic.class);
|
MockControl mockDestination = MockControl.createControl(Topic.class);
|
||||||
|
|
@ -227,6 +245,7 @@ public final class MessageListenerAdapter102Tests extends TestCase {
|
||||||
mockTopicPublisher.verify();
|
mockTopicPublisher.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testWithResponsiveMessageDelegateNoDefaultDestination_SendsReturnTextMessageWhenSessionSupplied() throws Exception {
|
public void testWithResponsiveMessageDelegateNoDefaultDestination_SendsReturnTextMessageWhenSessionSupplied() throws Exception {
|
||||||
|
|
||||||
MockControl mockDestination = MockControl.createControl(Queue.class);
|
MockControl mockDestination = MockControl.createControl(Queue.class);
|
||||||
|
|
@ -286,6 +305,7 @@ public final class MessageListenerAdapter102Tests extends TestCase {
|
||||||
mockQueueSender.verify();
|
mockQueueSender.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testWithResponsiveMessageDelegateNoDefaultDestinationAndNoReplyToDestination_SendsReturnTextMessageWhenSessionSupplied() throws Exception {
|
public void testWithResponsiveMessageDelegateNoDefaultDestinationAndNoReplyToDestination_SendsReturnTextMessageWhenSessionSupplied() throws Exception {
|
||||||
|
|
||||||
MockControl mockSentTextMessage = MockControl.createControl(TextMessage.class);
|
MockControl mockSentTextMessage = MockControl.createControl(TextMessage.class);
|
||||||
|
|
@ -321,11 +341,10 @@ public final class MessageListenerAdapter102Tests extends TestCase {
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
new AssertThrows(InvalidDestinationException.class) {
|
try {
|
||||||
public void test() throws Exception {
|
adapter.onMessage(sentTextMessage, session);
|
||||||
adapter.onMessage(sentTextMessage, session);
|
fail("expected InvalidDestinationException");
|
||||||
}
|
} catch (InvalidDestinationException ex) { /* expected */ }
|
||||||
}.runTest();
|
|
||||||
|
|
||||||
mockDelegate.verify();
|
mockDelegate.verify();
|
||||||
mockSentTextMessage.verify();
|
mockSentTextMessage.verify();
|
||||||
|
|
@ -333,6 +352,7 @@ public final class MessageListenerAdapter102Tests extends TestCase {
|
||||||
mockSession.verify();
|
mockSession.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testWithResponsiveMessageDelegateNoDefaultDestination_SendsReturnTextMessageWhenSessionSupplied_AndSendingThrowsJMSException() throws Exception {
|
public void testWithResponsiveMessageDelegateNoDefaultDestination_SendsReturnTextMessageWhenSessionSupplied_AndSendingThrowsJMSException() throws Exception {
|
||||||
|
|
||||||
MockControl mockDestination = MockControl.createControl(Queue.class);
|
MockControl mockDestination = MockControl.createControl(Queue.class);
|
||||||
|
|
@ -383,11 +403,10 @@ public final class MessageListenerAdapter102Tests extends TestCase {
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
new AssertThrows(JMSException.class) {
|
try {
|
||||||
public void test() throws Exception {
|
adapter.onMessage(sentTextMessage, session);
|
||||||
adapter.onMessage(sentTextMessage, session);
|
fail("expected JMSException");
|
||||||
}
|
} catch (JMSException ex) { /* expected */ }
|
||||||
}.runTest();
|
|
||||||
|
|
||||||
mockDelegate.verify();
|
mockDelegate.verify();
|
||||||
mockSentTextMessage.verify();
|
mockSentTextMessage.verify();
|
||||||
|
|
@ -397,6 +416,7 @@ public final class MessageListenerAdapter102Tests extends TestCase {
|
||||||
mockQueueSender.verify();
|
mockQueueSender.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testWithResponsiveMessageDelegateDoesNotSendReturnTextMessageWhenSessionSupplied_AndListenerMethodThrowsException() throws Exception {
|
public void testWithResponsiveMessageDelegateDoesNotSendReturnTextMessageWhenSessionSupplied_AndListenerMethodThrowsException() throws Exception {
|
||||||
|
|
||||||
MockControl mockSentTextMessage = MockControl.createControl(TextMessage.class);
|
MockControl mockSentTextMessage = MockControl.createControl(TextMessage.class);
|
||||||
|
|
@ -418,11 +438,10 @@ public final class MessageListenerAdapter102Tests extends TestCase {
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
new AssertThrows(ListenerExecutionFailedException.class) {
|
try {
|
||||||
public void test() throws Exception {
|
adapter.onMessage(sentTextMessage, session);
|
||||||
adapter.onMessage(sentTextMessage, session);
|
fail("expected ListenerExecutionFailedException");
|
||||||
}
|
} catch (ListenerExecutionFailedException ex) { /* expected */ }
|
||||||
}.runTest();
|
|
||||||
|
|
||||||
mockDelegate.verify();
|
mockDelegate.verify();
|
||||||
mockSentTextMessage.verify();
|
mockSentTextMessage.verify();
|
||||||
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
package org.springframework.jms.listener.adapter;
|
package org.springframework.jms.listener.adapter;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
import javax.jms.BytesMessage;
|
import javax.jms.BytesMessage;
|
||||||
|
|
@ -33,16 +35,17 @@ import javax.jms.TextMessage;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
import org.easymock.MockControl;
|
import org.easymock.MockControl;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
import org.springframework.jms.support.converter.MessageConversionException;
|
import org.springframework.jms.support.converter.MessageConversionException;
|
||||||
import org.springframework.jms.support.converter.SimpleMessageConverter;
|
import org.springframework.jms.support.converter.SimpleMessageConverter;
|
||||||
import org.springframework.test.AssertThrows;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Rick Evans
|
* @author Rick Evans
|
||||||
* @author Juergen Hoeller
|
* @author Juergen Hoeller
|
||||||
|
* @author Chris Beams
|
||||||
*/
|
*/
|
||||||
public class MessageListenerAdapterTests extends TestCase {
|
public class MessageListenerAdapterTests {
|
||||||
|
|
||||||
private static final String TEXT = "I fancy a good cuppa right now";
|
private static final String TEXT = "I fancy a good cuppa right now";
|
||||||
|
|
||||||
|
|
@ -55,6 +58,7 @@ public class MessageListenerAdapterTests extends TestCase {
|
||||||
private static final String RESPONSE_TEXT = "... wi' some full fat creamy milk. Top banana.";
|
private static final String RESPONSE_TEXT = "... wi' some full fat creamy milk. Top banana.";
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testWithMessageContentsDelegateForTextMessage() throws Exception {
|
public void testWithMessageContentsDelegateForTextMessage() throws Exception {
|
||||||
MockControl mockTextMessage = MockControl.createControl(TextMessage.class);
|
MockControl mockTextMessage = MockControl.createControl(TextMessage.class);
|
||||||
TextMessage textMessage = (TextMessage) mockTextMessage.getMock();
|
TextMessage textMessage = (TextMessage) mockTextMessage.getMock();
|
||||||
|
|
@ -76,6 +80,7 @@ public class MessageListenerAdapterTests extends TestCase {
|
||||||
mockTextMessage.verify();
|
mockTextMessage.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testWithMessageContentsDelegateForBytesMessage() throws Exception {
|
public void testWithMessageContentsDelegateForBytesMessage() throws Exception {
|
||||||
MockControl mockBytesMessage = MockControl.createControl(BytesMessage.class);
|
MockControl mockBytesMessage = MockControl.createControl(BytesMessage.class);
|
||||||
BytesMessage bytesMessage = (BytesMessage) mockBytesMessage.getMock();
|
BytesMessage bytesMessage = (BytesMessage) mockBytesMessage.getMock();
|
||||||
|
|
@ -101,6 +106,7 @@ public class MessageListenerAdapterTests extends TestCase {
|
||||||
mockBytesMessage.verify();
|
mockBytesMessage.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testWithMessageContentsDelegateForObjectMessage() throws Exception {
|
public void testWithMessageContentsDelegateForObjectMessage() throws Exception {
|
||||||
MockControl mockObjectMessage = MockControl.createControl(ObjectMessage.class);
|
MockControl mockObjectMessage = MockControl.createControl(ObjectMessage.class);
|
||||||
ObjectMessage objectMessage = (ObjectMessage) mockObjectMessage.getMock();
|
ObjectMessage objectMessage = (ObjectMessage) mockObjectMessage.getMock();
|
||||||
|
|
@ -121,6 +127,7 @@ public class MessageListenerAdapterTests extends TestCase {
|
||||||
mockObjectMessage.verify();
|
mockObjectMessage.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testWithMessageContentsDelegateForObjectMessageWithPlainObject() throws Exception {
|
public void testWithMessageContentsDelegateForObjectMessageWithPlainObject() throws Exception {
|
||||||
MockControl mockObjectMessage = MockControl.createControl(ObjectMessage.class);
|
MockControl mockObjectMessage = MockControl.createControl(ObjectMessage.class);
|
||||||
ObjectMessage objectMessage = (ObjectMessage) mockObjectMessage.getMock();
|
ObjectMessage objectMessage = (ObjectMessage) mockObjectMessage.getMock();
|
||||||
|
|
@ -141,6 +148,7 @@ public class MessageListenerAdapterTests extends TestCase {
|
||||||
mockObjectMessage.verify();
|
mockObjectMessage.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testWithMessageDelegate() throws Exception {
|
public void testWithMessageDelegate() throws Exception {
|
||||||
MockControl mockTextMessage = MockControl.createControl(TextMessage.class);
|
MockControl mockTextMessage = MockControl.createControl(TextMessage.class);
|
||||||
TextMessage textMessage = (TextMessage) mockTextMessage.getMock();
|
TextMessage textMessage = (TextMessage) mockTextMessage.getMock();
|
||||||
|
|
@ -161,6 +169,7 @@ public class MessageListenerAdapterTests extends TestCase {
|
||||||
mockTextMessage.verify();
|
mockTextMessage.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testWhenTheAdapterItselfIsTheDelegate() throws Exception {
|
public void testWhenTheAdapterItselfIsTheDelegate() throws Exception {
|
||||||
MockControl mockTextMessage = MockControl.createControl(TextMessage.class);
|
MockControl mockTextMessage = MockControl.createControl(TextMessage.class);
|
||||||
TextMessage textMessage = (TextMessage) mockTextMessage.getMock();
|
TextMessage textMessage = (TextMessage) mockTextMessage.getMock();
|
||||||
|
|
@ -176,6 +185,7 @@ public class MessageListenerAdapterTests extends TestCase {
|
||||||
mockTextMessage.verify();
|
mockTextMessage.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testRainyDayWithNoApplicableHandlingMethods() throws Exception {
|
public void testRainyDayWithNoApplicableHandlingMethods() throws Exception {
|
||||||
MockControl mockTextMessage = MockControl.createControl(TextMessage.class);
|
MockControl mockTextMessage = MockControl.createControl(TextMessage.class);
|
||||||
TextMessage textMessage = (TextMessage) mockTextMessage.getMock();
|
TextMessage textMessage = (TextMessage) mockTextMessage.getMock();
|
||||||
|
|
@ -192,6 +202,7 @@ public class MessageListenerAdapterTests extends TestCase {
|
||||||
mockTextMessage.verify();
|
mockTextMessage.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testThatAnExceptionThrownFromTheHandlingMethodIsSimplySwallowedByDefault() throws Exception {
|
public void testThatAnExceptionThrownFromTheHandlingMethodIsSimplySwallowedByDefault() throws Exception {
|
||||||
final IllegalArgumentException exception = new IllegalArgumentException();
|
final IllegalArgumentException exception = new IllegalArgumentException();
|
||||||
|
|
||||||
|
|
@ -224,6 +235,7 @@ public class MessageListenerAdapterTests extends TestCase {
|
||||||
mockTextMessage.verify();
|
mockTextMessage.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testThatTheDefaultMessageConverterisIndeedTheSimpleMessageConverter() throws Exception {
|
public void testThatTheDefaultMessageConverterisIndeedTheSimpleMessageConverter() throws Exception {
|
||||||
MessageListenerAdapter adapter = new MessageListenerAdapter();
|
MessageListenerAdapter adapter = new MessageListenerAdapter();
|
||||||
assertNotNull("The default [MessageConverter] must never be null.", adapter.getMessageConverter());
|
assertNotNull("The default [MessageConverter] must never be null.", adapter.getMessageConverter());
|
||||||
|
|
@ -231,16 +243,19 @@ public class MessageListenerAdapterTests extends TestCase {
|
||||||
adapter.getMessageConverter() instanceof SimpleMessageConverter);
|
adapter.getMessageConverter() instanceof SimpleMessageConverter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testThatWhenNoDelegateIsSuppliedTheDelegateIsAssumedToBeTheMessageListenerAdapterItself() throws Exception {
|
public void testThatWhenNoDelegateIsSuppliedTheDelegateIsAssumedToBeTheMessageListenerAdapterItself() throws Exception {
|
||||||
MessageListenerAdapter adapter = new MessageListenerAdapter();
|
MessageListenerAdapter adapter = new MessageListenerAdapter();
|
||||||
assertSame(adapter, adapter.getDelegate());
|
assertSame(adapter, adapter.getDelegate());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testThatTheDefaultMessageHandlingMethodNameIsTheConstantDefault() throws Exception {
|
public void testThatTheDefaultMessageHandlingMethodNameIsTheConstantDefault() throws Exception {
|
||||||
MessageListenerAdapter adapter = new MessageListenerAdapter();
|
MessageListenerAdapter adapter = new MessageListenerAdapter();
|
||||||
assertEquals(MessageListenerAdapter.ORIGINAL_DEFAULT_LISTENER_METHOD, adapter.getDefaultListenerMethod());
|
assertEquals(MessageListenerAdapter.ORIGINAL_DEFAULT_LISTENER_METHOD, adapter.getDefaultListenerMethod());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testWithResponsiveMessageDelegate_DoesNotSendReturnTextMessageIfNoSessionSupplied() throws Exception {
|
public void testWithResponsiveMessageDelegate_DoesNotSendReturnTextMessageIfNoSessionSupplied() throws Exception {
|
||||||
MockControl mockTextMessage = MockControl.createControl(TextMessage.class);
|
MockControl mockTextMessage = MockControl.createControl(TextMessage.class);
|
||||||
TextMessage textMessage = (TextMessage) mockTextMessage.getMock();
|
TextMessage textMessage = (TextMessage) mockTextMessage.getMock();
|
||||||
|
|
@ -261,6 +276,7 @@ public class MessageListenerAdapterTests extends TestCase {
|
||||||
mockTextMessage.verify();
|
mockTextMessage.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testWithResponsiveMessageDelegateWithDefaultDestination_SendsReturnTextMessageWhenSessionSupplied() throws Exception {
|
public void testWithResponsiveMessageDelegateWithDefaultDestination_SendsReturnTextMessageWhenSessionSupplied() throws Exception {
|
||||||
MockControl mockDestination = MockControl.createControl(Queue.class);
|
MockControl mockDestination = MockControl.createControl(Queue.class);
|
||||||
Queue destination = (Queue) mockDestination.getMock();
|
Queue destination = (Queue) mockDestination.getMock();
|
||||||
|
|
@ -320,6 +336,7 @@ public class MessageListenerAdapterTests extends TestCase {
|
||||||
mockQueueSender.verify();
|
mockQueueSender.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testWithResponsiveMessageDelegateNoDefaultDestination_SendsReturnTextMessageWhenSessionSupplied() throws Exception {
|
public void testWithResponsiveMessageDelegateNoDefaultDestination_SendsReturnTextMessageWhenSessionSupplied() throws Exception {
|
||||||
MockControl mockDestination = MockControl.createControl(Queue.class);
|
MockControl mockDestination = MockControl.createControl(Queue.class);
|
||||||
Queue destination = (Queue) mockDestination.getMock();
|
Queue destination = (Queue) mockDestination.getMock();
|
||||||
|
|
@ -380,6 +397,7 @@ public class MessageListenerAdapterTests extends TestCase {
|
||||||
mockMessageProducer.verify();
|
mockMessageProducer.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testWithResponsiveMessageDelegateNoDefaultDestinationAndNoReplyToDestination_SendsReturnTextMessageWhenSessionSupplied() throws Exception {
|
public void testWithResponsiveMessageDelegateNoDefaultDestinationAndNoReplyToDestination_SendsReturnTextMessageWhenSessionSupplied() throws Exception {
|
||||||
MockControl mockSentTextMessage = MockControl.createControl(TextMessage.class);
|
MockControl mockSentTextMessage = MockControl.createControl(TextMessage.class);
|
||||||
final TextMessage sentTextMessage = (TextMessage) mockSentTextMessage.getMock();
|
final TextMessage sentTextMessage = (TextMessage) mockSentTextMessage.getMock();
|
||||||
|
|
@ -414,11 +432,10 @@ public class MessageListenerAdapterTests extends TestCase {
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
new AssertThrows(InvalidDestinationException.class) {
|
try {
|
||||||
public void test() throws Exception {
|
adapter.onMessage(sentTextMessage, session);
|
||||||
adapter.onMessage(sentTextMessage, session);
|
fail("expected InvalidDestinationException");
|
||||||
}
|
} catch(InvalidDestinationException ex) { /* expected */ }
|
||||||
}.runTest();
|
|
||||||
|
|
||||||
mockDelegate.verify();
|
mockDelegate.verify();
|
||||||
mockSentTextMessage.verify();
|
mockSentTextMessage.verify();
|
||||||
|
|
@ -426,6 +443,7 @@ public class MessageListenerAdapterTests extends TestCase {
|
||||||
mockSession.verify();
|
mockSession.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testWithResponsiveMessageDelegateNoDefaultDestination_SendsReturnTextMessageWhenSessionSupplied_AndSendingThrowsJMSException() throws Exception {
|
public void testWithResponsiveMessageDelegateNoDefaultDestination_SendsReturnTextMessageWhenSessionSupplied_AndSendingThrowsJMSException() throws Exception {
|
||||||
MockControl mockDestination = MockControl.createControl(Queue.class);
|
MockControl mockDestination = MockControl.createControl(Queue.class);
|
||||||
Queue destination = (Queue) mockDestination.getMock();
|
Queue destination = (Queue) mockDestination.getMock();
|
||||||
|
|
@ -475,11 +493,10 @@ public class MessageListenerAdapterTests extends TestCase {
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
new AssertThrows(JMSException.class) {
|
try {
|
||||||
public void test() throws Exception {
|
adapter.onMessage(sentTextMessage, session);
|
||||||
adapter.onMessage(sentTextMessage, session);
|
fail("expected JMSException");
|
||||||
}
|
} catch(JMSException ex) { /* expected */ }
|
||||||
}.runTest();
|
|
||||||
|
|
||||||
mockDelegate.verify();
|
mockDelegate.verify();
|
||||||
mockSentTextMessage.verify();
|
mockSentTextMessage.verify();
|
||||||
|
|
@ -489,6 +506,7 @@ public class MessageListenerAdapterTests extends TestCase {
|
||||||
mockMessageProducer.verify();
|
mockMessageProducer.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testWithResponsiveMessageDelegateDoesNotSendReturnTextMessageWhenSessionSupplied_AndListenerMethodThrowsException() throws Exception {
|
public void testWithResponsiveMessageDelegateDoesNotSendReturnTextMessageWhenSessionSupplied_AndListenerMethodThrowsException() throws Exception {
|
||||||
MockControl mockMessage = MockControl.createControl(TextMessage.class);
|
MockControl mockMessage = MockControl.createControl(TextMessage.class);
|
||||||
final TextMessage message = (TextMessage) mockMessage.getMock();
|
final TextMessage message = (TextMessage) mockMessage.getMock();
|
||||||
|
|
@ -509,17 +527,17 @@ public class MessageListenerAdapterTests extends TestCase {
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
new AssertThrows(ListenerExecutionFailedException.class) {
|
try {
|
||||||
public void test() throws Exception {
|
adapter.onMessage(message, session);
|
||||||
adapter.onMessage(message, session);
|
fail("expected ListenerExecutionFailedException");
|
||||||
}
|
} catch(ListenerExecutionFailedException ex) { /* expected */ }
|
||||||
}.runTest();
|
|
||||||
|
|
||||||
mockDelegate.verify();
|
mockDelegate.verify();
|
||||||
mockMessage.verify();
|
mockMessage.verify();
|
||||||
mockSession.verify();
|
mockSession.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testFailsIfNoDefaultListenerMethodNameIsSupplied() throws Exception {
|
public void testFailsIfNoDefaultListenerMethodNameIsSupplied() throws Exception {
|
||||||
MockControl mockMessage = MockControl.createControl(TextMessage.class);
|
MockControl mockMessage = MockControl.createControl(TextMessage.class);
|
||||||
final TextMessage message = (TextMessage) mockMessage.getMock();
|
final TextMessage message = (TextMessage) mockMessage.getMock();
|
||||||
|
|
@ -539,6 +557,7 @@ public class MessageListenerAdapterTests extends TestCase {
|
||||||
mockMessage.verify();
|
mockMessage.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testFailsWhenOverriddenGetListenerMethodNameReturnsNull() throws Exception {
|
public void testFailsWhenOverriddenGetListenerMethodNameReturnsNull() throws Exception {
|
||||||
MockControl mockMessage = MockControl.createControl(TextMessage.class);
|
MockControl mockMessage = MockControl.createControl(TextMessage.class);
|
||||||
final TextMessage message = (TextMessage) mockMessage.getMock();
|
final TextMessage message = (TextMessage) mockMessage.getMock();
|
||||||
|
|
@ -561,6 +580,7 @@ public class MessageListenerAdapterTests extends TestCase {
|
||||||
mockMessage.verify();
|
mockMessage.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testWithResponsiveMessageDelegateWhenReturnTypeIsNotAJMSMessageAndNoMessageConverterIsSupplied() throws Exception {
|
public void testWithResponsiveMessageDelegateWhenReturnTypeIsNotAJMSMessageAndNoMessageConverterIsSupplied() throws Exception {
|
||||||
MockControl mockSentTextMessage = MockControl.createControl(TextMessage.class);
|
MockControl mockSentTextMessage = MockControl.createControl(TextMessage.class);
|
||||||
final TextMessage sentTextMessage = (TextMessage) mockSentTextMessage.getMock();
|
final TextMessage sentTextMessage = (TextMessage) mockSentTextMessage.getMock();
|
||||||
|
|
@ -582,17 +602,17 @@ public class MessageListenerAdapterTests extends TestCase {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
adapter.setMessageConverter(null);
|
adapter.setMessageConverter(null);
|
||||||
new AssertThrows(MessageConversionException.class) {
|
try {
|
||||||
public void test() throws Exception {
|
adapter.onMessage(sentTextMessage, session);
|
||||||
adapter.onMessage(sentTextMessage, session);
|
fail("expected MessageConversionException");
|
||||||
}
|
} catch(MessageConversionException ex) { /* expected */ }
|
||||||
}.runTest();
|
|
||||||
|
|
||||||
mockDelegate.verify();
|
mockDelegate.verify();
|
||||||
mockSentTextMessage.verify();
|
mockSentTextMessage.verify();
|
||||||
mockSession.verify();
|
mockSession.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testWithResponsiveMessageDelegateWhenReturnTypeIsAJMSMessageAndNoMessageConverterIsSupplied() throws Exception {
|
public void testWithResponsiveMessageDelegateWhenReturnTypeIsAJMSMessageAndNoMessageConverterIsSupplied() throws Exception {
|
||||||
MockControl mockDestination = MockControl.createControl(Queue.class);
|
MockControl mockDestination = MockControl.createControl(Queue.class);
|
||||||
Queue destination = (Queue) mockDestination.getMock();
|
Queue destination = (Queue) mockDestination.getMock();
|
||||||
|
|
@ -16,27 +16,27 @@
|
||||||
|
|
||||||
package org.springframework.jms.support;
|
package org.springframework.jms.support;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import static org.junit.Assert.*;
|
||||||
import org.springframework.test.AssertThrows;
|
|
||||||
|
|
||||||
import javax.jms.Session;
|
import javax.jms.Session;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unit tests for the {@link JmsAccessor} class.
|
* Unit tests for the {@link JmsAccessor} class.
|
||||||
*
|
*
|
||||||
* @author Rick Evans
|
* @author Rick Evans
|
||||||
|
* @author Chris Beams
|
||||||
*/
|
*/
|
||||||
public final class JmsAccessorTests extends TestCase {
|
public final class JmsAccessorTests {
|
||||||
|
|
||||||
|
@Test(expected=IllegalArgumentException.class)
|
||||||
public void testChokesIfConnectionFactoryIsNotSupplied() throws Exception {
|
public void testChokesIfConnectionFactoryIsNotSupplied() throws Exception {
|
||||||
new AssertThrows(IllegalArgumentException.class) {
|
JmsAccessor accessor = new StubJmsAccessor();
|
||||||
public void test() throws Exception {
|
accessor.afterPropertiesSet();
|
||||||
JmsAccessor accessor = new StubJmsAccessor();
|
}
|
||||||
accessor.afterPropertiesSet();
|
|
||||||
}
|
|
||||||
}.runTest();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testSessionTransactedModeReallyDoesDefaultToFalse() throws Exception {
|
public void testSessionTransactedModeReallyDoesDefaultToFalse() throws Exception {
|
||||||
JmsAccessor accessor = new StubJmsAccessor();
|
JmsAccessor accessor = new StubJmsAccessor();
|
||||||
assertFalse("The [sessionTransacted] property of JmsAccessor must default to " +
|
assertFalse("The [sessionTransacted] property of JmsAccessor must default to " +
|
||||||
|
|
@ -45,6 +45,7 @@ public final class JmsAccessorTests extends TestCase {
|
||||||
accessor.isSessionTransacted());
|
accessor.isSessionTransacted());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testAcknowledgeModeReallyDoesDefaultToAutoAcknowledge() throws Exception {
|
public void testAcknowledgeModeReallyDoesDefaultToAutoAcknowledge() throws Exception {
|
||||||
JmsAccessor accessor = new StubJmsAccessor();
|
JmsAccessor accessor = new StubJmsAccessor();
|
||||||
assertEquals("The [sessionAcknowledgeMode] property of JmsAccessor must default to " +
|
assertEquals("The [sessionAcknowledgeMode] property of JmsAccessor must default to " +
|
||||||
|
|
@ -54,12 +55,9 @@ public final class JmsAccessorTests extends TestCase {
|
||||||
accessor.getSessionAcknowledgeMode());
|
accessor.getSessionAcknowledgeMode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(expected=IllegalArgumentException.class)
|
||||||
public void testSetAcknowledgeModeNameChokesIfBadAckModeIsSupplied() throws Exception {
|
public void testSetAcknowledgeModeNameChokesIfBadAckModeIsSupplied() throws Exception {
|
||||||
new AssertThrows(IllegalArgumentException.class) {
|
new StubJmsAccessor().setSessionAcknowledgeModeName("Tally ho chaps!");
|
||||||
public void test() throws Exception {
|
|
||||||
new StubJmsAccessor().setSessionAcknowledgeModeName("Tally ho chaps!");
|
|
||||||
}
|
|
||||||
}.runTest();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -16,19 +16,27 @@
|
||||||
|
|
||||||
package org.springframework.jms.support;
|
package org.springframework.jms.support;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import static org.junit.Assert.*;
|
||||||
import org.easymock.ArgumentsMatcher;
|
|
||||||
import org.easymock.MockControl;
|
|
||||||
import org.springframework.jms.support.converter.MessageConversionException;
|
|
||||||
import org.springframework.jms.support.converter.SimpleMessageConverter;
|
|
||||||
import org.springframework.test.AssertThrows;
|
|
||||||
|
|
||||||
import javax.jms.*;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.jms.BytesMessage;
|
||||||
|
import javax.jms.JMSException;
|
||||||
|
import javax.jms.MapMessage;
|
||||||
|
import javax.jms.Message;
|
||||||
|
import javax.jms.ObjectMessage;
|
||||||
|
import javax.jms.Session;
|
||||||
|
import javax.jms.TextMessage;
|
||||||
|
|
||||||
|
import org.easymock.ArgumentsMatcher;
|
||||||
|
import org.easymock.MockControl;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.springframework.jms.support.converter.MessageConversionException;
|
||||||
|
import org.springframework.jms.support.converter.SimpleMessageConverter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unit tests for the {@link SimpleMessageConverter} class.
|
* Unit tests for the {@link SimpleMessageConverter} class.
|
||||||
*
|
*
|
||||||
|
|
@ -36,8 +44,9 @@ import java.util.Map;
|
||||||
* @author Rick Evans
|
* @author Rick Evans
|
||||||
* @since 18.09.2004
|
* @since 18.09.2004
|
||||||
*/
|
*/
|
||||||
public final class SimpleMessageConverterTests extends TestCase {
|
public final class SimpleMessageConverterTests {
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testStringConversion() throws JMSException {
|
public void testStringConversion() throws JMSException {
|
||||||
MockControl sessionControl = MockControl.createControl(Session.class);
|
MockControl sessionControl = MockControl.createControl(Session.class);
|
||||||
Session session = (Session) sessionControl.getMock();
|
Session session = (Session) sessionControl.getMock();
|
||||||
|
|
@ -61,6 +70,7 @@ public final class SimpleMessageConverterTests extends TestCase {
|
||||||
messageControl.verify();
|
messageControl.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testByteArrayConversion() throws JMSException {
|
public void testByteArrayConversion() throws JMSException {
|
||||||
MockControl sessionControl = MockControl.createControl(Session.class);
|
MockControl sessionControl = MockControl.createControl(Session.class);
|
||||||
Session session = (Session) sessionControl.getMock();
|
Session session = (Session) sessionControl.getMock();
|
||||||
|
|
@ -99,6 +109,7 @@ public final class SimpleMessageConverterTests extends TestCase {
|
||||||
messageControl.verify();
|
messageControl.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testMapConversion() throws JMSException {
|
public void testMapConversion() throws JMSException {
|
||||||
|
|
||||||
MockControl sessionControl = MockControl.createControl(Session.class);
|
MockControl sessionControl = MockControl.createControl(Session.class);
|
||||||
|
|
@ -134,6 +145,7 @@ public final class SimpleMessageConverterTests extends TestCase {
|
||||||
messageControl.verify();
|
messageControl.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testSerializableConversion() throws JMSException {
|
public void testSerializableConversion() throws JMSException {
|
||||||
MockControl sessionControl = MockControl.createControl(Session.class);
|
MockControl sessionControl = MockControl.createControl(Session.class);
|
||||||
Session session = (Session) sessionControl.getMock();
|
Session session = (Session) sessionControl.getMock();
|
||||||
|
|
@ -157,22 +169,17 @@ public final class SimpleMessageConverterTests extends TestCase {
|
||||||
messageControl.verify();
|
messageControl.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(expected=MessageConversionException.class)
|
||||||
public void testToMessageThrowsExceptionIfGivenNullObjectToConvert() throws Exception {
|
public void testToMessageThrowsExceptionIfGivenNullObjectToConvert() throws Exception {
|
||||||
new AssertThrows(MessageConversionException.class) {
|
new SimpleMessageConverter().toMessage(null, null);
|
||||||
public void test() throws Exception {
|
|
||||||
new SimpleMessageConverter().toMessage(null, null);
|
|
||||||
}
|
|
||||||
}.runTest();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(expected=MessageConversionException.class)
|
||||||
public void testToMessageThrowsExceptionIfGivenIncompatibleObjectToConvert() throws Exception {
|
public void testToMessageThrowsExceptionIfGivenIncompatibleObjectToConvert() throws Exception {
|
||||||
new AssertThrows(MessageConversionException.class) {
|
new SimpleMessageConverter().toMessage(new Object(), null);
|
||||||
public void test() throws Exception {
|
|
||||||
new SimpleMessageConverter().toMessage(new Object(), null);
|
|
||||||
}
|
|
||||||
}.runTest();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testToMessageSimplyReturnsMessageAsIsIfSuppliedWithMessage() throws JMSException {
|
public void testToMessageSimplyReturnsMessageAsIsIfSuppliedWithMessage() throws JMSException {
|
||||||
|
|
||||||
MockControl sessionControl = MockControl.createControl(Session.class);
|
MockControl sessionControl = MockControl.createControl(Session.class);
|
||||||
|
|
@ -192,6 +199,7 @@ public final class SimpleMessageConverterTests extends TestCase {
|
||||||
messageControl.verify();
|
messageControl.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testFromMessageSimplyReturnsMessageAsIsIfSuppliedWithMessage() throws JMSException {
|
public void testFromMessageSimplyReturnsMessageAsIsIfSuppliedWithMessage() throws JMSException {
|
||||||
|
|
||||||
MockControl messageControl = MockControl.createControl(Message.class);
|
MockControl messageControl = MockControl.createControl(Message.class);
|
||||||
|
|
@ -206,6 +214,7 @@ public final class SimpleMessageConverterTests extends TestCase {
|
||||||
messageControl.verify();
|
messageControl.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testMapConversionWhereMapHasNonStringTypesForKeys() throws JMSException {
|
public void testMapConversionWhereMapHasNonStringTypesForKeys() throws JMSException {
|
||||||
|
|
||||||
MockControl messageControl = MockControl.createControl(MapMessage.class);
|
MockControl messageControl = MockControl.createControl(MapMessage.class);
|
||||||
|
|
@ -222,15 +231,15 @@ public final class SimpleMessageConverterTests extends TestCase {
|
||||||
content.put(new Integer(1), "value1");
|
content.put(new Integer(1), "value1");
|
||||||
|
|
||||||
final SimpleMessageConverter converter = new SimpleMessageConverter();
|
final SimpleMessageConverter converter = new SimpleMessageConverter();
|
||||||
new AssertThrows(MessageConversionException.class) {
|
try {
|
||||||
public void test() throws Exception {
|
converter.toMessage(content, session);
|
||||||
converter.toMessage(content, session);
|
fail("expected MessageConversionException");
|
||||||
}
|
} catch (MessageConversionException ex) { /* expected */ }
|
||||||
}.runTest();
|
|
||||||
|
|
||||||
sessionControl.verify();
|
sessionControl.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testMapConversionWhereMapHasNNullForKey() throws JMSException {
|
public void testMapConversionWhereMapHasNNullForKey() throws JMSException {
|
||||||
|
|
||||||
MockControl messageControl = MockControl.createControl(MapMessage.class);
|
MockControl messageControl = MockControl.createControl(MapMessage.class);
|
||||||
|
|
@ -247,11 +256,10 @@ public final class SimpleMessageConverterTests extends TestCase {
|
||||||
content.put(null, "value1");
|
content.put(null, "value1");
|
||||||
|
|
||||||
final SimpleMessageConverter converter = new SimpleMessageConverter();
|
final SimpleMessageConverter converter = new SimpleMessageConverter();
|
||||||
new AssertThrows(MessageConversionException.class) {
|
try {
|
||||||
public void test() throws Exception {
|
converter.toMessage(content, session);
|
||||||
converter.toMessage(content, session);
|
fail("expected MessageConversionException");
|
||||||
}
|
} catch (MessageConversionException ex) { /* expected */ }
|
||||||
}.runTest();
|
|
||||||
|
|
||||||
sessionControl.verify();
|
sessionControl.verify();
|
||||||
}
|
}
|
||||||
|
|
@ -16,35 +16,36 @@
|
||||||
|
|
||||||
package org.springframework.jms.support.destination;
|
package org.springframework.jms.support.destination;
|
||||||
|
|
||||||
|
import static org.easymock.EasyMock.*;
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
import javax.jms.ConnectionFactory;
|
import javax.jms.ConnectionFactory;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import org.junit.Test;
|
||||||
import org.easymock.MockControl;
|
|
||||||
|
|
||||||
import org.springframework.test.AssertThrows;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Rick Evans
|
* @author Rick Evans
|
||||||
|
* @author Chris Beams
|
||||||
*/
|
*/
|
||||||
public class JmsDestinationAccessorTests extends TestCase {
|
public class JmsDestinationAccessorTests {
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testChokesIfDestinationResolverIsetToNullExplcitly() throws Exception {
|
public void testChokesIfDestinationResolverIsetToNullExplcitly() throws Exception {
|
||||||
MockControl mockConnectionFactory = MockControl.createControl(ConnectionFactory.class);
|
ConnectionFactory connectionFactory = createMock(ConnectionFactory.class);
|
||||||
final ConnectionFactory connectionFactory = (ConnectionFactory) mockConnectionFactory.getMock();
|
replay(connectionFactory);
|
||||||
mockConnectionFactory.replay();
|
|
||||||
|
|
||||||
new AssertThrows(IllegalArgumentException.class) {
|
try {
|
||||||
public void test() throws Exception {
|
JmsDestinationAccessor accessor = new StubJmsDestinationAccessor();
|
||||||
JmsDestinationAccessor accessor = new StubJmsDestinationAccessor();
|
accessor.setConnectionFactory(connectionFactory);
|
||||||
accessor.setConnectionFactory(connectionFactory);
|
accessor.setDestinationResolver(null);
|
||||||
accessor.setDestinationResolver(null);
|
accessor.afterPropertiesSet();
|
||||||
accessor.afterPropertiesSet();
|
fail("expected IllegalArgumentException");
|
||||||
}
|
} catch (IllegalArgumentException ex) { /* expected */ }
|
||||||
}.runTest();
|
|
||||||
|
|
||||||
mockConnectionFactory.verify();
|
verify(connectionFactory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testSessionTransactedModeReallyDoesDefaultToFalse() throws Exception {
|
public void testSessionTransactedModeReallyDoesDefaultToFalse() throws Exception {
|
||||||
JmsDestinationAccessor accessor = new StubJmsDestinationAccessor();
|
JmsDestinationAccessor accessor = new StubJmsDestinationAccessor();
|
||||||
assertFalse("The [pubSubDomain] property of JmsDestinationAccessor must default to " +
|
assertFalse("The [pubSubDomain] property of JmsDestinationAccessor must default to " +
|
||||||
|
|
@ -16,26 +16,28 @@
|
||||||
|
|
||||||
package org.springframework.jms.support.destination;
|
package org.springframework.jms.support.destination;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import static org.junit.Assert.*;
|
||||||
import org.easymock.MockControl;
|
|
||||||
|
|
||||||
import org.springframework.test.AssertThrows;
|
|
||||||
import org.springframework.jms.StubTopic;
|
|
||||||
|
|
||||||
import javax.jms.Destination;
|
import javax.jms.Destination;
|
||||||
import javax.jms.Session;
|
import javax.jms.Session;
|
||||||
import javax.naming.NamingException;
|
import javax.naming.NamingException;
|
||||||
|
|
||||||
|
import org.easymock.MockControl;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.springframework.jms.StubTopic;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Rick Evans
|
* @author Rick Evans
|
||||||
|
* @author Chris Beams
|
||||||
*/
|
*/
|
||||||
public class JndiDestinationResolverTests extends TestCase {
|
public class JndiDestinationResolverTests {
|
||||||
|
|
||||||
private static final String DESTINATION_NAME = "foo";
|
private static final String DESTINATION_NAME = "foo";
|
||||||
|
|
||||||
private static final Destination DESTINATION = new StubTopic();
|
private static final Destination DESTINATION = new StubTopic();
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testHitsCacheSecondTimeThrough() throws Exception {
|
public void testHitsCacheSecondTimeThrough() throws Exception {
|
||||||
|
|
||||||
MockControl mockSession = MockControl.createControl(Session.class);
|
MockControl mockSession = MockControl.createControl(Session.class);
|
||||||
|
|
@ -50,6 +52,7 @@ public class JndiDestinationResolverTests extends TestCase {
|
||||||
mockSession.verify();
|
mockSession.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testDoesNotUseCacheIfCachingIsTurnedOff() throws Exception {
|
public void testDoesNotUseCacheIfCachingIsTurnedOff() throws Exception {
|
||||||
|
|
||||||
MockControl mockSession = MockControl.createControl(Session.class);
|
MockControl mockSession = MockControl.createControl(Session.class);
|
||||||
|
|
@ -72,6 +75,7 @@ public class JndiDestinationResolverTests extends TestCase {
|
||||||
mockSession.verify();
|
mockSession.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testDelegatesToFallbackIfNotResolvedInJndi() throws Exception {
|
public void testDelegatesToFallbackIfNotResolvedInJndi() throws Exception {
|
||||||
MockControl mockSession = MockControl.createControl(Session.class);
|
MockControl mockSession = MockControl.createControl(Session.class);
|
||||||
Session session = (Session) mockSession.getMock();
|
Session session = (Session) mockSession.getMock();
|
||||||
|
|
@ -99,6 +103,7 @@ public class JndiDestinationResolverTests extends TestCase {
|
||||||
mockDestinationResolver.verify();
|
mockDestinationResolver.verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void testDoesNotDelegateToFallbackIfNotResolvedInJndi() throws Exception {
|
public void testDoesNotDelegateToFallbackIfNotResolvedInJndi() throws Exception {
|
||||||
MockControl mockSession = MockControl.createControl(Session.class);
|
MockControl mockSession = MockControl.createControl(Session.class);
|
||||||
final Session session = (Session) mockSession.getMock();
|
final Session session = (Session) mockSession.getMock();
|
||||||
|
|
@ -115,11 +120,10 @@ public class JndiDestinationResolverTests extends TestCase {
|
||||||
};
|
};
|
||||||
resolver.setDynamicDestinationResolver(dynamicResolver);
|
resolver.setDynamicDestinationResolver(dynamicResolver);
|
||||||
|
|
||||||
new AssertThrows(DestinationResolutionException.class) {
|
try {
|
||||||
public void test() throws Exception {
|
resolver.resolveDestinationName(session, DESTINATION_NAME, true);
|
||||||
resolver.resolveDestinationName(session, DESTINATION_NAME, true);
|
fail("expected DestinationResolutionException");
|
||||||
}
|
} catch (DestinationResolutionException ex) { /* expected */ }
|
||||||
}.runTest();
|
|
||||||
|
|
||||||
mockSession.verify();
|
mockSession.verify();
|
||||||
mockDestinationResolver.verify();
|
mockDestinationResolver.verify();
|
||||||
|
|
@ -0,0 +1,58 @@
|
||||||
|
/*
|
||||||
|
* 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.transaction;
|
||||||
|
|
||||||
|
import org.springframework.transaction.support.AbstractPlatformTransactionManager;
|
||||||
|
import org.springframework.transaction.support.DefaultTransactionStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Rod Johnson
|
||||||
|
* @author Juergen Hoeller
|
||||||
|
*/
|
||||||
|
public class CallCountingTransactionManager extends AbstractPlatformTransactionManager {
|
||||||
|
|
||||||
|
public TransactionDefinition lastDefinition;
|
||||||
|
public int begun;
|
||||||
|
public int commits;
|
||||||
|
public int rollbacks;
|
||||||
|
public int inflight;
|
||||||
|
|
||||||
|
protected Object doGetTransaction() {
|
||||||
|
return new Object();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void doBegin(Object transaction, TransactionDefinition definition) {
|
||||||
|
this.lastDefinition = definition;
|
||||||
|
++begun;
|
||||||
|
++inflight;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void doCommit(DefaultTransactionStatus status) {
|
||||||
|
++commits;
|
||||||
|
--inflight;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void doRollback(DefaultTransactionStatus status) {
|
||||||
|
++rollbacks;
|
||||||
|
--inflight;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clear() {
|
||||||
|
begun = commits = rollbacks = inflight = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue