Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/search/NLSSearchTest.java')
-rw-r--r--testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/search/NLSSearchTest.java76
1 files changed, 76 insertions, 0 deletions
diff --git a/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/search/NLSSearchTest.java b/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/search/NLSSearchTest.java
index f2edf15e7..591083318 100644
--- a/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/search/NLSSearchTest.java
+++ b/testplugins/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/search/NLSSearchTest.java
@@ -554,4 +554,80 @@ public class NLSSearchTest extends TestCase {
NLSSearchTestHelper.assertNumberOfProblems(accessor, propertiesFile, 0);
}
+
+ public void testBug306168_1() throws Exception {
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
+ StringBuffer buf= new StringBuffer();
+ buf.append("package test;\n");
+ buf.append("import java.util.MissingResourceException;\n");
+ buf.append("import java.util.ResourceBundle;\n");
+ buf.append("public class Accessor {\n");
+ buf.append(" private static final String BUNDLE_NAME = \"test.Accessor\"; //$NON-NLS-1$\n");
+ buf.append(" private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);\n");
+ buf.append(" private Accessor() {}\n");
+ buf.append(" public static String getString(String key) {\n");
+ buf.append(" try {\n");
+ buf.append(" return RESOURCE_BUNDLE.getString(key);\n");
+ buf.append(" } catch (MissingResourceException e) {\n");
+ buf.append(" return '!' + key + '!';\n");
+ buf.append(" }\n");
+ buf.append(" }\n");
+ buf.append("}\n");
+ ICompilationUnit accessor= pack1.createCompilationUnit("Accessor.java", buf.toString(), false, null);
+
+ buf= new StringBuffer();
+ buf.append("package test;\n");
+ buf.append("public class Client {\n");
+ buf.append(" private static final String X =\"Main.indirect\";//$NON-NLS-1$ \n");
+ buf.append(" public static void main(String[] args) { \n");
+ buf.append(" Accessor.getString(test.Client.X); \n");
+ buf.append(" }\n");
+ buf.append("}\n");
+
+ pack1.createCompilationUnit("Client.java", buf.toString(), false, null);
+
+ buf= new StringBuffer();
+ buf.append("Main.indirect=Main.indirect\n");
+ IFile propertiesFile= write((IFolder)pack1.getCorrespondingResource(), buf.toString(), "Accessor.properties");
+
+ NLSSearchTestHelper.assertNumberOfProblems(accessor, propertiesFile, 0);
+ }
+
+ public void testBug306168_2() throws Exception {
+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test", false, null);
+ StringBuffer buf= new StringBuffer();
+ buf.append("package test;\n");
+ buf.append("import java.util.MissingResourceException;\n");
+ buf.append("import java.util.ResourceBundle;\n");
+ buf.append("public class Accessor {\n");
+ buf.append(" private static final String BUNDLE_NAME = \"test.Accessor\"; //$NON-NLS-1$\n");
+ buf.append(" private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);\n");
+ buf.append(" private Accessor() {}\n");
+ buf.append(" public static String getString(String key) {\n");
+ buf.append(" try {\n");
+ buf.append(" return RESOURCE_BUNDLE.getString(key);\n");
+ buf.append(" } catch (MissingResourceException e) {\n");
+ buf.append(" return '!' + key + '!';\n");
+ buf.append(" }\n");
+ buf.append(" }\n");
+ buf.append("}\n");
+ ICompilationUnit accessor= pack1.createCompilationUnit("Accessor.java", buf.toString(), false, null);
+
+ buf= new StringBuffer();
+ buf.append("package test;\n");
+ buf.append("public class Client {\n");
+ buf.append(" private static final String X =\"Main.undefined\";//$NON-NLS-1$ \n");
+ buf.append(" public static void main(String[] args) { \n");
+ buf.append(" Accessor.getString(test.Client.X); \n");
+ buf.append(" }\n");
+ buf.append("}\n");
+
+ pack1.createCompilationUnit("Client.java", buf.toString(), false, null);
+
+ buf= new StringBuffer();
+ IFile propertiesFile= write((IFolder)pack1.getCorrespondingResource(), buf.toString(), "Accessor.properties");
+
+ NLSSearchTestHelper.assertNumberOfProblems(accessor, propertiesFile, 1);
+ }
+
}

Back to the top