Author: pyaschenko
Date: 2010-10-27 12:48:01 -0400 (Wed, 27 Oct 2010)
New Revision: 19707
Added:
branches/RF-8742/ui/validator/ui/src/main/resources/META-INF/resources/org.richfaces/short-converter.js
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/ShortConverterTest.java
Modified:
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/ByteConverterTest.java
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/NumberConverterTest.java
Log:
https://jira.jboss.org/browse/RF-9521
short converter was added
unused imports were deleted
Added:
branches/RF-8742/ui/validator/ui/src/main/resources/META-INF/resources/org.richfaces/short-converter.js
===================================================================
---
branches/RF-8742/ui/validator/ui/src/main/resources/META-INF/resources/org.richfaces/short-converter.js
(rev 0)
+++
branches/RF-8742/ui/validator/ui/src/main/resources/META-INF/resources/org.richfaces/short-converter.js 2010-10-27
16:48:01 UTC (rev 19707)
@@ -0,0 +1,11 @@
+RichFaces.csv.addConverter({"byte":
+(function(rf) {
+ return function (value, params) {
+ var result = parseInt(value);
+ if (isNaN(result) || result<-32768 || result>32767) {
+ throw rf.csv.getMessage(params.customMessage, 'SHORT_CONVERTER_SHORT', [value,
0, params.componentId]);
+ }
+ return result;
+ }
+})(window.RichFaces || (window.RichFaces={}))
+});
\ No newline at end of file
Modified:
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/ByteConverterTest.java
===================================================================
---
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/ByteConverterTest.java 2010-10-27
16:37:39 UTC (rev 19706)
+++
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/ByteConverterTest.java 2010-10-27
16:48:01 UTC (rev 19707)
@@ -21,14 +21,9 @@
*/
package org.richfaces.convert;
-import static org.junit.Assert.*;
-
import javax.faces.convert.ByteConverter;
-import javax.faces.convert.NumberConverter;
import org.junit.Test;
-import org.richfaces.application.MessageFactory;
-import org.richfaces.application.ServiceTracker;
import org.richfaces.appplication.FacesMessages;
/**
Modified:
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/NumberConverterTest.java
===================================================================
---
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/NumberConverterTest.java 2010-10-27
16:37:39 UTC (rev 19706)
+++
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/NumberConverterTest.java 2010-10-27
16:48:01 UTC (rev 19707)
@@ -21,13 +21,9 @@
*/
package org.richfaces.convert;
-import static org.junit.Assert.*;
-
import javax.faces.convert.NumberConverter;
import org.junit.Test;
-import org.richfaces.application.MessageFactory;
-import org.richfaces.application.ServiceTracker;
import org.richfaces.appplication.FacesMessages;
/**
Added:
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/ShortConverterTest.java
===================================================================
---
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/ShortConverterTest.java
(rev 0)
+++
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/convert/ShortConverterTest.java 2010-10-27
16:48:01 UTC (rev 19707)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.richfaces.convert;
+
+import javax.faces.convert.ShortConverter;
+
+import org.junit.Test;
+import org.richfaces.appplication.FacesMessages;
+
+/**
+ * @author Pavel Yaschenko
+ *
+ */
+public class ShortConverterTest extends BaseConverterTest {
+
+ public ShortConverterTest() {
+ super("META-INF/resources/org.richfaces/short-converter.js");
+ }
+
+ @Test
+ @TestDataHolder(
+ successes = {
+ @TestData(submittedValue = "-32768"),
+ @TestData(submittedValue = "0"),
+ @TestData(submittedValue = "32767")
+ },
+ failures = {
+ @TestData(submittedValue = "-32769"),
+ @TestData(submittedValue = "32768"),
+ @TestData(submittedValue = "aaa")
+ }
+ )
+ public void testSuccess() throws Exception {
+
setClientConverterClassName("RichFaces.csv.getConverter('byte')");
+ setConverterId(ShortConverter.CONVERTER_ID);
+ setConversionErrorMessageEnum(FacesMessages.SHORT_CONVERTER_SHORT);
+ }
+}