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 67026 Details for
Bug 177676
[JUnit] Problems with JUnits with multiple versions of same bundle
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]
updated patch
177676.patch (text/plain), 8.90 KB, created by
Martin Aeschlimann
on 2007-05-14 05:46:26 EDT
(
hide
)
Description:
updated patch
Filename:
MIME Type:
Creator:
Martin Aeschlimann
Created:
2007-05-14 05:46:26 EDT
Size:
8.90 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.junit >Index: src/org/eclipse/jdt/internal/junit/ui/JUnitPlugin.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/JUnitPlugin.java,v >retrieving revision 1.50 >diff -u -r1.50 JUnitPlugin.java >--- src/org/eclipse/jdt/internal/junit/ui/JUnitPlugin.java 28 Mar 2007 14:43:42 -0000 1.50 >+++ src/org/eclipse/jdt/internal/junit/ui/JUnitPlugin.java 14 May 2007 09:38:36 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2006 IBM Corporation and others. >+ * Copyright (c) 2000, 2007 IBM 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 >@@ -320,16 +320,29 @@ > * @since 3.2 > */ > public Bundle getBundle(String bundleName) { >- Bundle bundle= Platform.getBundle(bundleName); >- if (bundle != null) >- return bundle; >+ Bundle[] bundles= getBundles(bundleName, null); >+ if (bundles != null && bundles.length > 0) >+ return bundles[0]; >+ return null; >+ } >+ >+ /** >+ * Returns the bundles for a given bundle name, >+ * >+ * @param bundleName the bundle name >+ * @return the bundles of the given name >+ */ >+ public Bundle[] getBundles(String bundleName, String version) { >+ Bundle[] bundles= Platform.getBundles(bundleName, version); >+ if (bundles != null) >+ return bundles; > > // Accessing unresolved bundle > ServiceReference serviceRef= fBundleContext.getServiceReference(PackageAdmin.class.getName()); > PackageAdmin admin= (PackageAdmin)fBundleContext.getService(serviceRef); >- Bundle[] bundles= admin.getBundles(bundleName, null); >+ bundles= admin.getBundles(bundleName, version); > if (bundles != null && bundles.length > 0) >- return bundles[0]; >+ return bundles; > return null; > } > >Index: src/org/eclipse/jdt/internal/junit/buildpath/JUnitHomeInitializer.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/buildpath/JUnitHomeInitializer.java,v >retrieving revision 1.3 >diff -u -r1.3 JUnitHomeInitializer.java >--- src/org/eclipse/jdt/internal/junit/buildpath/JUnitHomeInitializer.java 11 May 2007 20:03:27 -0000 1.3 >+++ src/org/eclipse/jdt/internal/junit/buildpath/JUnitHomeInitializer.java 14 May 2007 09:38:36 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2006 IBM Corporation and others. >+ * Copyright (c) 2000, 2007 IBM 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 >@@ -34,7 +34,7 @@ > > private void initializeHome() { > try { >- IPath location= BuildPathSupport.getBundleLocation(BuildPathSupport.JUNIT3_PLUGIN_ID); >+ IPath location= BuildPathSupport.getBundleLocation(BuildPathSupport.JUNIT3_PLUGIN); > if (location != null) { > JavaCore.setClasspathVariable(JUnitPlugin.JUNIT_HOME, location, null); > } else { >@@ -47,7 +47,7 @@ > > private void initializeSource() { > try { >- IPath sourceLocation= BuildPathSupport.getSourceLocation(BuildPathSupport.JUNIT3_PLUGIN_ID); >+ IPath sourceLocation= BuildPathSupport.getSourceLocation(BuildPathSupport.JUNIT3_PLUGIN); > if (sourceLocation != null) { > JavaCore.setClasspathVariable(JUnitPlugin.JUNIT_SRC_HOME, sourceLocation, null); > } else { >Index: src/org/eclipse/jdt/internal/junit/buildpath/BuildPathSupport.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/buildpath/BuildPathSupport.java,v >retrieving revision 1.12 >diff -u -r1.12 BuildPathSupport.java >--- src/org/eclipse/jdt/internal/junit/buildpath/BuildPathSupport.java 11 May 2007 20:03:27 -0000 1.12 >+++ src/org/eclipse/jdt/internal/junit/buildpath/BuildPathSupport.java 14 May 2007 09:38:36 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2006 IBM Corporation and others. >+ * Copyright (c) 2000, 2007 IBM 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 >@@ -19,6 +19,8 @@ > import org.eclipse.core.runtime.IPath; > import org.eclipse.core.runtime.Path; > >+import org.eclipse.osgi.service.resolver.VersionRange; >+ > import org.eclipse.jdt.core.IAccessRule; > import org.eclipse.jdt.core.IClasspathAttribute; > import org.eclipse.jdt.core.IClasspathEntry; >@@ -28,17 +30,51 @@ > import org.eclipse.jdt.internal.junit.ui.JUnitPreferencesConstants; > > import org.osgi.framework.Bundle; >+import org.osgi.framework.Constants; >+import org.osgi.framework.Version; > > /** > * > */ > public class BuildPathSupport { > >- public static final String JUNIT3_PLUGIN_ID= "org.junit"; //$NON-NLS-1$ >- public static final String JUNIT4_PLUGIN_ID= "org.junit4"; //$NON-NLS-1$ >+ public static class JUnitPluginDescription { >+ private final String fBundleId; >+ private final VersionRange fVersionRange; >+ >+ public JUnitPluginDescription(String bundleId, VersionRange versionRange) { >+ fBundleId= bundleId; >+ fVersionRange= versionRange; >+ } >+ >+ public Bundle getBundle() { >+ Bundle[] bundles= JUnitPlugin.getDefault().getBundles(fBundleId, null); >+ if (bundles != null) { >+ for (int i= 0; i < bundles.length; i++) { >+ Bundle curr= bundles[i]; >+ String version= (String) curr.getHeaders().get(Constants.BUNDLE_VERSION); >+ try { >+ if (fVersionRange.isIncluded(Version.parseVersion(version))) { >+ return curr; >+ } >+ } catch (IllegalArgumentException e) { >+ // ignore >+ } >+ } >+ } >+ return null; >+ } >+ >+ public String getBundleId() { >+ return fBundleId; >+ } >+ } >+ >+ public static final JUnitPluginDescription JUNIT3_PLUGIN= new JUnitPluginDescription("org.junit", new VersionRange("[3.8.2,3.9)")); //$NON-NLS-1$//$NON-NLS-2$ >+ public static final JUnitPluginDescription JUNIT4_PLUGIN= new JUnitPluginDescription("org.junit4", new VersionRange("[4.3.1,4.4.0)")); //$NON-NLS-1$ //$NON-NLS-2$ > >- public static IPath getBundleLocation(String bundleName) { >- Bundle bundle= JUnitPlugin.getDefault().getBundle(bundleName); >+ public static IPath getBundleLocation(JUnitPluginDescription pluginDesc) { >+ Bundle bundle= pluginDesc.getBundle(); > if (bundle == null) > return null; > >@@ -52,12 +88,12 @@ > return Path.fromOSString(fullPath); > } > >- public static IPath getSourceLocation(String bundleName) { >- Bundle bundle= JUnitPlugin.getDefault().getBundle(bundleName); >+ public static IPath getSourceLocation(JUnitPluginDescription pluginDesc) { >+ Bundle bundle= pluginDesc.getBundle(); > if (bundle == null) > return null; > >- String version= (String)bundle.getHeaders().get("Bundle-Version"); //$NON-NLS-1$ >+ String version= (String)bundle.getHeaders().get(Constants.BUNDLE_VERSION); > if (version == null) { > return null; > } >@@ -72,7 +108,7 @@ > return null; > } > String fullPath= new File(local.getPath()).getAbsolutePath() >- + File.separator + "src" + File.separator + bundleName + "_" + version; //$NON-NLS-1$ //$NON-NLS-2$ >+ + File.separator + "src" + File.separator + pluginDesc.getBundleId() + "_" + version; //$NON-NLS-1$ //$NON-NLS-2$ > return Path.fromOSString(fullPath); > } > >@@ -85,11 +121,11 @@ > } > > public static IClasspathEntry getJUnit3LibraryEntry() { >- IPath bundleBase= getBundleLocation(JUNIT3_PLUGIN_ID); >+ IPath bundleBase= getBundleLocation(JUNIT3_PLUGIN); > if (bundleBase != null) { > IPath jarLocation= bundleBase.append("junit.jar"); //$NON-NLS-1$ > >- IPath sourceBase= getSourceLocation(JUNIT3_PLUGIN_ID); >+ IPath sourceBase= getSourceLocation(JUNIT3_PLUGIN); > IPath srcLocation= sourceBase != null ? sourceBase.append("junitsrc.zip") : null; //$NON-NLS-1$ > > IAccessRule[] accessRules= { }; >@@ -103,11 +139,11 @@ > } > > public static IClasspathEntry getJUnit4LibraryEntry() { >- IPath bundleBase= getBundleLocation(JUNIT4_PLUGIN_ID); >+ IPath bundleBase= getBundleLocation(JUNIT4_PLUGIN); > if (bundleBase != null) { > IPath jarLocation= bundleBase.append("junit.jar"); //$NON-NLS-1$ > >- IPath sourceBase= getSourceLocation(JUNIT4_PLUGIN_ID); >+ IPath sourceBase= getSourceLocation(JUNIT4_PLUGIN); > IPath srcLocation= sourceBase != null ? sourceBase.append("junitsrc.zip") : null; //$NON-NLS-1$ > > IAccessRule[] accessRules= { };
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 Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 177676
:
61024
|
66684
|
66925
| 67026