lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [20/58] lucenenet git commit: QueryParser.Flexible: Fixed support for localized messages to make all TestNLS tests pass
Date Tue, 06 Dec 2016 15:11:55 GMT
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c6ee3d5f/src/Lucene.Net.Tests.QueryParser/Flexible/Messages/TestNLS.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.QueryParser/Flexible/Messages/TestNLS.cs b/src/Lucene.Net.Tests.QueryParser/Flexible/Messages/TestNLS.cs
index e99c73e..a2cf735 100644
--- a/src/Lucene.Net.Tests.QueryParser/Flexible/Messages/TestNLS.cs
+++ b/src/Lucene.Net.Tests.QueryParser/Flexible/Messages/TestNLS.cs
@@ -14,108 +14,108 @@ namespace Lucene.Net.QueryParsers.Flexible.Messages
         [Test]
         public void testMessageLoading()
         {
-            string message = MessagesTestBundle.ResourceManager.GetString("Q0001E_INVALID_SYNTAX");
+            //string message = MessagesTestBundle.ResourceManager.GetString("Q0001E_INVALID_SYNTAX");
 
-            fail("not implemented");
+            //fail("not implemented");
 
-            //IMessage invalidSyntax = new MessageImpl(
-            //    MessagesTestBundle.Q0001E_INVALID_SYNTAX, "XXX");
-            ///* 
-            // * if the default locale is ja, you get ja as a fallback:
-            // * see ResourceBundle.html#getBundle(java.lang.String, java.util.Locale, java.lang.ClassLoader)
-            // */
-            ////if (!Locale.getDefault().getLanguage().equals("ja"))
-            ////    assertEquals("Syntax Error: XXX", invalidSyntax.getLocalizedMessage(Locale.ENGLISH));
-            //if (!CultureInfo.CurrentUICulture.Equals(new CultureInfo("ja-JP")))
-            //    assertEquals("Syntax Error: XXX", invalidSyntax.GetLocalizedMessage(new
CultureInfo("en")));
+            IMessage invalidSyntax = new MessageImpl(
+                MessagesTestBundle.Q0001E_INVALID_SYNTAX, "XXX");
+            /* 
+             * if the default locale is ja, you get ja as a fallback:
+             * see ResourceBundle.html#getBundle(java.lang.String, java.util.Locale, java.lang.ClassLoader)
+             */
+            //if (!Locale.getDefault().getLanguage().equals("ja"))
+            //    assertEquals("Syntax Error: XXX", invalidSyntax.getLocalizedMessage(Locale.ENGLISH));
+            if (!CultureInfo.CurrentUICulture.Equals(new CultureInfo("ja")))
+                assertEquals("Syntax Error: XXX", invalidSyntax.GetLocalizedMessage(new CultureInfo("en")));
         }
 
-        //[Test]
-        //public void testMessageLoading_ja()
-        //{
-        //    IMessage invalidSyntax = new MessageImpl(
-        //        MessagesTestBundle.Q0001E_INVALID_SYNTAX, "XXX");
-        //    assertEquals("構文エラー: XXX", invalidSyntax
-        //        .GetLocalizedMessage(new CultureInfo("ja-JP")));
-        //}
+        [Test]
+        public void testMessageLoading_ja()
+        {
+            IMessage invalidSyntax = new MessageImpl(
+                MessagesTestBundle.Q0001E_INVALID_SYNTAX, "XXX");
+            assertEquals("構文エラー: XXX", invalidSyntax
+                .GetLocalizedMessage(new CultureInfo("ja")));
+        }
 
