Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix bean editor override test #13

Closed
wants to merge 30 commits into from

2 participants

@jochenberger
Collaborator

If the test are run on a system whose browser prefers another locale than en, the bean_editor_override test will fail.
This patch makes sure the selenium test runs against the English version of the BeanEditorDemo page

jochenberger added some commits
@jochenberger jochenberger use 12- or 24-hour time format depending on format pattern 9fca265
@jochenberger jochenberger a format string containing %k (hour 0-23, not padded) resulted in 0 b…
…eing printed as '%k' due to 0 being interpreted as false in JavaScript
ad9e3f0
@jochenberger jochenberger bean_editor_override test fails if run in a browser that will prefer …
…de or fr locales over en
e5dd9dc
@jochenberger jochenberger add support for un-padded month, hour and minute in the format string 1478476
@jochenberger jochenberger also replace yy by yyyy if it's not at the end of the format string 6f1ad6c
@jochenberger jochenberger don't use a 4-digit year on the client side if a format with a 2-digi…
…t representation was explicitly specified
55c6bf3
@jochenberger jochenberger move Kaptcha portion into a separate module 87a6e6c
@jochenberger jochenberger allow to control the alignment of the popup by introducing "align" an…
…d "showAtElement" parameters
5fafcf7
@jochenberger jochenberger add singleClick parameter, controlling whether the pop-up closes when…
… a date is selected
b3735f2
@jochenberger jochenberger Merge branch 'master' of git://github.com/hlship/tapx b904d61
@jochenberger jochenberger Merge remote branch 'upstream/master' 61f9087
@jochenberger jochenberger Merge remote branch 'upstream/master'
Conflicts:
	pom.xml
	tapx-core/pom.xml
98db925
@jochenberger jochenberger fix package in library mapping d03cd87
@jochenberger jochenberger Merge branch 'master' of git://github.com/hlship/tapx
Conflicts:
	build.gradle
	tapx-core/src/main/java/com/howardlewisship/tapx/core/services/CoreModule.java
2869fee
@jochenberger jochenberger Merge remote branch 'upstream/master'
Conflicts:
	settings.gradle
	tapx-core/src/main/java/com/howardlewisship/tapx/core/internal/services/KaptchaProducerImpl.java
	tapx-core/src/main/java/com/howardlewisship/tapx/core/services/CoreModule.java
	tapx-core/src/main/java/com/howardlewisship/tapx/core/services/KaptchaProducer.java
	tapx-core/src/test/java/core/demo/pages/KaptchaDemo.java
	tapx-core/src/test/resources/core/demo/pages/KaptchaDemo.tml
	tapx-datefield/src/test/java/com/howardlewisship/tapx/datefield/integration/IntegrationTests.java
	tapx-kaptcha/build.gradle
	tapx-kaptcha/src/main/java/com/howardlewisship/tapx/internal/kaptcha/services/KaptchaProducer.java
	tapx-kaptcha/src/main/java/com/howardlewisship/tapx/internal/kaptcha/services/KaptchaProducerImpl.java
	tapx-kaptcha/src/main/java/com/howardlewisship/tapx/kaptcha/components/KaptchaImage.java
	tapx-kaptcha/src/main/java/com/howardlewisship/tapx/kaptcha/internal/services/KaptchaProducerImpl.java
	tapx-kaptcha/src/main/java/com/howardlewisship/tapx/kaptcha/services/KaptchaModule.java
	tapx-kaptcha/src/main/java/com/howardlewisship/tapx/kaptcha/services/KaptchaProducer.java
	tapx-kaptcha/src/main/resources/com/howardlewisship/tapx/kaptcha/tapx-kaptcha.properties
	tapx-kaptcha/src/test/conf/testng.xml
	tapx-kaptcha/src/test/java/demo/pages/Index.java
	tapx-kaptcha/src/test/java/kaptcha/demo/pages/KaptchaDemo.java
	tapx-kaptcha/src/test/resources/kaptcha/demo/pages/KaptchaDemo.tml
	tapx-kaptcha/src/test/resources/log4j.properties
	tapx-kaptcha/src/test/webapp/Index.tml
	tapx-kaptcha/src/test/webapp/WEB-INF/web.xml
