Updated Branches:
  refs/heads/master bf0e69c60 -> 4e308198c

Wicket 6 requires Java 6, added testcase

Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/4e308198
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/4e308198
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/4e308198

Branch: refs/heads/master
Commit: 4e308198c2c499d40120a5fc5ea72d5ffbfb5aef
Parents: bf0e69c
Author: svenmeier <[email protected]>
Authored: Tue Dec 11 10:03:01 2012 +0100
Committer: svenmeier <[email protected]>
Committed: Tue Dec 11 10:03:01 2012 +0100

----------------------------------------------------------------------
 .../UtfPropertiesFilePropertiesLoader.java         |   38 +--------------
 .../wicket/resource/PageWithUTF8Properties.java    |   36 ++++++++++++++
 .../PageWithUTF8Properties.utf8.properties         |   21 ++++++++
 .../UtfPropertiesFilePropertiesLoaderTest.java     |   37 ++++++++++++++
 4 files changed, 95 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/4e308198/wicket-core/src/main/java/org/apache/wicket/resource/UtfPropertiesFilePropertiesLoader.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/main/java/org/apache/wicket/resource/UtfPropertiesFilePropertiesLoader.java
 
b/wicket-core/src/main/java/org/apache/wicket/resource/UtfPropertiesFilePropertiesLoader.java
index 7d6d38b..94f82a8 100644
--- 
a/wicket-core/src/main/java/org/apache/wicket/resource/UtfPropertiesFilePropertiesLoader.java
+++ 
b/wicket-core/src/main/java/org/apache/wicket/resource/UtfPropertiesFilePropertiesLoader.java
@@ -20,8 +20,6 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.Reader;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
 
 import org.apache.wicket.util.value.ValueMap;
 
@@ -29,9 +27,6 @@ import org.apache.wicket.util.value.ValueMap;
  * Load properties from properties file via a Reader, which allows to provide 
the charset and thus
  * the encoding can be different than ISO 8859-1.
  * 
- * The implementation depends on the Java 6 Properties implementation and is 
disable if the
- * reflection cannot find the method load(Reader).
- * 
  * @author Juergen Donnerstag
  */
 public class UtfPropertiesFilePropertiesLoader implements IPropertiesLoader
@@ -40,8 +35,6 @@ public class UtfPropertiesFilePropertiesLoader implements 
IPropertiesLoader
 
        private final String encoding;
 
-       private Method load;
-
        /**
         * Construct.
         * 
@@ -52,15 +45,6 @@ public class UtfPropertiesFilePropertiesLoader implements 
IPropertiesLoader
        {
                this.fileExtension = fileExtension;
                this.encoding = encoding;
-
-               try
-               {
-                       load = java.util.Properties.class.getMethod("load", new 
Class[] { Reader.class });
-               }
-               catch (NoSuchMethodException ex)
-               {
-                       load = null;
-               }
        }
 
        /**
@@ -78,30 +62,10 @@ public class UtfPropertiesFilePropertiesLoader implements 
IPropertiesLoader
        @Override
        public java.util.Properties loadJavaProperties(final InputStream in) 
throws IOException
        {
-               if (load == null)
-               {
-                       return null;
-               }
-
                java.util.Properties properties = new java.util.Properties();
                Reader reader = new InputStreamReader(in, encoding);
 
-               try
-               {
-                       load.invoke(properties, reader);
-               }
-               catch (IllegalArgumentException ex)
-               {
-                       properties = null;
-               }
-               catch (IllegalAccessException ex)
-               {
-                       properties = null;
-               }
-               catch (InvocationTargetException ex)
-               {
-                       properties = null;
-               }
+               properties.load(reader);
 
                return properties;
        }

http://git-wip-us.apache.org/repos/asf/wicket/blob/4e308198/wicket-core/src/test/java/org/apache/wicket/resource/PageWithUTF8Properties.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/test/java/org/apache/wicket/resource/PageWithUTF8Properties.java
 
b/wicket-core/src/test/java/org/apache/wicket/resource/PageWithUTF8Properties.java
new file mode 100644
index 0000000..3491f8c
--- /dev/null
+++ 
b/wicket-core/src/test/java/org/apache/wicket/resource/PageWithUTF8Properties.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.wicket.resource;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.wicket.util.tester.DummyHomePage;
+
+/**
+ * Test page for WICKET-2035
+ */
+public class PageWithUTF8Properties extends DummyHomePage
+{
+       private static final long serialVersionUID = 1L;
+
+       /***/
+       public PageWithUTF8Properties()
+       {
+               String actual = getString("testProperty");
+               assertEquals("encöding", actual);
+       }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/wicket/blob/4e308198/wicket-core/src/test/java/org/apache/wicket/resource/PageWithUTF8Properties.utf8.properties
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/test/java/org/apache/wicket/resource/PageWithUTF8Properties.utf8.properties
 
b/wicket-core/src/test/java/org/apache/wicket/resource/PageWithUTF8Properties.utf8.properties
new file mode 100644
index 0000000..e6b6671
--- /dev/null
+++ 
b/wicket-core/src/test/java/org/apache/wicket/resource/PageWithUTF8Properties.utf8.properties
@@ -0,0 +1,21 @@
+#
+# $Id$
+# $Revision$
+# $Date$
+#
+# ====================================================================
+# 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.
+#
+
+# NOTE: this file has to be encoded in UTF-8 !!!
+testProperty = encöding
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/wicket/blob/4e308198/wicket-core/src/test/java/org/apache/wicket/resource/UtfPropertiesFilePropertiesLoaderTest.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/test/java/org/apache/wicket/resource/UtfPropertiesFilePropertiesLoaderTest.java
 
b/wicket-core/src/test/java/org/apache/wicket/resource/UtfPropertiesFilePropertiesLoaderTest.java
new file mode 100644
index 0000000..87d5735
--- /dev/null
+++ 
b/wicket-core/src/test/java/org/apache/wicket/resource/UtfPropertiesFilePropertiesLoaderTest.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.wicket.resource;
+
+
+import org.apache.wicket.WicketTestCase;
+import org.junit.Test;
+
+/**
+ * WICKET-2035 Change naming convention for xml properties files to 
*.properties.xml instead of
+ * *.xml
+ */
+public class UtfPropertiesFilePropertiesLoaderTest extends WicketTestCase
+{
+       /**
+        * Test encoding.
+        */
+       @Test
+       public void encoding()
+       {
+               tester.startPage(PageWithUTF8Properties.class);
+       }
+}

Reply via email to