Java 5 code style
This commit is contained in:
@@ -1,78 +0,0 @@
|
||||
/*
|
||||
* 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.factory.generic;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.springframework.beans.factory.xml.XmlBeanFactory;
|
||||
import org.springframework.beans.TestBean;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.test.AssertThrows;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Rob Harrop
|
||||
* @see 2.0
|
||||
*/
|
||||
public class GenericBeanFactoryAccessorTests extends TestCase {
|
||||
|
||||
private GenericBeanFactoryAccessor beanFactoryAccessor;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
XmlBeanFactory beanFactory = new XmlBeanFactory(new ClassPathResource("genericBeanFactoryAccessorTests.xml", getClass()));
|
||||
this.beanFactoryAccessor = new GenericBeanFactoryAccessor(beanFactory);
|
||||
}
|
||||
|
||||
public void testGetBean() throws Exception {
|
||||
TestBean testBean = this.beanFactoryAccessor.getBean("testBean");
|
||||
assertNotNull("TestBean should not be null", testBean);
|
||||
}
|
||||
|
||||
public void testGetBeanWithType() throws Exception {
|
||||
TestBean testBean = this.beanFactoryAccessor.getBean("testBean", TestBean.class);
|
||||
assertNotNull("TestBean should not be null", testBean);
|
||||
}
|
||||
|
||||
public void testGetBeanFails() throws Exception {
|
||||
new AssertThrows(ClassCastException.class) {
|
||||
public void test() throws Exception {
|
||||
Integer bean = beanFactoryAccessor.getBean("testBean");
|
||||
}
|
||||
}.runTest();
|
||||
}
|
||||
|
||||
public void testGetBeansOfType() throws Exception {
|
||||
Map<String, TestBean> beansOfType = this.beanFactoryAccessor.getBeansOfType(TestBean.class);
|
||||
assertEquals(3, beansOfType.size());
|
||||
assertNotNull(beansOfType.get("testBean"));
|
||||
assertNotNull(beansOfType.get("otherTestBean"));
|
||||
assertNotNull(beansOfType.get("prototypeTestBean"));
|
||||
}
|
||||
|
||||
public void testGetBeansOfTypeExtended() throws Exception {
|
||||
Map<String, TestBean> beansOfType = this.beanFactoryAccessor.getBeansOfType(TestBean.class, false, false);
|
||||
assertEquals(2, beansOfType.size());
|
||||
assertNotNull(beansOfType.get("testBean"));
|
||||
assertNotNull(beansOfType.get("otherTestBean"));
|
||||
}
|
||||
|
||||
public void testGetBeansWithAnnotation() throws Exception {
|
||||
Map<String, Object> beansWithAnnotation = this.beanFactoryAccessor.getBeansWithAnnotation(MyAnnotation.class);
|
||||
assertEquals(1, beansWithAnnotation.size());
|
||||
assertNotNull(beansWithAnnotation.get("annotatedBean"));
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
* 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.factory.generic;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.annotation.ElementType;
|
||||
|
||||
/**
|
||||
* @author Rob Harrop
|
||||
* @since 2.0
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface MyAnnotation {
|
||||
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
* 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.factory.generic;
|
||||
|
||||
/**
|
||||
* @author Rob Harrop
|
||||
* @since 2.0
|
||||
*/
|
||||
@MyAnnotation
|
||||
public class SomeAnnotatedBean {
|
||||
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
<?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="testBean" class="org.springframework.beans.TestBean"/>
|
||||
<bean id="otherTestBean" class="org.springframework.beans.TestBean"/>
|
||||
<bean id="prototypeTestBean" class="org.springframework.beans.TestBean" scope="prototype"/>
|
||||
<bean id="annotatedBean" class="org.springframework.beans.factory.generic.SomeAnnotatedBean"/>
|
||||
</beans>
|
||||
@@ -1,75 +0,0 @@
|
||||
package org.springframework.context.support;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.beans.MutablePropertyValues;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
/**
|
||||
* @author Juergen Hoeller
|
||||
* @since 25.04.2004
|
||||
*/
|
||||
public class ResourceMapFactoryBeanTests extends TestCase {
|
||||
|
||||
public void testResourceMapFactoryBeanWithoutContext() {
|
||||
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
|
||||
Properties props = new Properties();
|
||||
props.setProperty("test1", "classpath:org/springframework/context/support/contextA.xml");
|
||||
props.setProperty("test2", "classpath:org/springframework/context/support/contextB.xml");
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("properties", props);
|
||||
RootBeanDefinition bd = new RootBeanDefinition(ResourceMapFactoryBean.class, pvs);
|
||||
beanFactory.registerBeanDefinition("resourceMap", bd);
|
||||
Map result = (Map) beanFactory.getBean("resourceMap");
|
||||
assertEquals(2, result.size());
|
||||
assertTrue(result.get("test1") instanceof ClassPathResource);
|
||||
assertTrue(((Resource) result.get("test1")).getDescription().indexOf("contextA.xml") != -1);
|
||||
assertTrue(((Resource) result.get("test2")).getDescription().indexOf("contextB.xml") != -1);
|
||||
}
|
||||
|
||||
public void testResourceMapFactoryBeanWithContext() {
|
||||
StaticApplicationContext context = new StaticApplicationContext() {
|
||||
public Resource getResource(String location) {
|
||||
return super.getResource("classpath:org/springframework/context/support/context" + location);
|
||||
}
|
||||
};
|
||||
DefaultListableBeanFactory beanFactory = context.getDefaultListableBeanFactory();
|
||||
Properties props = new Properties();
|
||||
props.setProperty("test1", "A.xml");
|
||||
props.setProperty("test2", "B.xml");
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("properties", props);
|
||||
RootBeanDefinition bd = new RootBeanDefinition(ResourceMapFactoryBean.class, pvs);
|
||||
beanFactory.registerBeanDefinition("resourceMap", bd);
|
||||
context.refresh();
|
||||
Map result = (Map) beanFactory.getBean("resourceMap");
|
||||
assertEquals(2, result.size());
|
||||
assertTrue(result.get("test1") instanceof ClassPathResource);
|
||||
assertTrue(((Resource) result.get("test1")).getDescription().indexOf("contextA.xml") != -1);
|
||||
assertTrue(((Resource) result.get("test2")).getDescription().indexOf("contextB.xml") != -1);
|
||||
}
|
||||
|
||||
public void testResourceMapFactoryBeanWithResourceBasePath() {
|
||||
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
|
||||
Properties props = new Properties();
|
||||
props.setProperty("test1", "A.xml");
|
||||
props.setProperty("test2", "B.xml");
|
||||
MutablePropertyValues pvs = new MutablePropertyValues();
|
||||
pvs.addPropertyValue("properties", props);
|
||||
pvs.addPropertyValue("resourceBasePath", "classpath:org/springframework/context/support/context");
|
||||
RootBeanDefinition bd = new RootBeanDefinition(ResourceMapFactoryBean.class, pvs);
|
||||
beanFactory.registerBeanDefinition("resourceMap", bd);
|
||||
Map result = (Map) beanFactory.getBean("resourceMap");
|
||||
assertEquals(2, result.size());
|
||||
assertTrue(result.get("test1") instanceof ClassPathResource);
|
||||
assertTrue(((Resource) result.get("test1")).getDescription().indexOf("contextA.xml") != -1);
|
||||
assertTrue(((Resource) result.get("test2")).getDescription().indexOf("contextB.xml") != -1);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -20,6 +20,7 @@ import java.io.Serializable;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.TypeVariable;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
@@ -106,7 +107,7 @@ public class BridgeMethodResolverTests extends TestCase {
|
||||
}
|
||||
|
||||
public void testCreateTypeVariableMap() throws Exception {
|
||||
Map<String, Class> typeVariableMap = GenericTypeResolver.getTypeVariableMap(MyBar.class);
|
||||
Map<TypeVariable, Type> typeVariableMap = GenericTypeResolver.getTypeVariableMap(MyBar.class);
|
||||
TypeVariable barT = findTypeVariable(InterBar.class, "T");
|
||||
assertEquals(String.class, typeVariableMap.get(barT));
|
||||
|
||||
|
||||
@@ -19,14 +19,12 @@ package org.springframework.transaction.annotation;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.management.MBeanServer;
|
||||
import javax.management.ObjectName;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.aop.support.AopUtils;
|
||||
import org.springframework.beans.factory.generic.GenericBeanFactoryAccessor;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.jmx.export.annotation.ManagedOperation;
|
||||
@@ -54,7 +52,7 @@ public class AnnotationTransactionNamespaceHandlerTests extends TestCase {
|
||||
public void testIsProxy() throws Exception {
|
||||
TransactionalTestBean bean = getTestBean();
|
||||
assertTrue("testBean is not a proxy", AopUtils.isAopProxy(bean));
|
||||
Map services = new GenericBeanFactoryAccessor(this.context).getBeansWithAnnotation(Service.class);
|
||||
Map services = this.context.getBeansWithAnnotation(Service.class);
|
||||
assertTrue("Stereotype annotation not visible", services.containsKey("testBean"));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2005 the original author or authors.
|
||||
* 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.
|
||||
@@ -34,7 +34,7 @@ import org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver;
|
||||
|
||||
/**
|
||||
* @author Rob Harrop
|
||||
* @since 18.11.2004
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public abstract class AbstractJasperReportsTests extends TestCase {
|
||||
|
||||
@@ -71,7 +71,7 @@ public abstract class AbstractJasperReportsTests extends TestCase {
|
||||
}
|
||||
|
||||
|
||||
protected Map getModel() {
|
||||
protected Map<String, Object> getModel() {
|
||||
Map model = new HashMap();
|
||||
model.put("ReportTitle", "Dear Lord!");
|
||||
model.put("dataSource", new JRBeanCollectionDataSource(getData()));
|
||||
@@ -82,7 +82,7 @@ public abstract class AbstractJasperReportsTests extends TestCase {
|
||||
/**
|
||||
* Subclasses can extend the model if they need to.
|
||||
*/
|
||||
protected void extendModel(Map model) {
|
||||
protected void extendModel(Map<String, Object> model) {
|
||||
}
|
||||
|
||||
protected List getData() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2005 the original author or authors.
|
||||
* 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.
|
||||
@@ -19,19 +19,17 @@ package org.springframework.web.servlet.view.jasperreports;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import net.sf.jasperreports.engine.JasperPrint;
|
||||
import net.sf.jasperreports.engine.JRExporterParameter;
|
||||
|
||||
/**
|
||||
* @author Rob Harrop
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class JasperReportsMultiFormatViewTests extends AbstractJasperReportsViewTests {
|
||||
|
||||
protected void extendModel(Map model) {
|
||||
protected void extendModel(Map<String, Object> model) {
|
||||
model.put(getDiscriminatorKey(), "csv");
|
||||
}
|
||||
|
||||
@@ -42,7 +40,7 @@ public class JasperReportsMultiFormatViewTests extends AbstractJasperReportsView
|
||||
|
||||
AbstractJasperReportsView view = getView(UNCOMPILED_REPORT);
|
||||
|
||||
Map model = getBaseModel();
|
||||
Map<String, Object> model = getBaseModel();
|
||||
model.put(getDiscriminatorKey(), "html");
|
||||
|
||||
view.render(model, request, response);
|
||||
@@ -57,7 +55,7 @@ public class JasperReportsMultiFormatViewTests extends AbstractJasperReportsView
|
||||
|
||||
AbstractJasperReportsView view = getView(UNCOMPILED_REPORT);
|
||||
|
||||
Map model = getBaseModel();
|
||||
Map<String, Object> model = getBaseModel();
|
||||
model.put(getDiscriminatorKey(), "csv");
|
||||
|
||||
String headerValue = "inline; filename=foo.txt";
|
||||
@@ -80,10 +78,10 @@ public class JasperReportsMultiFormatViewTests extends AbstractJasperReportsView
|
||||
|
||||
JasperReportsMultiFormatView view = (JasperReportsMultiFormatView) getView(UNCOMPILED_REPORT);
|
||||
|
||||
Properties mappings = new Properties();
|
||||
mappings.put("test", ExporterParameterTestView.class.getName());
|
||||
Map<String, Class> mappings = new HashMap<String, Class>();
|
||||
mappings.put("test", ExporterParameterTestView.class);
|
||||
|
||||
Map exporterParameters = new HashMap();
|
||||
Map<String, String> exporterParameters = new HashMap<String, String>();
|
||||
|
||||
// test view class performs the assertions - robh
|
||||
exporterParameters.put(ExporterParameterTestView.TEST_PARAM, "foo");
|
||||
@@ -92,7 +90,7 @@ public class JasperReportsMultiFormatViewTests extends AbstractJasperReportsView
|
||||
view.setFormatMappings(mappings);
|
||||
view.initApplicationContext();
|
||||
|
||||
Map model = getBaseModel();
|
||||
Map<String, Object> model = getBaseModel();
|
||||
model.put(getDiscriminatorKey(), "test");
|
||||
|
||||
view.render(model, request, response);
|
||||
@@ -110,8 +108,8 @@ public class JasperReportsMultiFormatViewTests extends AbstractJasperReportsView
|
||||
return "text/csv";
|
||||
}
|
||||
|
||||
private Map getBaseModel() {
|
||||
Map model = new HashMap();
|
||||
private Map<String, Object> getBaseModel() {
|
||||
Map<String, Object> model = new HashMap<String, Object>();
|
||||
model.put("ReportTitle", "Foo");
|
||||
model.put("dataSource", getData());
|
||||
return model;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2005 the original author or authors.
|
||||
* 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.
|
||||
@@ -16,24 +16,23 @@
|
||||
|
||||
package org.springframework.web.servlet.view.jasperreports;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* @author Rob Harrop
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
public class JasperReportsMultiFormatViewWithCustomMappingsTests extends JasperReportsMultiFormatViewTests {
|
||||
|
||||
protected AbstractJasperReportsView getViewImplementation() {
|
||||
JasperReportsMultiFormatView view = new JasperReportsMultiFormatView();
|
||||
view.setFormatKey("fmt");
|
||||
|
||||
Properties props = new Properties();
|
||||
props.setProperty("csv", JasperReportsCsvView.class.getName());
|
||||
props.setProperty("comma-separated", JasperReportsCsvView.class.getName());
|
||||
props.setProperty("html", JasperReportsHtmlView.class.getName());
|
||||
|
||||
view.setFormatMappings(props);
|
||||
Map<String, Class> mappings = new HashMap<String, Class>();
|
||||
mappings.put("csv", JasperReportsCsvView.class);
|
||||
mappings.put("comma-separated", JasperReportsCsvView.class);
|
||||
mappings.put("html", JasperReportsHtmlView.class);
|
||||
view.setFormatMappings(mappings);
|
||||
return view;
|
||||
}
|
||||
|
||||
@@ -41,7 +40,7 @@ public class JasperReportsMultiFormatViewWithCustomMappingsTests extends JasperR
|
||||
return "fmt";
|
||||
}
|
||||
|
||||
protected void extendModel(Map model) {
|
||||
protected void extendModel(Map<String, Object> model) {
|
||||
model.put(getDiscriminatorKey(), "comma-separated");
|
||||
}
|
||||
|
||||
|
||||
@@ -20,15 +20,12 @@ import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.apache.velocity.Template;
|
||||
import org.apache.velocity.app.VelocityEngine;
|
||||
import org.apache.velocity.app.tools.VelocityFormatter;
|
||||
import org.apache.velocity.context.Context;
|
||||
import org.apache.velocity.exception.ParseErrorException;
|
||||
import org.apache.velocity.exception.ResourceNotFoundException;
|
||||
@@ -310,7 +307,6 @@ public class VelocityViewTests extends TestCase {
|
||||
assertTrue(response == expectedResponse);
|
||||
|
||||
assertEquals("myValue", context.get("myHelper"));
|
||||
assertTrue(context.get("velocityFormatter") instanceof VelocityFormatter);
|
||||
assertTrue(context.get("math") instanceof MathTool);
|
||||
|
||||
assertTrue(context.get("dateTool") instanceof DateTool);
|
||||
@@ -329,10 +325,9 @@ public class VelocityViewTests extends TestCase {
|
||||
|
||||
vv.setUrl(templateName);
|
||||
vv.setApplicationContext(wac);
|
||||
Properties toolAttributes = new Properties();
|
||||
toolAttributes.setProperty("math", MathTool.class.getName());
|
||||
Map<String, Class> toolAttributes = new HashMap<String, Class>();
|
||||
toolAttributes.put("math", MathTool.class);
|
||||
vv.setToolAttributes(toolAttributes);
|
||||
vv.setVelocityFormatterAttribute("velocityFormatter");
|
||||
vv.setDateToolAttribute("dateTool");
|
||||
vv.setNumberToolAttribute("numberTool");
|
||||
vv.setExposeSpringMacroHelpers(false);
|
||||
@@ -383,9 +378,9 @@ public class VelocityViewTests extends TestCase {
|
||||
|
||||
vv.setUrl(templateName);
|
||||
vv.setApplicationContext(wac);
|
||||
Properties toolAttributes = new Properties();
|
||||
toolAttributes.setProperty("math", MathTool.class.getName());
|
||||
toolAttributes.setProperty("link2", LinkTool.class.getName());
|
||||
Map<String, Class> toolAttributes = new HashMap<String, Class>();
|
||||
toolAttributes.put("math", MathTool.class);
|
||||
toolAttributes.put("link2", LinkTool.class);
|
||||
vv.setToolAttributes(toolAttributes);
|
||||
vv.setToolboxConfigLocation("org/springframework/web/servlet/view/velocity/toolbox.xml");
|
||||
vv.setExposeSpringMacroHelpers(false);
|
||||
|
||||
Reference in New Issue
Block a user