summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2018-04-30 15:10:25 -0400
committerAlexander Kurtakov2018-04-30 15:10:25 -0400
commit3f3510b75d8828493da4a02860055280570f8587 (patch)
tree85df495b213428eebf6aa90a769b95c66ec5d434
parent52841a43a6cca7a6df578d756c5fc87643a1463d (diff)
downloadrt.equinox.p2-3f3510b75d8828493da4a02860055280570f8587.zip
rt.equinox.p2-3f3510b75d8828493da4a02860055280570f8587.tar.gz
rt.equinox.p2-3f3510b75d8828493da4a02860055280570f8587.tar.xz
Foreach and efficient Map traversal changes.I20180502-0100I20180501-2000I20180430-2000
Change-Id: I27e76c54d54a7c9d22aec5a124db6f11b7bc6444 Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java94
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestData.java21
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/FragmentMethodTest.java15
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/IUPatchPersistenceTest.java54
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/IUPersistenceTest.java45
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/expression/FilterTest.java31
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/JarURLMetadataRepositoryTest.java18
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/LocalMetadataRepositoryTest.java24
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/MetadataRepositoryManagerTest.java26
9 files changed, 232 insertions, 96 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java
index 08e2d36..ae79254 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2017 IBM Corporation and others.
+ * Copyright (c) 2007, 2018 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
@@ -11,17 +11,50 @@
******************************************************************************/
package org.eclipse.equinox.p2.tests;
-import java.io.*;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.PrintStream;
import java.lang.reflect.Field;
import java.net.URI;
import java.net.URL;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
import java.util.Map.Entry;
+import java.util.Properties;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
-import org.eclipse.core.runtime.*;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.URIUtil;
import org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepository;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
import org.eclipse.equinox.internal.p2.core.helpers.URLUtil;
@@ -33,16 +66,46 @@ import org.eclipse.equinox.internal.p2.metadata.repository.MetadataRepositoryMan
import org.eclipse.equinox.internal.p2.repository.Transport;
import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus;
import org.eclipse.equinox.internal.provisional.p2.director.IDirector;
-import org.eclipse.equinox.p2.core.*;
-import org.eclipse.equinox.p2.engine.*;
-import org.eclipse.equinox.p2.metadata.*;
+import org.eclipse.equinox.p2.core.IAgentLocation;
+import org.eclipse.equinox.p2.core.IProvisioningAgent;
+import org.eclipse.equinox.p2.core.IProvisioningAgentProvider;
+import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.engine.IEngine;
+import org.eclipse.equinox.p2.engine.IProfile;
+import org.eclipse.equinox.p2.engine.IProfileRegistry;
+import org.eclipse.equinox.p2.engine.IProvisioningPlan;
+import org.eclipse.equinox.p2.metadata.IArtifactKey;
+import org.eclipse.equinox.p2.metadata.ICopyright;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.IInstallableUnitFragment;
+import org.eclipse.equinox.p2.metadata.IInstallableUnitPatch;
+import org.eclipse.equinox.p2.metadata.ILicense;
+import org.eclipse.equinox.p2.metadata.IProvidedCapability;
+import org.eclipse.equinox.p2.metadata.IRequirement;
+import org.eclipse.equinox.p2.metadata.IRequirementChange;
+import org.eclipse.equinox.p2.metadata.ITouchpointData;
+import org.eclipse.equinox.p2.metadata.ITouchpointType;
+import org.eclipse.equinox.p2.metadata.IUpdateDescriptor;
+import org.eclipse.equinox.p2.metadata.MetadataFactory;
+import org.eclipse.equinox.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.VersionRange;
import org.eclipse.equinox.p2.metadata.expression.IMatchExpression;
-import org.eclipse.equinox.p2.planner.*;
+import org.eclipse.equinox.p2.planner.IPlanner;
+import org.eclipse.equinox.p2.planner.IProfileChangeRequest;
+import org.eclipse.equinox.p2.planner.ProfileInclusionRules;
import org.eclipse.equinox.p2.publisher.PublisherInfo;
-import org.eclipse.equinox.p2.publisher.eclipse.*;
-import org.eclipse.equinox.p2.query.*;
+import org.eclipse.equinox.p2.publisher.eclipse.BundleShapeAdvice;
+import org.eclipse.equinox.p2.publisher.eclipse.BundlesAction;
+import org.eclipse.equinox.p2.publisher.eclipse.IBundleShapeAdvice;
+import org.eclipse.equinox.p2.query.IQueryResult;
+import org.eclipse.equinox.p2.query.IQueryable;
+import org.eclipse.equinox.p2.query.QueryUtil;
import org.eclipse.equinox.p2.repository.IRepositoryManager;
-import org.eclipse.equinox.p2.repository.artifact.*;
+import org.eclipse.equinox.p2.repository.artifact.ArtifactDescriptorQuery;
+import org.eclipse.equinox.p2.repository.artifact.ArtifactKeyQuery;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
import org.eclipse.equinox.spi.p2.publisher.PublisherHelper;
@@ -434,10 +497,8 @@ public abstract class AbstractProvisioningTest extends TestCase {
for (int i = 0; i < additionalProvides.length; i++) {
provides[i + 1] = additionalProvides[i];
}
- for (Iterator<String> iter = properties.keySet().iterator(); iter.hasNext();) {
- String nextKey = iter.next();
- String nextValue = properties.get(nextKey);
- iu.setProperty(nextKey, nextValue);
+ for (Entry<String, String> entry : properties.entrySet()) {
+ iu.setProperty(entry.getKey(), entry.getValue());
}
iu.setCapabilities(provides);
iu.setRequirements(required);
@@ -542,8 +603,7 @@ public abstract class AbstractProvisioningTest extends TestCase {
desc.setVersion(prototype.getVersion());
Map<String, String> prototypeProperties = prototype.getProperties();
Set<Entry<String, String>> entries = prototypeProperties.entrySet();
- for (Iterator<Entry<String, String>> iterator = entries.iterator(); iterator.hasNext();) {
- Entry<String, String> entry = iterator.next();
+ for (Entry<String, String> entry : entries) {
desc.setProperty(entry.getKey(), entry.getValue());
}
return desc;
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestData.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestData.java
index 1d995b4..2969cfa 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestData.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestData.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2017 compeople AG and others.
+ * Copyright (c) 2007, 2018 compeople AG 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
@@ -11,8 +11,17 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests;
-import java.io.*;
-import java.util.*;
+import java.io.BufferedInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import org.eclipse.core.runtime.FileLocator;
@@ -126,8 +135,7 @@ public class TestData {
public static void assertEquals(ZipInputStream expected, ZipInputStream actual) throws IOException {
Map<String, Object[]> jar1 = getEntries(expected);
Map<String, Object[]> jar2 = getEntries(actual);
- for (Iterator<String> i = jar1.keySet().iterator(); i.hasNext();) {
- String name = i.next();
+ for (String name : jar1.keySet()) {
Object[] file1 = jar1.get(name);
Object[] file2 = jar2.remove(name);
Assert.assertNotNull(file2);
@@ -163,8 +171,7 @@ public class TestData {
public static void assertContains(Map<String, Object[]> fileMap, ZipInputStream input2, boolean compareContent) throws IOException {
Map<String, Object[]> jar2 = getEntries(input2);
- for (Iterator<String> i = fileMap.keySet().iterator(); i.hasNext();) {
- String name = i.next();
+ for (String name : fileMap.keySet()) {
Object[] file1 = fileMap.get(name);
Object[] file2 = jar2.remove(name);
Assert.assertNotNull(file2);
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/FragmentMethodTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/FragmentMethodTest.java
index 466b20b..85aa4b5 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/FragmentMethodTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/FragmentMethodTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2017 IBM Corporation and others.
+ * Copyright (c) 2007, 2018 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
@@ -10,12 +10,18 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.metadata;
-import java.util.*;
+import java.util.Collection;
+import java.util.HashSet;
import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
-import org.eclipse.equinox.p2.metadata.*;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.IProvidedCapability;
+import org.eclipse.equinox.p2.metadata.IRequirement;
+import org.eclipse.equinox.p2.metadata.MetadataFactory;
import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription;
import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitFragmentDescription;
+import org.eclipse.equinox.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.VersionRange;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
public class FragmentMethodTest extends TestCase {
@@ -38,8 +44,7 @@ public class FragmentMethodTest extends TestCase {
hash.add(iu1);
hash.add(iu3);
// Collection result = new ResolutionHelper(new Hashtable(), null).attachCUs(hash);
- for (Iterator<IInstallableUnit> iterator = hash.iterator(); iterator.hasNext();) {
- IInstallableUnit iu = iterator.next();
+ for (IInstallableUnit iu : hash) {
if (iu.getId().equals(iu1.getId()))
iu1 = iu;
if (iu.getId().equals(iu3.getId()))
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/IUPatchPersistenceTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/IUPatchPersistenceTest.java
index 980c5b2..71c09a0 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/IUPatchPersistenceTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/IUPatchPersistenceTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2017 IBM Corporation and others.
+ * Copyright (c) 2007, 2018 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
@@ -10,20 +10,42 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.metadata;
-import java.io.*;
-import java.util.*;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
import javax.xml.parsers.ParserConfigurationException;
import org.eclipse.equinox.internal.p2.core.helpers.OrderedProperties;
-import org.eclipse.equinox.internal.p2.metadata.*;
+import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability;
+import org.eclipse.equinox.internal.p2.metadata.InstallableUnit;
+import org.eclipse.equinox.internal.p2.metadata.InstallableUnitPatch;
+import org.eclipse.equinox.internal.p2.metadata.RequiredCapability;
import org.eclipse.equinox.internal.p2.metadata.repository.io.MetadataParser;
import org.eclipse.equinox.internal.p2.metadata.repository.io.MetadataWriter;
-import org.eclipse.equinox.p2.metadata.*;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.IInstallableUnitPatch;
+import org.eclipse.equinox.p2.metadata.IProvidedCapability;
+import org.eclipse.equinox.p2.metadata.IRequirement;
+import org.eclipse.equinox.p2.metadata.IRequirementChange;
+import org.eclipse.equinox.p2.metadata.ITouchpointData;
+import org.eclipse.equinox.p2.metadata.IUpdateDescriptor;
+import org.eclipse.equinox.p2.metadata.MetadataFactory;
import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription;
+import org.eclipse.equinox.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.VersionRange;
import org.eclipse.equinox.p2.metadata.expression.IMatchExpression;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
import org.eclipse.equinox.p2.tests.TestActivator;
import org.osgi.framework.BundleContext;
-import org.xml.sax.*;
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
public class IUPatchPersistenceTest extends AbstractProvisioningTest {
@@ -82,8 +104,7 @@ public class IUPatchPersistenceTest extends AbstractProvisioningTest {
private static Map<String, String> createProperties(String[][] keyValuePairs) {
OrderedProperties props = new OrderedProperties(keyValuePairs.length);
- for (int i = 0; i < keyValuePairs.length; i++) {
- String[] nextPair = keyValuePairs[i];
+ for (String[] nextPair : keyValuePairs) {
props.put(nextPair[0], nextPair[1]);
}
return props;
@@ -110,8 +131,7 @@ public class IUPatchPersistenceTest extends AbstractProvisioningTest {
private static ITouchpointData createTouchpointData(String[][] instructionData) {
Map<String, Object> map = new LinkedHashMap<>(instructionData.length);
- for (int i = 0; i < instructionData.length; i++) {
- String[] nextInstruction = instructionData[i];
+ for (String[] nextInstruction : instructionData) {
map.put(nextInstruction[0], nextInstruction[1]);
}
return MetadataFactory.createTouchpointData(map);
@@ -329,10 +349,8 @@ public class IUPatchPersistenceTest extends AbstractProvisioningTest {
Set<String> keys = props.keySet();
String[][] pairs = new String[keys.size()][2];
int index = 0;
- for (Iterator<String> iter = keys.iterator(); iter.hasNext();) {
- String nextKey = iter.next();
- String nextValue = props.get(nextKey);
- pairs[index] = new String[] {nextKey, nextValue};
+ for (Entry<String, String> entry : props.entrySet()) {
+ pairs[index] = new String[] {entry.getKey(), entry.getValue()};
index++;
}
return pairs;
@@ -362,8 +380,8 @@ public class IUPatchPersistenceTest extends AbstractProvisioningTest {
Collection<IRequirement> reqs = iu.getRequirements();
String[][] tuples = new String[reqs.size()][4];
int i = 0;
- for (Iterator<IRequirement> iterator = reqs.iterator(); iterator.hasNext();) {
- IRequiredCapability next = (IRequiredCapability) iterator.next();
+ for (IRequirement iRequirement : reqs) {
+ IRequiredCapability next = (IRequiredCapability) iRequirement;
tuples[i++] = new String[] {next.getNamespace(), next.getName(), next.getRange().toString(), Boolean.valueOf(next.getMin() == 0).toString()};
}
return tuples;
@@ -373,8 +391,8 @@ public class IUPatchPersistenceTest extends AbstractProvisioningTest {
Collection<IRequirement> requyres = iu.getMetaRequirements();
String[][] tuples = new String[requyres.size()][4];
int i = 0;
- for (Iterator<IRequirement> iterator = requyres.iterator(); iterator.hasNext();) {
- IRequiredCapability next = (IRequiredCapability) iterator.next();
+ for (IRequirement iRequirement : requyres) {
+ IRequiredCapability next = (IRequiredCapability) iRequirement;
tuples[i++] = new String[] {next.getNamespace(), next.getName(), next.getRange().toString(), Boolean.valueOf(next.getMin() == 0).toString()};
}
return tuples;
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/IUPersistenceTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/IUPersistenceTest.java
index 485be52..120c579 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/IUPersistenceTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/IUPersistenceTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2017 IBM Corporation and others.
+ * Copyright (c) 2007, 2018 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
@@ -10,21 +10,44 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.metadata;
-import java.io.*;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.StringReader;
import java.net.URI;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
import javax.xml.parsers.ParserConfigurationException;
import org.eclipse.equinox.internal.p2.core.helpers.OrderedProperties;
-import org.eclipse.equinox.internal.p2.metadata.*;
+import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability;
+import org.eclipse.equinox.internal.p2.metadata.InstallableUnit;
+import org.eclipse.equinox.internal.p2.metadata.InstallableUnitPatch;
+import org.eclipse.equinox.internal.p2.metadata.RequiredCapability;
import org.eclipse.equinox.internal.p2.metadata.repository.io.MetadataParser;
import org.eclipse.equinox.internal.p2.metadata.repository.io.MetadataWriter;
-import org.eclipse.equinox.p2.metadata.*;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.IInstallableUnitPatch;
+import org.eclipse.equinox.p2.metadata.ILicense;
+import org.eclipse.equinox.p2.metadata.IProvidedCapability;
+import org.eclipse.equinox.p2.metadata.IRequirement;
+import org.eclipse.equinox.p2.metadata.IRequirementChange;
+import org.eclipse.equinox.p2.metadata.ITouchpointData;
+import org.eclipse.equinox.p2.metadata.IUpdateDescriptor;
+import org.eclipse.equinox.p2.metadata.MetadataFactory;
import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription;
+import org.eclipse.equinox.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.VersionRange;
import org.eclipse.equinox.p2.metadata.expression.IMatchExpression;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
import org.eclipse.equinox.p2.tests.TestActivator;
import org.osgi.framework.BundleContext;
-import org.xml.sax.*;
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
public class IUPersistenceTest extends AbstractProvisioningTest {
@@ -261,8 +284,8 @@ public class IUPersistenceTest extends AbstractProvisioningTest {
Collection<IRequirement> requyres = iu.getMetaRequirements();
String[][] tuples = new String[requyres.size()][4];
int i = 0;
- for (Iterator<IRequirement> iterator = requyres.iterator(); iterator.hasNext();) {
- IRequiredCapability next = (IRequiredCapability) iterator.next();
+ for (IRequirement iRequirement : requyres) {
+ IRequiredCapability next = (IRequiredCapability) iRequirement;
tuples[i++] = new String[] {next.getNamespace(), next.getName(), next.getRange().toString(), Boolean.valueOf(next.getMin() == 0).toString()};
}
return tuples;
@@ -320,10 +343,8 @@ public class IUPersistenceTest extends AbstractProvisioningTest {
for (int i = 0; i < additionalProvides.length; i++) {
provides1[i + 1] = additionalProvides[i];
}
- for (Iterator<String> iter = propertyMap.keySet().iterator(); iter.hasNext();) {
- String nextKey = iter.next();
- String nextValue = propertyMap.get(nextKey);
- iu1.setProperty(nextKey, nextValue);
+ for (Entry<String, String> entry : propertyMap.entrySet()) {
+ iu1.setProperty(entry.getKey(), entry.getValue());
}
iu1.setCapabilities(provides1);
iu1.setRequirements(requirements);
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/expression/FilterTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/expression/FilterTest.java
index 4a51833..e56a2e0 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/expression/FilterTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/expression/FilterTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2017 IBM Corporation and others.
+ * Copyright (c) 2010, 2018 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
@@ -203,21 +203,21 @@ public class FilterTest {
private static class SampleComparable implements Comparable<SampleComparable> {
private int value = -1;
-
+
public SampleComparable(String value) {
this.value = Integer.parseInt(value);
}
-
+
@Override
public boolean equals(Object o) {
return o instanceof SampleComparable && value == ((SampleComparable) o).value;
}
-
+
@Override
public int compareTo(SampleComparable o) {
return value - o.value;
}
-
+
@Override
public String toString() {
return String.valueOf(value);
@@ -226,9 +226,9 @@ public class FilterTest {
private static class DictionaryServiceReference implements ServiceReference {
private final Map<String, ? extends Object> dictionary;
-
+
private final String[] keys;
-
+
DictionaryServiceReference(Map<String, ? extends Object> dictionary) {
if (dictionary == null) {
this.dictionary = null;
@@ -248,43 +248,42 @@ public class FilterTest {
}
this.keys = keyList.toArray(new String[keyList.size()]);
}
-
+
@Override
public int compareTo(Object reference) {
throw new UnsupportedOperationException();
}
-
+
@Override
public Bundle getBundle() {
return null;
}
-
+
@Override
public Object getProperty(String k) {
- for (int i = 0, length = keys.length; i < length; i++) {
- String key = keys[i];
+ for (String key : keys) {
if (key.equalsIgnoreCase(k)) {
return dictionary.get(key);
}
}
return null;
}
-
+
@Override
public String[] getPropertyKeys() {
return keys.clone();
}
-
+
@Override
public Bundle[] getUsingBundles() {
throw new UnsupportedOperationException();
}
-
+
@Override
public boolean isAssignableTo(Bundle bundle, String className) {
throw new UnsupportedOperationException();
}
-
+
@Override
public Dictionary<String, Object> getProperties() {
return new Hashtable<>(dictionary);
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/JarURLMetadataRepositoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/JarURLMetadataRepositoryTest.java
index 7f2f4a9..d56cee7 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/JarURLMetadataRepositoryTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/JarURLMetadataRepositoryTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2017 IBM Corporation and others.
+ * Copyright (c) 2007, 2018 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
@@ -15,12 +15,18 @@ import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
-import java.util.*;
-import org.eclipse.core.runtime.*;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.URIUtil;
import org.eclipse.equinox.internal.p2.core.helpers.FileUtils;
import org.eclipse.equinox.p2.core.ProvisionException;
-import org.eclipse.equinox.p2.metadata.*;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.MetadataFactory;
import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription;
+import org.eclipse.equinox.p2.metadata.Version;
import org.eclipse.equinox.p2.query.QueryUtil;
import org.eclipse.equinox.p2.repository.IRepository;
import org.eclipse.equinox.p2.repository.IRepositoryManager;
@@ -104,8 +110,8 @@ public class JarURLMetadataRepositoryTest extends AbstractProvisioningTest {
URI[] local = manager.getKnownRepositories(IRepositoryManager.REPOSITORIES_LOCAL);
boolean found = false;
- for (int i = 0; i < local.length; i++)
- if (local[i].equals(jarRepoLocation))
+ for (URI element : local)
+ if (element.equals(jarRepoLocation))
found = true;
assertTrue(found);
manager.removeRepository(jarRepoLocation);
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/LocalMetadataRepositoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/LocalMetadataRepositoryTest.java
index 9ff3e27..de46b6e 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/LocalMetadataRepositoryTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/LocalMetadataRepositoryTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2017 IBM Corporation and others.
+ * Copyright (c) 2008, 2018 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
@@ -13,14 +13,22 @@ package org.eclipse.equinox.p2.tests.metadata.repository;
import java.io.File;
import java.net.URI;
-import java.util.*;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus;
import org.eclipse.equinox.internal.provisional.p2.core.eventbus.SynchronousProvisioningListener;
import org.eclipse.equinox.internal.provisional.p2.repository.RepositoryEvent;
import org.eclipse.equinox.p2.core.ProvisionException;
-import org.eclipse.equinox.p2.metadata.*;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.ILicense;
+import org.eclipse.equinox.p2.metadata.MetadataFactory;
import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription;
+import org.eclipse.equinox.p2.metadata.Version;
import org.eclipse.equinox.p2.query.IQueryResult;
import org.eclipse.equinox.p2.query.QueryUtil;
import org.eclipse.equinox.p2.repository.IRepository;
@@ -69,11 +77,11 @@ public class LocalMetadataRepositoryTest extends AbstractProvisioningTest {
boolean jarFilePresent = false;
boolean xmlFilePresent = false;
// one of the files in the repository should be the content.xml.jar
- for (int i = 0; i < files.length; i++) {
- if ("content.jar".equalsIgnoreCase(files[i].getName())) {
+ for (File file : files) {
+ if ("content.jar".equalsIgnoreCase(file.getName())) {
jarFilePresent = true;
}
- if ("content.xml".equalsIgnoreCase(files[i].getName())) {
+ if ("content.xml".equalsIgnoreCase(file.getName())) {
xmlFilePresent = true;
}
}
@@ -165,8 +173,8 @@ public class LocalMetadataRepositoryTest extends AbstractProvisioningTest {
File[] files = repoLocation.listFiles();
boolean jarFilePresent = false;
// none of the files in the repository should be the content.xml.jar
- for (int i = 0; i < files.length; i++) {
- if ("content.jar".equalsIgnoreCase(files[i].getName())) {
+ for (File file : files) {
+ if ("content.jar".equalsIgnoreCase(file.getName())) {
jarFilePresent = true;
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/MetadataRepositoryManagerTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/MetadataRepositoryManagerTest.java
index 615a8ef..98e63fb 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/MetadataRepositoryManagerTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/MetadataRepositoryManagerTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2017 IBM Corporation and others.
+ * Copyright (c) 2007, 2018 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
@@ -11,14 +11,22 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.metadata.repository;
-import java.io.*;
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintStream;
import java.lang.reflect.Field;
import java.net.URI;
import java.net.URISyntaxException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
import junit.framework.Test;
import junit.framework.TestSuite;
-import org.eclipse.core.runtime.*;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.URIUtil;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
import org.eclipse.equinox.internal.p2.metadata.repository.SimpleMetadataRepositoryFactory;
@@ -36,7 +44,11 @@ import org.eclipse.equinox.p2.repository.IRepositoryManager;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
import org.eclipse.equinox.p2.repository.metadata.spi.MetadataRepositoryFactory;
-import org.eclipse.equinox.p2.tests.*;
+import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
+import org.eclipse.equinox.p2.tests.FailingMetadataRepositoryFactory;
+import org.eclipse.equinox.p2.tests.StringBufferStream;
+import org.eclipse.equinox.p2.tests.TestActivator;
+import org.eclipse.equinox.p2.tests.TestRepositoryListener;
/**
* Tests for API of {@link IMetadataRepositoryManager}.
@@ -615,8 +627,8 @@ public class MetadataRepositoryManagerTest extends AbstractProvisioningTest {
*/
private boolean managerContains(URI location) {
URI[] locations = manager.getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL);
- for (int i = 0; i < locations.length; i++) {
- if (locations[i].equals(location))
+ for (URI location2 : locations) {
+ if (location2.equals(location))
return true;
}
return false;