Browse Source
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@258 50f2f4bb-b051-0410-bef5-90022cba6387pull/1/head
17 changed files with 1079 additions and 374 deletions
@ -1,90 +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.web.bind; |
|
||||||
|
|
||||||
import junit.framework.TestCase; |
|
||||||
|
|
||||||
import org.springframework.beans.TestBean; |
|
||||||
import org.springframework.validation.BindException; |
|
||||||
import org.springframework.validation.Errors; |
|
||||||
import org.springframework.validation.FieldError; |
|
||||||
import org.springframework.validation.ObjectError; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author Juergen Hoeller |
|
||||||
* @since 02.05.2003 |
|
||||||
*/ |
|
||||||
public class EscapedErrorsTests extends TestCase { |
|
||||||
|
|
||||||
public void testEscapedErrors() { |
|
||||||
TestBean tb = new TestBean(); |
|
||||||
tb.setName("empty &"); |
|
||||||
|
|
||||||
Errors errors = new EscapedErrors(new BindException(tb, "tb")); |
|
||||||
errors.rejectValue("name", "NAME_EMPTY &", null, "message: &"); |
|
||||||
errors.rejectValue("age", "AGE_NOT_SET <tag>", null, "message: <tag>"); |
|
||||||
errors.rejectValue("age", "AGE_NOT_32 <tag>", null, "message: <tag>"); |
|
||||||
errors.reject("GENERAL_ERROR \" '", null, "message: \" '"); |
|
||||||
|
|
||||||
assertTrue("Correct errors flag", errors.hasErrors()); |
|
||||||
assertTrue("Correct number of errors", errors.getErrorCount() == 4); |
|
||||||
assertTrue("Correct object name", "tb".equals(errors.getObjectName())); |
|
||||||
|
|
||||||
assertTrue("Correct global errors flag", errors.hasGlobalErrors()); |
|
||||||
assertTrue("Correct number of global errors", errors.getGlobalErrorCount() == 1); |
|
||||||
ObjectError globalError = errors.getGlobalError(); |
|
||||||
assertTrue("Global error message escaped", "message: " '".equals(globalError.getDefaultMessage())); |
|
||||||
assertTrue("Global error code not escaped", "GENERAL_ERROR \" '".equals(globalError.getCode())); |
|
||||||
ObjectError globalErrorInList = (ObjectError) errors.getGlobalErrors().get(0); |
|
||||||
assertTrue("Same global error in list", globalError.getDefaultMessage().equals(globalErrorInList.getDefaultMessage())); |
|
||||||
ObjectError globalErrorInAllList = (ObjectError) errors.getAllErrors().get(3); |
|
||||||
assertTrue("Same global error in list", globalError.getDefaultMessage().equals(globalErrorInAllList.getDefaultMessage())); |
|
||||||
|
|
||||||
assertTrue("Correct field errors flag", errors.hasFieldErrors()); |
|
||||||
assertTrue("Correct number of field errors", errors.getFieldErrorCount() == 3); |
|
||||||
assertTrue("Correct number of field errors in list", errors.getFieldErrors().size() == 3); |
|
||||||
FieldError fieldError = errors.getFieldError(); |
|
||||||
assertTrue("Field error code not escaped", "NAME_EMPTY &".equals(fieldError.getCode())); |
|
||||||
assertTrue("Field value escaped", "empty &".equals(errors.getFieldValue("name"))); |
|
||||||
FieldError fieldErrorInList = (FieldError) errors.getFieldErrors().get(0); |
|
||||||
assertTrue("Same field error in list", fieldError.getDefaultMessage().equals(fieldErrorInList.getDefaultMessage())); |
|
||||||
|
|
||||||
assertTrue("Correct name errors flag", errors.hasFieldErrors("name")); |
|
||||||
assertTrue("Correct number of name errors", errors.getFieldErrorCount("name") == 1); |
|
||||||
assertTrue("Correct number of name errors in list", errors.getFieldErrors("name").size() == 1); |
|
||||||
FieldError nameError = errors.getFieldError("name"); |
|
||||||
assertTrue("Name error message escaped", "message: &".equals(nameError.getDefaultMessage())); |
|
||||||
assertTrue("Name error code not escaped", "NAME_EMPTY &".equals(nameError.getCode())); |
|
||||||
assertTrue("Name value escaped", "empty &".equals(errors.getFieldValue("name"))); |
|
||||||
FieldError nameErrorInList = (FieldError) errors.getFieldErrors("name").get(0); |
|
||||||
assertTrue("Same name error in list", nameError.getDefaultMessage().equals(nameErrorInList.getDefaultMessage())); |
|
||||||
|
|
||||||
assertTrue("Correct age errors flag", errors.hasFieldErrors("age")); |
|
||||||
assertTrue("Correct number of age errors", errors.getFieldErrorCount("age") == 2); |
|
||||||
assertTrue("Correct number of age errors in list", errors.getFieldErrors("age").size() == 2); |
|
||||||
FieldError ageError = errors.getFieldError("age"); |
|
||||||
assertTrue("Age error message escaped", "message: <tag>".equals(ageError.getDefaultMessage())); |
|
||||||
assertTrue("Age error code not escaped", "AGE_NOT_SET <tag>".equals(ageError.getCode())); |
|
||||||
assertTrue("Age value not escaped", (new Integer(0)).equals(errors.getFieldValue("age"))); |
|
||||||
FieldError ageErrorInList = (FieldError) errors.getFieldErrors("age").get(0); |
|
||||||
assertTrue("Same name error in list", ageError.getDefaultMessage().equals(ageErrorInList.getDefaultMessage())); |
|
||||||
FieldError ageError2 = (FieldError) errors.getFieldErrors("age").get(1); |
|
||||||
assertTrue("Age error 2 message escaped", "message: <tag>".equals(ageError2.getDefaultMessage())); |
|
||||||
assertTrue("Age error 2 code not escaped", "AGE_NOT_32 <tag>".equals(ageError2.getCode())); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
@ -1,100 +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.web.jsf; |
|
||||||
|
|
||||||
import javax.faces.application.NavigationHandler; |
|
||||||
import javax.faces.context.FacesContext; |
|
||||||
|
|
||||||
import junit.framework.TestCase; |
|
||||||
|
|
||||||
import org.springframework.beans.factory.BeanFactory; |
|
||||||
import org.springframework.beans.factory.support.StaticListableBeanFactory; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author Colin Sampaleanu |
|
||||||
* @author Juergen Hoeller |
|
||||||
*/ |
|
||||||
public class DelegatingNavigationHandlerTests extends TestCase { |
|
||||||
|
|
||||||
private MockFacesContext facesContext; |
|
||||||
private StaticListableBeanFactory beanFactory; |
|
||||||
private TestNavigationHandler origNavHandler; |
|
||||||
private DelegatingNavigationHandlerProxy delNavHandler; |
|
||||||
|
|
||||||
protected void setUp() { |
|
||||||
facesContext = new MockFacesContext(); |
|
||||||
beanFactory = new StaticListableBeanFactory(); |
|
||||||
origNavHandler = new TestNavigationHandler(); |
|
||||||
|
|
||||||
delNavHandler = new DelegatingNavigationHandlerProxy(origNavHandler) { |
|
||||||
protected BeanFactory getBeanFactory(FacesContext facesContext) { |
|
||||||
return beanFactory; |
|
||||||
} |
|
||||||
}; |
|
||||||
} |
|
||||||
|
|
||||||
public void testHandleNavigationWithoutDecoration() { |
|
||||||
TestNavigationHandler targetHandler = new TestNavigationHandler(); |
|
||||||
beanFactory.addBean("jsfNavigationHandler", targetHandler); |
|
||||||
|
|
||||||
delNavHandler.handleNavigation(facesContext, "fromAction", "myViewId"); |
|
||||||
assertEquals(targetHandler.lastFromAction, "fromAction"); |
|
||||||
assertEquals(targetHandler.lastOutcome, "myViewId"); |
|
||||||
} |
|
||||||
|
|
||||||
public void testHandleNavigationWithDecoration() { |
|
||||||
TestDecoratingNavigationHandler targetHandler = new TestDecoratingNavigationHandler(); |
|
||||||
beanFactory.addBean("jsfNavigationHandler", targetHandler); |
|
||||||
|
|
||||||
delNavHandler.handleNavigation(facesContext, "fromAction", "myViewId"); |
|
||||||
assertEquals(targetHandler.lastFromAction, "fromAction"); |
|
||||||
assertEquals(targetHandler.lastOutcome, "myViewId"); |
|
||||||
|
|
||||||
// Original handler must have been invoked as well...
|
|
||||||
assertEquals(origNavHandler.lastFromAction, "fromAction"); |
|
||||||
assertEquals(origNavHandler.lastOutcome, "myViewId"); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
public static class TestNavigationHandler extends NavigationHandler { |
|
||||||
|
|
||||||
private String lastFromAction; |
|
||||||
private String lastOutcome; |
|
||||||
|
|
||||||
public void handleNavigation(FacesContext facesContext, String fromAction, String outcome) { |
|
||||||
lastFromAction = fromAction; |
|
||||||
lastOutcome = outcome; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
public static class TestDecoratingNavigationHandler extends DecoratingNavigationHandler { |
|
||||||
|
|
||||||
private String lastFromAction; |
|
||||||
private String lastOutcome; |
|
||||||
|
|
||||||
public void handleNavigation( |
|
||||||
FacesContext facesContext, String fromAction, String outcome, NavigationHandler originalNavigationHandler) { |
|
||||||
lastFromAction = fromAction; |
|
||||||
lastOutcome = outcome; |
|
||||||
if (originalNavigationHandler != null) { |
|
||||||
originalNavigationHandler.handleNavigation(facesContext, fromAction, outcome); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
@ -1,101 +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.web.jsf; |
|
||||||
|
|
||||||
import javax.faces.context.FacesContext; |
|
||||||
import javax.faces.event.PhaseEvent; |
|
||||||
import javax.faces.event.PhaseId; |
|
||||||
import javax.faces.event.PhaseListener; |
|
||||||
|
|
||||||
import junit.framework.TestCase; |
|
||||||
|
|
||||||
import org.springframework.beans.factory.ListableBeanFactory; |
|
||||||
import org.springframework.beans.factory.support.StaticListableBeanFactory; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author Colin Sampaleanu |
|
||||||
* @author Juergen Hoeller |
|
||||||
*/ |
|
||||||
public class DelegatingPhaseListenerTests extends TestCase { |
|
||||||
|
|
||||||
private MockFacesContext facesContext; |
|
||||||
private StaticListableBeanFactory beanFactory; |
|
||||||
private DelegatingPhaseListenerMulticaster delPhaseListener; |
|
||||||
|
|
||||||
protected void setUp() { |
|
||||||
facesContext = new MockFacesContext(); |
|
||||||
beanFactory = new StaticListableBeanFactory(); |
|
||||||
|
|
||||||
delPhaseListener = new DelegatingPhaseListenerMulticaster() { |
|
||||||
protected ListableBeanFactory getBeanFactory(FacesContext facesContext) { |
|
||||||
return beanFactory; |
|
||||||
} |
|
||||||
}; |
|
||||||
} |
|
||||||
|
|
||||||
public void testBeforeAndAfterPhaseWithSingleTarget() { |
|
||||||
TestListener target = new TestListener(); |
|
||||||
beanFactory.addBean("testListener", target); |
|
||||||
|
|
||||||
assertEquals(delPhaseListener.getPhaseId(), PhaseId.ANY_PHASE); |
|
||||||
PhaseEvent event = new PhaseEvent(facesContext, PhaseId.INVOKE_APPLICATION, new MockLifecycle()); |
|
||||||
|
|
||||||
delPhaseListener.beforePhase(event); |
|
||||||
assertTrue(target.beforeCalled); |
|
||||||
|
|
||||||
delPhaseListener.afterPhase(event); |
|
||||||
assertTrue(target.afterCalled); |
|
||||||
} |
|
||||||
|
|
||||||
public void testBeforeAndAfterPhaseWithMultipleTargets() { |
|
||||||
TestListener target1 = new TestListener(); |
|
||||||
TestListener target2 = new TestListener(); |
|
||||||
beanFactory.addBean("testListener1", target1); |
|
||||||
beanFactory.addBean("testListener2", target2); |
|
||||||
|
|
||||||
assertEquals(delPhaseListener.getPhaseId(), PhaseId.ANY_PHASE); |
|
||||||
PhaseEvent event = new PhaseEvent(facesContext, PhaseId.INVOKE_APPLICATION, new MockLifecycle()); |
|
||||||
|
|
||||||
delPhaseListener.beforePhase(event); |
|
||||||
assertTrue(target1.beforeCalled); |
|
||||||
assertTrue(target2.beforeCalled); |
|
||||||
|
|
||||||
delPhaseListener.afterPhase(event); |
|
||||||
assertTrue(target1.afterCalled); |
|
||||||
assertTrue(target2.afterCalled); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
public static class TestListener implements PhaseListener { |
|
||||||
|
|
||||||
boolean beforeCalled = false; |
|
||||||
boolean afterCalled = false; |
|
||||||
|
|
||||||
public PhaseId getPhaseId() { |
|
||||||
return PhaseId.ANY_PHASE; |
|
||||||
} |
|
||||||
|
|
||||||
public void beforePhase(PhaseEvent arg0) { |
|
||||||
beforeCalled = true; |
|
||||||
} |
|
||||||
|
|
||||||
public void afterPhase(PhaseEvent arg0) { |
|
||||||
afterCalled = true; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
@ -1,83 +0,0 @@ |
|||||||
/* |
|
||||||
* 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.web.jsf; |
|
||||||
|
|
||||||
import javax.faces.context.FacesContext; |
|
||||||
import javax.faces.el.EvaluationException; |
|
||||||
import javax.faces.el.VariableResolver; |
|
||||||
|
|
||||||
import junit.framework.TestCase; |
|
||||||
|
|
||||||
import org.springframework.beans.TestBean; |
|
||||||
import org.springframework.web.context.WebApplicationContext; |
|
||||||
import org.springframework.web.context.support.StaticWebApplicationContext; |
|
||||||
|
|
||||||
/** |
|
||||||
* @author Juergen Hoeller |
|
||||||
* @since 02.08.2004 |
|
||||||
*/ |
|
||||||
public class DelegatingVariableResolverTests extends TestCase { |
|
||||||
|
|
||||||
public void testDelegatingVariableResolver() { |
|
||||||
final StaticWebApplicationContext wac = new StaticWebApplicationContext(); |
|
||||||
wac.registerSingleton("bean1", TestBean.class, null); |
|
||||||
wac.registerSingleton("var1", TestBean.class, null); |
|
||||||
wac.refresh(); |
|
||||||
TestBean bean1 = (TestBean) wac.getBean("bean1"); |
|
||||||
|
|
||||||
// We need to override the getWebApplicationContext method here:
|
|
||||||
// FacesContext and ExternalContext are hard to mock.
|
|
||||||
DelegatingVariableResolver resolver = new DelegatingVariableResolver(new OriginalVariableResolver()) { |
|
||||||
protected WebApplicationContext getWebApplicationContext(FacesContext facesContext) { |
|
||||||
return wac; |
|
||||||
} |
|
||||||
}; |
|
||||||
assertEquals(bean1, resolver.resolveVariable(null, "bean1")); |
|
||||||
assertEquals("val1", resolver.resolveVariable(null, "var1")); |
|
||||||
} |
|
||||||
|
|
||||||
public void testSpringBeanVariableResolver() { |
|
||||||
final StaticWebApplicationContext wac = new StaticWebApplicationContext(); |
|
||||||
wac.registerSingleton("bean1", TestBean.class, null); |
|
||||||
wac.registerSingleton("var1", TestBean.class, null); |
|
||||||
wac.refresh(); |
|
||||||
TestBean bean1 = (TestBean) wac.getBean("bean1"); |
|
||||||
TestBean var1 = (TestBean) wac.getBean("var1"); |
|
||||||
|
|
||||||
// We need to override the getWebApplicationContext method here:
|
|
||||||
// FacesContext and ExternalContext are hard to mock.
|
|
||||||
SpringBeanVariableResolver resolver = new SpringBeanVariableResolver(new OriginalVariableResolver()) { |
|
||||||
protected WebApplicationContext getWebApplicationContext(FacesContext facesContext) { |
|
||||||
return wac; |
|
||||||
} |
|
||||||
}; |
|
||||||
assertEquals(bean1, resolver.resolveVariable(null, "bean1")); |
|
||||||
assertEquals(var1, resolver.resolveVariable(null, "var1")); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
private static class OriginalVariableResolver extends VariableResolver { |
|
||||||
|
|
||||||
public Object resolveVariable(FacesContext facesContext, String name) throws EvaluationException { |
|
||||||
if ("var1".equals(name)) { |
|
||||||
return "val1"; |
|
||||||
} |
|
||||||
return null; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
@ -0,0 +1,20 @@ |
|||||||
|
package org.springframework.web.bind.annotation; |
||||||
|
|
||||||
|
import java.lang.annotation.Target; |
||||||
|
import java.lang.annotation.ElementType; |
||||||
|
import java.lang.annotation.Retention; |
||||||
|
import java.lang.annotation.RetentionPolicy; |
||||||
|
import java.lang.annotation.Documented; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Arjen Poutsma |
||||||
|
* @since 3.0 |
||||||
|
*/ |
||||||
|
@Target({ElementType.METHOD, ElementType.TYPE}) |
||||||
|
@Retention(RetentionPolicy.RUNTIME) |
||||||
|
@Documented |
||||||
|
public @interface RequestMappings { |
||||||
|
|
||||||
|
RequestMapping[] annotations(); |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,35 @@ |
|||||||
|
/* |
||||||
|
* 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; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Juergen Hoeller |
||||||
|
* @since 17.08.2004 |
||||||
|
*/ |
||||||
|
public class BeanWithObjectProperty { |
||||||
|
|
||||||
|
private Object object; |
||||||
|
|
||||||
|
public Object getObject() { |
||||||
|
return object; |
||||||
|
} |
||||||
|
|
||||||
|
public void setObject(Object object) { |
||||||
|
this.object = object; |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -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,85 @@ |
|||||||
|
/* |
||||||
|
* 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.Serializable; |
||||||
|
|
||||||
|
import org.springframework.beans.factory.BeanNameAware; |
||||||
|
import org.springframework.beans.factory.DisposableBean; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Juergen Hoeller |
||||||
|
* @since 21.08.2003 |
||||||
|
*/ |
||||||
|
public class DerivedTestBean extends TestBean implements Serializable, BeanNameAware, DisposableBean { |
||||||
|
|
||||||
|
private String beanName; |
||||||
|
|
||||||
|
private boolean initialized; |
||||||
|
|
||||||
|
private boolean destroyed; |
||||||
|
|
||||||
|
|
||||||
|
public DerivedTestBean() { |
||||||
|
} |
||||||
|
|
||||||
|
public DerivedTestBean(String[] names) { |
||||||
|
if (names == null || names.length < 2) { |
||||||
|
throw new IllegalArgumentException("Invalid names array"); |
||||||
|
} |
||||||
|
setName(names[0]); |
||||||
|
setBeanName(names[1]); |
||||||
|
} |
||||||
|
|
||||||
|
public static DerivedTestBean create(String[] names) { |
||||||
|
return new DerivedTestBean(names); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public void setBeanName(String beanName) { |
||||||
|
if (this.beanName == null || beanName == null) { |
||||||
|
this.beanName = beanName; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public String getBeanName() { |
||||||
|
return beanName; |
||||||
|
} |
||||||
|
|
||||||
|
public void setSpouseRef(String name) { |
||||||
|
setSpouse(new TestBean(name)); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public void initialize() { |
||||||
|
this.initialized = true; |
||||||
|
} |
||||||
|
|
||||||
|
public boolean wasInitialized() { |
||||||
|
return initialized; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public void destroy() { |
||||||
|
this.destroyed = true; |
||||||
|
} |
||||||
|
|
||||||
|
public boolean wasDestroyed() { |
||||||
|
return destroyed; |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,44 @@ |
|||||||
|
/* |
||||||
|
* 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; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Juergen Hoeller |
||||||
|
* @since 07.03.2006 |
||||||
|
*/ |
||||||
|
public class FieldAccessBean { |
||||||
|
|
||||||
|
public String name; |
||||||
|
|
||||||
|
protected int age; |
||||||
|
|
||||||
|
private TestBean spouse; |
||||||
|
|
||||||
|
|
||||||
|
public String getName() { |
||||||
|
return name; |
||||||
|
} |
||||||
|
|
||||||
|
public int getAge() { |
||||||
|
return age; |
||||||
|
} |
||||||
|
|
||||||
|
public TestBean getSpouse() { |
||||||
|
return spouse; |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -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,36 @@ |
|||||||
|
/* |
||||||
|
* 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; |
||||||
|
|
||||||
|
/** |
||||||
|
* |
||||||
|
* @author Rod Johnson |
||||||
|
*/ |
||||||
|
public interface Person { |
||||||
|
|
||||||
|
String getName(); |
||||||
|
void setName(String name); |
||||||
|
int getAge(); |
||||||
|
void setAge(int i); |
||||||
|
|
||||||
|
/** |
||||||
|
* Test for non-property method matching. |
||||||
|
* If the parameter is a Throwable, it will be thrown rather than |
||||||
|
* returned. |
||||||
|
*/ |
||||||
|
Object echo(Object o) throws Throwable; |
||||||
|
} |
||||||
@ -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.beans; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
|
||||||
|
import org.springframework.util.ObjectUtils; |
||||||
|
|
||||||
|
/** |
||||||
|
* Serializable implementation of the Person interface. |
||||||
|
* |
||||||
|
* @author Rod Johnson |
||||||
|
*/ |
||||||
|
public class SerializablePerson implements Person, Serializable { |
||||||
|
|
||||||
|
private String name; |
||||||
|
private int age; |
||||||
|
|
||||||
|
public int getAge() { |
||||||
|
return age; |
||||||
|
} |
||||||
|
|
||||||
|
public void setAge(int age) { |
||||||
|
this.age = age; |
||||||
|
} |
||||||
|
|
||||||
|
public String getName() { |
||||||
|
return name; |
||||||
|
} |
||||||
|
|
||||||
|
public void setName(String name) { |
||||||
|
this.name = name; |
||||||
|
} |
||||||
|
|
||||||
|
public Object echo(Object o) throws Throwable { |
||||||
|
if (o instanceof Throwable) { |
||||||
|
throw (Throwable) o; |
||||||
|
} |
||||||
|
return o; |
||||||
|
} |
||||||
|
|
||||||
|
public boolean equals(Object other) { |
||||||
|
if (!(other instanceof SerializablePerson)) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
SerializablePerson p = (SerializablePerson) other; |
||||||
|
return p.age == age && ObjectUtils.nullSafeEquals(name, p.name); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -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; |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
Loading…
Reference in new issue