diff options
author | gkessler | 2007-09-05 21:59:40 +0000 |
---|---|---|
committer | gkessler | 2007-09-05 21:59:40 +0000 |
commit | 6c6ac2243441a5ddca2186c2cd914fab3f7ae84e (patch) | |
tree | 6e57a0c3301b4765ddf0967121c8b369a8fad45d | |
parent | 4751fe7b6c62d3ec59ffa3aef99dcb907974d9d6 (diff) | |
download | webtools.jsf-6c6ac2243441a5ddca2186c2cd914fab3f7ae84e.tar.gz webtools.jsf-6c6ac2243441a5ddca2186c2cd914fab3f7ae84e.tar.xz webtools.jsf-6c6ac2243441a5ddca2186c2cd914fab3f7ae84e.zip |
fix for failing JSF JUnits wrt resourceBundles on linux build machine. Probably also fixes https://bugs.eclipse.org/bugs/show_bug.cgi?id=181751.
5 files changed, 27 insertions, 22 deletions
diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IResourceBundleProvider.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IResourceBundleProvider.java index 1e862c1ed..640da3540 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IResourceBundleProvider.java +++ b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/IResourceBundleProvider.java @@ -10,8 +10,6 @@ *******************************************************************************/ package org.eclipse.jst.jsf.common.metadata.internal; -import java.io.IOException; -import java.net.MalformedURLException; import java.util.ResourceBundle; /** @@ -21,5 +19,5 @@ public interface IResourceBundleProvider { /** * @return ResourceBundle - implementers should eat exceptions and return null whenever resourceBundle cannot be returned */ - public ResourceBundle getResourceBundle() throws IOException, MalformedURLException; + public ResourceBundle getResourceBundle(); } diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/PluginRelativeStandardMetaDataSourceFileLocator.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/PluginRelativeStandardMetaDataSourceFileLocator.java index 492099a10..0fb939c4c 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/PluginRelativeStandardMetaDataSourceFileLocator.java +++ b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/PluginRelativeStandardMetaDataSourceFileLocator.java @@ -69,7 +69,7 @@ public class PluginRelativeStandardMetaDataSourceFileLocator extends StandardMet IPath annotationPath = Path.fromOSString(fileInfo.getLocation()); IPath annotationFolder = annotationPath.removeLastSegments(1); IPath propertiesLocation = annotationPath.removeFirstSegments(annotationPath.segmentCount() - 1).removeFileExtension(); - // append location of propertiles file + // append location of properties file IPath propertiesFile = annotationFolder.append(propertiesLocation); // append .properties extension if needed diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/ResourceBundleHelper.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/ResourceBundleHelper.java index 229bc7db3..8856beec4 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/ResourceBundleHelper.java +++ b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/ResourceBundleHelper.java @@ -20,6 +20,8 @@ import java.util.Locale; import java.util.ResourceBundle; import org.eclipse.core.runtime.FileLocator; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; /** * ResourceBundleHelper @@ -49,6 +51,13 @@ public class ResourceBundleHelper { // we make the assumption that the resourceURI points to the local // file system + //in case of linux, let's change back to a path... + IPath resourcePath = new Path(resourceURI); + //ensure we have at least 2 segments... 1 for bundle/device, and 1 for propfile + if (resourcePath.segmentCount() < 2) + throw new IllegalArgumentException("Invalid resourceURI"); //$NON-NLS-1$ + +/* OLD CODE int index = resourceURI.lastIndexOf("/"); //$NON-NLS-1$ if (index == -1) { throw new IllegalArgumentException("Invalid resourceURI"); //$NON-NLS-1$ @@ -60,9 +69,13 @@ public class ResourceBundleHelper { // Otherwise, the URL is assumed // to refer to a JAR file which will be opened as needed. // - String resourceDirectory = resourceURI.substring(0, index + 1); - String resourceBundleName = resourceURI.substring(index + 1); - +// String resourceDirectory = resourceURI.substring(0, index + 1); +// String resourceBundleName = resourceURI.substring(index + 1); + +*/ + String resourceDirectory = resourcePath.removeLastSegments(1).toString(); + String resourceBundleName = resourcePath.lastSegment(); + // create a class loader with a class path that points to the resource // bundle's location // diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/StandardMetaDataFileRegistry.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/StandardMetaDataFileRegistry.java index c8621e510..e49ca1ae7 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/StandardMetaDataFileRegistry.java +++ b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/StandardMetaDataFileRegistry.java @@ -16,12 +16,12 @@ package org.eclipse.jst.jsf.common.metadata.internal; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; -import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.MissingResourceException; import java.util.ResourceBundle; import org.eclipse.core.runtime.FileLocator; @@ -183,15 +183,15 @@ class StandardMetaDataFilesProvider implements IMetaDataSourceModelProvider { /* (non-Javadoc) * @see org.eclipse.jst.jsf.common.metadata.internal.IMetaDataSourceModelProvider#getResourceBundle() */ - private ResourceBundle internalGetResourceBundle()throws IOException, MalformedURLException { + private ResourceBundle internalGetResourceBundle() { if (getFileLocator() != null){ -// try { + try { return fileLocator.getResourceBundle(); -// } catch (MissingResourceException e) { -// //eat it -// } catch (IOException e) { -// //eat it -// } + } catch (MissingResourceException e) { + JSFCommonPlugin.log(IStatus.ERROR, "InternalGetResourceBundle1", e); + } catch (IOException e) { + JSFCommonPlugin.log(IStatus.ERROR, "InternalGetResourceBundle2", e); + } } return null; } @@ -232,7 +232,7 @@ class StandardMetaDataFilesProvider implements IMetaDataSourceModelProvider { } else if (klass == IResourceBundleProvider.class) { return new IResourceBundleProvider(){ - public ResourceBundle getResourceBundle() throws IOException, MalformedURLException { + public ResourceBundle getResourceBundle() { return mdp.internalGetResourceBundle(); } diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/TraitValueHelper.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/TraitValueHelper.java index f3031b3c6..d45da0f83 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/TraitValueHelper.java +++ b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/metadata/internal/TraitValueHelper.java @@ -11,8 +11,6 @@ ********************************************************************************/ package org.eclipse.jst.jsf.common.metadata.internal; -import java.io.IOException; -import java.net.MalformedURLException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -162,10 +160,6 @@ public class TraitValueHelper { } catch (MissingResourceException e){ //fall thru JSFCommonPlugin.log(e, NLS.bind(Messages.MissingResource_exception, new String[]{key})); - } catch (MalformedURLException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); } return key + KEY_NOT_FOUND; } |