Package java.util.ResourceBundle

Examples of java.util.ResourceBundle.Control


        if (values == null) {
            values = new TextAndMnemonicHashMap();
            for (int i=resourceBundles.size()-1; i >= 0; i--) {
                String bundleName = resourceBundles.get(i);
                try {
                    Control c = CoreResourceBundleControl.getRBControlInstance(bundleName);
                    ResourceBundle b;
                    if (c != null) {
                        b = ResourceBundle.getBundle(bundleName, l, c);
                    } else {
                        b = ResourceBundle.getBundle(bundleName, l);
View Full Code Here


        if (values == null) {
            values = new HashMap();
            for (int i=resourceBundles.size()-1; i >= 0; i--) {
                String bundleName = (String)resourceBundles.get(i);
                try {
        Control c = CoreResourceBundleControl.getRBControlInstance(bundleName);
                    ResourceBundle b;
        if (c != null) {
                        b = ResourceBundle.getBundle(bundleName, l, c);
        } else {
                        b = ResourceBundle.getBundle(bundleName, l);
View Full Code Here

        if (values == null) {
            values = new TextAndMnemonicHashMap();
            for (int i=resourceBundles.size()-1; i >= 0; i--) {
                String bundleName = resourceBundles.get(i);
                try {
                    Control c = CoreResourceBundleControl.getRBControlInstance(bundleName);
                    ResourceBundle b;
                    if (c != null) {
                        b = ResourceBundle.getBundle(bundleName, l, c);
                    } else {
                        b = ResourceBundle.getBundle(bundleName, l);
View Full Code Here

        if (values == null) {
            values = new HashMap();
            for (int i=resourceBundles.size()-1; i >= 0; i--) {
                String bundleName = (String)resourceBundles.get(i);
                try {
                    Control c = CoreResourceBundleControl.getRBControlInstance(bundleName);
                    ResourceBundle b;
                    if (c != null) {
                        b = ResourceBundle.getBundle(bundleName, l, c);
                    } else {
                        b = ResourceBundle.getBundle(bundleName, l);
View Full Code Here

        class SubControl extends Control {
            SubControl() {
                super();
            }
        }
        Control subControl = new SubControl();
        assertEquals(FORMAT_DEFAULT, subControl.getFormats(""));
        assertFalse(control.equals(subControl));
    }
View Full Code Here

        } catch (NullPointerException e) {
            // expected
        }
        // null is returned by toBundleName method
        try {
            new Control() {
                @Override
                public String toBundleName(@SuppressWarnings("unused")
                String baseName, @SuppressWarnings("unused")
                Locale locale) {
                    return null;
View Full Code Here

            fail("Should throw NullPointerException");
        } catch (NullPointerException e) {
            // expected
        }
        // illegal control causes IllegalArgumentException
        Control otherControl = new NullCandidateLocalesControl();
        try {
            ResourceBundle.getBundle(SUBFOLDER_PROPERTIES_NAME, otherControl);
            fail("Should throw IllegalArgumentException");
        } catch (IllegalArgumentException e) {
            // expected
View Full Code Here

            fail("Should throw NullPointerException");
        } catch (NullPointerException e) {
            // expected
        }
        // illegal control causes IllegalArgumentException
        Control otherControl = new NullCandidateLocalesControl();
        try {
            ResourceBundle.getBundle(SUBFOLDER_PROPERTIES_NAME, LOCALE_FRFR,
                    otherControl);
            fail("Should throw IllegalArgumentException");
        } catch (IllegalArgumentException e) {
View Full Code Here

    @SuppressWarnings("nls")
    private void getBundleWithControlTester() {
        // 1. cache feature: is tested in other methods
        // 2. Formats/Locale
        // the "reverse" control that take java.properties first
        Control reverseControl = new GivenFormatsControl(Arrays
                .asList(new String[] { "java.properties", "java.class" }));
        // locale that has both class file and properties file support.
        ResourceBundle.clearCache();
        bundle = ResourceBundle.getBundle(SUBFOLDER_PROPERTIES_NAME,
                LOCALE_FRFR, SYSTEM_LOADER, DEFAULT_CONTROL);
        assertEquals(6, bundle.keySet().size());
        assertEquals("frFRChildValue2", bundle.getString("subChild2"));
        assertEquals("subParentValue1", bundle.getString("subParent1"));
        assertEquals("frFRValue4", bundle.getString("subParent4"));
        assertFalse(bundle.containsKey("property"));

        ResourceBundle.clearCache();
        bundle = ResourceBundle.getBundle(SUBFOLDER_PROPERTIES_NAME,
                LOCALE_FRFR, SYSTEM_LOADER, CLASS_CONTROL);
        assertEquals(6, bundle.keySet().size());
        assertEquals("frFRChildValue2", bundle.getString("subChild2"));
        assertEquals("subParentValue1", bundle.getString("subParent1"));
        assertEquals("frFRValue4", bundle.getString("subParent4"));
        assertFalse(bundle.containsKey("property"));

        ResourceBundle.clearCache();
        bundle = ResourceBundle.getBundle(SUBFOLDER_PROPERTIES_NAME,
                LOCALE_FRFR, SYSTEM_LOADER, PROPERTIES_CONTROL);
        assertEquals(4, bundle.keySet().size());
        assertEquals("valueInFRFR", bundle.getString("propertyInFRFR"));
        assertEquals("valueInURLParent", bundle
                .getString("propertyInURLParent"));
        assertEquals("fr_FR_resource", bundle.getString("property"));
        assertEquals("valueInFR", bundle.getString("propertyInFR"));
        assertFalse(bundle.containsKey("subParent1"));

        ResourceBundle.clearCache();
        bundle = ResourceBundle.getBundle(SUBFOLDER_PROPERTIES_NAME,
                LOCALE_FRFR, SYSTEM_LOADER, reverseControl);
        assertEquals(4, bundle.keySet().size());
        assertEquals("valueInFRFR", bundle.getString("propertyInFRFR"));
        assertEquals("valueInURLParent", bundle
                .getString("propertyInURLParent"));
        assertEquals("fr_FR_resource", bundle.getString("property"));
        assertEquals("valueInFR", bundle.getString("propertyInFR"));
        assertFalse(bundle.containsKey("subParent1"));

        // locale that has only properties file support.
        ResourceBundle.clearCache();
        bundle = ResourceBundle.getBundle(SUBFOLDER_PROPERTIES_NAME, LOCALE_EN,
                SYSTEM_LOADER, DEFAULT_CONTROL);
        assertEquals(5, bundle.keySet().size());
        assertEquals("en_resource", bundle.getString("property"));
        assertEquals("subParentValue1", bundle.getString("subParent1"));
        assertEquals("subParentValue4", bundle.getString("subParent4"));
        assertFalse(bundle.containsKey("subChild1"));

        ResourceBundle.clearCache();
        bundle = ResourceBundle.getBundle(SUBFOLDER_PROPERTIES_NAME, LOCALE_EN,
                SYSTEM_LOADER, CLASS_CONTROL);
        assertEquals(6, bundle.keySet().size());
        assertEquals("subParentValue1", bundle.getString("subParent1"));
        assertEquals("subParentValue2", bundle.getString("subParent2"));
        assertEquals("enUSValue3", bundle.getString("subParent3"));
        assertEquals("enUSValue4", bundle.getString("subParent4"));
        assertEquals("enUSChildValue1", bundle.getString("subChild1"));
        assertEquals("enUSChildValue2", bundle.getString("subChild2"));

        ResourceBundle.clearCache();
        bundle = ResourceBundle.getBundle(SUBFOLDER_PROPERTIES_NAME, LOCALE_EN,
                SYSTEM_LOADER, PROPERTIES_CONTROL);
        assertEquals(2, bundle.keySet().size());
        assertEquals("en_resource", bundle.getString("property"));
        assertEquals("valueInURLParent", bundle
                .getString("propertyInURLParent"));

        ResourceBundle.clearCache();
        bundle = ResourceBundle.getBundle(SUBFOLDER_PROPERTIES_NAME, LOCALE_EN,
                SYSTEM_LOADER, reverseControl);
        assertEquals(2, bundle.keySet().size());
        assertEquals("en_resource", bundle.getString("property"));
        assertEquals("valueInURLParent", bundle
                .getString("propertyInURLParent"));

        // locale that has only class file support.
        ResourceBundle.clearCache();
        bundle = ResourceBundle.getBundle(SUBFOLDER_PROPERTIES_NAME,
                LOCALE_ENUSVAR, SYSTEM_LOADER, DEFAULT_CONTROL);
        assertEquals(8, bundle.keySet().size());
        assertEquals("enUSVARChildValue3", bundle.getString("subChild3"));
        assertEquals("subParentValue1", bundle.getString("subParent1"));
        assertEquals("en_resource", bundle.getString("property"));
        assertEquals("enUSVARValue4", bundle.getString("subParent4"));
        assertEquals("enUSValue3", bundle.getString("subParent3"));
        assertEquals("subParentValue2", bundle.getString("subParent2"));

        ResourceBundle.clearCache();
        bundle = ResourceBundle.getBundle(SUBFOLDER_PROPERTIES_NAME,
                LOCALE_ENUSVAR, SYSTEM_LOADER, CLASS_CONTROL);
        assertEquals(7, bundle.keySet().size());
        assertEquals("enUSVARChildValue3", bundle.getString("subChild3"));
        assertEquals("subParentValue1", bundle.getString("subParent1"));
        assertEquals("enUSVARValue4", bundle.getString("subParent4"));
        assertEquals("enUSValue3", bundle.getString("subParent3"));
        assertEquals("subParentValue2", bundle.getString("subParent2"));
        assertFalse(bundle.containsKey("property"));

        ResourceBundle.clearCache();
        bundle = ResourceBundle.getBundle(SUBFOLDER_PROPERTIES_NAME,
                LOCALE_ENUSVAR, SYSTEM_LOADER, PROPERTIES_CONTROL);
        assertEquals(2, bundle.keySet().size());
        assertEquals("en_US_resource", bundle.getString("property"));
        assertEquals("valueInURLParent", bundle
                .getString("propertyInURLParent"));

        ResourceBundle.clearCache();
        bundle = ResourceBundle.getBundle(SUBFOLDER_PROPERTIES_NAME,
                LOCALE_ENUSVAR, SYSTEM_LOADER, reverseControl);
        assertEquals(6, bundle.keySet().size());
        assertEquals("en_US_resource", bundle.getString("property"));
        assertEquals("valueInURLParent", bundle
                .getString("propertyInURLParent"));
        assertEquals("enUSVARChildValue1", bundle.getString("subChild1"));
        assertEquals("enUSVARChildValue2", bundle.getString("subChild2"));
        assertEquals("enUSVARChildValue3", bundle.getString("subChild3"));
        assertEquals("enUSVARValue4", bundle.getString("subParent4"));

        // root locale
        ResourceBundle.clearCache();
        bundle = ResourceBundle.getBundle(SUBFOLDER_PROPERTIES_NAME,
                Locale.ROOT, SYSTEM_LOADER, DEFAULT_CONTROL);
        assertEquals(4, bundle.keySet().size());
        assertEquals("subParentValue1", bundle.getString("subParent1"));
        assertEquals("subParentValue4", bundle.getString("subParent4"));
        assertFalse(bundle.containsKey("property"));
        assertFalse(bundle.containsKey("subChild1"));

        ResourceBundle.clearCache();
        bundle = ResourceBundle.getBundle(SUBFOLDER_PROPERTIES_NAME,
                Locale.ROOT, SYSTEM_LOADER, CLASS_CONTROL);
        assertEquals(4, bundle.keySet().size());
        assertEquals("subParentValue1", bundle.getString("subParent1"));
        assertEquals("subParentValue4", bundle.getString("subParent4"));
        assertFalse(bundle.containsKey("property"));
        assertFalse(bundle.containsKey("subChild1"));

        ResourceBundle.clearCache();
        bundle = ResourceBundle.getBundle(SUBFOLDER_PROPERTIES_NAME,
                Locale.ROOT, SYSTEM_LOADER, PROPERTIES_CONTROL);
        assertEquals(2, bundle.keySet().size());
        assertEquals("resource", bundle.getString("property"));
        assertEquals("valueInURLParent", bundle
                .getString("propertyInURLParent"));

        ResourceBundle.clearCache();
        bundle = ResourceBundle.getBundle(SUBFOLDER_PROPERTIES_NAME,
                Locale.ROOT, SYSTEM_LOADER, reverseControl);
        assertEquals(2, bundle.keySet().size());
        assertEquals("resource", bundle.getString("property"));
        assertEquals("valueInURLParent", bundle
                .getString("propertyInURLParent"));

        // 3.use the FallbackLocale
        Locale.setDefault(LOCALE_FRFR);
        // no resource for Locale.ITALY
        ResourceBundle.clearCache();
        bundle = ResourceBundle.getBundle(SUBFOLDER_PROPERTIES_NAME,
                Locale.ITALY, SYSTEM_LOADER, DEFAULT_CONTROL);
        assertEquals(6, bundle.keySet().size());
        assertEquals("frFRChildValue1", bundle.getString("subChild1"));
        assertEquals("frFRChildValue2", bundle.getString("subChild2"));
        assertEquals("subParentValue1", bundle.getString("subParent1"));
        assertEquals("frFRValue4", bundle.getString("subParent4"));
        assertFalse(bundle.containsKey("property"));

        ResourceBundle.clearCache();
        bundle = ResourceBundle.getBundle(SUBFOLDER_PROPERTIES_NAME,
                Locale.ITALY, SYSTEM_LOADER, CLASS_CONTROL);
        assertEquals(6, bundle.keySet().size());
        assertEquals("frFRChildValue1", bundle.getString("subChild1"));
        assertEquals("frFRChildValue2", bundle.getString("subChild2"));
        assertEquals("subParentValue1", bundle.getString("subParent1"));
        assertEquals("frFRValue4", bundle.getString("subParent4"));
        assertFalse(bundle.containsKey("property"));

        ResourceBundle.clearCache();
        bundle = ResourceBundle.getBundle(SUBFOLDER_PROPERTIES_NAME,
                Locale.ITALY, SYSTEM_LOADER, PROPERTIES_CONTROL);
        assertEquals(4, bundle.keySet().size());
        assertEquals("valueInFRFR", bundle.getString("propertyInFRFR"));
        assertEquals("valueInFR", bundle.getString("propertyInFR"));
        assertEquals("valueInURLParent", bundle
                .getString("propertyInURLParent"));
        assertEquals("fr_FR_resource", bundle.getString("property"));

        ResourceBundle.clearCache();
        bundle = ResourceBundle.getBundle(SUBFOLDER_PROPERTIES_NAME,
                Locale.ITALY, SYSTEM_LOADER, reverseControl);
        assertEquals(4, bundle.keySet().size());
        assertEquals("valueInFRFR", bundle.getString("propertyInFRFR"));
        assertEquals("valueInFR", bundle.getString("propertyInFR"));
        assertEquals("valueInURLParent", bundle
                .getString("propertyInURLParent"));
        assertEquals("fr_FR_resource", bundle.getString("property"));

        // with NoFallbackControl
        Control noFallbackControl = Control
                .getNoFallbackControl(FORMAT_DEFAULT);
        ResourceBundle.clearCache();
        bundle = ResourceBundle.getBundle(SUBFOLDER_PROPERTIES_NAME,
                Locale.ITALY, SYSTEM_LOADER, noFallbackControl);
        assertEquals(4, bundle.keySet().size());
        assertEquals("subParentValue1", bundle.getString("subParent1"));
        assertEquals("subParentValue4", bundle.getString("subParent4"));
        assertFalse(bundle.containsKey("property"));

        noFallbackControl = Control.getNoFallbackControl(FORMAT_CLASS);
        ResourceBundle.clearCache();
        bundle = ResourceBundle.getBundle(SUBFOLDER_PROPERTIES_NAME,
                Locale.ITALY, SYSTEM_LOADER, noFallbackControl);
        assertEquals(4, bundle.keySet().size());
        assertEquals("subParentValue1", bundle.getString("subParent1"));
        assertEquals("subParentValue4", bundle.getString("subParent4"));
        assertFalse(bundle.containsKey("property"));

        noFallbackControl = Control.getNoFallbackControl(FORMAT_PROPERTIES);
        ResourceBundle.clearCache();
        bundle = ResourceBundle.getBundle(SUBFOLDER_PROPERTIES_NAME,
                Locale.ITALY, SYSTEM_LOADER, noFallbackControl);
        assertEquals(2, bundle.keySet().size());
        assertEquals("valueInURLParent", bundle
                .getString("propertyInURLParent"));
        assertEquals("resource", bundle.getString("property"));

        noFallbackControl = new ReverseNoFallbackLocaleControl();
        ResourceBundle.clearCache();
        bundle = ResourceBundle.getBundle(SUBFOLDER_PROPERTIES_NAME,
                Locale.ITALY, SYSTEM_LOADER, noFallbackControl);
        assertEquals(2, bundle.keySet().size());
        assertEquals("valueInURLParent", bundle
                .getString("propertyInURLParent"));
        assertEquals("resource", bundle.getString("property"));

        // locale is equal to the default locale
        Locale.setDefault(Locale.ITALY);
        ResourceBundle.clearCache();
        bundle = ResourceBundle.getBundle(SUBFOLDER_PROPERTIES_NAME,
                Locale.ITALY, SYSTEM_LOADER, DEFAULT_CONTROL);
        assertEquals(4, bundle.keySet().size());
        assertEquals("subParentValue1", bundle.getString("subParent1"));
        assertEquals("subParentValue4", bundle.getString("subParent4"));
        assertFalse(bundle.containsKey("property"));
        assertFalse(bundle.containsKey("subChild1"));

        // 4.test the resources without a root resource
        // locale that has both class file and properties file support.
        ResourceBundle.clearCache();
        bundle = ResourceBundle.getBundle(SUBFOLDER_NOROOT_NAME, LOCALE_FRFR,
                SYSTEM_LOADER, DEFAULT_CONTROL);
        assertEquals(5, bundle.keySet().size());
        assertEquals("frFRChildValue2", bundle.getString("subChild2"));
        assertEquals("frFRValue4", bundle.getString("subParent4"));
        assertFalse(bundle.containsKey("property"));
        assertFalse(bundle.containsKey("subParent1"));

        ResourceBundle.clearCache();
        bundle = ResourceBundle.getBundle(SUBFOLDER_NOROOT_NAME, LOCALE_FRFR,
                SYSTEM_LOADER, CLASS_CONTROL);
        assertEquals(5, bundle.keySet().size());
        assertEquals("frFRChildValue2", bundle.getString("subChild2"));
        assertEquals("frFRValue4", bundle.getString("subParent4"));
        assertFalse(bundle.containsKey("property"));
        assertFalse(bundle.containsKey("subParent1"));

        ResourceBundle.clearCache();
        bundle = ResourceBundle.getBundle(SUBFOLDER_NOROOT_NAME, LOCALE_FRFR,
                SYSTEM_LOADER, PROPERTIES_CONTROL);
        assertEquals(3, bundle.keySet().size());
        assertEquals("valueInFRFR", bundle.getString("propertyInFRFR"));
        assertEquals("fr_FR_resource", bundle.getString("property"));
        assertEquals("valueInFR", bundle.getString("propertyInFR"));

        ResourceBundle.clearCache();
        bundle = ResourceBundle.getBundle(SUBFOLDER_NOROOT_NAME, LOCALE_FRFR,
                SYSTEM_LOADER, reverseControl);
        assertEquals(3, bundle.keySet().size());
        assertEquals("valueInFRFR", bundle.getString("propertyInFRFR"));
        assertEquals("fr_FR_resource", bundle.getString("property"));
        assertEquals("valueInFR", bundle.getString("propertyInFR"));

        // root locale
        ResourceBundle.clearCache();
        try {
            ResourceBundle.getBundle(SUBFOLDER_NOROOT_NAME, Locale.ROOT,
                    SYSTEM_LOADER, DEFAULT_CONTROL);
            fail("Should throw MissingResourceException");
        } catch (MissingResourceException e) {
            // expected
        }

        ResourceBundle.clearCache();
        try {
            ResourceBundle.getBundle(SUBFOLDER_NOROOT_NAME, Locale.ROOT,
                    SYSTEM_LOADER, CLASS_CONTROL);
            fail("Should throw MissingResourceException");
        } catch (MissingResourceException e) {
            // expected
        }

        ResourceBundle.clearCache();
        try {
            ResourceBundle.getBundle(SUBFOLDER_NOROOT_NAME, Locale.ROOT,
                    SYSTEM_LOADER, PROPERTIES_CONTROL);
            fail("Should throw MissingResourceException");
        } catch (MissingResourceException e) {
            // expected
        }

        ResourceBundle.clearCache();
        try {
            ResourceBundle.getBundle(SUBFOLDER_NOROOT_NAME, Locale.ROOT,
                    SYSTEM_LOADER, reverseControl);
            fail("Should throw MissingResourceException");
        } catch (MissingResourceException e) {
            // expected
        }

        // fall back locale
        Locale.setDefault(LOCALE_FRFR);
        // no resource for Locale.ITALY
        ResourceBundle.clearCache();
        bundle = ResourceBundle.getBundle(SUBFOLDER_NOROOT_NAME, Locale.ITALY,
                SYSTEM_LOADER, DEFAULT_CONTROL);
        assertEquals(5, bundle.keySet().size());
        assertEquals("frFRChildValue1", bundle.getString("subChild1"));
        assertEquals("frFRChildValue2", bundle.getString("subChild2"));
        assertEquals("frValue2", bundle.getString("subParent2"));
        assertEquals("frFRValue4", bundle.getString("subParent4"));
        assertEquals("frFRValue3", bundle.getString("subParent3"));

        ResourceBundle.clearCache();
        bundle = ResourceBundle.getBundle(SUBFOLDER_NOROOT_NAME, Locale.ITALY,
                SYSTEM_LOADER, CLASS_CONTROL);
        assertEquals(5, bundle.keySet().size());
        assertEquals("frFRChildValue1", bundle.getString("subChild1"));
        assertEquals("frFRChildValue2", bundle.getString("subChild2"));
        assertEquals("frValue2", bundle.getString("subParent2"));
        assertEquals("frFRValue4", bundle.getString("subParent4"));
        assertEquals("frFRValue3", bundle.getString("subParent3"));

        ResourceBundle.clearCache();
        bundle = ResourceBundle.getBundle(SUBFOLDER_NOROOT_NAME, Locale.ITALY,
                SYSTEM_LOADER, PROPERTIES_CONTROL);
        assertEquals(3, bundle.keySet().size());
        assertEquals("valueInFRFR", bundle.getString("propertyInFRFR"));
        assertEquals("valueInFR", bundle.getString("propertyInFR"));
        assertEquals("fr_FR_resource", bundle.getString("property"));

        ResourceBundle.clearCache();
        bundle = ResourceBundle.getBundle(SUBFOLDER_NOROOT_NAME, Locale.ITALY,
                SYSTEM_LOADER, reverseControl);
        assertEquals(3, bundle.keySet().size());
        assertEquals("valueInFRFR", bundle.getString("propertyInFRFR"));
        assertEquals("valueInFR", bundle.getString("propertyInFR"));
        assertEquals("fr_FR_resource", bundle.getString("property"));

        // with NoFallbackControl
        noFallbackControl = Control.getNoFallbackControl(FORMAT_DEFAULT);
        ResourceBundle.clearCache();
        try {
            ResourceBundle.getBundle(SUBFOLDER_NOROOT_NAME, Locale.ITALY,
                    SYSTEM_LOADER, noFallbackControl);
            fail("Should throw MissingResourceException");
        } catch (MissingResourceException e) {
            // expected
        }

        noFallbackControl = Control.getNoFallbackControl(FORMAT_CLASS);
        ResourceBundle.clearCache();
        try {
            ResourceBundle.getBundle(SUBFOLDER_NOROOT_NAME, Locale.ITALY,
                    SYSTEM_LOADER, noFallbackControl);
            fail("Should throw MissingResourceException");
        } catch (MissingResourceException e) {
            // expected
        }

        noFallbackControl = Control.getNoFallbackControl(FORMAT_PROPERTIES);
        ResourceBundle.clearCache();
        try {
            ResourceBundle.getBundle(SUBFOLDER_NOROOT_NAME, Locale.ITALY,
                    SYSTEM_LOADER, noFallbackControl);
            fail("Should throw MissingResourceException");
        } catch (MissingResourceException e) {
            // expected
        }

        noFallbackControl = new ReverseNoFallbackLocaleControl();
        ResourceBundle.clearCache();
        try {
            ResourceBundle.getBundle(SUBFOLDER_NOROOT_NAME, Locale.ITALY,
                    SYSTEM_LOADER, noFallbackControl);
            fail("Should throw MissingResourceException");
        } catch (MissingResourceException e) {
            // expected
        }

        // locale is equal to the default locale
        Locale.setDefault(Locale.ITALY);
        ResourceBundle.clearCache();
        try {
            ResourceBundle.getBundle(SUBFOLDER_NOROOT_NAME, Locale.ITALY,
                    SYSTEM_LOADER, noFallbackControl);
            fail("Should throw MissingResourceException");
        } catch (MissingResourceException e) {
            // expected
        }

        // 5.simple exceptions
        ResourceBundle.clearCache();
        try {
            ResourceBundle.getBundle("wrongName", LOCALE_FRFR, SYSTEM_LOADER,
                    DEFAULT_CONTROL);
            fail("Should throw MissingResourceException");
        } catch (MissingResourceException e) {
            // expected
        }
        try {
            ResourceBundle.getBundle(SUBFOLDER_PROPERTIES_NAME, LOCALE_FRFR,
                    URL_LOADER, DEFAULT_CONTROL);
            fail("Should throw MissingResourceException");
        } catch (MissingResourceException e) {
            // expected
        }
        try {
            ResourceBundle.getBundle(null, LOCALE_FRFR, SYSTEM_LOADER,
                    DEFAULT_CONTROL);
            fail("Should throw NullPointerException");
        } catch (NullPointerException e) {
            // expected
        }
        try {
            ResourceBundle.getBundle(SUBFOLDER_PROPERTIES_NAME, null,
                    SYSTEM_LOADER, DEFAULT_CONTROL);
            fail("Should throw NullPointerException");
        } catch (NullPointerException e) {
            // expected
        }
        try {
            ResourceBundle.getBundle(SUBFOLDER_PROPERTIES_NAME, LOCALE_FRFR,
                    null, DEFAULT_CONTROL);
            fail("Should throw NullPointerException");
        } catch (NullPointerException e) {
            // expected
        }
        try {
            ResourceBundle.getBundle(SUBFOLDER_PROPERTIES_NAME, LOCALE_FRFR,
                    SYSTEM_LOADER, null);
            fail("Should throw NullPointerException");
        } catch (NullPointerException e) {
            // expected
        }
        // 6. exceptions caused by control
        // illegal control causes IllegalArgumentException
        Control otherControl = new NullCandidateLocalesControl();
        try {
            ResourceBundle.getBundle(SUBFOLDER_PROPERTIES_NAME, LOCALE_FRFR,
                    SYSTEM_LOADER, otherControl);
            fail("Should throw IllegalArgumentException");
        } catch (IllegalArgumentException e) {
View Full Code Here

        if (values == null) {
            values = new HashMap();
            for (int i=resourceBundles.size()-1; i >= 0; i--) {
                String bundleName = (String)resourceBundles.get(i);
                try {
                    Control c = CoreResourceBundleControl.getRBControlInstance(bundleName);
                    ResourceBundle b;
                    if (c != null) {
                        b = ResourceBundle.getBundle(bundleName, l, c);
                    } else {
                        b = ResourceBundle.getBundle(bundleName, l);
View Full Code Here

TOP

Related Classes of java.util.ResourceBundle.Control

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.