-        //[Test]
-        //public void testNLSLoading()
-        //{
-        //    String message = NLS
-        //        .GetLocalizedMessage(MessagesTestBundle.Q0004E_INVALID_SYNTAX_ESCAPE_UNICODE_TRUNCATION,
new CultureInfo("en"));
-        //    /* 
-        //     * if the default locale is ja, you get ja as a fallback:
-        //     * see ResourceBundle.html#getBundle(java.lang.String, java.util.Locale, java.lang.ClassLoader)
-        //     */
-        //    //if (!Locale.getDefault().getLanguage().equals("ja"))
-        //    if (!CultureInfo.CurrentUICulture.TwoLetterISOLanguageName.Equals("ja", StringComparison.OrdinalIgnoreCase))
-        //        assertEquals("Truncated unicode escape sequence.", message);
+        [Test]
+        public void testNLSLoading()
+        {
+            String message = NLS
+                .GetLocalizedMessage(MessagesTestBundle.Q0004E_INVALID_SYNTAX_ESCAPE_UNICODE_TRUNCATION,
new CultureInfo("en"));
+            /* 
+             * if the default locale is ja, you get ja as a fallback:
+             * see ResourceBundle.html#getBundle(java.lang.String, java.util.Locale, java.lang.ClassLoader)
+             */
+            //if (!Locale.getDefault().getLanguage().equals("ja"))
+            if (!CultureInfo.CurrentUICulture.TwoLetterISOLanguageName.Equals("ja", StringComparison.OrdinalIgnoreCase))
+                assertEquals("Truncated unicode escape sequence.", message);
 
-        //    message = NLS.GetLocalizedMessage(MessagesTestBundle.Q0001E_INVALID_SYNTAX,
new CultureInfo("en"),
-        //        "XXX");
-        //    /* 
-        //     * if the default locale is ja, you get ja as a fallback:
-        //     * see ResourceBundle.html#getBundle(java.lang.String, java.util.Locale, java.lang.ClassLoader)
-        //     */
-        //    //if (!Locale.getDefault().getLanguage().equals("ja"))
-        //    //if (!CultureInfo.CurrentUICulture.Equals(new CultureInfo("ja-JP")))
-        //    if (!CultureInfo.CurrentUICulture.TwoLetterISOLanguageName.Equals("ja", StringComparison.OrdinalIgnoreCase))
-        //        assertEquals("Syntax Error: XXX", message);
-        //}
+            message = NLS.GetLocalizedMessage(MessagesTestBundle.Q0001E_INVALID_SYNTAX, new
CultureInfo("en"),
+                "XXX");
+            /* 
+             * if the default locale is ja, you get ja as a fallback:
+             * see ResourceBundle.html#getBundle(java.lang.String, java.util.Locale, java.lang.ClassLoader)
+             */
+            //if (!Locale.getDefault().getLanguage().equals("ja"))
+            //if (!CultureInfo.CurrentUICulture.Equals(new CultureInfo("ja-JP")))
+            if (!CultureInfo.CurrentUICulture.TwoLetterISOLanguageName.Equals("ja", StringComparison.OrdinalIgnoreCase))
+                assertEquals("Syntax Error: XXX", message);
+        }
 
-        //[Test]
-        //public void testNLSLoading_ja()
-        //{
-        //    String message = NLS.GetLocalizedMessage(
-        //        MessagesTestBundle.Q0004E_INVALID_SYNTAX_ESCAPE_UNICODE_TRUNCATION,
-        //        new CultureInfo("ja-JP"));
-        //    assertEquals("切り捨てられたユニコード・エスケープ・シーケンス。",
message);
+        [Test]
+        public void testNLSLoading_ja()
+        {
+            String message = NLS.GetLocalizedMessage(
+                MessagesTestBundle.Q0004E_INVALID_SYNTAX_ESCAPE_UNICODE_TRUNCATION,
+                new CultureInfo("ja-JP"));
+            assertEquals("切り捨てられたユニコード・エスケープ・シーケンス。",
message);
 
-        //    message = NLS.GetLocalizedMessage(MessagesTestBundle.Q0001E_INVALID_SYNTAX,
-        //        new CultureInfo("ja-JP"), "XXX");
-        //    assertEquals("構文エラー: XXX", message);
-        //}
+            message = NLS.GetLocalizedMessage(MessagesTestBundle.Q0001E_INVALID_SYNTAX,
+                new CultureInfo("ja-JP"), "XXX");
+            assertEquals("構文エラー: XXX", message);
+        }
 
-        //[Test]
-        //public void testNLSLoading_xx_XX()
-        //{
-        //    //Locale locale = new Locale("xx", "XX", "");
-        //    CultureInfo locale = new CultureInfo("xx-XX");
-        //    String message = NLS.GetLocalizedMessage(
-        //        MessagesTestBundle.Q0004E_INVALID_SYNTAX_ESCAPE_UNICODE_TRUNCATION,
-        //        locale);
-        //    /* 
-        //     * if the default locale is ja, you get ja as a fallback:
-        //     * see ResourceBundle.html#getBundle(java.lang.String, java.util.Locale, java.lang.ClassLoader)
-        //     */
-        //    //if (!Locale.getDefault().getLanguage().equals("ja"))
-        //    if (!CultureInfo.CurrentUICulture.TwoLetterISOLanguageName.Equals("ja", StringComparison.OrdinalIgnoreCase))
-        //        assertEquals("Truncated unicode escape sequence.", message);
+        [Test]
+        public void testNLSLoading_xx_XX()
+        {
+            //Locale locale = new Locale("xx", "XX", "");
+            CultureInfo locale = new CultureInfo("xx-XX");
+            String message = NLS.GetLocalizedMessage(
+                MessagesTestBundle.Q0004E_INVALID_SYNTAX_ESCAPE_UNICODE_TRUNCATION,
+                locale);
+            /* 
+             * if the default locale is ja, you get ja as a fallback:
+             * see ResourceBundle.html#getBundle(java.lang.String, java.util.Locale, java.lang.ClassLoader)
+             */
+            //if (!Locale.getDefault().getLanguage().equals("ja"))
+            if (!CultureInfo.CurrentUICulture.TwoLetterISOLanguageName.Equals("ja", StringComparison.OrdinalIgnoreCase))
+                assertEquals("Truncated unicode escape sequence.", message);
 
-        //    message = NLS.GetLocalizedMessage(MessagesTestBundle.Q0001E_INVALID_SYNTAX,
-        //        locale, "XXX");
-        //    /* 
-        //     * if the default locale is ja, you get ja as a fallback:
-        //     * see ResourceBundle.html#getBundle(java.lang.String, java.util.Locale, java.lang.ClassLoader)
-        //     */
-        //    //if (!Locale.getDefault().getLanguage().equals("ja"))
-        //    if (!CultureInfo.CurrentUICulture.TwoLetterISOLanguageName.Equals("ja", StringComparison.OrdinalIgnoreCase))
-        //        assertEquals("Syntax Error: XXX", message);
-        //}
+            message = NLS.GetLocalizedMessage(MessagesTestBundle.Q0001E_INVALID_SYNTAX,
+                locale, "XXX");
+            /* 
+             * if the default locale is ja, you get ja as a fallback:
+             * see ResourceBundle.html#getBundle(java.lang.String, java.util.Locale, java.lang.ClassLoader)
+             */
+            //if (!Locale.getDefault().getLanguage().equals("ja"))
+            if (!CultureInfo.CurrentUICulture.TwoLetterISOLanguageName.Equals("ja", StringComparison.OrdinalIgnoreCase))
+                assertEquals("Syntax Error: XXX", message);
+        }
 
         // LUCENENET TODO: This doesn't compile because the resources don't contain this