7f51538
@jochenberger jochenberger fix broken merge 196bdee
@jochenberger jochenberger change date field tests to reflect the changes from [55c6bf3] bbee822
@jochenberger jochenberger bean_editor_override test fails if run in a browser that will prefer …
…de or fr locales over en
4d45e98
@jochenberger jochenberger use 12- or 24-hour time format depending on format pattern 4886c17
@jochenberger jochenberger a format string containing %k (hour 0-23, not padded) resulted in 0 b…
…eing printed as '%k' due to 0 being interpreted as false in JavaScript
8ae612d
@jochenberger jochenberger add support for un-padded month, hour and minute in the format string 8d66f33
@jochenberger jochenberger also replace yy by yyyy if it's not at the end of the format string 2facac1
@jochenberger jochenberger allow to control the alignment of the popup by introducing "align" an…
…d "showAtElement" parameters
b137bb1
@jochenberger jochenberger add singleClick parameter, controlling whether the pop-up closes when…
… a date is selected
f9c1071
@jochenberger jochenberger change date field tests to reflect the changes from [55c6bf3] 409edc1
@jochenberger jochenberger bean_editor_override test fails if run in a browser that will prefer …
…de or fr locales over en
25ee7d8
@jochenberger jochenberger don't use a 4-digit year on the client side if a format with a 2-digi…
…t representation was explicitly specified
895bf4a
@jochenberger jochenberger Merge branch 'master' of github.com:jochenberger/tapx b75194e
@jochenberger jochenberger bean_editor_override test fails if run in a browser that will prefer …
…de or fr locales over en
0b086e0
@jochenberger jochenberger Merge remote branch 'origin/fix-bean_editor_override-test' into fix-b…
…ean_editor_override-test
b8d8399
@hlship
Owner

Fixed by 82acd75

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 23, 2010
  1. @jochenberger
  2. @jochenberger

    a format string containing %k (hour 0-23, not padded) resulted in 0 b…

    jochenberger authored
    …eing printed as '%k' due to 0 being interpreted as false in JavaScript
  3. @jochenberger
  4. @jochenberger
Commits on Aug 24, 2010
  1. @jochenberger
  2. @jochenberger

    don't use a 4-digit year on the client side if a format with a 2-digi…

    jochenberger authored
    …t representation was explicitly specified
  3. @jochenberger
Commits on Aug 25, 2010
  1. @jochenberger

    allow to control the alignment of the popup by introducing "align" an…

    jochenberger authored
    …d "showAtElement" parameters
  2. @jochenberger
Commits on Sep 3, 2010
  1. @jochenberger
Commits on Oct 26, 2010
  1. @jochenberger
Commits on Nov 1, 2010
  1. @jochenberger

    Merge remote branch 'upstream/master'

    jochenberger authored
    Conflicts:
    	pom.xml
    	tapx-core/pom.xml
  2. @jochenberger
Commits on Nov 29, 2010
  1. @jochenberger

    Merge branch 'master' of git://github.com/hlship/tapx

    jochenberger authored
    Conflicts:
    	build.gradle
    	tapx-core/src/main/java/com/howardlewisship/tapx/core/services/CoreModule.java
