From 3d93e01777f8cb86cc1339c682909fbb4c588556 Mon Sep 17 00:00:00 2001 From: Andrew Niefer Date: Wed, 12 May 2010 20:23:59 +0000 Subject: bug 309566 - Bundle-Localization defaults and with sub folders --- .../p2/publisher/eclipse/BundlesAction.java | 2 +- .../spi/p2/publisher/LocalizationHelper.java | 2 +- .../All p2 Tests.launch | 2 +- .../tests/publisher/actions/LocalizationTests.java | 57 +++++++++++++++++++++ .../foobundle_1.0.0.qualifier.jar | Bin 0 -> 1148 bytes .../foobundle_default/META-INF/MANIFEST.MF | 8 +++ .../OSGI-INF/l10n/bundle.properties | 2 + .../OSGI-INF/l10n/bundle_de.properties | 2 + .../foobundle_osgi-inf/META-INF/MANIFEST.MF | 9 ++++ .../foobundle_osgi-inf/OSGI-INF/bundle.properties | 2 + .../OSGI-INF/bundle_de.properties | 2 + 11 files changed, 85 insertions(+), 3 deletions(-) create mode 100644 bundles/org.eclipse.equinox.p2.tests/testData/localizationtests/foobundle_1.0.0.qualifier.jar create mode 100644 bundles/org.eclipse.equinox.p2.tests/testData/localizationtests/foobundle_default/META-INF/MANIFEST.MF create mode 100644 bundles/org.eclipse.equinox.p2.tests/testData/localizationtests/foobundle_default/OSGI-INF/l10n/bundle.properties create mode 100644 bundles/org.eclipse.equinox.p2.tests/testData/localizationtests/foobundle_default/OSGI-INF/l10n/bundle_de.properties create mode 100644 bundles/org.eclipse.equinox.p2.tests/testData/localizationtests/foobundle_osgi-inf/META-INF/MANIFEST.MF create mode 100644 bundles/org.eclipse.equinox.p2.tests/testData/localizationtests/foobundle_osgi-inf/OSGI-INF/bundle.properties create mode 100644 bundles/org.eclipse.equinox.p2.tests/testData/localizationtests/foobundle_osgi-inf/OSGI-INF/bundle_de.properties diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/BundlesAction.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/BundlesAction.java index 3c5e68aed..e64e63c2a 100644 --- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/BundlesAction.java +++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/BundlesAction.java @@ -85,7 +85,7 @@ public class BundlesAction extends AbstractPublisherAction { public static final IProvidedCapability BUNDLE_CAPABILITY = MetadataFactory.createProvidedCapability(PublisherHelper.NAMESPACE_ECLIPSE_TYPE, TYPE_ECLIPSE_BUNDLE, Version.createOSGi(1, 0, 0)); public static final IProvidedCapability SOURCE_BUNDLE_CAPABILITY = MetadataFactory.createProvidedCapability(PublisherHelper.NAMESPACE_ECLIPSE_TYPE, TYPE_ECLIPSE_SOURCE, Version.createOSGi(1, 0, 0)); - static final String DEFAULT_BUNDLE_LOCALIZATION = "plugin"; //$NON-NLS-1$ + static final String DEFAULT_BUNDLE_LOCALIZATION = "OSGI-INF/l10n/bundle"; //$NON-NLS-1$ private static final String[] BUNDLE_IU_PROPERTY_MAP = {Constants.BUNDLE_NAME, IInstallableUnit.PROP_NAME, Constants.BUNDLE_DESCRIPTION, IInstallableUnit.PROP_DESCRIPTION, Constants.BUNDLE_VENDOR, IInstallableUnit.PROP_PROVIDER, Constants.BUNDLE_CONTACTADDRESS, IInstallableUnit.PROP_CONTACT, Constants.BUNDLE_DOCURL, IInstallableUnit.PROP_DOC_URL, Constants.BUNDLE_UPDATELOCATION, IInstallableUnit.PROP_BUNDLE_LOCALIZATION, Constants.BUNDLE_LOCALIZATION, IInstallableUnit.PROP_BUNDLE_LOCALIZATION}; public static final int BUNDLE_LOCALIZATION_INDEX = PublisherHelper.BUNDLE_LOCALIZED_PROPERTIES.length - 1; diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/spi/p2/publisher/LocalizationHelper.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/spi/p2/publisher/LocalizationHelper.java index db80201ee..32d1e2ec1 100644 --- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/spi/p2/publisher/LocalizationHelper.java +++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/spi/p2/publisher/LocalizationHelper.java @@ -72,7 +72,7 @@ public final class LocalizationHelper { Locale nextLocale = getLocale(LocalizationHelper.getLocaleString(nextFile, localizationFile)); try { - Map properties = loadProperties(root, nextFile); + Map properties = loadProperties(localizationDir, nextFile); Map localizedStrings = getLocalizedProperties(propertyKeys, properties); if (localizedStrings.size() > 0) { localizations.put(nextLocale, localizedStrings); diff --git a/bundles/org.eclipse.equinox.p2.tests/All p2 Tests.launch b/bundles/org.eclipse.equinox.p2.tests/All p2 Tests.launch index 852c329c6..1b0fa7c0b 100644 --- a/bundles/org.eclipse.equinox.p2.tests/All p2 Tests.launch +++ b/bundles/org.eclipse.equinox.p2.tests/All p2 Tests.launch @@ -52,7 +52,7 @@ - + diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/LocalizationTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/LocalizationTests.java index a9c32c38e..de26b0068 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/LocalizationTests.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/LocalizationTests.java @@ -53,6 +53,7 @@ public class LocalizationTests extends TestCase { } public void testBundleLocalizationDE() throws IOException { + //Tests with the default localization file location File file = TestData.getFile("localizationtests/foobundle", ""); BundlesAction action = new BundlesAction(new File[] {file}); action.perform(info, results, monitor); @@ -63,6 +64,39 @@ public class LocalizationTests extends TestCase { assertEquals("1.1", "Foo German Provider", utils.getIUProperty(iu, IInstallableUnit.PROP_PROVIDER, Locale.GERMAN.toString())); } + public void testBundleLocalizationDefaultDE() throws IOException { + File file = TestData.getFile("localizationtests/foobundle_default", ""); + BundlesAction action = new BundlesAction(new File[] {file}); + action.perform(info, results, monitor); + TranslationSupport utils = getTranslationSupport(); + IQueryResult queryResult = results.query(QueryUtil.createIUQuery("foobundle"), monitor); + IInstallableUnit iu = (IInstallableUnit) queryResult.iterator().next(); + assertEquals("1.0", "Foo German Bundle", utils.getIUProperty(iu, IInstallableUnit.PROP_NAME, Locale.GERMAN.toString())); + assertEquals("1.1", "Foo German Provider", utils.getIUProperty(iu, IInstallableUnit.PROP_PROVIDER, Locale.GERMAN.toString())); + } + + public void testBundleLocalizationDefaultDEJar() throws IOException { + File file = TestData.getFile("localizationtests/foobundle_1.0.0.qualifier.jar", ""); + BundlesAction action = new BundlesAction(new File[] {file}); + action.perform(info, results, monitor); + TranslationSupport utils = getTranslationSupport(); + IQueryResult queryResult = results.query(QueryUtil.createIUQuery("foobundle"), monitor); + IInstallableUnit iu = (IInstallableUnit) queryResult.iterator().next(); + assertEquals("1.0", "Foo German Bundle", utils.getIUProperty(iu, IInstallableUnit.PROP_NAME, Locale.GERMAN.toString())); + assertEquals("1.1", "Foo German Provider", utils.getIUProperty(iu, IInstallableUnit.PROP_PROVIDER, Locale.GERMAN.toString())); + } + + public void testBundleLocalizationOSGI_INF_DE() throws IOException { + File file = TestData.getFile("localizationtests/foobundle_osgi-inf", ""); + BundlesAction action = new BundlesAction(new File[] {file}); + action.perform(info, results, monitor); + TranslationSupport utils = getTranslationSupport(); + IQueryResult queryResult = results.query(QueryUtil.createIUQuery("foobundle"), monitor); + IInstallableUnit iu = (IInstallableUnit) queryResult.iterator().next(); + assertEquals("1.0", "Foo German Bundle", utils.getIUProperty(iu, IInstallableUnit.PROP_NAME, Locale.GERMAN.toString())); + assertEquals("1.1", "Foo German Provider", utils.getIUProperty(iu, IInstallableUnit.PROP_PROVIDER, Locale.GERMAN.toString())); + } + public void testBundleLocalizationDE_alternatePropFile() throws IOException { File file = TestData.getFile("localizationtests/barbundle", ""); BundlesAction action = new BundlesAction(new File[] {file}); @@ -100,6 +134,17 @@ public class LocalizationTests extends TestCase { assertEquals("1.1", "Foo German Provider - Translated in the Fragment", utils.getIUProperty(iu, IInstallableUnit.PROP_PROVIDER, Locale.GERMAN.toString())); } + public void testBundleLocalizationOSGI_INF_EN() throws IOException { + File file = TestData.getFile("localizationtests/foobundle_osgi-inf", ""); + BundlesAction action = new BundlesAction(new File[] {file}); + action.perform(info, results, monitor); + TranslationSupport utils = getTranslationSupport(); + IQueryResult queryResult = results.query(QueryUtil.createIUQuery("foobundle"), monitor); + IInstallableUnit iu = (IInstallableUnit) queryResult.iterator().next(); + assertEquals("1.0", "Foo English Bundle", utils.getIUProperty(iu, IInstallableUnit.PROP_NAME, Locale.ENGLISH.toString())); + assertEquals("1.1", "Foo English Provider", utils.getIUProperty(iu, IInstallableUnit.PROP_PROVIDER, Locale.ENGLISH.toString())); + } + public void testBundleLocalizationEN() throws IOException { File file = TestData.getFile("localizationtests/foobundle", ""); BundlesAction action = new BundlesAction(new File[] {file}); @@ -111,6 +156,18 @@ public class LocalizationTests extends TestCase { assertEquals("1.1", "Foo English Provider", utils.getIUProperty(iu, IInstallableUnit.PROP_PROVIDER, Locale.ENGLISH.toString())); } + public void testBundleLocalizationENDefault() throws IOException { + // Tests with the default localization file location + File file = TestData.getFile("localizationtests/foobundle_default", ""); + BundlesAction action = new BundlesAction(new File[] {file}); + action.perform(info, results, monitor); + TranslationSupport utils = getTranslationSupport(); + IQueryResult queryResult = results.query(QueryUtil.createIUQuery("foobundle"), monitor); + IInstallableUnit iu = (IInstallableUnit) queryResult.iterator().next(); + assertEquals("1.0", "Foo English Bundle", utils.getIUProperty(iu, IInstallableUnit.PROP_NAME, Locale.ENGLISH.toString())); + assertEquals("1.1", "Foo English Provider", utils.getIUProperty(iu, IInstallableUnit.PROP_PROVIDER, Locale.ENGLISH.toString())); + } + public void testBundleLocalizationEN_alternatePropFile() throws IOException { File file = TestData.getFile("localizationtests/barbundle", ""); BundlesAction action = new BundlesAction(new File[] {file}); diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/localizationtests/foobundle_1.0.0.qualifier.jar b/bundles/org.eclipse.equinox.p2.tests/testData/localizationtests/foobundle_1.0.0.qualifier.jar new file mode 100644 index 000000000..f8f42facd Binary files /dev/null and b/bundles/org.eclipse.equinox.p2.tests/testData/localizationtests/foobundle_1.0.0.qualifier.jar differ diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/localizationtests/foobundle_default/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.tests/testData/localizationtests/foobundle_default/META-INF/MANIFEST.MF new file mode 100644 index 000000000..54aa697a9 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests/testData/localizationtests/foobundle_default/META-INF/MANIFEST.MF @@ -0,0 +1,8 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: %name +Bundle-SymbolicName: foobundle +Bundle-Version: 1.0.0.qualifier +Bundle-Vendor: %provider +Require-Bundle: org.eclipse.core.runtime +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/localizationtests/foobundle_default/OSGI-INF/l10n/bundle.properties b/bundles/org.eclipse.equinox.p2.tests/testData/localizationtests/foobundle_default/OSGI-INF/l10n/bundle.properties new file mode 100644 index 000000000..9a0f12777 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests/testData/localizationtests/foobundle_default/OSGI-INF/l10n/bundle.properties @@ -0,0 +1,2 @@ +name=Foo English Bundle +provider=Foo English Provider \ No newline at end of file diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/localizationtests/foobundle_default/OSGI-INF/l10n/bundle_de.properties b/bundles/org.eclipse.equinox.p2.tests/testData/localizationtests/foobundle_default/OSGI-INF/l10n/bundle_de.properties new file mode 100644 index 000000000..cbd6d5c5b --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests/testData/localizationtests/foobundle_default/OSGI-INF/l10n/bundle_de.properties @@ -0,0 +1,2 @@ +name=Foo German Bundle +provider=Foo German Provider \ No newline at end of file diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/localizationtests/foobundle_osgi-inf/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.tests/testData/localizationtests/foobundle_osgi-inf/META-INF/MANIFEST.MF new file mode 100644 index 000000000..e69b74ad9 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests/testData/localizationtests/foobundle_osgi-inf/META-INF/MANIFEST.MF @@ -0,0 +1,9 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: %name +Bundle-SymbolicName: foobundle +Bundle-Version: 1.0.0.qualifier +Bundle-Vendor: %provider +Require-Bundle: org.eclipse.core.runtime +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Bundle-Localization: OSGI-INF/bundle diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/localizationtests/foobundle_osgi-inf/OSGI-INF/bundle.properties b/bundles/org.eclipse.equinox.p2.tests/testData/localizationtests/foobundle_osgi-inf/OSGI-INF/bundle.properties new file mode 100644 index 000000000..9a0f12777 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests/testData/localizationtests/foobundle_osgi-inf/OSGI-INF/bundle.properties @@ -0,0 +1,2 @@ +name=Foo English Bundle +provider=Foo English Provider \ No newline at end of file diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/localizationtests/foobundle_osgi-inf/OSGI-INF/bundle_de.properties b/bundles/org.eclipse.equinox.p2.tests/testData/localizationtests/foobundle_osgi-inf/OSGI-INF/bundle_de.properties new file mode 100644 index 000000000..cbd6d5c5b --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests/testData/localizationtests/foobundle_osgi-inf/OSGI-INF/bundle_de.properties @@ -0,0 +1,2 @@ +name=Foo German Bundle +provider=Foo German Provider \ No newline at end of file -- cgit v1.2.3