Skip to content

Commit f49b833

Browse files
committed
Clean-up LocalTargetDefinitionTests
Remove unused code and unify and modernize remaining code.
1 parent 827fec0 commit f49b833

File tree

5 files changed

+56
-266
lines changed

5 files changed

+56
-266
lines changed

ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/P2Utils.java

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -107,46 +107,6 @@ public class P2Utils {
107107
public static final IProvidedCapability BUNDLE_CAPABILITY = MetadataFactory.createProvidedCapability(NAMESPACE_ECLIPSE_TYPE, TYPE_ECLIPSE_BUNDLE, Version.createOSGi(1, 0, 0));
108108
public static final String CAPABILITY_NS_JAVA_PACKAGE = "java.package"; //$NON-NLS-1$
109109

110-
/**
111-
* Returns bundles defined by the 'bundles.info' file in the
112-
* specified location, or <code>null</code> if none. The "bundles.info" file
113-
* is assumed to be at a fixed location relative to the configuration area URL.
114-
* This method will also look for a "source.info". If available, any source
115-
* bundles found will also be added to the returned list. If bundle URLs found
116-
* in the bundles.info are relative, they will be appended to platformHome to
117-
* make them absolute.
118-
*
119-
* @param platformHome absolute path in the local file system to an installation
120-
* @param configurationArea url location of the configuration directory to search for bundles.info and source.info
121-
* @return URLs of all bundles in the installation or <code>null</code> if not able
122-
* to locate a bundles.info
123-
*/
124-
public static URL[] readBundlesTxt(String platformHome, File configurationArea) {
125-
if (configurationArea == null) {
126-
return null;
127-
}
128-
try {
129-
BundleInfo[] bundles = readBundles(platformHome, configurationArea);
130-
if (bundles == null) {
131-
return null;
132-
}
133-
int length = bundles.length;
134-
BundleInfo[] srcBundles = readSourceBundles(platformHome, configurationArea);
135-
if (srcBundles != null) {
136-
length += srcBundles.length;
137-
}
138-
URL[] urls = new URL[length];
139-
copyURLs(urls, 0, bundles);
140-
if (srcBundles != null && srcBundles.length > 0) {
141-
copyURLs(urls, bundles.length, srcBundles);
142-
}
143-
return urls;
144-
} catch (MalformedURLException e) {
145-
PDECore.log(e);
146-
return null;
147-
}
148-
}
149-
150110
/**
151111
* Returns bundles defined by the 'bundles.info' relative to the given
152112
* home and configuration area, or <code>null</code> if none.
@@ -207,19 +167,6 @@ public static BundleInfo[] readSourceBundles(String platformHome, File configura
207167
}
208168
}
209169

210-
/**
211-
* Copies URLs from the given bundle info objects into the specified array starting at the given index.
212-
*
213-
* @param dest array to copy URLs into
214-
* @param start index to start copying into
215-
* @param infos associated bundle infos
216-
*/
217-
private static void copyURLs(URL[] dest, int start, BundleInfo[] infos) throws MalformedURLException {
218-
for (BundleInfo info : infos) {
219-
dest[start++] = new File(info.getLocation()).toURL();
220-
}
221-
}
222-
223170
/**
224171
* Returns a list of {@link BundleInfo} for each bundle entry or
225172
* <code>null</code> if there is a problem reading the file.

ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/build/properties/AbstractBuildValidationTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
import org.eclipse.pde.internal.ui.PDEPlugin;
5252
import org.eclipse.pde.internal.ui.correction.ResolutionGenerator;
5353
import org.eclipse.pde.ui.tests.PDETestsPlugin;
54-
import org.eclipse.pde.ui.tests.target.LocalTargetDefinitionTests;
5554
import org.eclipse.ui.IMarkerResolution;
5655
import org.junit.Before;
5756
import org.osgi.service.prefs.BackingStoreException;
@@ -243,7 +242,7 @@ protected IPath doUnZip(IPath location, String archivePath) throws IOException {
243242
file.createNewFile();
244243
try (InputStream inputStream = new BufferedInputStream(zipFile.getInputStream(entry));
245244
BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(file))) {
246-
byte[] bytes = LocalTargetDefinitionTests.getInputStreamAsByteArray(inputStream, -1);
245+
byte[] bytes = inputStream.readAllBytes();
247246
outputStream.write(bytes);
248247
}
249248
}

ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/performance/parts/TargetPlatformPerfTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
import org.eclipse.pde.core.target.LoadTargetDefinitionJob;
4646
import org.eclipse.pde.internal.core.PDECore;
4747
import org.eclipse.pde.ui.tests.PDETestsPlugin;
48-
import org.eclipse.pde.ui.tests.target.LocalTargetDefinitionTests;
4948
import org.eclipse.pde.ui.tests.util.TargetPlatformUtil;
5049
import org.eclipse.pde.ui.tests.util.TestBundleCreator;
5150
import org.eclipse.test.performance.Dimension;
@@ -274,7 +273,7 @@ private static IPath doUnZip(IPath location, String archivePath) throws IOExcept
274273
file.createNewFile();
275274
try (InputStream inputStream = new BufferedInputStream(zipFile.getInputStream(entry));
276275
BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(file))) {
277-
byte[] bytes = LocalTargetDefinitionTests.getInputStreamAsByteArray(inputStream, -1);
276+
byte[] bytes = inputStream.readAllBytes();
278277
outputStream.write(bytes);
279278
}
280279
}

ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/AbstractTargetTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ private IPath doUnZip(IPath location, String archivePath) throws IOException {
178178
file.createNewFile();
179179
try (InputStream inputStream = new BufferedInputStream(zipFile.getInputStream(entry));
180180
BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(file))) {
181-
byte[] bytes = LocalTargetDefinitionTests.getInputStreamAsByteArray(inputStream, -1);
181+
byte[] bytes = inputStream.readAllBytes();
182182
outputStream.write(bytes);
183183
}
184184
}

0 commit comments

Comments
 (0)