Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 141730 Details for
Bug 283472
JSF facet does not validate user library version for JSF
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
Patch to add JUnits for version validation code
patch.txt (text/plain), 11.70 KB, created by
Debajit Adhikary
on 2009-07-15 20:40:38 EDT
(
hide
)
Description:
Patch to add JUnits for version validation code
Filename:
MIME Type:
Creator:
Debajit Adhikary
Created:
2009-07-15 20:40:38 EDT
Size:
11.70 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jst.jsf.core.tests >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jsf/components/jsf/tests/org.eclipse.jst.jsf.core.tests/META-INF/MANIFEST.MF,v >retrieving revision 1.28 >diff -u -r1.28 MANIFEST.MF >--- META-INF/MANIFEST.MF 6 Feb 2009 22:14:05 -0000 1.28 >+++ META-INF/MANIFEST.MF 16 Jul 2009 00:35:15 -0000 >@@ -29,7 +29,8 @@ > org.eclipse.jst.jsp.core, > org.eclipse.wst.html.core, > org.eclipse.ui.ide;bundle-version="3.4.0", >- org.eclipse.jst.common.frameworks;bundle-version="[1.1.0,2.0.0)" >+ org.eclipse.jst.common.frameworks;bundle-version="[1.1.0,2.0.0)", >+ org.eclipse.jst.common.project.facet.core > Bundle-ActivationPolicy: lazy > Export-Package: org.eclipse.jst.jsf.core.tests;x-friends:="org.eclipse.jst.jsf.ui.tests,org.eclipse.jst.jsf.context.symbol.tests,org.eclipse.jst.jsf.designtime.tests", > org.eclipse.jst.jsf.core.tests.appconfig.provider;x-internal:=true, >Index: src/org/eclipse/jst/jsf/core/tests/AllTests.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jsf/components/jsf/tests/org.eclipse.jst.jsf.core.tests/src/org/eclipse/jst/jsf/core/tests/AllTests.java,v >retrieving revision 1.19 >diff -u -r1.19 AllTests.java >--- src/org/eclipse/jst/jsf/core/tests/AllTests.java 4 Nov 2008 01:28:14 -0000 1.19 >+++ src/org/eclipse/jst/jsf/core/tests/AllTests.java 16 Jul 2009 00:35:15 -0000 >@@ -14,6 +14,7 @@ > import junit.framework.TestSuite; > > import org.eclipse.jst.jsf.core.tests.appconfig.validation.AppConfigValidationUtilTestCase; >+import org.eclipse.jst.jsf.core.tests.facet.JsfLibraryValidatorTest; > import org.eclipse.jst.jsf.core.tests.jsflibraryconfig.JSFLibraryConfigDialogSettingDataTestCases; > import org.eclipse.jst.jsf.core.tests.jsflibraryconfig.JSFLibraryConfigModelTestCases; > import org.eclipse.jst.jsf.core.tests.jsflibraryconfig.JSFLibraryRegistryUtilTestCases; >@@ -95,6 +96,10 @@ > > suite.addTestSuite(JSFLibraryReferenceTestCases.class); > suite.addTestSuite(JSFLibraryServerSuppliedReferenceTestCases.class); >+ >+ // JSF library version validation tests >+ suite.addTestSuite(JsfLibraryValidatorTest.class); >+ > // > //$JUnit-END$ > return suite; >Index: src/org/eclipse/jst/jsf/core/tests/facet/JsfLibraryValidatorTest.java >=================================================================== >RCS file: src/org/eclipse/jst/jsf/core/tests/facet/JsfLibraryValidatorTest.java >diff -N src/org/eclipse/jst/jsf/core/tests/facet/JsfLibraryValidatorTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jst/jsf/core/tests/facet/JsfLibraryValidatorTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,39 @@ >+/******************************************************************************* >+ * Copyright (c) 2001, 2008 Oracle Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Oracle Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+ >+package org.eclipse.jst.jsf.core.tests.facet; >+ >+ >+/** >+ * @author Debajit Adhikary >+ * >+ */ >+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 EXPECTED_LIBRARY_VERSION = "1.1.3"; //$NON-NLS-1$ >+ >+ >+ /** >+ * @param name >+ */ >+ public JsfLibraryValidatorTest (final String name) >+ { >+ super(name, >+ CLASS_NAME_IDENTIFYING_IMPLEMENTATION_JAR, >+ JARFILE, >+ JARFILE_WITHOUT_IMPLEMENTATION_VERSION_ENTRY, >+ EXPECTED_LIBRARY_VERSION); >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/jst/jsf/core/tests/facet/UserLibraryVersionValidatorProxy.java >=================================================================== >RCS file: src/org/eclipse/jst/jsf/core/tests/facet/UserLibraryVersionValidatorProxy.java >diff -N src/org/eclipse/jst/jsf/core/tests/facet/UserLibraryVersionValidatorProxy.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jst/jsf/core/tests/facet/UserLibraryVersionValidatorProxy.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,52 @@ >+/******************************************************************************* >+ * Copyright (c) 2001, 2008 Oracle Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Oracle Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+ >+package org.eclipse.jst.jsf.core.tests.facet; >+ >+import java.io.IOException; >+import java.util.jar.JarFile; >+ >+ >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.jst.jsf.common.facet.libraryprovider.UserLibraryVersionValidator; >+ >+ >+/** >+ * "Proxy" class for the actual UserLibraryVersionValidator. This is only used so >+ * that the protected methods in UserLibraryVersionValidator can be tested. >+ * >+ * The test-cases have package-level access to these protected methods. >+ * >+ * @author Debajit Adhikary >+ * >+ */ >+public class UserLibraryVersionValidatorProxy extends UserLibraryVersionValidator >+{ >+ public UserLibraryVersionValidatorProxy (final String classNameIdentifyingJar) >+ { >+ super(classNameIdentifyingJar); >+ } >+ >+ >+ @Override >+ protected IStatus validateVersionStrings (final String facetVersion, final String libraryVersion) >+ { >+ return super.validateVersionStrings(facetVersion, libraryVersion); >+ } >+ >+ >+ @Override >+ protected String getLibraryVersion (final JarFile jarFile) throws IOException >+ { >+ return super.getLibraryVersion(jarFile); >+ } >+} >Index: src/org/eclipse/jst/jsf/core/tests/facet/LibraryValidatorTest.java >=================================================================== >RCS file: src/org/eclipse/jst/jsf/core/tests/facet/LibraryValidatorTest.java >diff -N src/org/eclipse/jst/jsf/core/tests/facet/LibraryValidatorTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jst/jsf/core/tests/facet/LibraryValidatorTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,146 @@ >+/******************************************************************************* >+ * Copyright (c) 2001, 2008 Oracle Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Oracle Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+ >+package org.eclipse.jst.jsf.core.tests.facet; >+ >+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; >+ >+import org.eclipse.core.runtime.FileLocator; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Plugin; >+import org.eclipse.jst.jsf.core.tests.TestsPlugin; >+import org.osgi.framework.Bundle; >+ >+ >+/** >+ * @author Debajit Adhikary >+ * >+ */ >+public abstract class LibraryValidatorTest extends TestCase >+{ >+ private String classNameIdentifyingJarToUse; >+ private String jarPath; >+ private String jarPathWithoutImplementationVersionEntry; >+ private String expectedLibraryVersion; >+ private UserLibraryVersionValidatorProxy validator; >+ >+ >+ /** >+ * @param name >+ */ >+ public LibraryValidatorTest (final String name) >+ { >+ super(name); >+ } >+ >+ >+ public LibraryValidatorTest (final String name, >+ final String classNameIdentifyingJarToUse, >+ final String jarPath, >+ final String jarPathWithoutImplementationVersionEntry, >+ final String expectedLibraryVersion) >+ { >+ super(name); >+ >+ this.classNameIdentifyingJarToUse = classNameIdentifyingJarToUse; >+ this.jarPath = jarPath; >+ this.jarPathWithoutImplementationVersionEntry = jarPathWithoutImplementationVersionEntry; >+ this.expectedLibraryVersion = expectedLibraryVersion; >+ >+ this.validator = new UserLibraryVersionValidatorProxy(this.classNameIdentifyingJarToUse); >+ } >+ >+ >+ public void testVersionStringSuffixMatch () >+ { >+ assertNotNull(validator); >+ >+ final IStatus status = validator.validateVersionStrings("1.2", "1.1.2"); >+ assertEquals(IStatus.ERROR, status.getSeverity()); >+ } >+ >+ >+ public void testVersionStringPrefixMatch () >+ { >+ assertNotNull(validator); >+ >+ final IStatus status = validator.validateVersionStrings("1.2", "1.2.11"); >+ assertEquals(IStatus.OK, status.getSeverity()); >+ } >+ >+ >+ public void testNullLibraryVersionString () >+ { >+ assertNotNull(validator); >+ >+ final IStatus status = validator.validateVersionStrings("1.2", null); >+ assertEquals(IStatus.WARNING, status.getSeverity()); >+ } >+ >+ >+ public void testNullFacetVersionString () >+ { >+ assertNotNull(validator); >+ >+ try >+ { >+ validator.validateVersionStrings(null, "1.0.1.2.11"); // Fails >+ } >+ catch (final IllegalArgumentException e) >+ { >+ assertEquals("Cannot read facet version", e.getLocalizedMessage()); >+ return; >+ } >+ >+ fail(); >+ } >+ >+ >+ protected File getFileFromPlugin (final String relativePathToFile, >+ final Plugin plugin) >+ throws IOException, URISyntaxException >+ { >+ final Bundle bundle = TestsPlugin.getDefault().getBundle(); >+ >+ final URL bundleUrl = bundle.getEntry(relativePathToFile); >+ assertNotNull(bundleUrl); >+ >+ final URL fileUrl = FileLocator.toFileURL(bundleUrl); >+ final File file = new File(fileUrl.getPath()); >+ assertTrue(file.exists()); >+ return file; >+ } >+ >+ >+ public void testReadLibraryVersionFromJarWithManifestEntry () >+ throws IOException, URISyntaxException >+ { >+ final JarFile jarFile = new JarFile(getFileFromPlugin(jarPath, TestsPlugin.getDefault())); >+ assertEquals(expectedLibraryVersion, validator.getLibraryVersion(jarFile)); >+ } >+ >+ >+ public void testReadLibraryVersionFromJarWithoutManifestEntry () >+ throws IOException, URISyntaxException >+ { >+ final JarFile jarFile = new JarFile(getFileFromPlugin(jarPathWithoutImplementationVersionEntry, TestsPlugin.getDefault())); >+ assertNull("Was expecting library-version string to be null", validator.getLibraryVersion(jarFile)); //$NON-NLS-1$ >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 283472
:
141582
| 141730