Revision: 1159
          http://stripes.svn.sourceforge.net/stripes/?rev=1159&view=rev
Author:   bengunter
Date:     2009-10-15 17:28:45 +0000 (Thu, 15 Oct 2009)

Log Message:
-----------
Added unit test from trunk for STS-651

Added Paths:
-----------
    
branches/1.5.x/tests/src/net/sourceforge/stripes/controller/InvalidDateKeyBreaksInvariant_STS_651.java

Added: 
branches/1.5.x/tests/src/net/sourceforge/stripes/controller/InvalidDateKeyBreaksInvariant_STS_651.java
===================================================================
--- 
branches/1.5.x/tests/src/net/sourceforge/stripes/controller/InvalidDateKeyBreaksInvariant_STS_651.java
                              (rev 0)
+++ 
branches/1.5.x/tests/src/net/sourceforge/stripes/controller/InvalidDateKeyBreaksInvariant_STS_651.java
      2009-10-15 17:28:45 UTC (rev 1159)
@@ -0,0 +1,44 @@
+package net.sourceforge.stripes.controller;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+import net.sourceforge.stripes.mock.MockRoundtrip;
+import net.sourceforge.stripes.mock.MockServletContext;
+import net.sourceforge.stripes.StripesTestFixture;
+
+import java.util.Date;
+import java.util.Map;
+
+/**
+ * reproduces http://www.stripesframework.org/jira/browse/STS-651
+ */
+public class InvalidDateKeyBreaksInvariant_STS_651 {
+
+    /** Helper method to create a roundtrip with the TestActionBean class. */
+    protected MockRoundtrip getRoundtrip() {
+        MockServletContext context = StripesTestFixture.getServletContext();
+        return new MockRoundtrip(context, MapBindingTests.class);
+    }
+
+    @Test
+    public void bindInvalidDateKeysInMapBreaksMapInvariant() throws Exception {
+        MockRoundtrip trip = getRoundtrip();
+        trip.addParameter("mapDateDate['notadate']", "01/01/2000");
+        trip.execute();
+
+        MapBindingTests bean = trip.getActionBean(MapBindingTests.class);
+        Map<Date, Date> mapDateDate = bean.getMapDateDate();
+        try {
+            // there should be only java.util.Date objects as keys of the map
+            for (Date dateKey : mapDateDate.keySet()) {
+                // if we go this far then it's ok, but we try to see
+                // if the value if ok as well...
+                Date dateValue = mapDateDate.get(dateKey);
+                Assert.assertNotNull(dateValue);
+            }
+        }
+        catch (ClassCastException e) {
+            Assert.fail("bad ! Map<Date,Date> contains a <String,?> entry, the 
map's invariant has been violated", e);
+        }
+    }
+}


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development

Reply via email to