message
 
-        //[Test]
-        //public void testMissingMessage()
-        //{
-        //    //Locale locale = Locale.ENGLISH;
-        //    CultureInfo locale = new CultureInfo("en");
-        //    String message = NLS.GetLocalizedMessage(
-        //        MessagesTestBundle.Q0005E_MESSAGE_NOT_IN_BUNDLE, locale);
+        [Test]
+        public void testMissingMessage()
+        {
+            //Locale locale = Locale.ENGLISH;
+            CultureInfo locale = new CultureInfo("en");
+            String message = NLS.GetLocalizedMessage(
+                MessagesTestBundle.Q0005E_MESSAGE_NOT_IN_BUNDLE, locale);
 
-        //    assertEquals("Message with key:Q0005E_MESSAGE_NOT_IN_BUNDLE and locale: "
-        //        + locale.toString() + " not found.", message);
-        //}
+            assertEquals("Message with key:Q0005E_MESSAGE_NOT_IN_BUNDLE and locale: "
+                + locale.toString() + " not found.", message);
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c6ee3d5f/src/Lucene.Net.Tests.QueryParser/Lucene.Net.Tests.QueryParser.csproj
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.QueryParser/Lucene.Net.Tests.QueryParser.csproj b/src/Lucene.Net.Tests.QueryParser/Lucene.Net.Tests.QueryParser.csproj
index 4ba267d..6a9d560 100644
--- a/src/Lucene.Net.Tests.QueryParser/Lucene.Net.Tests.QueryParser.csproj
+++ b/src/Lucene.Net.Tests.QueryParser/Lucene.Net.Tests.QueryParser.csproj
@@ -53,10 +53,10 @@
     <Compile Include="Flexible\Core\Builders\TestQueryTreeBuilder.cs" />
     <Compile Include="Flexible\Core\Nodes\TestQueryNode.cs" />
     <Compile Include="Flexible\Messages\MessagesTestBundle.cs" />
-    <Compile Include="Flexible\Messages\MessagesTestBundle.Designer.cs">
+    <Compile Include="Flexible\Messages\MessagesTestBundleBundle.Designer.cs">
       <AutoGen>True</AutoGen>
       <DesignTime>True</DesignTime>
-      <DependentUpon>MessagesTestBundle.resx</DependentUpon>
+      <DependentUpon>MessagesTestBundleBundle.resx</DependentUpon>
     </Compile>
     <Compile Include="Flexible\Messages\TestNLS.cs" />
     <Compile Include="Flexible\Precedence\TestPrecedenceQueryParser.cs" />
@@ -112,13 +112,10 @@
     <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
   </ItemGroup>
   <ItemGroup>
-    <EmbeddedResource Include="Flexible\Messages\MessagesTestBundle.ja-JP.resx">
-      <DependentUpon>MessagesTestBundle.cs</DependentUpon>
-    </EmbeddedResource>
-    <EmbeddedResource Include="Flexible\Messages\MessagesTestBundle.resx">
-      <DependentUpon>MessagesTestBundle.cs</DependentUpon>
+    <EmbeddedResource Include="Flexible\Messages\MessagesTestBundleBundle.ja.resx" />
+    <EmbeddedResource Include="Flexible\Messages\MessagesTestBundleBundle.resx">
       <Generator>ResXFileCodeGenerator</Generator>
-      <LastGenOutput>MessagesTestBundle.Designer.cs</LastGenOutput>
+      <LastGenOutput>MessagesTestBundleBundle.Designer.cs</LastGenOutput>
     </EmbeddedResource>
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />


Mime
View raw message