Rename modules {org.springframework.*=>spring-*}
This renaming more intuitively expresses the relationship between
subprojects and the JAR artifacts they produce.
Tracking history across these renames is possible, but it requires
use of the --follow flag to `git log`, for example
$ git log spring-aop/src/main/java/org/springframework/aop/Advisor.java
will show history up until the renaming event, where
$ git log --follow spring-aop/src/main/java/org/springframework/aop/Advisor.java
will show history for all changes to the file, before and after the
renaming.
See http://chrisbeams.com/git-diff-across-renamed-directories
This commit is contained in:
@@ -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 org.springframework.beans.ITestBean#exceptional(Throwable)
|
||||
*/
|
||||
public void exceptional(Throwable t) throws Throwable {
|
||||
if (t != null) {
|
||||
throw t;
|
||||
}
|
||||
}
|
||||
|
||||
public void unreliableFileOperation() throws IOException {
|
||||
throw new IOException();
|
||||
}
|
||||
/**
|
||||
* @see org.springframework.beans.ITestBean#returnsThis()
|
||||
*/
|
||||
public Object returnsThis() {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.springframework.beans.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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
/*
|
||||
* 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.mail;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author Dmitriy Kopylenko
|
||||
* @author Juergen Hoeller
|
||||
* @author Rick Evans
|
||||
* @author Chris Beams
|
||||
* @since 10.09.2003
|
||||
*/
|
||||
public final class SimpleMailMessageTests {
|
||||
|
||||
@Test
|
||||
public void testSimpleMessageCopyCtor() {
|
||||
SimpleMailMessage message = new SimpleMailMessage();
|
||||
message.setFrom("me@mail.org");
|
||||
message.setTo("you@mail.org");
|
||||
|
||||
SimpleMailMessage messageCopy = new SimpleMailMessage(message);
|
||||
assertEquals("me@mail.org", messageCopy.getFrom());
|
||||
assertEquals("you@mail.org", messageCopy.getTo()[0]);
|
||||
|
||||
message.setReplyTo("reply@mail.org");
|
||||
message.setCc(new String[]{"he@mail.org", "she@mail.org"});
|
||||
message.setBcc(new String[]{"us@mail.org", "them@mail.org"});
|
||||
Date sentDate = new Date();
|
||||
message.setSentDate(sentDate);
|
||||
message.setSubject("my subject");
|
||||
message.setText("my text");
|
||||
|
||||
assertEquals("me@mail.org", message.getFrom());
|
||||
assertEquals("reply@mail.org", message.getReplyTo());
|
||||
assertEquals("you@mail.org", message.getTo()[0]);
|
||||
List<String> ccs = Arrays.asList(message.getCc());
|
||||
assertTrue(ccs.contains("he@mail.org"));
|
||||
assertTrue(ccs.contains("she@mail.org"));
|
||||
List<String> bccs = Arrays.asList(message.getBcc());
|
||||
assertTrue(bccs.contains("us@mail.org"));
|
||||
assertTrue(bccs.contains("them@mail.org"));
|
||||
assertEquals(sentDate, message.getSentDate());
|
||||
assertEquals("my subject", message.getSubject());
|
||||
assertEquals("my text", message.getText());
|
||||
|
||||
messageCopy = new SimpleMailMessage(message);
|
||||
assertEquals("me@mail.org", messageCopy.getFrom());
|
||||
assertEquals("reply@mail.org", messageCopy.getReplyTo());
|
||||
assertEquals("you@mail.org", messageCopy.getTo()[0]);
|
||||
ccs = Arrays.asList(messageCopy.getCc());
|
||||
assertTrue(ccs.contains("he@mail.org"));
|
||||
assertTrue(ccs.contains("she@mail.org"));
|
||||
bccs = Arrays.asList(message.getBcc());
|
||||
assertTrue(bccs.contains("us@mail.org"));
|
||||
assertTrue(bccs.contains("them@mail.org"));
|
||||
assertEquals(sentDate, messageCopy.getSentDate());
|
||||
assertEquals("my subject", messageCopy.getSubject());
|
||||
assertEquals("my text", messageCopy.getText());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeepCopyOfStringArrayTypedFieldsOnCopyCtor() throws Exception {
|
||||
|
||||
SimpleMailMessage original = new SimpleMailMessage();
|
||||
original.setTo(new String[]{"fiona@mail.org", "apple@mail.org"});
|
||||
original.setCc(new String[]{"he@mail.org", "she@mail.org"});
|
||||
original.setBcc(new String[]{"us@mail.org", "them@mail.org"});
|
||||
|
||||
SimpleMailMessage copy = new SimpleMailMessage(original);
|
||||
|
||||
original.getTo()[0] = "mmm@mmm.org";
|
||||
original.getCc()[0] = "mmm@mmm.org";
|
||||
original.getBcc()[0] = "mmm@mmm.org";
|
||||
|
||||
assertEquals("fiona@mail.org", copy.getTo()[0]);
|
||||
assertEquals("he@mail.org", copy.getCc()[0]);
|
||||
assertEquals("us@mail.org", copy.getBcc()[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that two equal SimpleMailMessages have equal hash codes.
|
||||
*/
|
||||
@Test
|
||||
public final void testHashCode() {
|
||||
SimpleMailMessage message1 = new SimpleMailMessage();
|
||||
message1.setFrom("from@somewhere");
|
||||
message1.setReplyTo("replyTo@somewhere");
|
||||
message1.setTo("to@somewhere");
|
||||
message1.setCc("cc@somewhere");
|
||||
message1.setBcc("bcc@somewhere");
|
||||
message1.setSentDate(new Date());
|
||||
message1.setSubject("subject");
|
||||
message1.setText("text");
|
||||
|
||||
// Copy the message
|
||||
SimpleMailMessage message2 = new SimpleMailMessage(message1);
|
||||
|
||||
assertEquals(message1, message2);
|
||||
assertEquals(message1.hashCode(), message2.hashCode());
|
||||
}
|
||||
|
||||
public final void testEqualsObject() {
|
||||
SimpleMailMessage message1;
|
||||
SimpleMailMessage message2;
|
||||
|
||||
// Same object is equal
|
||||
message1 = new SimpleMailMessage();
|
||||
message2 = message1;
|
||||
assertTrue(message1.equals(message2));
|
||||
|
||||
// Null object is not equal
|
||||
message1 = new SimpleMailMessage();
|
||||
message2 = null;
|
||||
assertTrue(!(message1.equals(message2)));
|
||||
|
||||
// Different class is not equal
|
||||
assertTrue(!(message1.equals(new Object())));
|
||||
|
||||
// Equal values are equal
|
||||
message1 = new SimpleMailMessage();
|
||||
message2 = new SimpleMailMessage();
|
||||
assertTrue(message1.equals(message2));
|
||||
|
||||
message1 = new SimpleMailMessage();
|
||||
message1.setFrom("from@somewhere");
|
||||
message1.setReplyTo("replyTo@somewhere");
|
||||
message1.setTo("to@somewhere");
|
||||
message1.setCc("cc@somewhere");
|
||||
message1.setBcc("bcc@somewhere");
|
||||
message1.setSentDate(new Date());
|
||||
message1.setSubject("subject");
|
||||
message1.setText("text");
|
||||
message2 = new SimpleMailMessage(message1);
|
||||
assertTrue(message1.equals(message2));
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void testCopyCtorChokesOnNullOriginalMessage() throws Exception {
|
||||
new SimpleMailMessage(null);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void testCopyToChokesOnNullTargetMessage() throws Exception {
|
||||
new SimpleMailMessage().copyTo(null);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* 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.mail.javamail;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
/**
|
||||
* @author Rob Harrop
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class ConfigurableMimeFileTypeMapTests extends TestCase {
|
||||
|
||||
public void testAgainstDefaultConfiguration() throws Exception {
|
||||
ConfigurableMimeFileTypeMap ftm = new ConfigurableMimeFileTypeMap();
|
||||
ftm.afterPropertiesSet();
|
||||
|
||||
assertEquals("Invalid content type for HTM", "text/html", ftm.getContentType("foobar.HTM"));
|
||||
assertEquals("Invalid content type for html", "text/html", ftm.getContentType("foobar.html"));
|
||||
assertEquals("Invalid content type for c++", "text/plain", ftm.getContentType("foobar.c++"));
|
||||
assertEquals("Invalid content type for svf", "image/vnd.svf", ftm.getContentType("foobar.svf"));
|
||||
assertEquals("Invalid content type for dsf", "image/x-mgx-dsf", ftm.getContentType("foobar.dsf"));
|
||||
assertEquals("Invalid default content type", "application/octet-stream", ftm.getContentType("foobar.foo"));
|
||||
}
|
||||
|
||||
public void testAgainstDefaultConfigurationWithFilePath() throws Exception {
|
||||
ConfigurableMimeFileTypeMap ftm = new ConfigurableMimeFileTypeMap();
|
||||
assertEquals("Invalid content type for HTM", "text/html", ftm.getContentType(new File("/tmp/foobar.HTM")));
|
||||
}
|
||||
|
||||
public void testWithAdditionalMappings() throws Exception {
|
||||
ConfigurableMimeFileTypeMap ftm = new ConfigurableMimeFileTypeMap();
|
||||
ftm.setMappings(new String[] {"foo/bar HTM foo", "foo/cpp c++"});
|
||||
ftm.afterPropertiesSet();
|
||||
|
||||
assertEquals("Invalid content type for HTM - override didn't work", "foo/bar", ftm.getContentType("foobar.HTM"));
|
||||
assertEquals("Invalid content type for c++ - override didn't work", "foo/cpp", ftm.getContentType("foobar.c++"));
|
||||
assertEquals("Invalid content type for foo - new mapping didn't work", "foo/bar", ftm.getContentType("bar.foo"));
|
||||
}
|
||||
|
||||
public void testWithCustomMappingLocation() throws Exception {
|
||||
Resource resource = new ClassPathResource("test.mime.types", getClass());
|
||||
|
||||
ConfigurableMimeFileTypeMap ftm = new ConfigurableMimeFileTypeMap();
|
||||
ftm.setMappingLocation(resource);
|
||||
ftm.afterPropertiesSet();
|
||||
|
||||
assertEquals("Invalid content type for foo", "text/foo", ftm.getContentType("foobar.foo"));
|
||||
assertEquals("Invalid content type for bar", "text/bar", ftm.getContentType("foobar.bar"));
|
||||
assertEquals("Invalid content type for fimg", "image/foo", ftm.getContentType("foobar.fimg"));
|
||||
assertEquals("Invalid content type for bimg", "image/bar", ftm.getContentType("foobar.bimg"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* 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.mail.javamail;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* @author Brian Hanafee
|
||||
* @since 09.07.2005
|
||||
*/
|
||||
public class InternetAddressEditorTests extends TestCase {
|
||||
|
||||
private static final String EMPTY = "";
|
||||
private static final String SIMPLE = "nobody@nowhere.com";
|
||||
private static final String BAD = "(";
|
||||
|
||||
private InternetAddressEditor editor;
|
||||
|
||||
protected void setUp() {
|
||||
editor = new InternetAddressEditor();
|
||||
}
|
||||
|
||||
public void testUninitialized() {
|
||||
assertEquals("Uninitialized editor did not return empty value string", EMPTY, editor.getAsText());
|
||||
}
|
||||
|
||||
public void testSetNull() {
|
||||
editor.setAsText(null);
|
||||
assertEquals("Setting null did not result in empty value string", EMPTY, editor.getAsText());
|
||||
}
|
||||
|
||||
public void testSetEmpty() {
|
||||
editor.setAsText(EMPTY);
|
||||
assertEquals("Setting empty string did not result in empty value string", EMPTY, editor.getAsText());
|
||||
}
|
||||
|
||||
public void testAllWhitespace() {
|
||||
editor.setAsText(" ");
|
||||
assertEquals("All whitespace was not recognized", EMPTY, editor.getAsText());
|
||||
}
|
||||
|
||||
public void testSimpleGoodAddess() {
|
||||
editor.setAsText(SIMPLE);
|
||||
assertEquals("Simple email address failed", SIMPLE, editor.getAsText());
|
||||
}
|
||||
|
||||
public void testExcessWhitespace() {
|
||||
editor.setAsText(" " + SIMPLE + " ");
|
||||
assertEquals("Whitespace was not stripped", SIMPLE, editor.getAsText());
|
||||
}
|
||||
|
||||
public void testSimpleBadAddress() {
|
||||
try {
|
||||
editor.setAsText(BAD);
|
||||
fail("Should have failed on \"" + BAD + "\", instead got " + editor.getAsText());
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
// Passed the test
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,564 @@
|
||||
/*
|
||||
* Copyright 2002-2010 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.mail.javamail;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import javax.activation.FileTypeMap;
|
||||
import javax.mail.Address;
|
||||
import javax.mail.Message;
|
||||
import javax.mail.MessagingException;
|
||||
import javax.mail.NoSuchProviderException;
|
||||
import javax.mail.Session;
|
||||
import javax.mail.Transport;
|
||||
import javax.mail.URLName;
|
||||
import javax.mail.internet.AddressException;
|
||||
import javax.mail.internet.InternetAddress;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.mail.MailParseException;
|
||||
import org.springframework.mail.MailSendException;
|
||||
import org.springframework.mail.SimpleMailMessage;
|
||||
|
||||
/**
|
||||
* @author Juergen Hoeller
|
||||
* @since 09.10.2004
|
||||
*/
|
||||
public class JavaMailSenderTests extends TestCase {
|
||||
|
||||
public void testJavaMailSenderWithSimpleMessage() throws MessagingException, IOException {
|
||||
MockJavaMailSender sender = new MockJavaMailSender();
|
||||
sender.setHost("host");
|
||||
sender.setPort(30);
|
||||
sender.setUsername("username");
|
||||
sender.setPassword("password");
|
||||
|
||||
SimpleMailMessage simpleMessage = new SimpleMailMessage();
|
||||
simpleMessage.setFrom("me@mail.org");
|
||||
simpleMessage.setReplyTo("reply@mail.org");
|
||||
simpleMessage.setTo("you@mail.org");
|
||||
simpleMessage.setCc(new String[] {"he@mail.org", "she@mail.org"});
|
||||
simpleMessage.setBcc(new String[] {"us@mail.org", "them@mail.org"});
|
||||
Date sentDate = new Date(2004, 1, 1);
|
||||
simpleMessage.setSentDate(sentDate);
|
||||
simpleMessage.setSubject("my subject");
|
||||
simpleMessage.setText("my text");
|
||||
sender.send(simpleMessage);
|
||||
|
||||
assertEquals("host", sender.transport.getConnectedHost());
|
||||
assertEquals(30, sender.transport.getConnectedPort());
|
||||
assertEquals("username", sender.transport.getConnectedUsername());
|
||||
assertEquals("password", sender.transport.getConnectedPassword());
|
||||
assertTrue(sender.transport.isCloseCalled());
|
||||
|
||||
assertEquals(1, sender.transport.getSentMessages().size());
|
||||
MimeMessage sentMessage = sender.transport.getSentMessage(0);
|
||||
List froms = Arrays.asList(sentMessage.getFrom());
|
||||
assertEquals(1, froms.size());
|
||||
assertEquals("me@mail.org", ((InternetAddress) froms.get(0)).getAddress());
|
||||
List replyTos = Arrays.asList(sentMessage.getReplyTo());
|
||||
assertEquals("reply@mail.org", ((InternetAddress) replyTos.get(0)).getAddress());
|
||||
List tos = Arrays.asList(sentMessage.getRecipients(Message.RecipientType.TO));
|
||||
assertEquals(1, tos.size());
|
||||
assertEquals("you@mail.org", ((InternetAddress) tos.get(0)).getAddress());
|
||||
List ccs = Arrays.asList(sentMessage.getRecipients(Message.RecipientType.CC));
|
||||
assertEquals(2, ccs.size());
|
||||
assertEquals("he@mail.org", ((InternetAddress) ccs.get(0)).getAddress());
|
||||
assertEquals("she@mail.org", ((InternetAddress) ccs.get(1)).getAddress());
|
||||
List bccs = Arrays.asList(sentMessage.getRecipients(Message.RecipientType.BCC));
|
||||
assertEquals(2, bccs.size());
|
||||
assertEquals("us@mail.org", ((InternetAddress) bccs.get(0)).getAddress());
|
||||
assertEquals("them@mail.org", ((InternetAddress) bccs.get(1)).getAddress());
|
||||
assertEquals(sentDate.getTime(), sentMessage.getSentDate().getTime());
|
||||
assertEquals("my subject", sentMessage.getSubject());
|
||||
assertEquals("my text", sentMessage.getContent());
|
||||
}
|
||||
|
||||
public void testJavaMailSenderWithSimpleMessages() throws MessagingException, IOException {
|
||||
MockJavaMailSender sender = new MockJavaMailSender();
|
||||
sender.setHost("host");
|
||||
sender.setUsername("username");
|
||||
sender.setPassword("password");
|
||||
|
||||
SimpleMailMessage simpleMessage1 = new SimpleMailMessage();
|
||||
simpleMessage1.setTo("he@mail.org");
|
||||
SimpleMailMessage simpleMessage2 = new SimpleMailMessage();
|
||||
simpleMessage2.setTo("she@mail.org");
|
||||
sender.send(new SimpleMailMessage[] {simpleMessage1, simpleMessage2});
|
||||
|
||||
assertEquals("host", sender.transport.getConnectedHost());
|
||||
assertEquals("username", sender.transport.getConnectedUsername());
|
||||
assertEquals("password", sender.transport.getConnectedPassword());
|
||||
assertTrue(sender.transport.isCloseCalled());
|
||||
|
||||
assertEquals(2, sender.transport.getSentMessages().size());
|
||||
MimeMessage sentMessage1 = sender.transport.getSentMessage(0);
|
||||
List tos1 = Arrays.asList(sentMessage1.getRecipients(Message.RecipientType.TO));
|
||||
assertEquals(1, tos1.size());
|
||||
assertEquals("he@mail.org", ((InternetAddress) tos1.get(0)).getAddress());
|
||||
MimeMessage sentMessage2 = sender.transport.getSentMessage(1);
|
||||
List tos2 = Arrays.asList(sentMessage2.getRecipients(Message.RecipientType.TO));
|
||||
assertEquals(1, tos2.size());
|
||||
assertEquals("she@mail.org", ((InternetAddress) tos2.get(0)).getAddress());
|
||||
}
|
||||
|
||||
public void testJavaMailSenderWithMimeMessage() throws MessagingException {
|
||||
MockJavaMailSender sender = new MockJavaMailSender();
|
||||
sender.setHost("host");
|
||||
sender.setUsername("username");
|
||||
sender.setPassword("password");
|
||||
|
||||
MimeMessage mimeMessage = sender.createMimeMessage();
|
||||
mimeMessage.setRecipient(Message.RecipientType.TO, new InternetAddress("you@mail.org"));
|
||||
sender.send(mimeMessage);
|
||||
|
||||
assertEquals("host", sender.transport.getConnectedHost());
|
||||
assertEquals("username", sender.transport.getConnectedUsername());
|
||||
assertEquals("password", sender.transport.getConnectedPassword());
|
||||
assertTrue(sender.transport.isCloseCalled());
|
||||
assertEquals(1, sender.transport.getSentMessages().size());
|
||||
assertEquals(mimeMessage, sender.transport.getSentMessage(0));
|
||||
}
|
||||
|
||||
public void testJavaMailSenderWithMimeMessages() throws MessagingException {
|
||||
MockJavaMailSender sender = new MockJavaMailSender();
|
||||
sender.setHost("host");
|
||||
sender.setUsername("username");
|
||||
sender.setPassword("password");
|
||||
|
||||
MimeMessage mimeMessage1 = sender.createMimeMessage();
|
||||
mimeMessage1.setRecipient(Message.RecipientType.TO, new InternetAddress("he@mail.org"));
|
||||
MimeMessage mimeMessage2 = sender.createMimeMessage();
|
||||
mimeMessage2.setRecipient(Message.RecipientType.TO, new InternetAddress("she@mail.org"));
|
||||
sender.send(new MimeMessage[] {mimeMessage1, mimeMessage2});
|
||||
|
||||
assertEquals("host", sender.transport.getConnectedHost());
|
||||
assertEquals("username", sender.transport.getConnectedUsername());
|
||||
assertEquals("password", sender.transport.getConnectedPassword());
|
||||
assertTrue(sender.transport.isCloseCalled());
|
||||
assertEquals(2, sender.transport.getSentMessages().size());
|
||||
assertEquals(mimeMessage1, sender.transport.getSentMessage(0));
|
||||
assertEquals(mimeMessage2, sender.transport.getSentMessage(1));
|
||||
}
|
||||
|
||||
public void testJavaMailSenderWithMimeMessagePreparator() {
|
||||
MockJavaMailSender sender = new MockJavaMailSender();
|
||||
sender.setHost("host");
|
||||
sender.setUsername("username");
|
||||
sender.setPassword("password");
|
||||
|
||||
final List<Message> messages = new ArrayList<Message>();
|
||||
|
||||
MimeMessagePreparator preparator = new MimeMessagePreparator() {
|
||||
public void prepare(MimeMessage mimeMessage) throws MessagingException {
|
||||
mimeMessage.setRecipient(Message.RecipientType.TO, new InternetAddress("you@mail.org"));
|
||||
messages.add(mimeMessage);
|
||||
}
|
||||
};
|
||||
sender.send(preparator);
|
||||
|
||||
assertEquals("host", sender.transport.getConnectedHost());
|
||||
assertEquals("username", sender.transport.getConnectedUsername());
|
||||
assertEquals("password", sender.transport.getConnectedPassword());
|
||||
assertTrue(sender.transport.isCloseCalled());
|
||||
assertEquals(1, sender.transport.getSentMessages().size());
|
||||
assertEquals(messages.get(0), sender.transport.getSentMessage(0));
|
||||
}
|
||||
|
||||
public void testJavaMailSenderWithMimeMessagePreparators() {
|
||||
MockJavaMailSender sender = new MockJavaMailSender();
|
||||
sender.setHost("host");
|
||||
sender.setUsername("username");
|
||||
sender.setPassword("password");
|
||||
|
||||
final List<Message> messages = new ArrayList<Message>();
|
||||
|
||||
MimeMessagePreparator preparator1 = new MimeMessagePreparator() {
|
||||
public void prepare(MimeMessage mimeMessage) throws MessagingException {
|
||||
mimeMessage.setRecipient(Message.RecipientType.TO, new InternetAddress("he@mail.org"));
|
||||
messages.add(mimeMessage);
|
||||
}
|
||||
};
|
||||
MimeMessagePreparator preparator2 = new MimeMessagePreparator() {
|
||||
public void prepare(MimeMessage mimeMessage) throws MessagingException {
|
||||
mimeMessage.setRecipient(Message.RecipientType.TO, new InternetAddress("she@mail.org"));
|
||||
messages.add(mimeMessage);
|
||||
}
|
||||
};
|
||||
sender.send(new MimeMessagePreparator[] {preparator1, preparator2});
|
||||
|
||||
assertEquals("host", sender.transport.getConnectedHost());
|
||||
assertEquals("username", sender.transport.getConnectedUsername());
|
||||
assertEquals("password", sender.transport.getConnectedPassword());
|
||||
assertTrue(sender.transport.isCloseCalled());
|
||||
assertEquals(2, sender.transport.getSentMessages().size());
|
||||
assertEquals(messages.get(0), sender.transport.getSentMessage(0));
|
||||
assertEquals(messages.get(1), sender.transport.getSentMessage(1));
|
||||
}
|
||||
|
||||
public void testJavaMailSenderWithMimeMessageHelper() throws MessagingException {
|
||||
MockJavaMailSender sender = new MockJavaMailSender();
|
||||
sender.setHost("host");
|
||||
sender.setUsername("username");
|
||||
sender.setPassword("password");
|
||||
|
||||
MimeMessageHelper message = new MimeMessageHelper(sender.createMimeMessage());
|
||||
assertNull(message.getEncoding());
|
||||
assertTrue(message.getFileTypeMap() instanceof ConfigurableMimeFileTypeMap);
|
||||
|
||||
message.setTo("you@mail.org");
|
||||
sender.send(message.getMimeMessage());
|
||||
|
||||
assertEquals("host", sender.transport.getConnectedHost());
|
||||
assertEquals("username", sender.transport.getConnectedUsername());
|
||||
assertEquals("password", sender.transport.getConnectedPassword());
|
||||
assertTrue(sender.transport.isCloseCalled());
|
||||
assertEquals(1, sender.transport.getSentMessages().size());
|
||||
assertEquals(message.getMimeMessage(), sender.transport.getSentMessage(0));
|
||||
}
|
||||
|
||||
public void testJavaMailSenderWithMimeMessageHelperAndSpecificEncoding() throws MessagingException {
|
||||
MockJavaMailSender sender = new MockJavaMailSender();
|
||||
sender.setHost("host");
|
||||
sender.setUsername("username");
|
||||
sender.setPassword("password");
|
||||
|
||||
MimeMessageHelper message = new MimeMessageHelper(sender.createMimeMessage(), "UTF-8");
|
||||
assertEquals("UTF-8", message.getEncoding());
|
||||
FileTypeMap fileTypeMap = new ConfigurableMimeFileTypeMap();
|
||||
message.setFileTypeMap(fileTypeMap);
|
||||
assertEquals(fileTypeMap, message.getFileTypeMap());
|
||||
|
||||
message.setTo("you@mail.org");
|
||||
sender.send(message.getMimeMessage());
|
||||
|
||||
assertEquals("host", sender.transport.getConnectedHost());
|
||||
assertEquals("username", sender.transport.getConnectedUsername());
|
||||
assertEquals("password", sender.transport.getConnectedPassword());
|
||||
assertTrue(sender.transport.isCloseCalled());
|
||||
assertEquals(1, sender.transport.getSentMessages().size());
|
||||
assertEquals(message.getMimeMessage(), sender.transport.getSentMessage(0));
|
||||
}
|
||||
|
||||
public void testJavaMailSenderWithMimeMessageHelperAndDefaultEncoding() throws MessagingException {
|
||||
MockJavaMailSender sender = new MockJavaMailSender();
|
||||
sender.setHost("host");
|
||||
sender.setUsername("username");
|
||||
sender.setPassword("password");
|
||||
sender.setDefaultEncoding("UTF-8");
|
||||
|
||||
FileTypeMap fileTypeMap = new ConfigurableMimeFileTypeMap();
|
||||
sender.setDefaultFileTypeMap(fileTypeMap);
|
||||
MimeMessageHelper message = new MimeMessageHelper(sender.createMimeMessage());
|
||||
assertEquals("UTF-8", message.getEncoding());
|
||||
assertEquals(fileTypeMap, message.getFileTypeMap());
|
||||
|
||||
message.setTo("you@mail.org");
|
||||
sender.send(message.getMimeMessage());
|
||||
|
||||
assertEquals("host", sender.transport.getConnectedHost());
|
||||
assertEquals("username", sender.transport.getConnectedUsername());
|
||||
assertEquals("password", sender.transport.getConnectedPassword());
|
||||
assertTrue(sender.transport.isCloseCalled());
|
||||
assertEquals(1, sender.transport.getSentMessages().size());
|
||||
assertEquals(message.getMimeMessage(), sender.transport.getSentMessage(0));
|
||||
}
|
||||
|
||||
public void testJavaMailSenderWithParseExceptionOnSimpleMessage() {
|
||||
MockJavaMailSender sender = new MockJavaMailSender();
|
||||
SimpleMailMessage simpleMessage = new SimpleMailMessage();
|
||||
simpleMessage.setFrom("");
|
||||
try {
|
||||
sender.send(simpleMessage);
|
||||
}
|
||||
catch (MailParseException ex) {
|
||||
// expected
|
||||
assertTrue(ex.getCause() instanceof AddressException);
|
||||
}
|
||||
}
|
||||
|
||||
public void testJavaMailSenderWithParseExceptionOnMimeMessagePreparator() {
|
||||
MockJavaMailSender sender = new MockJavaMailSender();
|
||||
MimeMessagePreparator preparator = new MimeMessagePreparator() {
|
||||
public void prepare(MimeMessage mimeMessage) throws MessagingException {
|
||||
mimeMessage.setFrom(new InternetAddress(""));
|
||||
}
|
||||
};
|
||||
try {
|
||||
sender.send(preparator);
|
||||
}
|
||||
catch (MailParseException ex) {
|
||||
// expected
|
||||
assertTrue(ex.getCause() instanceof AddressException);
|
||||
}
|
||||
}
|
||||
|
||||
public void testJavaMailSenderWithCustomSession() throws MessagingException {
|
||||
final Session session = Session.getInstance(new Properties());
|
||||
MockJavaMailSender sender = new MockJavaMailSender() {
|
||||
@Override
|
||||
protected Transport getTransport(Session sess) throws NoSuchProviderException {
|
||||
assertEquals(session, sess);
|
||||
return super.getTransport(sess);
|
||||
}
|
||||
};
|
||||
sender.setSession(session);
|
||||
sender.setHost("host");
|
||||
sender.setUsername("username");
|
||||
sender.setPassword("password");
|
||||
|
||||
MimeMessage mimeMessage = sender.createMimeMessage();
|
||||
mimeMessage.setSubject("custom");
|
||||
mimeMessage.setRecipient(Message.RecipientType.TO, new InternetAddress("you@mail.org"));
|
||||
mimeMessage.setSentDate(new Date(2005, 3, 1));
|
||||
sender.send(mimeMessage);
|
||||
|
||||
assertEquals("host", sender.transport.getConnectedHost());
|
||||
assertEquals("username", sender.transport.getConnectedUsername());
|
||||
assertEquals("password", sender.transport.getConnectedPassword());
|
||||
assertTrue(sender.transport.isCloseCalled());
|
||||
assertEquals(1, sender.transport.getSentMessages().size());
|
||||
assertEquals(mimeMessage, sender.transport.getSentMessage(0));
|
||||
}
|
||||
|
||||
public void testJavaMailProperties() throws MessagingException {
|
||||
Properties props = new Properties();
|
||||
props.setProperty("bogusKey", "bogusValue");
|
||||
MockJavaMailSender sender = new MockJavaMailSender() {
|
||||
@Override
|
||||
protected Transport getTransport(Session sess) throws NoSuchProviderException {
|
||||
assertEquals("bogusValue", sess.getProperty("bogusKey"));
|
||||
return super.getTransport(sess);
|
||||
}
|
||||
};
|
||||
sender.setJavaMailProperties(props);
|
||||
sender.setHost("host");
|
||||
sender.setUsername("username");
|
||||
sender.setPassword("password");
|
||||
|
||||
MimeMessage mimeMessage = sender.createMimeMessage();
|
||||
mimeMessage.setRecipient(Message.RecipientType.TO, new InternetAddress("you@mail.org"));
|
||||
sender.send(mimeMessage);
|
||||
|
||||
assertEquals("host", sender.transport.getConnectedHost());
|
||||
assertEquals("username", sender.transport.getConnectedUsername());
|
||||
assertEquals("password", sender.transport.getConnectedPassword());
|
||||
assertTrue(sender.transport.isCloseCalled());
|
||||
assertEquals(1, sender.transport.getSentMessages().size());
|
||||
assertEquals(mimeMessage, sender.transport.getSentMessage(0));
|
||||
}
|
||||
|
||||
public void testFailedMailServerConnect() throws Exception {
|
||||
MockJavaMailSender sender = new MockJavaMailSender();
|
||||
sender.setHost(null);
|
||||
sender.setUsername("username");
|
||||
sender.setPassword("password");
|
||||
SimpleMailMessage simpleMessage1 = new SimpleMailMessage();
|
||||
try {
|
||||
sender.send(simpleMessage1);
|
||||
fail("Should have thrown MailSendException");
|
||||
}
|
||||
catch (MailSendException ex) {
|
||||
// expected
|
||||
ex.printStackTrace();
|
||||
assertTrue(ex.getFailedMessages() != null);
|
||||
assertEquals(1, ex.getFailedMessages().size());
|
||||
assertSame(simpleMessage1, ex.getFailedMessages().keySet().iterator().next());
|
||||
assertSame(ex.getCause(), ex.getFailedMessages().values().iterator().next());
|
||||
}
|
||||
}
|
||||
|
||||
public void testFailedMailServerClose() throws Exception {
|
||||
MockJavaMailSender sender = new MockJavaMailSender();
|
||||
sender.setHost("");
|
||||
sender.setUsername("username");
|
||||
sender.setPassword("password");
|
||||
SimpleMailMessage simpleMessage1 = new SimpleMailMessage();
|
||||
try {
|
||||
sender.send(simpleMessage1);
|
||||
fail("Should have thrown MailSendException");
|
||||
}
|
||||
catch (MailSendException ex) {
|
||||
// expected
|
||||
ex.printStackTrace();
|
||||
assertTrue(ex.getFailedMessages() != null);
|
||||
assertEquals(0, ex.getFailedMessages().size());
|
||||
}
|
||||
}
|
||||
|
||||
public void testFailedSimpleMessage() throws Exception {
|
||||
MockJavaMailSender sender = new MockJavaMailSender();
|
||||
sender.setHost("host");
|
||||
sender.setUsername("username");
|
||||
sender.setPassword("password");
|
||||
|
||||
SimpleMailMessage simpleMessage1 = new SimpleMailMessage();
|
||||
simpleMessage1.setTo("he@mail.org");
|
||||
simpleMessage1.setSubject("fail");
|
||||
SimpleMailMessage simpleMessage2 = new SimpleMailMessage();
|
||||
simpleMessage2.setTo("she@mail.org");
|
||||
|
||||
try {
|
||||
sender.send(new SimpleMailMessage[] {simpleMessage1, simpleMessage2});
|
||||
}
|
||||
catch (MailSendException ex) {
|
||||
ex.printStackTrace();
|
||||
assertEquals("host", sender.transport.getConnectedHost());
|
||||
assertEquals("username", sender.transport.getConnectedUsername());
|
||||
assertEquals("password", sender.transport.getConnectedPassword());
|
||||
assertTrue(sender.transport.isCloseCalled());
|
||||
assertEquals(1, sender.transport.getSentMessages().size());
|
||||
assertEquals(new InternetAddress("she@mail.org"), sender.transport.getSentMessage(0).getAllRecipients()[0]);
|
||||
assertEquals(1, ex.getFailedMessages().size());
|
||||
assertEquals(simpleMessage1, ex.getFailedMessages().keySet().iterator().next());
|
||||
Object subEx = ex.getFailedMessages().values().iterator().next();
|
||||
assertTrue(subEx instanceof MessagingException);
|
||||
assertEquals("failed", ((MessagingException) subEx).getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void testFailedMimeMessage() throws Exception {
|
||||
MockJavaMailSender sender = new MockJavaMailSender();
|
||||
sender.setHost("host");
|
||||
sender.setUsername("username");
|
||||
sender.setPassword("password");
|
||||
|
||||
MimeMessage mimeMessage1 = sender.createMimeMessage();
|
||||
mimeMessage1.setRecipient(Message.RecipientType.TO, new InternetAddress("he@mail.org"));
|
||||
mimeMessage1.setSubject("fail");
|
||||
MimeMessage mimeMessage2 = sender.createMimeMessage();
|
||||
mimeMessage2.setRecipient(Message.RecipientType.TO, new InternetAddress("she@mail.org"));
|
||||
|
||||
try {
|
||||
sender.send(new MimeMessage[] {mimeMessage1, mimeMessage2});
|
||||
}
|
||||
catch (MailSendException ex) {
|
||||
ex.printStackTrace();
|
||||
assertEquals("host", sender.transport.getConnectedHost());
|
||||
assertEquals("username", sender.transport.getConnectedUsername());
|
||||
assertEquals("password", sender.transport.getConnectedPassword());
|
||||
assertTrue(sender.transport.isCloseCalled());
|
||||
assertEquals(1, sender.transport.getSentMessages().size());
|
||||
assertEquals(mimeMessage2, sender.transport.getSentMessage(0));
|
||||
assertEquals(1, ex.getFailedMessages().size());
|
||||
assertEquals(mimeMessage1, ex.getFailedMessages().keySet().iterator().next());
|
||||
Object subEx = ex.getFailedMessages().values().iterator().next();
|
||||
assertTrue(subEx instanceof MessagingException);
|
||||
assertEquals("failed", ((MessagingException) subEx).getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static class MockJavaMailSender extends JavaMailSenderImpl {
|
||||
|
||||
private MockTransport transport;
|
||||
|
||||
@Override
|
||||
protected Transport getTransport(Session session) throws NoSuchProviderException {
|
||||
this.transport = new MockTransport(session, null);
|
||||
return transport;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static class MockTransport extends Transport {
|
||||
|
||||
private String connectedHost = null;
|
||||
private int connectedPort = -2;
|
||||
private String connectedUsername = null;
|
||||
private String connectedPassword = null;
|
||||
private boolean closeCalled = false;
|
||||
private List<Message> sentMessages = new ArrayList<Message>();
|
||||
|
||||
private MockTransport(Session session, URLName urlName) {
|
||||
super(session, urlName);
|
||||
}
|
||||
|
||||
public String getConnectedHost() {
|
||||
return connectedHost;
|
||||
}
|
||||
|
||||
public int getConnectedPort() {
|
||||
return connectedPort;
|
||||
}
|
||||
|
||||
public String getConnectedUsername() {
|
||||
return connectedUsername;
|
||||
}
|
||||
|
||||
public String getConnectedPassword() {
|
||||
return connectedPassword;
|
||||
}
|
||||
|
||||
public boolean isCloseCalled() {
|
||||
return closeCalled;
|
||||
}
|
||||
|
||||
public List getSentMessages() {
|
||||
return sentMessages;
|
||||
}
|
||||
|
||||
public MimeMessage getSentMessage(int index) {
|
||||
return (MimeMessage) this.sentMessages.get(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connect(String host, int port, String username, String password) throws MessagingException {
|
||||
if (host == null) {
|
||||
throw new MessagingException("no host");
|
||||
}
|
||||
this.connectedHost = host;
|
||||
this.connectedPort = port;
|
||||
this.connectedUsername = username;
|
||||
this.connectedPassword = password;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void close() throws MessagingException {
|
||||
if ("".equals(connectedHost)) {
|
||||
throw new MessagingException("close failure");
|
||||
}
|
||||
this.closeCalled = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(Message message, Address[] addresses) throws MessagingException {
|
||||
if ("fail".equals(message.getSubject())) {
|
||||
throw new MessagingException("failed");
|
||||
}
|
||||
List addr1 = Arrays.asList(message.getAllRecipients());
|
||||
List addr2 = Arrays.asList(addresses);
|
||||
if (!addr1.equals(addr2)) {
|
||||
throw new MessagingException("addresses not correct");
|
||||
}
|
||||
if (message.getSentDate() == null) {
|
||||
throw new MessagingException("No sentDate specified");
|
||||
}
|
||||
if (message.getSubject() != null && message.getSubject().contains("custom")) {
|
||||
assertEquals(new Date(2005, 3, 1), message.getSentDate());
|
||||
}
|
||||
this.sentMessages.add(message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* 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.scheduling;
|
||||
|
||||
/**
|
||||
* @author Juergen Hoeller
|
||||
* @since 09.10.2004
|
||||
*/
|
||||
public class TestMethodInvokingTask {
|
||||
|
||||
public int counter = 0;
|
||||
|
||||
private Object lock = new Object();
|
||||
|
||||
public void doSomething() {
|
||||
this.counter++;
|
||||
}
|
||||
|
||||
public void doWait() {
|
||||
this.counter++;
|
||||
// wait until stop is called
|
||||
synchronized (this.lock) {
|
||||
try {
|
||||
this.lock.wait();
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
// fall through
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
synchronized(this.lock) {
|
||||
this.lock.notify();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright 2002-2009 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.scheduling.quartz;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Calendar;
|
||||
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/** @author Rob Harrop */
|
||||
public class CronTriggerBeanTests {
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testInvalidStartDelay() {
|
||||
createTriggerBean().setStartDelay(-1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStartTime() throws Exception {
|
||||
CronTriggerBean bean = createTriggerBean();
|
||||
Date startTime = new Date(System.currentTimeMillis() + 1234L);
|
||||
bean.setStartTime(startTime);
|
||||
bean.afterPropertiesSet();
|
||||
assertTimeEquals(startTime, bean.getStartTime());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStartDelay() throws Exception {
|
||||
CronTriggerBean bean = createTriggerBean();
|
||||
long startDelay = 1234L;
|
||||
Date startTime = new Date(System.currentTimeMillis() + startDelay);
|
||||
bean.setStartDelay(startDelay);
|
||||
bean.afterPropertiesSet();
|
||||
assertTimeEquals(startTime, bean.getStartTime());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStartDelayOverridesStartTime() throws Exception {
|
||||
CronTriggerBean bean = createTriggerBean();
|
||||
long startDelay = 1234L;
|
||||
Date startTime = new Date(System.currentTimeMillis() + startDelay);
|
||||
bean.setStartTime(new Date(System.currentTimeMillis() + 123456789L));
|
||||
bean.setStartDelay(startDelay);
|
||||
bean.afterPropertiesSet();
|
||||
assertTimeEquals(startTime, bean.getStartTime());
|
||||
}
|
||||
|
||||
private CronTriggerBean createTriggerBean() {
|
||||
CronTriggerBean triggerBean = new CronTriggerBean();
|
||||
triggerBean.setName("test");
|
||||
return triggerBean;
|
||||
}
|
||||
|
||||
private void assertTimeEquals(Date a, Date b) {
|
||||
Calendar ca = Calendar.getInstance();
|
||||
ca.setTime(a);
|
||||
ca.set(Calendar.MILLISECOND, 0);
|
||||
Calendar cb = Calendar.getInstance();
|
||||
cb.setTime(b);
|
||||
cb.set(Calendar.MILLISECOND, 0);
|
||||
assertEquals(ca, cb);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright 2002-2009 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.scheduling.quartz;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.context.support.AbstractApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.util.StopWatch;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
* @since 3.0
|
||||
*/
|
||||
public class QuartzSchedulerLifecycleTests {
|
||||
|
||||
@Test // SPR-6354
|
||||
public void destroyLazyInitSchedulerWithDefaultShutdownOrderDoesNotHang() {
|
||||
AbstractApplicationContext context = new ClassPathXmlApplicationContext("quartzSchedulerLifecycleTests.xml", this.getClass());
|
||||
assertNotNull(context.getBean("lazyInitSchedulerWithDefaultShutdownOrder"));
|
||||
StopWatch sw = new StopWatch();
|
||||
sw.start("lazyScheduler");
|
||||
context.destroy();
|
||||
sw.stop();
|
||||
assertTrue("Quartz Scheduler with lazy-init is hanging on destruction: " +
|
||||
sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 500);
|
||||
}
|
||||
|
||||
@Test // SPR-6354
|
||||
public void destroyLazyInitSchedulerWithCustomShutdownOrderDoesNotHang() {
|
||||
AbstractApplicationContext context = new ClassPathXmlApplicationContext("quartzSchedulerLifecycleTests.xml", this.getClass());
|
||||
assertNotNull(context.getBean("lazyInitSchedulerWithCustomShutdownOrder"));
|
||||
StopWatch sw = new StopWatch();
|
||||
sw.start("lazyScheduler");
|
||||
context.destroy();
|
||||
sw.stop();
|
||||
assertTrue("Quartz Scheduler with lazy-init is hanging on destruction: " +
|
||||
sw.getTotalTimeMillis(), sw.getTotalTimeMillis() < 500);
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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.scheduling.quartz;
|
||||
|
||||
/**
|
||||
* @author Rob Harrop
|
||||
*/
|
||||
public class QuartzTestBean {
|
||||
|
||||
private int importCount;
|
||||
|
||||
private int exportCount;
|
||||
|
||||
|
||||
public void doImport() {
|
||||
++importCount;
|
||||
}
|
||||
|
||||
public void doExport() {
|
||||
++exportCount;
|
||||
}
|
||||
|
||||
public int getImportCount() {
|
||||
return importCount;
|
||||
}
|
||||
|
||||
public int getExportCount() {
|
||||
return exportCount;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,247 @@
|
||||
/*
|
||||
* 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.ui.jasperreports;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.StringWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import net.sf.jasperreports.engine.JRDataSource;
|
||||
import net.sf.jasperreports.engine.JRParameter;
|
||||
import net.sf.jasperreports.engine.JasperFillManager;
|
||||
import net.sf.jasperreports.engine.JasperPrint;
|
||||
import net.sf.jasperreports.engine.JasperReport;
|
||||
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
|
||||
import net.sf.jasperreports.engine.export.JRCsvExporterParameter;
|
||||
import net.sf.jasperreports.engine.export.JRExportProgressMonitor;
|
||||
import net.sf.jasperreports.engine.export.JRHtmlExporter;
|
||||
import net.sf.jasperreports.engine.export.JRHtmlExporterParameter;
|
||||
import net.sf.jasperreports.engine.export.JRPdfExporter;
|
||||
import net.sf.jasperreports.engine.export.JRPdfExporterParameter;
|
||||
import net.sf.jasperreports.engine.export.JRXlsExporterParameter;
|
||||
import net.sf.jasperreports.engine.util.JRLoader;
|
||||
import org.apache.poi.hssf.usermodel.HSSFCell;
|
||||
import org.apache.poi.hssf.usermodel.HSSFRow;
|
||||
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
/**
|
||||
* @author Rob Harrop
|
||||
* @author Juergen Hoeller
|
||||
* @since 18.11.2004
|
||||
*/
|
||||
public class JasperReportsUtilsTests extends TestCase {
|
||||
|
||||
public void testRenderAsCsvWithDataSource() throws Exception {
|
||||
StringWriter writer = new StringWriter();
|
||||
JasperReportsUtils.renderAsCsv(getReport(), getParameters(), getDataSource(), writer);
|
||||
String output = writer.getBuffer().toString();
|
||||
assertCsvOutputCorrect(output);
|
||||
}
|
||||
|
||||
public void testRenderAsCsvWithCollection() throws Exception {
|
||||
StringWriter writer = new StringWriter();
|
||||
JasperReportsUtils.renderAsCsv(getReport(), getParameters(), getData(), writer);
|
||||
String output = writer.getBuffer().toString();
|
||||
assertCsvOutputCorrect(output);
|
||||
}
|
||||
|
||||
public void testRenderAsCsvWithExporterParameters() throws Exception {
|
||||
StringWriter writer = new StringWriter();
|
||||
Map exporterParameters = new HashMap();
|
||||
exporterParameters.put(JRCsvExporterParameter.FIELD_DELIMITER, "~");
|
||||
JasperReportsUtils.renderAsCsv(getReport(), getParameters(), getData(), writer, exporterParameters);
|
||||
String output = writer.getBuffer().toString();
|
||||
assertCsvOutputCorrect(output);
|
||||
assertTrue("Delimiter is incorrect", output.indexOf("~") > -1);
|
||||
}
|
||||
|
||||
public void testRenderAsHtmlWithDataSource() throws Exception {
|
||||
StringWriter writer = new StringWriter();
|
||||
JasperReportsUtils.renderAsHtml(getReport(), getParameters(), getDataSource(), writer);
|
||||
String output = writer.getBuffer().toString();
|
||||
assertHtmlOutputCorrect(output);
|
||||
}
|
||||
|
||||
public void testRenderAsHtmlWithCollection() throws Exception {
|
||||
StringWriter writer = new StringWriter();
|
||||
JasperReportsUtils.renderAsHtml(getReport(), getParameters(), getData(), writer);
|
||||
String output = writer.getBuffer().toString();
|
||||
assertHtmlOutputCorrect(output);
|
||||
}
|
||||
|
||||
public void testRenderAsHtmlWithExporterParameters() throws Exception {
|
||||
StringWriter writer = new StringWriter();
|
||||
Map exporterParameters = new HashMap();
|
||||
String uri = "/my/uri";
|
||||
exporterParameters.put(JRHtmlExporterParameter.IMAGES_URI, uri);
|
||||
JasperReportsUtils.renderAsHtml(getReport(), getParameters(), getData(), writer, exporterParameters);
|
||||
String output = writer.getBuffer().toString();
|
||||
assertHtmlOutputCorrect(output);
|
||||
assertTrue("URI not included", output.indexOf(uri) > -1);
|
||||
}
|
||||
|
||||
public void testRenderAsPdfWithDataSource() throws Exception {
|
||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||
JasperReportsUtils.renderAsPdf(getReport(), getParameters(), getDataSource(), os);
|
||||
byte[] output = os.toByteArray();
|
||||
assertPdfOutputCorrect(output);
|
||||
}
|
||||
|
||||
public void testRenderAsPdfWithCollection() throws Exception {
|
||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||
JasperReportsUtils.renderAsPdf(getReport(), getParameters(), getData(), os);
|
||||
byte[] output = os.toByteArray();
|
||||
assertPdfOutputCorrect(output);
|
||||
}
|
||||
|
||||
public void testRenderAsPdfWithExporterParameters() throws Exception {
|
||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||
Map exporterParameters = new HashMap();
|
||||
exporterParameters.put(JRPdfExporterParameter.PDF_VERSION, JRPdfExporterParameter.PDF_VERSION_1_6.toString());
|
||||
JasperReportsUtils.renderAsPdf(getReport(), getParameters(), getData(), os, exporterParameters);
|
||||
byte[] output = os.toByteArray();
|
||||
assertPdfOutputCorrect(output);
|
||||
assertTrue(new String(output).indexOf("PDF-1.6") > -1);
|
||||
}
|
||||
|
||||
public void testRenderAsXlsWithDataSource() throws Exception {
|
||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||
JasperReportsUtils.renderAsXls(getReport(), getParameters(), getDataSource(), os);
|
||||
byte[] output = os.toByteArray();
|
||||
assertXlsOutputCorrect(output);
|
||||
}
|
||||
|
||||
public void testRenderAsXlsWithCollection() throws Exception {
|
||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||
JasperReportsUtils.renderAsXls(getReport(), getParameters(), getData(), os);
|
||||
byte[] output = os.toByteArray();
|
||||
assertXlsOutputCorrect(output);
|
||||
}
|
||||
|
||||
public void testRenderAsXlsWithExporterParameters() throws Exception {
|
||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||
Map exporterParameters = new HashMap();
|
||||
|
||||
SimpleProgressMonitor monitor = new SimpleProgressMonitor();
|
||||
exporterParameters.put(JRXlsExporterParameter.PROGRESS_MONITOR, monitor);
|
||||
|
||||
JasperReportsUtils.renderAsXls(getReport(), getParameters(), getData(), os, exporterParameters);
|
||||
byte[] output = os.toByteArray();
|
||||
assertXlsOutputCorrect(output);
|
||||
assertTrue(monitor.isInvoked());
|
||||
}
|
||||
|
||||
public void testRenderWithWriter() throws Exception {
|
||||
StringWriter writer = new StringWriter();
|
||||
JasperPrint print = JasperFillManager.fillReport(getReport(), getParameters(), getDataSource());
|
||||
JasperReportsUtils.render(new JRHtmlExporter(), print, writer);
|
||||
String output = writer.getBuffer().toString();
|
||||
assertHtmlOutputCorrect(output);
|
||||
}
|
||||
|
||||
public void testRenderWithOutputStream() throws Exception {
|
||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||
JasperPrint print = JasperFillManager.fillReport(getReport(), getParameters(), getDataSource());
|
||||
JasperReportsUtils.render(new JRPdfExporter(), print, os);
|
||||
byte[] output = os.toByteArray();
|
||||
assertPdfOutputCorrect(output);
|
||||
}
|
||||
|
||||
private void assertCsvOutputCorrect(String output) {
|
||||
assertTrue("Output length should be greater than 0", (output.length() > 0));
|
||||
assertTrue("Output should start with Dear Lord!", output.startsWith("Dear Lord!"));
|
||||
assertTrue("Output should contain 'MeineSeite'", output.indexOf("MeineSeite") > -1);
|
||||
}
|
||||
|
||||
private void assertHtmlOutputCorrect(String output) {
|
||||
assertTrue("Output length should be greater than 0", (output.length() > 0));
|
||||
assertTrue("Output should contain <html>", output.indexOf("<html>") > -1);
|
||||
assertTrue("Output should contain 'MeineSeite'", output.indexOf("MeineSeite") > -1);
|
||||
}
|
||||
|
||||
private void assertPdfOutputCorrect(byte[] output) throws Exception {
|
||||
assertTrue("Output length should be greater than 0", (output.length > 0));
|
||||
|
||||
String translated = new String(output, "US-ASCII");
|
||||
assertTrue("Output should start with %PDF", translated.startsWith("%PDF"));
|
||||
}
|
||||
|
||||
private void assertXlsOutputCorrect(byte[] output) throws Exception {
|
||||
HSSFWorkbook workbook = new HSSFWorkbook(new ByteArrayInputStream(output));
|
||||
HSSFSheet sheet = workbook.getSheetAt(0);
|
||||
assertNotNull("Sheet should not be null", sheet);
|
||||
HSSFRow row = sheet.getRow(3);
|
||||
HSSFCell cell = row.getCell((short) 1);
|
||||
assertNotNull("Cell should not be null", cell);
|
||||
assertEquals("Cell content should be Dear Lord!", "Dear Lord!", cell.getStringCellValue());
|
||||
}
|
||||
|
||||
private JasperReport getReport() throws Exception {
|
||||
ClassPathResource resource = new ClassPathResource("DataSourceReport.jasper", getClass());
|
||||
return (JasperReport) JRLoader.loadObject(resource.getInputStream());
|
||||
}
|
||||
|
||||
private Map getParameters() {
|
||||
Map model = new HashMap();
|
||||
model.put("ReportTitle", "Dear Lord!");
|
||||
model.put(JRParameter.REPORT_LOCALE, Locale.GERMAN);
|
||||
model.put(JRParameter.REPORT_RESOURCE_BUNDLE,
|
||||
ResourceBundle.getBundle("org/springframework/ui/jasperreports/messages", Locale.GERMAN));
|
||||
return model;
|
||||
}
|
||||
|
||||
private JRDataSource getDataSource() {
|
||||
return new JRBeanCollectionDataSource(getData());
|
||||
}
|
||||
|
||||
private List getData() {
|
||||
List list = new ArrayList();
|
||||
for (int x = 0; x < 10; x++) {
|
||||
PersonBean bean = new PersonBean();
|
||||
bean.setId(x);
|
||||
bean.setName("Rob Harrop");
|
||||
bean.setStreet("foo");
|
||||
list.add(bean);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
private static class SimpleProgressMonitor implements JRExportProgressMonitor {
|
||||
|
||||
private boolean invoked = false;
|
||||
|
||||
public void afterPageExport() {
|
||||
this.invoked = true;
|
||||
}
|
||||
|
||||
public boolean isInvoked() {
|
||||
return invoked;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* 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.ui.jasperreports;
|
||||
|
||||
/**
|
||||
* @author Rob Harrop
|
||||
*/
|
||||
public class PersonBean {
|
||||
|
||||
private int id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String street;
|
||||
|
||||
private String city;
|
||||
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getStreet() {
|
||||
return street;
|
||||
}
|
||||
|
||||
public void setStreet(String street) {
|
||||
this.street = street;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* 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.ui.jasperreports;
|
||||
|
||||
/**
|
||||
* @author Rob Harrop
|
||||
*/
|
||||
public class ProductBean {
|
||||
|
||||
private int id;
|
||||
|
||||
private String name;
|
||||
|
||||
private float quantity;
|
||||
|
||||
private float price;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public float getQuantity() {
|
||||
return quantity;
|
||||
}
|
||||
|
||||
public void setQuantity(float quantity) {
|
||||
this.quantity = quantity;
|
||||
}
|
||||
|
||||
public float getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(float price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
}
|
||||
28
spring-context-support/src/test/resources/log4j.xml
Normal file
28
spring-context-support/src/test/resources/log4j.xml
Normal file
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
|
||||
|
||||
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
|
||||
|
||||
<!-- Appenders -->
|
||||
<appender name="console" class="org.apache.log4j.ConsoleAppender">
|
||||
<param name="Target" value="System.out" />
|
||||
<layout class="org.apache.log4j.PatternLayout">
|
||||
<param name="ConversionPattern" value="%-5p: %c - %m%n" />
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<logger name="org.springframework.beans">
|
||||
<level value="warn" />
|
||||
</logger>
|
||||
|
||||
<logger name="org.springframework.binding">
|
||||
<level value="debug" />
|
||||
</logger>
|
||||
|
||||
<!-- Root Logger -->
|
||||
<root>
|
||||
<priority value="warn" />
|
||||
<appender-ref ref="console" />
|
||||
</root>
|
||||
|
||||
</log4j:configuration>
|
||||
@@ -0,0 +1,4 @@
|
||||
text/foo foo
|
||||
text/bar bar
|
||||
image/foo fimg
|
||||
image/bar bimg
|
||||
@@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jdbc="http://www.springframework.org/schema/jdbc"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
<bean id="scheduler"
|
||||
class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
|
||||
<property name="triggers" ref="trigger" />
|
||||
<property name="dataSource" ref="dataSource"/>
|
||||
</bean>
|
||||
|
||||
<bean id="trigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean">
|
||||
<property name="repeatInterval" value="1000" />
|
||||
<property name="repeatCount" value="1" />
|
||||
<property name="jobDetail">
|
||||
<bean class="org.springframework.scheduling.quartz.JobDetailBean">
|
||||
<property name="jobDataAsMap">
|
||||
<map>
|
||||
<entry key="param" value="10" />
|
||||
</map>
|
||||
</property>
|
||||
<property name="jobClass"
|
||||
value="org.springframework.scheduling.quartz.QuartzSupportTests$DummyJob" />
|
||||
</bean>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<jdbc:embedded-database id="dataSource" type="HSQL">
|
||||
<jdbc:script location="org/springframework/scheduling/quartz/quartz-hsql.sql" />
|
||||
</jdbc:embedded-database>
|
||||
|
||||
</beans>
|
||||
@@ -0,0 +1,29 @@
|
||||
<quartz xmlns="http://www.opensymphony.com/quartz/JobSchedulingData"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.opensymphony.com/quartz/JobSchedulingData
|
||||
http://www.opensymphony.com/quartz/xml/job_scheduling_data_1_5.xsd"
|
||||
version="1.5">
|
||||
|
||||
<job>
|
||||
<job-detail>
|
||||
<name>myJob</name>
|
||||
<group>myGroup</group>
|
||||
<job-class>org.springframework.scheduling.quartz.QuartzSupportTests$DummyJob</job-class>
|
||||
<job-data-map>
|
||||
<entry>
|
||||
<key>param</key>
|
||||
<value>10</value>
|
||||
</entry>
|
||||
</job-data-map>
|
||||
</job-detail>
|
||||
<trigger>
|
||||
<simple>
|
||||
<name>myTrigger</name>
|
||||
<group>myGroup</group>
|
||||
<repeat-count>1</repeat-count>
|
||||
<repeat-interval>500</repeat-interval>
|
||||
</simple>
|
||||
</trigger>
|
||||
</job>
|
||||
|
||||
</quartz>
|
||||
@@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
|
||||
|
||||
<beans>
|
||||
|
||||
<bean id="scheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
|
||||
<property name="triggers">
|
||||
<list>
|
||||
<ref local="exportTrigger"/>
|
||||
<ref local="importTrigger"/>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="exportTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean">
|
||||
<property name="jobDetail">
|
||||
<bean class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
|
||||
<property name="targetObject" ref="exportService"/>
|
||||
<property name="targetMethod" value="doExport"/>
|
||||
</bean>
|
||||
</property>
|
||||
<property name="repeatInterval" value="1000"/>
|
||||
<property name="repeatCount" value="1"/>
|
||||
</bean>
|
||||
|
||||
<bean id="importTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean">
|
||||
<property name="jobDetail">
|
||||
<bean class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
|
||||
<property name="targetObject" ref="importService"/>
|
||||
<property name="targetMethod" value="doImport"/>
|
||||
</bean>
|
||||
</property>
|
||||
<property name="repeatInterval" value="1000"/>
|
||||
<property name="repeatCount" value="1"/>
|
||||
</bean>
|
||||
|
||||
<bean id="exportService" class="org.springframework.scheduling.quartz.QuartzTestBean"/>
|
||||
|
||||
<bean id="importService" class="org.springframework.scheduling.quartz.QuartzTestBean"/>
|
||||
|
||||
</beans>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
|
||||
|
||||
<beans>
|
||||
|
||||
<bean id="scheduler1" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
|
||||
<property name="schedulerName" value="quartz1"/>
|
||||
</bean>
|
||||
|
||||
<bean id="scheduler2" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
|
||||
<property name="schedulerName" value="quartz2"/>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
@@ -0,0 +1,152 @@
|
||||
DROP TABLE qrtz_locks IF EXISTS;
|
||||
DROP TABLE qrtz_scheduler_state IF EXISTS;
|
||||
DROP TABLE qrtz_fired_triggers IF EXISTS;
|
||||
DROP TABLE qrtz_paused_trigger_grps IF EXISTS;
|
||||
DROP TABLE qrtz_calendars IF EXISTS;
|
||||
DROP TABLE qrtz_trigger_listeners IF EXISTS;
|
||||
DROP TABLE qrtz_blob_triggers IF EXISTS;
|
||||
DROP TABLE qrtz_cron_triggers IF EXISTS;
|
||||
DROP TABLE qrtz_simple_triggers IF EXISTS;
|
||||
DROP TABLE qrtz_triggers IF EXISTS;
|
||||
DROP TABLE qrtz_job_listeners IF EXISTS;
|
||||
DROP TABLE qrtz_job_details IF EXISTS;
|
||||
|
||||
CREATE TABLE qrtz_job_details
|
||||
(
|
||||
JOB_NAME VARCHAR(200) NOT NULL,
|
||||
JOB_GROUP VARCHAR(200) NOT NULL,
|
||||
DESCRIPTION VARCHAR(250) NULL,
|
||||
JOB_CLASS_NAME VARCHAR(250) NOT NULL,
|
||||
IS_DURABLE VARCHAR(1) NOT NULL,
|
||||
IS_VOLATILE VARCHAR(1) NOT NULL,
|
||||
IS_STATEFUL VARCHAR(1) NOT NULL,
|
||||
REQUESTS_RECOVERY VARCHAR(1) NOT NULL,
|
||||
JOB_DATA BINARY NULL,
|
||||
PRIMARY KEY (JOB_NAME,JOB_GROUP)
|
||||
);
|
||||
|
||||
CREATE TABLE qrtz_job_listeners
|
||||
(
|
||||
JOB_NAME VARCHAR(200) NOT NULL,
|
||||
JOB_GROUP VARCHAR(200) NOT NULL,
|
||||
JOB_LISTENER VARCHAR(200) NOT NULL,
|
||||
PRIMARY KEY (JOB_NAME,JOB_GROUP,JOB_LISTENER),
|
||||
FOREIGN KEY (JOB_NAME,JOB_GROUP)
|
||||
REFERENCES QRTZ_JOB_DETAILS(JOB_NAME,JOB_GROUP)
|
||||
);
|
||||
|
||||
CREATE TABLE qrtz_triggers
|
||||
(
|
||||
TRIGGER_NAME VARCHAR(200) NOT NULL,
|
||||
TRIGGER_GROUP VARCHAR(200) NOT NULL,
|
||||
JOB_NAME VARCHAR(200) NOT NULL,
|
||||
JOB_GROUP VARCHAR(200) NOT NULL,
|
||||
IS_VOLATILE VARCHAR(1) NOT NULL,
|
||||
DESCRIPTION VARCHAR(250) NULL,
|
||||
NEXT_FIRE_TIME NUMERIC(13) NULL,
|
||||
PREV_FIRE_TIME NUMERIC(13) NULL,
|
||||
PRIORITY INTEGER NULL,
|
||||
TRIGGER_STATE VARCHAR(16) NOT NULL,
|
||||
TRIGGER_TYPE VARCHAR(8) NOT NULL,
|
||||
START_TIME NUMERIC(13) NOT NULL,
|
||||
END_TIME NUMERIC(13) NULL,
|
||||
CALENDAR_NAME VARCHAR(200) NULL,
|
||||
MISFIRE_INSTR NUMERIC(2) NULL,
|
||||
JOB_DATA BINARY NULL,
|
||||
PRIMARY KEY (TRIGGER_NAME,TRIGGER_GROUP),
|
||||
FOREIGN KEY (JOB_NAME,JOB_GROUP)
|
||||
REFERENCES QRTZ_JOB_DETAILS(JOB_NAME,JOB_GROUP)
|
||||
);
|
||||
|
||||
CREATE TABLE qrtz_simple_triggers
|
||||
(
|
||||
TRIGGER_NAME VARCHAR(200) NOT NULL,
|
||||
TRIGGER_GROUP VARCHAR(200) NOT NULL,
|
||||
REPEAT_COUNT NUMERIC(7) NOT NULL,
|
||||
REPEAT_INTERVAL NUMERIC(12) NOT NULL,
|
||||
TIMES_TRIGGERED NUMERIC(7) NOT NULL,
|
||||
PRIMARY KEY (TRIGGER_NAME,TRIGGER_GROUP),
|
||||
FOREIGN KEY (TRIGGER_NAME,TRIGGER_GROUP)
|
||||
REFERENCES QRTZ_TRIGGERS(TRIGGER_NAME,TRIGGER_GROUP)
|
||||
);
|
||||
|
||||
CREATE TABLE qrtz_cron_triggers
|
||||
(
|
||||
TRIGGER_NAME VARCHAR(200) NOT NULL,
|
||||
TRIGGER_GROUP VARCHAR(200) NOT NULL,
|
||||
CRON_EXPRESSION VARCHAR(120) NOT NULL,
|
||||
TIME_ZONE_ID VARCHAR(80),
|
||||
PRIMARY KEY (TRIGGER_NAME,TRIGGER_GROUP),
|
||||
FOREIGN KEY (TRIGGER_NAME,TRIGGER_GROUP)
|
||||
REFERENCES QRTZ_TRIGGERS(TRIGGER_NAME,TRIGGER_GROUP)
|
||||
);
|
||||
|
||||
CREATE TABLE qrtz_blob_triggers
|
||||
(
|
||||
TRIGGER_NAME VARCHAR(200) NOT NULL,
|
||||
TRIGGER_GROUP VARCHAR(200) NOT NULL,
|
||||
BLOB_DATA BINARY NULL,
|
||||
PRIMARY KEY (TRIGGER_NAME,TRIGGER_GROUP),
|
||||
FOREIGN KEY (TRIGGER_NAME,TRIGGER_GROUP)
|
||||
REFERENCES QRTZ_TRIGGERS(TRIGGER_NAME,TRIGGER_GROUP)
|
||||
);
|
||||
|
||||
CREATE TABLE qrtz_trigger_listeners
|
||||
(
|
||||
TRIGGER_NAME VARCHAR(200) NOT NULL,
|
||||
TRIGGER_GROUP VARCHAR(200) NOT NULL,
|
||||
TRIGGER_LISTENER VARCHAR(200) NOT NULL,
|
||||
PRIMARY KEY (TRIGGER_NAME,TRIGGER_GROUP,TRIGGER_LISTENER),
|
||||
FOREIGN KEY (TRIGGER_NAME,TRIGGER_GROUP)
|
||||
REFERENCES QRTZ_TRIGGERS(TRIGGER_NAME,TRIGGER_GROUP)
|
||||
);
|
||||
|
||||
CREATE TABLE qrtz_calendars
|
||||
(
|
||||
CALENDAR_NAME VARCHAR(200) NOT NULL,
|
||||
CALENDAR BINARY NOT NULL,
|
||||
PRIMARY KEY (CALENDAR_NAME)
|
||||
);
|
||||
|
||||
CREATE TABLE qrtz_paused_trigger_grps
|
||||
(
|
||||
TRIGGER_GROUP VARCHAR(200) NOT NULL,
|
||||
PRIMARY KEY (TRIGGER_GROUP)
|
||||
);
|
||||
|
||||
CREATE TABLE qrtz_fired_triggers
|
||||
(
|
||||
ENTRY_ID VARCHAR(95) NOT NULL,
|
||||
TRIGGER_NAME VARCHAR(200) NOT NULL,
|
||||
TRIGGER_GROUP VARCHAR(200) NOT NULL,
|
||||
IS_VOLATILE VARCHAR(1) NOT NULL,
|
||||
INSTANCE_NAME VARCHAR(200) NOT NULL,
|
||||
FIRED_TIME NUMERIC(13) NOT NULL,
|
||||
PRIORITY INTEGER NOT NULL,
|
||||
STATE VARCHAR(16) NOT NULL,
|
||||
JOB_NAME VARCHAR(200) NULL,
|
||||
JOB_GROUP VARCHAR(200) NULL,
|
||||
IS_STATEFUL VARCHAR(1) NULL,
|
||||
REQUESTS_RECOVERY VARCHAR(1) NULL,
|
||||
PRIMARY KEY (ENTRY_ID)
|
||||
);
|
||||
|
||||
CREATE TABLE qrtz_scheduler_state
|
||||
(
|
||||
INSTANCE_NAME VARCHAR(200) NOT NULL,
|
||||
LAST_CHECKIN_TIME NUMERIC(13) NOT NULL,
|
||||
CHECKIN_INTERVAL NUMERIC(13) NOT NULL,
|
||||
PRIMARY KEY (INSTANCE_NAME)
|
||||
);
|
||||
|
||||
CREATE TABLE qrtz_locks
|
||||
(
|
||||
LOCK_NAME VARCHAR(40) NOT NULL,
|
||||
PRIMARY KEY (LOCK_NAME)
|
||||
);
|
||||
|
||||
INSERT INTO qrtz_locks values('TRIGGER_ACCESS');
|
||||
INSERT INTO qrtz_locks values('JOB_ACCESS');
|
||||
INSERT INTO qrtz_locks values('CALENDAR_ACCESS');
|
||||
INSERT INTO qrtz_locks values('STATE_ACCESS');
|
||||
INSERT INTO qrtz_locks values('MISFIRE_ACCESS');
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
<bean id="lazyInitSchedulerWithDefaultShutdownOrder" class="org.springframework.scheduling.quartz.SchedulerFactoryBean" lazy-init="true"/>
|
||||
|
||||
<bean id="lazyInitSchedulerWithCustomShutdownOrder" class="org.springframework.scheduling.quartz.SchedulerFactoryBean" lazy-init="true">
|
||||
<property name="phase" value="99"/>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
@@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
|
||||
|
||||
<beans>
|
||||
|
||||
<bean id="scheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"/>
|
||||
|
||||
<bean class="org.springframework.scheduling.quartz.SchedulerAccessorBean">
|
||||
<property name="scheduler" ref="scheduler"/>
|
||||
<property name="triggers">
|
||||
<list>
|
||||
<ref local="exportTrigger"/>
|
||||
<ref local="importTrigger"/>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="exportTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean">
|
||||
<property name="jobDetail">
|
||||
<bean class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
|
||||
<property name="targetObject" ref="exportService"/>
|
||||
<property name="targetMethod" value="doExport"/>
|
||||
</bean>
|
||||
</property>
|
||||
<property name="repeatInterval" value="1000"/>
|
||||
<property name="repeatCount" value="1"/>
|
||||
</bean>
|
||||
|
||||
<bean id="importTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean">
|
||||
<property name="jobDetail">
|
||||
<bean class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
|
||||
<property name="targetObject" ref="importService"/>
|
||||
<property name="targetMethod" value="doImport"/>
|
||||
</bean>
|
||||
</property>
|
||||
<property name="repeatInterval" value="1000"/>
|
||||
<property name="repeatCount" value="1"/>
|
||||
</bean>
|
||||
|
||||
<bean id="exportService" class="org.springframework.scheduling.quartz.QuartzTestBean"/>
|
||||
|
||||
<bean id="importService" class="org.springframework.scheduling.quartz.QuartzTestBean"/>
|
||||
|
||||
</beans>
|
||||
@@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
|
||||
|
||||
<beans>
|
||||
|
||||
<bean id="scheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
|
||||
<property name="schedulerName" value="myScheduler"/>
|
||||
<property name="exposeSchedulerInRepository" value="true"/>
|
||||
</bean>
|
||||
|
||||
<bean class="org.springframework.scheduling.quartz.SchedulerAccessorBean">
|
||||
<property name="schedulerName" value="myScheduler"/>
|
||||
<property name="triggers">
|
||||
<list>
|
||||
<ref local="exportTrigger"/>
|
||||
<ref local="importTrigger"/>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="exportTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean">
|
||||
<property name="jobDetail">
|
||||
<bean class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
|
||||
<property name="targetObject" ref="exportService"/>
|
||||
<property name="targetMethod" value="doExport"/>
|
||||
</bean>
|
||||
</property>
|
||||
<property name="repeatInterval" value="1000"/>
|
||||
<property name="repeatCount" value="1"/>
|
||||
</bean>
|
||||
|
||||
<bean id="importTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean">
|
||||
<property name="jobDetail">
|
||||
<bean class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
|
||||
<property name="targetObject" ref="importService"/>
|
||||
<property name="targetMethod" value="doImport"/>
|
||||
</bean>
|
||||
</property>
|
||||
<property name="repeatInterval" value="1000"/>
|
||||
<property name="repeatCount" value="1"/>
|
||||
</bean>
|
||||
|
||||
<bean id="exportService" class="org.springframework.scheduling.quartz.QuartzTestBean"/>
|
||||
|
||||
<bean id="importService" class="org.springframework.scheduling.quartz.QuartzTestBean"/>
|
||||
|
||||
</beans>
|
||||
Binary file not shown.
@@ -0,0 +1,185 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Created using JasperAssistant (http://www.jasperassistant.com) -->
|
||||
<!DOCTYPE jasperReport PUBLIC "-//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">
|
||||
|
||||
<jasperReport name="DataSourceReport" pageWidth="595" pageHeight="842" columnWidth="515" leftMargin="40" rightMargin="40" topMargin="50" bottomMargin="50">
|
||||
<reportFont name="Arial_Normal" isDefault="true" fontName="Arial" size="12" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
|
||||
<reportFont name="Arial_Bold" isDefault="false" fontName="Arial" size="12" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
|
||||
<reportFont name="Arial_Italic" isDefault="false" fontName="Arial" size="12" isBold="false" isItalic="true" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Oblique" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
|
||||
<parameter name="ReportTitle" class="java.lang.String">
|
||||
</parameter>
|
||||
<parameter name="DataFile" class="java.lang.String">
|
||||
</parameter>
|
||||
<field name="id" class="java.lang.Integer">
|
||||
</field>
|
||||
<field name="name" class="java.lang.String">
|
||||
</field>
|
||||
<field name="street" class="java.lang.String">
|
||||
</field>
|
||||
<field name="city" class="java.lang.String">
|
||||
</field>
|
||||
<variable name="CityNumber" class="java.lang.Integer" resetType="Group" resetGroup="CityGroup" calculation="System">
|
||||
<initialValueExpression><![CDATA[($V{CityNumber} != null)?(new Integer($V{CityNumber}.intValue() + 1)):(new Integer(1))]]></initialValueExpression>
|
||||
</variable>
|
||||
<group name="CityGroup" minHeightToStartNewPage="60">
|
||||
<groupExpression><![CDATA[$F{city}]]></groupExpression>
|
||||
<groupHeader>
|
||||
<band height="20">
|
||||
<rectangle>
|
||||
<reportElement x="0" y="4" width="515" height="15" forecolor="#c0c0c0" backcolor="#c0c0c0"/>
|
||||
<graphicElement/>
|
||||
</rectangle>
|
||||
<textField>
|
||||
<reportElement mode="Opaque" x="0" y="4" width="515" height="15" backcolor="#c0c0c0"/>
|
||||
<textElement>
|
||||
<font reportFont="Arial_Bold"/>
|
||||
</textElement>
|
||||
<textFieldExpression class="java.lang.String"><![CDATA[" " + String.valueOf($V{CityNumber}) + ". " + String.valueOf($F{city})]]></textFieldExpression>
|
||||
</textField>
|
||||
<line>
|
||||
<reportElement x="0" y="19" width="515" height="1"/>
|
||||
<graphicElement/>
|
||||
</line>
|
||||
</band>
|
||||
</groupHeader>
|
||||
<groupFooter>
|
||||
<band height="20">
|
||||
<line>
|
||||
<reportElement x="0" y="-1" width="515" height="1"/>
|
||||
<graphicElement/>
|
||||
</line>
|
||||
<staticText>
|
||||
<reportElement x="400" y="1" width="60" height="15"/>
|
||||
<textElement textAlignment="Right">
|
||||
<font reportFont="Arial_Bold"/>
|
||||
</textElement>
|
||||
<text><![CDATA[Count :]]></text>
|
||||
</staticText>
|
||||
<textField>
|
||||
<reportElement x="460" y="1" width="30" height="15"/>
|
||||
<textElement textAlignment="Right">
|
||||
<font reportFont="Arial_Bold"/>
|
||||
</textElement>
|
||||
<textFieldExpression class="java.lang.Integer"><![CDATA[$V{CityGroup_COUNT}]]></textFieldExpression>
|
||||
</textField>
|
||||
</band>
|
||||
</groupFooter>
|
||||
</group>
|
||||
<title>
|
||||
<band height="70">
|
||||
<line>
|
||||
<reportElement x="0" y="0" width="515" height="1"/>
|
||||
<graphicElement/>
|
||||
</line>
|
||||
<textField isBlankWhenNull="true">
|
||||
<reportElement x="0" y="10" width="515" height="30"/>
|
||||
<textElement textAlignment="Center">
|
||||
<font reportFont="Arial_Normal" size="22"/>
|
||||
</textElement>
|
||||
<textFieldExpression class="java.lang.String"><![CDATA[$P{ReportTitle}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField isBlankWhenNull="true">
|
||||
<reportElement x="0" y="40" width="515" height="20"/>
|
||||
<textElement textAlignment="Center">
|
||||
<font reportFont="Arial_Normal" size="14"/>
|
||||
</textElement>
|
||||
<textFieldExpression class="java.lang.String"><![CDATA[$P{DataFile}]]></textFieldExpression>
|
||||
</textField>
|
||||
</band>
|
||||
</title>
|
||||
<pageHeader>
|
||||
<band height="20">
|
||||
<rectangle>
|
||||
<reportElement x="0" y="5" width="515" height="15" forecolor="#333333" backcolor="#333333"/>
|
||||
<graphicElement/>
|
||||
</rectangle>
|
||||
<staticText>
|
||||
<reportElement mode="Opaque" x="0" y="5" width="55" height="15" forecolor="#ffffff" backcolor="#333333"/>
|
||||
<textElement textAlignment="Center">
|
||||
<font reportFont="Arial_Bold"/>
|
||||
</textElement>
|
||||
<text><![CDATA[ID]]></text>
|
||||
</staticText>
|
||||
<staticText>
|
||||
<reportElement mode="Opaque" x="55" y="5" width="205" height="15" forecolor="#ffffff" backcolor="#333333"/>
|
||||
<textElement>
|
||||
<font reportFont="Arial_Bold"/>
|
||||
</textElement>
|
||||
<text><![CDATA[Name]]></text>
|
||||
</staticText>
|
||||
<staticText>
|
||||
<reportElement mode="Opaque" x="260" y="5" width="255" height="15" forecolor="#ffffff" backcolor="#333333"/>
|
||||
<textElement>
|
||||
<font reportFont="Arial_Bold"/>
|
||||
</textElement>
|
||||
<text><![CDATA[Street]]></text>
|
||||
</staticText>
|
||||
</band>
|
||||
</pageHeader>
|
||||
<detail>
|
||||
<band height="20">
|
||||
<textField>
|
||||
<reportElement x="0" y="4" width="50" height="15"/>
|
||||
<textElement textAlignment="Right"/>
|
||||
<textFieldExpression class="java.lang.Integer"><![CDATA[$F{id}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField isStretchWithOverflow="true">
|
||||
<reportElement positionType="Float" x="55" y="4" width="200" height="15"/>
|
||||
<textElement/>
|
||||
<textFieldExpression class="java.lang.String"><![CDATA[$F{name}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField isStretchWithOverflow="true">
|
||||
<reportElement positionType="Float" x="260" y="4" width="255" height="15"/>
|
||||
<textElement/>
|
||||
<textFieldExpression class="java.lang.String"><![CDATA[$F{street}]]></textFieldExpression>
|
||||
</textField>
|
||||
<line>
|
||||
<reportElement positionType="Float" x="0" y="19" width="515" height="1" forecolor="#808080"/>
|
||||
<graphicElement/>
|
||||
</line>
|
||||
</band>
|
||||
</detail>
|
||||
<pageFooter>
|
||||
<band height="40">
|
||||
<line>
|
||||
<reportElement x="0" y="10" width="515" height="1"/>
|
||||
<graphicElement/>
|
||||
</line>
|
||||
<textField>
|
||||
<reportElement x="200" y="20" width="80" height="15"/>
|
||||
<textElement textAlignment="Right"/>
|
||||
<textFieldExpression class="java.lang.String"><![CDATA[$R{page} + " " + String.valueOf($V{PAGE_NUMBER}) + " of"]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField evaluationTime="Report">
|
||||
<reportElement x="280" y="20" width="75" height="15"/>
|
||||
<textElement/>
|
||||
<textFieldExpression class="java.lang.String"><![CDATA[" " + String.valueOf($V{PAGE_NUMBER})]]></textFieldExpression>
|
||||
</textField>
|
||||
</band>
|
||||
</pageFooter>
|
||||
<lastPageFooter>
|
||||
<band height="60">
|
||||
<textField>
|
||||
<reportElement x="0" y="10" width="515" height="15"/>
|
||||
<textElement textAlignment="Center"/>
|
||||
<textFieldExpression class="java.lang.String"><![CDATA["There were " +
|
||||
String.valueOf($V{REPORT_COUNT}) +
|
||||
" address records on this report."]]></textFieldExpression>
|
||||
</textField>
|
||||
<line>
|
||||
<reportElement x="0" y="30" width="515" height="1"/>
|
||||
<graphicElement/>
|
||||
</line>
|
||||
<textField>
|
||||
<reportElement x="200" y="40" width="80" height="15"/>
|
||||
<textElement textAlignment="Right"/>
|
||||
<textFieldExpression class="java.lang.String"><![CDATA[$R{page} + " " + String.valueOf($V{PAGE_NUMBER}) + " of"]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField evaluationTime="Report">
|
||||
<reportElement x="280" y="40" width="75" height="15"/>
|
||||
<textElement/>
|
||||
<textFieldExpression class="java.lang.String"><![CDATA[" " + String.valueOf($V{PAGE_NUMBER})]]></textFieldExpression>
|
||||
</textField>
|
||||
</band>
|
||||
</lastPageFooter>
|
||||
</jasperReport>
|
||||
@@ -0,0 +1 @@
|
||||
page=MeineSeite
|
||||
Binary file not shown.
@@ -0,0 +1,227 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Created using JasperAssistant (http://www.jasperassistant.com) -->
|
||||
<!DOCTYPE jasperReport PUBLIC "-//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">
|
||||
|
||||
<jasperReport name="ProductReport" columnCount="2" pageWidth="325" pageHeight="842" columnWidth="160" columnSpacing="5" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0">
|
||||
<reportFont name="Arial_Normal" isDefault="true" fontName="Arial" size="8" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
|
||||
<reportFont name="Arial_Bold" isDefault="false" fontName="Arial" size="8" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
|
||||
<reportFont name="Arial_Italic" isDefault="false" fontName="Arial" size="8" isBold="false" isItalic="true" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Oblique" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
|
||||
<parameter name="City" class="java.lang.String"/>
|
||||
<field name="id" class="java.lang.Integer">
|
||||
</field>
|
||||
<field name="name" class="java.lang.String">
|
||||
</field>
|
||||
<field name="quantity" class="java.lang.Float">
|
||||
</field>
|
||||
<field name="price" class="java.lang.Float">
|
||||
</field>
|
||||
<variable name="QuantityProductSum" class="java.lang.Float" resetType="Group" resetGroup="ProductGroup" calculation="Sum">
|
||||
<variableExpression><![CDATA[$F{quantity}]]></variableExpression>
|
||||
</variable>
|
||||
<variable name="PriceProductSum" class="java.lang.Float" resetType="Group" resetGroup="ProductGroup" calculation="Sum">
|
||||
<variableExpression><![CDATA[$F{price}]]></variableExpression>
|
||||
</variable>
|
||||
<variable name="QuantitySum" class="java.lang.Float" calculation="Sum">
|
||||
<variableExpression><![CDATA[$F{quantity}]]></variableExpression>
|
||||
</variable>
|
||||
<variable name="PriceSum" class="java.lang.Float" calculation="Sum">
|
||||
<variableExpression><![CDATA[$F{price}]]></variableExpression>
|
||||
</variable>
|
||||
<variable name="ProductCount" class="java.lang.Integer" resetType="Group" resetGroup="ProductGroup" calculation="System">
|
||||
<initialValueExpression><![CDATA[($V{ProductCount} != null)?(new Integer($V{ProductCount}.intValue() + 1)):(new Integer(1))]]></initialValueExpression>
|
||||
</variable>
|
||||
<group name="ProductGroup">
|
||||
<groupExpression><![CDATA[$F{id}]]></groupExpression>
|
||||
<groupHeader>
|
||||
<band height="14">
|
||||
<textField>
|
||||
<reportElement x="0" y="2" width="15" height="10"/>
|
||||
<textElement textAlignment="Right"/>
|
||||
<textFieldExpression class="java.lang.Integer"><![CDATA[$F{id}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField isStretchWithOverflow="true">
|
||||
<reportElement positionType="Float" x="20" y="2" width="80" height="10"/>
|
||||
<textElement/>
|
||||
<textFieldExpression class="java.lang.String"><![CDATA[$F{name}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField isStretchWithOverflow="true" evaluationTime="Group" evaluationGroup="ProductGroup" pattern="#0">
|
||||
<reportElement positionType="Float" x="105" y="2" width="20" height="10"/>
|
||||
<textElement textAlignment="Right"/>
|
||||
<textFieldExpression class="java.lang.Float"><![CDATA[$V{QuantityProductSum}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField isStretchWithOverflow="true" evaluationTime="Group" evaluationGroup="ProductGroup" pattern="#0.00">
|
||||
<reportElement positionType="Float" x="130" y="2" width="30" height="10"/>
|
||||
<textElement textAlignment="Right"/>
|
||||
<textFieldExpression class="java.lang.Float"><![CDATA[$V{PriceProductSum}]]></textFieldExpression>
|
||||
</textField>
|
||||
</band>
|
||||
</groupHeader>
|
||||
<groupFooter>
|
||||
<band>
|
||||
</band>
|
||||
</groupFooter>
|
||||
</group>
|
||||
<title>
|
||||
<band height="14">
|
||||
<staticText>
|
||||
<reportElement x="0" y="2" width="60" height="10"/>
|
||||
<textElement>
|
||||
<font reportFont="Arial_Italic"/>
|
||||
</textElement>
|
||||
<text><![CDATA[Title]]></text>
|
||||
</staticText>
|
||||
<textField>
|
||||
<reportElement x="0" y="2" width="325" height="10"/>
|
||||
<textElement textAlignment="Center">
|
||||
<font reportFont="Arial_Bold"/>
|
||||
</textElement>
|
||||
<textFieldExpression class="java.lang.String"><![CDATA["Products ordered by people in " + $P{City}]]></textFieldExpression>
|
||||
</textField>
|
||||
</band>
|
||||
</title>
|
||||
<pageHeader>
|
||||
<band height="14">
|
||||
<rectangle>
|
||||
<reportElement mode="Transparent" x="0" y="2" width="325" height="10" forecolor="#808000"/>
|
||||
<graphicElement pen="Thin"/>
|
||||
</rectangle>
|
||||
<staticText>
|
||||
<reportElement x="0" y="2" width="60" height="10" forecolor="#808000"/>
|
||||
<textElement>
|
||||
<font reportFont="Arial_Italic"/>
|
||||
</textElement>
|
||||
<text><![CDATA[Page Header]]></text>
|
||||
</staticText>
|
||||
</band>
|
||||
</pageHeader>
|
||||
<columnHeader>
|
||||
<band height="14">
|
||||
<rectangle>
|
||||
<reportElement x="0" y="2" width="160" height="10" forecolor="#ffff99" backcolor="#ffff99"/>
|
||||
<graphicElement/>
|
||||
</rectangle>
|
||||
<staticText>
|
||||
<reportElement mode="Opaque" x="0" y="2" width="20" height="10" backcolor="#ffff99"/>
|
||||
<textElement textAlignment="Center">
|
||||
<font reportFont="Arial_Bold"/>
|
||||
</textElement>
|
||||
<text><![CDATA[ID]]></text>
|
||||
</staticText>
|
||||
<staticText>
|
||||
<reportElement mode="Opaque" x="20" y="2" width="85" height="10" backcolor="#ffff99"/>
|
||||
<textElement>
|
||||
<font reportFont="Arial_Bold"/>
|
||||
</textElement>
|
||||
<text><![CDATA[Name]]></text>
|
||||
</staticText>
|
||||
<staticText>
|
||||
<reportElement mode="Opaque" x="105" y="2" width="20" height="10" backcolor="#ffff99"/>
|
||||
<textElement textAlignment="Right">
|
||||
<font reportFont="Arial_Bold"/>
|
||||
</textElement>
|
||||
<text><![CDATA[Qty]]></text>
|
||||
</staticText>
|
||||
<staticText>
|
||||
<reportElement mode="Opaque" x="125" y="2" width="35" height="10" backcolor="#ffff99"/>
|
||||
<textElement textAlignment="Right">
|
||||
<font reportFont="Arial_Bold"/>
|
||||
</textElement>
|
||||
<text><![CDATA[Price]]></text>
|
||||
</staticText>
|
||||
</band>
|
||||
</columnHeader>
|
||||
<columnFooter>
|
||||
<band height="14">
|
||||
<line>
|
||||
<reportElement x="0" y="1" width="160" height="1"/>
|
||||
<graphicElement pen="Thin"/>
|
||||
</line>
|
||||
<staticText>
|
||||
<reportElement x="0" y="2" width="60" height="10"/>
|
||||
<textElement>
|
||||
<font reportFont="Arial_Italic"/>
|
||||
</textElement>
|
||||
<text><![CDATA[Column Footer]]></text>
|
||||
</staticText>
|
||||
<staticText>
|
||||
<reportElement x="70" y="2" width="30" height="10"/>
|
||||
<textElement textAlignment="Right">
|
||||
<font reportFont="Arial_Bold"/>
|
||||
</textElement>
|
||||
<text><![CDATA[Total :]]></text>
|
||||
</staticText>
|
||||
<textField pattern="#0">
|
||||
<reportElement x="105" y="2" width="20" height="10"/>
|
||||
<textElement textAlignment="Right">
|
||||
<font reportFont="Arial_Bold"/>
|
||||
</textElement>
|
||||
<textFieldExpression class="java.lang.Float"><![CDATA[$V{QuantitySum}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField pattern="#0.00">
|
||||
<reportElement x="130" y="2" width="30" height="10"/>
|
||||
<textElement textAlignment="Right">
|
||||
<font reportFont="Arial_Bold"/>
|
||||
</textElement>
|
||||
<textFieldExpression class="java.lang.Float"><![CDATA[$V{PriceSum}]]></textFieldExpression>
|
||||
</textField>
|
||||
</band>
|
||||
</columnFooter>
|
||||
<pageFooter>
|
||||
<band height="14">
|
||||
<rectangle>
|
||||
<reportElement mode="Transparent" x="0" y="2" width="325" height="10" forecolor="#808000"/>
|
||||
<graphicElement pen="Thin"/>
|
||||
</rectangle>
|
||||
<staticText>
|
||||
<reportElement x="0" y="2" width="60" height="10" forecolor="#808000"/>
|
||||
<textElement>
|
||||
<font reportFont="Arial_Italic"/>
|
||||
</textElement>
|
||||
<text><![CDATA[Page Footer]]></text>
|
||||
</staticText>
|
||||
<textField>
|
||||
<reportElement x="150" y="2" width="100" height="10" forecolor="#808000"/>
|
||||
<textElement textAlignment="Right">
|
||||
<font reportFont="Arial_Italic"/>
|
||||
</textElement>
|
||||
<textFieldExpression class="java.lang.String"><![CDATA["Page " + String.valueOf($V{PAGE_NUMBER}) + " of "]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField evaluationTime="Report">
|
||||
<reportElement x="250" y="2" width="50" height="10" forecolor="#808000"/>
|
||||
<textElement>
|
||||
<font reportFont="Arial_Italic"/>
|
||||
</textElement>
|
||||
<textFieldExpression class="java.lang.Integer"><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression>
|
||||
</textField>
|
||||
</band>
|
||||
</pageFooter>
|
||||
<summary>
|
||||
<band height="14">
|
||||
<rectangle>
|
||||
<reportElement x="0" y="2" width="325" height="10" forecolor="#808000" backcolor="#808000"/>
|
||||
<graphicElement pen="Thin"/>
|
||||
</rectangle>
|
||||
<staticText>
|
||||
<reportElement mode="Opaque" x="0" y="2" width="230" height="10" backcolor="#808000"/>
|
||||
<textElement>
|
||||
<font reportFont="Arial_Italic"/>
|
||||
</textElement>
|
||||
<text><![CDATA[Summary]]></text>
|
||||
</staticText>
|
||||
<staticText>
|
||||
<reportElement mode="Opaque" x="230" y="2" width="55" height="10" backcolor="#808000"/>
|
||||
<textElement textAlignment="Right">
|
||||
<font reportFont="Arial_Bold"/>
|
||||
</textElement>
|
||||
<text><![CDATA[Count :]]></text>
|
||||
</staticText>
|
||||
<textField pattern="#0">
|
||||
<reportElement mode="Opaque" x="285" y="2" width="40" height="10" backcolor="#808000"/>
|
||||
<textElement textAlignment="Right">
|
||||
<font reportFont="Arial_Bold"/>
|
||||
</textElement>
|
||||
<textFieldExpression class="java.lang.Integer"><![CDATA[$V{ProductCount}]]></textFieldExpression>
|
||||
</textField>
|
||||
</band>
|
||||
</summary>
|
||||
</jasperReport>
|
||||
Binary file not shown.
@@ -0,0 +1,103 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Created using JasperAssistant (http://www.jasperassistant.com) -->
|
||||
<!DOCTYPE jasperReport PUBLIC "-//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">
|
||||
|
||||
<jasperReport name="MasterReport" pageWidth="595" pageHeight="842" columnWidth="515" leftMargin="40" rightMargin="40" topMargin="50" bottomMargin="50">
|
||||
<reportFont name="Arial_Normal" isDefault="true" fontName="Arial" size="12" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
|
||||
<reportFont name="Arial_Bold" isDefault="false" fontName="Arial" size="12" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
|
||||
<reportFont name="Arial_Italic" isDefault="false" fontName="Arial" size="12" isBold="false" isItalic="true" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Oblique" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
|
||||
<parameter name="ProductsSubReport" class="net.sf.jasperreports.engine.JasperReport"/>
|
||||
<parameter name="SubReportData" class="net.sf.jasperreports.engine.JRDataSource"/>
|
||||
<field name="city" class="java.lang.String">
|
||||
</field>
|
||||
<title>
|
||||
<band height="50">
|
||||
<line>
|
||||
<reportElement x="0" y="0" width="515" height="1"/>
|
||||
<graphicElement/>
|
||||
</line>
|
||||
<staticText>
|
||||
<reportElement x="0" y="10" width="515" height="30"/>
|
||||
<textElement textAlignment="Center">
|
||||
<font reportFont="Arial_Normal" size="22"/>
|
||||
</textElement>
|
||||
<text><![CDATA[Master Report]]></text>
|
||||
</staticText>
|
||||
</band>
|
||||
</title>
|
||||
<pageHeader>
|
||||
<band height="21">
|
||||
<rectangle>
|
||||
<reportElement x="0" y="5" width="515" height="15" backcolor="#333333"/>
|
||||
<graphicElement pen="None"/>
|
||||
</rectangle>
|
||||
<staticText>
|
||||
<reportElement mode="Opaque" x="0" y="5" width="515" height="15" forecolor="#ffffff" backcolor="#333333"/>
|
||||
<textElement>
|
||||
<font reportFont="Arial_Bold"/>
|
||||
</textElement>
|
||||
<text><![CDATA[City List]]></text>
|
||||
</staticText>
|
||||
<line>
|
||||
<reportElement x="0" y="20" width="515" height="1"/>
|
||||
<graphicElement/>
|
||||
</line>
|
||||
</band>
|
||||
</pageHeader>
|
||||
<detail>
|
||||
<band height="50">
|
||||
<textField>
|
||||
<reportElement x="5" y="5" width="100" height="15" isPrintWhenDetailOverflows="true"/>
|
||||
<textElement>
|
||||
<font reportFont="Arial_Bold"/>
|
||||
</textElement>
|
||||
<textFieldExpression class="java.lang.String"><![CDATA[$F{city}]]></textFieldExpression>
|
||||
</textField>
|
||||
<staticText>
|
||||
<reportElement isPrintRepeatedValues="false" x="110" y="5" width="100" height="15" isPrintWhenDetailOverflows="true"/>
|
||||
<textElement>
|
||||
<font reportFont="Arial_Bold"/>
|
||||
</textElement>
|
||||
<text><![CDATA[(continued)]]></text>
|
||||
</staticText>
|
||||
<line>
|
||||
<reportElement x="0" y="20" width="515" height="1" isPrintWhenDetailOverflows="true"/>
|
||||
<graphicElement/>
|
||||
</line>
|
||||
<subreport>
|
||||
<reportElement isPrintRepeatedValues="false" x="5" y="25" width="325" height="20" isRemoveLineWhenBlank="true" backcolor="#ffcc99"/>
|
||||
<subreportParameter name="City">
|
||||
<subreportParameterExpression><![CDATA[$F{city}]]></subreportParameterExpression>
|
||||
</subreportParameter>
|
||||
<dataSourceExpression><![CDATA[$P{SubReportData}]]></dataSourceExpression>
|
||||
<subreportExpression class="net.sf.jasperreports.engine.JasperReport"><![CDATA[$P{ProductsSubReport}]]></subreportExpression>
|
||||
</subreport>
|
||||
<!--<subreport>
|
||||
<reportElement positionType="Float" x="335" y="25" width="175" height="20" isRemoveLineWhenBlank="true" backcolor="#99ccff"/>
|
||||
<subreportParameter name="City">
|
||||
<subreportParameterExpression><![CDATA[$F{City}]]></subreportParameterExpression>
|
||||
</subreportParameter>
|
||||
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
|
||||
<subreportExpression class="java.lang.String"><![CDATA["AddressReport.jasper"]]></subreportExpression>
|
||||
</subreport> -->
|
||||
</band>
|
||||
</detail>
|
||||
<pageFooter>
|
||||
<band height="40">
|
||||
<line>
|
||||
<reportElement x="0" y="10" width="515" height="1"/>
|
||||
<graphicElement/>
|
||||
</line>
|
||||
<textField>
|
||||
<reportElement x="200" y="20" width="80" height="15"/>
|
||||
<textElement textAlignment="Right"/>
|
||||
<textFieldExpression class="java.lang.String"><![CDATA["Page " + String.valueOf($V{PAGE_NUMBER}) + " of"]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField evaluationTime="Report">
|
||||
<reportElement x="280" y="20" width="75" height="15"/>
|
||||
<textElement/>
|
||||
<textFieldExpression class="java.lang.String"><![CDATA[" " + String.valueOf($V{PAGE_NUMBER})]]></textFieldExpression>
|
||||
</textField>
|
||||
</band>
|
||||
</pageFooter>
|
||||
</jasperReport>
|
||||
Reference in New Issue
Block a user