You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltaspike.apache.org by gp...@apache.org on 2013/01/03 11:18:08 UTC
git commit: DELTASPIKE-309 fixed locale
Updated Branches:
refs/heads/master f8d072015 -> a8347771e
DELTASPIKE-309 fixed locale
Project: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/commit/a8347771
Tree: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/tree/a8347771
Diff: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/diff/a8347771
Branch: refs/heads/master
Commit: a8347771ebdb93cf2427d899d443ba8ca7babbff
Parents: f8d0720
Author: gpetracek <gp...@apache.org>
Authored: Thu Jan 3 11:16:19 2013 +0100
Committer: gpetracek <gp...@apache.org>
Committed: Thu Jan 3 11:17:19 2013 +0100
----------------------------------------------------------------------
.../test/core/api/message/SimpleMessageTest.java | 11 ++--
.../test/core/api/message/TestLocalResolver.java | 38 +++++++++++++++
2 files changed, 43 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/a8347771/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/message/SimpleMessageTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/message/SimpleMessageTest.java b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/message/SimpleMessageTest.java
index 68aed7a..602e5b5 100644
--- a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/message/SimpleMessageTest.java
+++ b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/message/SimpleMessageTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.deltaspike.test.core.api.message;
+import org.apache.deltaspike.core.api.message.LocaleResolver;
import org.apache.deltaspike.core.impl.message.MessageBundleExtension;
import org.apache.deltaspike.test.category.SeCategory;
import org.apache.deltaspike.test.util.ArchiveUtils;
@@ -34,8 +35,6 @@ import org.junit.runner.RunWith;
import javax.enterprise.inject.spi.Extension;
import javax.inject.Inject;
-import java.util.Locale;
-
import static org.junit.Assert.assertEquals;
/**
@@ -48,6 +47,9 @@ public class SimpleMessageTest
@Inject
private SimpleMessage simpleMessage;
+ @Inject
+ private LocaleResolver localeResolver;
+
/**
* X TODO creating a WebArchive is only a workaround because JavaArchive
* cannot contain other archives.
@@ -85,10 +87,7 @@ public class SimpleMessageTest
{
float f = 123.45f;
- // this is what the DefaultLocale uses as well
- Locale defaultLocale = Locale.getDefault();
-
- String expectedResult = "Welcome to " + String.format("%f", f);
+ String expectedResult = "Welcome to " + String.format(this.localeResolver.getLocale(), "%f", f);
String result = simpleMessage.welcomeWithFloatVariable(f);
assertEquals(expectedResult, result);
}
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/a8347771/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/message/TestLocalResolver.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/message/TestLocalResolver.java b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/message/TestLocalResolver.java
new file mode 100644
index 0000000..08142e3
--- /dev/null
+++ b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/message/TestLocalResolver.java
@@ -0,0 +1,38 @@
+/*
+ * 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.deltaspike.test.core.api.message;
+
+import org.apache.deltaspike.core.impl.message.DefaultLocaleResolver;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Specializes;
+import java.util.Locale;
+
+@ApplicationScoped
+@Specializes
+public class TestLocalResolver extends DefaultLocaleResolver
+{
+ private static final long serialVersionUID = 4947516315363672494L;
+
+ @Override
+ public Locale getLocale()
+ {
+ return Locale.ENGLISH;
+ }
+}