Revision: 1320
http://stripes.svn.sourceforge.net/stripes/?rev=1320&view=rev
Author: bengunter
Date: 2010-11-10 20:13:49 +0000 (Wed, 10 Nov 2010)
Log Message:
-----------
In testValidateTypeConverter, the original type converter for Integer must be
restored before the test exits.
Modified Paths:
--------------
trunk/tests/src/net/sourceforge/stripes/validation/ValidationAnnotationsTest.java
Modified:
trunk/tests/src/net/sourceforge/stripes/validation/ValidationAnnotationsTest.java
===================================================================
---
trunk/tests/src/net/sourceforge/stripes/validation/ValidationAnnotationsTest.java
2010-11-10 18:55:09 UTC (rev 1319)
+++
trunk/tests/src/net/sourceforge/stripes/validation/ValidationAnnotationsTest.java
2010-11-10 20:13:49 UTC (rev 1320)
@@ -80,15 +80,25 @@
* @see http://www.stripesframework.org/jira/browse/STS-610
*/
@Test(groups="extensions")
+ @SuppressWarnings({ "unchecked", "rawtypes" })
public void testValidateTypeConverterExtendsStock() throws Exception {
MockRoundtrip trip = new
MockRoundtrip(StripesTestFixture.getServletContext(), getClass());
-
StripesFilter.getConfiguration().getTypeConverterFactory().add(Integer.class,
MyIntegerTypeConverter.class);
- trip.addParameter("shouldBeDoubled", "42");
- trip.addParameter("shouldNotBeDoubled", "42");
- trip.execute("validateTypeConverters");
- ValidationAnnotationsTest actionBean = trip.getActionBean(getClass());
- Assert.assertEquals(actionBean.shouldBeDoubled, new Integer(84));
- Assert.assertEquals(actionBean.shouldNotBeDoubled, new Integer(42));
+ Locale locale = trip.getRequest().getLocale();
+ TypeConverterFactory factory =
StripesFilter.getConfiguration().getTypeConverterFactory();
+ TypeConverter<?> tc = factory.getTypeConverter(Integer.class, locale);
+ try {
+ factory.add(Integer.class, MyIntegerTypeConverter.class);
+ trip.addParameter("shouldBeDoubled", "42");
+ trip.addParameter("shouldNotBeDoubled", "42");
+ trip.execute("validateTypeConverters");
+ ValidationAnnotationsTest actionBean =
trip.getActionBean(getClass());
+ Assert.assertEquals(actionBean.shouldBeDoubled, new Integer(84));
+ Assert.assertEquals(actionBean.shouldNotBeDoubled, new
Integer(42));
+ }
+ finally {
+ Class<? extends TypeConverter> tcType = tc == null ? null :
tc.getClass();
+ factory.add(Integer.class, (Class<? extends TypeConverter<?>>)
tcType);
+ }
}
/**
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a
Billion" shares his insights and actions to help propel your
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development