Commits on Dec 2, 2010
  1. @jochenberger

    Merge remote branch 'upstream/master'

    jochenberger authored
    Conflicts:
    	settings.gradle
    	tapx-core/src/main/java/com/howardlewisship/tapx/core/internal/services/KaptchaProducerImpl.java
    	tapx-core/src/main/java/com/howardlewisship/tapx/core/services/CoreModule.java
    	tapx-core/src/main/java/com/howardlewisship/tapx/core/services/KaptchaProducer.java
    	tapx-core/src/test/java/core/demo/pages/KaptchaDemo.java
    	tapx-core/src/test/resources/core/demo/pages/KaptchaDemo.tml
    	tapx-datefield/src/test/java/com/howardlewisship/tapx/datefield/integration/IntegrationTests.java
    	tapx-kaptcha/build.gradle
    	tapx-kaptcha/src/main/java/com/howardlewisship/tapx/internal/kaptcha/services/KaptchaProducer.java
    	tapx-kaptcha/src/main/java/com/howardlewisship/tapx/internal/kaptcha/services/KaptchaProducerImpl.java
    	tapx-kaptcha/src/main/java/com/howardlewisship/tapx/kaptcha/components/KaptchaImage.java
    	tapx-kaptcha/src/main/java/com/howardlewisship/tapx/kaptcha/internal/services/KaptchaProducerImpl.java
    	tapx-kaptcha/src/main/java/com/howardlewisship/tapx/kaptcha/services/KaptchaModule.java
    	tapx-kaptcha/src/main/java/com/howardlewisship/tapx/kaptcha/services/KaptchaProducer.java
    	tapx-kaptcha/src/main/resources/com/howardlewisship/tapx/kaptcha/tapx-kaptcha.properties
    	tapx-kaptcha/src/test/conf/testng.xml
    	tapx-kaptcha/src/test/java/demo/pages/Index.java
    	tapx-kaptcha/src/test/java/kaptcha/demo/pages/KaptchaDemo.java
    	tapx-kaptcha/src/test/resources/kaptcha/demo/pages/KaptchaDemo.tml
    	tapx-kaptcha/src/test/resources/log4j.properties
    	tapx-kaptcha/src/test/webapp/Index.tml
    	tapx-kaptcha/src/test/webapp/WEB-INF/web.xml
  2. @jochenberger

    fix broken merge

    jochenberger authored
  3. @jochenberger
  4. @jochenberger
  5. @jochenberger
  6. @jochenberger

    a format string containing %k (hour 0-23, not padded) resulted in 0 b…

    jochenberger authored
    …eing printed as '%k' due to 0 being interpreted as false in JavaScript
  7. @jochenberger
  8. @jochenberger
  9. @jochenberger

    allow to control the alignment of the popup by introducing "align" an…

    jochenberger authored
    …d "showAtElement" parameters
  10. @jochenberger
  11. @jochenberger
  12. @jochenberger
  13. @jochenberger

    don't use a 4-digit year on the client side if a format with a 2-digi…

    jochenberger authored
    …t representation was explicitly specified
  14. @jochenberger
  15. @jochenberger
  16. @jochenberger
