PMC approved fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=286351
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/AllTests.java b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/AllTests.java
index 544bfe0..3007f93 100644
--- a/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/AllTests.java
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/AllTests.java
@@ -15,6 +15,7 @@
import org.eclipse.jst.jsf.core.tests.appconfig.validation.AppConfigValidationUtilTestCase;
import org.eclipse.jst.jsf.core.tests.facet.JsfLibraryProviderTests;
+import org.eclipse.jst.jsf.core.tests.facet.JsfLibraryValidatorTest;
import org.eclipse.jst.jsf.core.tests.facet.VendorSpecificWebXmlConfigurationForJ2EETest;
import org.eclipse.jst.jsf.core.tests.facet.VendorSpecificWebXmlConfigurationForJavaEETest;
import org.eclipse.jst.jsf.core.tests.jsflibraryconfig.JSFLibraryRegistryUtilTestCases;
@@ -79,6 +80,7 @@
suite.addTestSuite(JSFProjectLibraryReferenceTestCases.class);
// suite.addTestSuite(JSFLibraryConfigModelTestCases.class);
suite.addTestSuite(JSFLibraryRegistryUtilTestCases.class);
+ suite.addTestSuite(JsfLibraryValidatorTest.class);
suite.addTestSuite(TestJSPSemanticsValidator_Containment.class);
suite.addTestSuite(TestJSPSemanticsValidator_AttributeValues.class);
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/facet/JsfLibraryValidatorTest.java b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/facet/JsfLibraryValidatorTest.java
index 886381e..1b58f51 100644
--- a/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/facet/JsfLibraryValidatorTest.java
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/facet/JsfLibraryValidatorTest.java
@@ -20,8 +20,9 @@
public class JsfLibraryValidatorTest extends LibraryValidatorTest
{
private static final String CLASS_NAME_IDENTIFYING_IMPLEMENTATION_JAR = "javax/faces/render/RenderKit.class"; //$NON-NLS-1$
- private static final String JARFILE = "testdata/facet/jars/myfaces-api-1.1.3.jar"; //$NON-NLS-1$
- private static final String JARFILE_WITHOUT_IMPLEMENTATION_VERSION_ENTRY = "testdata/facet/jars/no-version-entry/myfaces-api-1.1.3.jar"; //$NON-NLS-1$
+ private static final String JARFILE = "testfiles/facet/jsflibrary-api-1.1.3.jar"; //$NON-NLS-1$
+ private static final String JARFILE_WITHOUT_IMPLEMENTATION_VERSION_ENTRY = "testfiles/facet/no-version-entry/jsflibrary-api-1.1.3.jar"; //$NON-NLS-1$
+ private static final String JARFILE_WITH_NONSTANDARD_IMPLEMENTATION_VERSION_ENTRY = "testfiles/facet/nonstandard_implementation_version/jsflibrary-api-1.1.3.jar"; //$NON-NLS-1$
private static final String EXPECTED_LIBRARY_VERSION = "1.1.3"; //$NON-NLS-1$
@@ -34,6 +35,7 @@
CLASS_NAME_IDENTIFYING_IMPLEMENTATION_JAR,
JARFILE,
JARFILE_WITHOUT_IMPLEMENTATION_VERSION_ENTRY,
+ JARFILE_WITH_NONSTANDARD_IMPLEMENTATION_VERSION_ENTRY,
EXPECTED_LIBRARY_VERSION);
}
}
\ No newline at end of file
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/facet/LibraryValidatorTest.java b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/facet/LibraryValidatorTest.java
index b95b55d..6c58344 100644
--- a/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/facet/LibraryValidatorTest.java
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/facet/LibraryValidatorTest.java
@@ -14,10 +14,8 @@
import java.io.File;
import java.io.IOException;
-import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
-import java.net.URLEncoder;
import java.util.jar.JarFile;
import junit.framework.TestCase;
@@ -38,6 +36,7 @@
private String classNameIdentifyingJarToUse;
private String jarPath;
private String jarPathWithoutImplementationVersionEntry;
+ private String jarPathWithNonstandardImplementationVersionEntry;
private String expectedLibraryVersion;
private UserLibraryVersionValidatorProxy validator;
@@ -55,6 +54,7 @@
final String classNameIdentifyingJarToUse,
final String jarPath,
final String jarPathWithoutImplementationVersionEntry,
+ final String jarPathWithNonstandardImplementationVersionEntry,
final String expectedLibraryVersion)
{
super(name);
@@ -62,6 +62,7 @@
this.classNameIdentifyingJarToUse = classNameIdentifyingJarToUse;
this.jarPath = jarPath;
this.jarPathWithoutImplementationVersionEntry = jarPathWithoutImplementationVersionEntry;
+ this.jarPathWithNonstandardImplementationVersionEntry = jarPathWithNonstandardImplementationVersionEntry;
this.expectedLibraryVersion = expectedLibraryVersion;
this.validator = new UserLibraryVersionValidatorProxy(this.classNameIdentifyingJarToUse);
@@ -143,4 +144,23 @@
final JarFile jarFile = new JarFile(getFileFromPlugin(jarPathWithoutImplementationVersionEntry, TestsPlugin.getDefault()));
assertNull("Was expecting library-version string to be null", validator.getLibraryVersion(jarFile)); //$NON-NLS-1$
}
+
+
+ /**
+ * Regression test-case. This would fail earlier without the patch in
+ *
+ * "JSF Facet version validator fails to validate some non-standard jars"
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=286351
+ *
+ * @throws IOException
+ * @throws URISyntaxException
+ *
+ */
+ public void testReadLibraryVersionFromJarWithNonstandardImplementationVersion()
+ throws IOException, URISyntaxException
+ {
+ final JarFile jarFile = new JarFile(getFileFromPlugin(jarPathWithNonstandardImplementationVersionEntry, TestsPlugin.getDefault()));
+ assertNotNull("Was expecting library-version string to be non-null", validator.getLibraryVersion(jarFile)); //$NON-NLS-1$
+ assertEquals(expectedLibraryVersion, validator.getLibraryVersion(jarFile));
+ }
}
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/facet/jsflibrary-api-1.1.3.jar b/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/facet/jsflibrary-api-1.1.3.jar
new file mode 100644
index 0000000..f4fac81
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/facet/jsflibrary-api-1.1.3.jar
Binary files differ
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/facet/no-version-entry/jsflibrary-api-1.1.3.jar b/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/facet/no-version-entry/jsflibrary-api-1.1.3.jar
new file mode 100644
index 0000000..5cff505
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/facet/no-version-entry/jsflibrary-api-1.1.3.jar
Binary files differ
diff --git a/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/facet/nonstandard_implementation_version/jsflibrary-api-1.1.3.jar b/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/facet/nonstandard_implementation_version/jsflibrary-api-1.1.3.jar
new file mode 100644
index 0000000..4bc7917
--- /dev/null
+++ b/jsf/tests/org.eclipse.jst.jsf.core.tests/testfiles/facet/nonstandard_implementation_version/jsflibrary-api-1.1.3.jar
Binary files differ