This page is out of date. Refresh to see the latest.
View
23 tapx-datefield/src/main/java/com/howardlewisship/tapx/datefield/components/DateField.java
@@ -58,6 +58,24 @@
public class DateField extends AbstractField
{
/**
+ * The id of a client-side DOM element to align the calendar to
+ */
+ @Parameter(defaultPrefix = BindingConstants.LITERAL)
+ private String showAtElement;
+
+ /**
+ * How to align the calendar pop-up to the element
+ */
+ @Parameter(defaultPrefix = BindingConstants.LITERAL)
+ private String align;
+
+ /**
+ * If true, the pop-up closes when a date is selected
+ */
+ @Parameter(defaultPrefix = BindingConstants.LITERAL)
+ private boolean singleClick = true;
+
+ /**
* The value parameter of a DateField must be a {@link java.util.Date}.
*/
@Parameter(required = true, principal = true, autoconnect = true)
@@ -187,7 +205,7 @@ public Object get()
String pattern = simpleDateFormat.toPattern();
- String revised = pattern.replaceAll("([^y])yy$", "$1yyyy");
+ String revised = pattern.replaceAll("(?<!y)yy(?!y)", "yyyy");
return new SimpleDateFormat(revised);
}
@@ -242,7 +260,8 @@ public void beginRender(MarkupWriter writer)
writer.end(); // img
JSONObject spec = new JSONObject("clientId", clientId, "clientDateFormat", formatConverter
- .convertToClient(format)).put("time", time);
+ .convertToClient(format), "showAtElement", showAtElement, "align", align)
+ .put("time", time).put("singleClick", singleClick);
javascriptSupport.addInitializerCall("tapxDateField", spec);
}
View
10 ...va/com/howardlewisship/tapx/internal/datefield/services/DateFieldFormatConverterImpl.java
@@ -28,13 +28,13 @@
// year
"yyyy", "Y",
- "yy", "Y",
+ "yy", "y",
// month
"MMMM", "B",
"MMM", "b",
"MM", "m",
- "M", "m",
+ "M", "o",
// day
"dd", "d",
@@ -50,16 +50,16 @@
"E", "a",
// hour (0-23)
- "HH", "k",
+ "HH", "H",
"H", "k",
// hour (1-12)
- "hh", "l",
+ "hh", "I",
"h", "l",
// minute
"mm", "M",
- "m", "M"
+ "m", "O"
};
View
6 ...ld/src/main/resources/com/howardlewisship/tapx/datefield/jscalendar-1.0/calendar-setup.js
@@ -32,6 +32,7 @@
* inputField | the ID of an input field to store the date
* displayArea | the ID of a DIV or other element to show the date
* button | ID of a button or other element that will trigger the calendar
+ * showAtElement | ID of an element to align the calendar to
* eventName | event that will trigger the calendar, without the "on" prefix (default: "click")
* ifFormat | date format that will be stored in the input field
* daFormat | the date format that will be used to display the date in displayArea
@@ -65,6 +66,7 @@ Calendar.setup = function (params) {
param_default("inputField", null);
param_default("displayArea", null);
param_default("button", null);
+ param_default("showAtElement", null);
param_default("eventName", "click");
param_default("ifFormat", "%Y/%m/%d");
param_default("daFormat", "%Y/%m/%d");
@@ -92,7 +94,7 @@ Calendar.setup = function (params) {
param_default("showOthers", false);
param_default("multiple", null);
- var tmp = ["inputField", "displayArea", "button"];
+ var tmp = ["inputField", "displayArea", "button", "showAtElement"];
for (var i in tmp) {
if (typeof params[tmp[i]] == "string") {
params[tmp[i]] = document.getElementById(params[tmp[i]]);
@@ -193,7 +195,7 @@ Calendar.setup = function (params) {
cal.create();
cal.refresh();
if (!params.position)
- cal.showAtElement(params.button || params.displayArea || params.inputField, params.align);
+ cal.showAtElement(params.showAtElement || params.button || params.displayArea || params.inputField, params.align);
else
cal.showAt(params.position[0], params.position[1]);
return false;
View
4 ...atefield/src/main/resources/com/howardlewisship/tapx/datefield/jscalendar-1.0/calendar.js
@@ -1753,11 +1753,13 @@ Date.prototype.print = function (str) {
s["%H"] = (hr < 10) ? ("0" + hr) : hr; // hour, range 00 to 23 (24h format)
s["%I"] = (ir < 10) ? ("0" + ir) : ir; // hour, range 01 to 12 (12h format)
s["%j"] = (dy < 100) ? ((dy < 10) ? ("00" + dy) : ("0" + dy)) : dy; // day of the year (range 001 to 366)
- s["%k"] = hr; // hour, range 0 to 23 (24h format)
+ s["%k"] = '' + hr; // hour, range 0 to 23 (24h format)
s["%l"] = ir; // hour, range 1 to 12 (12h format)
s["%m"] = (m < 9) ? ("0" + (1+m)) : (1+m); // month, range 01 to 12
s["%M"] = (min < 10) ? ("0" + min) : min; // minute, range 00 to 59
s["%n"] = "\n"; // a newline character
+ s["%o"] = (1+m); // month, range 1 to 12
+ s["%O"] = min; // minute, range 0 to 59
s["%p"] = pm ? "PM" : "AM";
s["%P"] = pm ? "pm" : "am";
// FIXME: %r : the time in am/pm notation %I:%M:%S %p
View
6 tapx-datefield/src/main/resources/com/howardlewisship/tapx/datefield/tapx-datefield.js
@@ -6,6 +6,10 @@ Tapestry.Initializer.tapxDateField = function(spec)
weekNumbers : false,
showsTime : spec.time,
ifFormat : spec.clientDateFormat,
- cache : true
+ timeFormat : spec.time && spec.clientDateFormat.match("%p") != null ? "12" : "24",
+ cache : true,
+ showAtElement : spec.showAtElement,
+ align : spec.align,
+ singleClick : spec.singleClick
});
}
View
4 ...ld/src/test/groovy/com/howardlewisship/tapx/datefield/integration/IntegrationTests.groovy
@@ -44,7 +44,7 @@ class IntegrationTests extends SeleniumTestCase
clickAndWait SUBMIT
- assertFieldValue "date", "3/13/09 12:00 AM"
+ assertFieldValue "date", "3/13/2009 12:00 AM"
assertText "outputdate", "March 13, 2009 12:00:00 AM"
}
@@ -58,6 +58,6 @@ class IntegrationTests extends SeleniumTestCase
// That's about as far as we take it; this demonstrates that the tapx DateField was used,
// and that it picked up on the @TimeSignificant annotation.
- assertFieldValue "date", "3/16/09 12:00 AM"
+ assertFieldValue "date", "3/16/2009 12:00 AM"
}
}
View
19 ...om/howardlewisship/tapx/internal/datefield/services/DateFieldFormatConverterImplTest.java
@@ -53,7 +53,11 @@ public Date parse(String s, ParsePosition parsePosition)
return new Object[][]
{
{ "dd/MM/yyyy", "%d/%m/%Y" },
- { "MMM dd, yyyy", "%b %d, %Y" } };
+ { "MMM dd, yyyy", "%b %d, %Y" },
+ { "HH:mm", "%H:%M" },
+ { "hh:m", "%I:%O" },
+ { "h:m", "%l:%O" },
+ { "d/M", "%e/%o" } };
}
@Test(dataProvider = "format_conversion_data")
@@ -77,10 +81,15 @@ public void english_default_locale_with_time()
{
DateFormat format = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, Locale.ENGLISH);
- // Note that DateField manipulates the Java "yy" format into "yyyy" before passing into the converter.
- // But this works because of an additional (and otherwise unnecessary) mapping from "yy".
-
- assertEquals(converter.convertToClient(format), "%m/%e/%Y %l:%M %p");
+ assertEquals(converter.convertToClient(format), "%o/%e/%y %l:%M %p");
+ }
+
+ @Test
+ public void german_default_locale_with_time()
+ {
+ DateFormat format = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, Locale.GERMAN);
+
+ assertEquals(converter.convertToClient(format), "%d.%m.%y %H:%M");
}
@Test
View
18 tapx-datefield/src/test/java/demo/pages/BeanEditorDemo.java
@@ -16,15 +16,33 @@
import java.util.Calendar;
import java.util.Date;
+import java.util.Locale;
import demo.data.NameAndDate;
import org.apache.tapestry5.annotations.Property;
+import org.apache.tapestry5.internal.TapestryInternalUtils;
+import org.apache.tapestry5.ioc.annotations.Inject;
+import org.apache.tapestry5.services.PersistentLocale;
public class BeanEditorDemo
{
@Property
private NameAndDate bean;
+ @Inject
+ private PersistentLocale persistentLocale;
+
+ Object onActivate() {
+ // make sure we serve the page with an English locale as the test case
+ // will fail otherwise
+ if (!TapestryInternalUtils.isEqual(persistentLocale.get(), Locale.ENGLISH))
+ {
+ persistentLocale.set(Locale.ENGLISH);
+ return BeanEditorDemo.class;
+ }
+ return null;
+ }
+
void setupRender()
{
bean = new NameAndDate();
Something went wrong with that request. Please try again.