diff options
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact')
24 files changed, 320 insertions, 277 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processors/ArtifactRepositoryMock.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processors/ArtifactRepositoryMock.java index ce63a67fe..447a60a7e 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processors/ArtifactRepositoryMock.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processors/ArtifactRepositoryMock.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 compeople AG and others. + * Copyright (c) 2007, 2017 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 @@ -33,6 +33,7 @@ public class ArtifactRepositoryMock implements InvocationHandler { this.artifactResource = artifactResource; } + @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (!method.getName().equals("getArtifact")) throw new RuntimeException("Unexpected usage!"); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactLockingTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactLockingTest.java index f66e38a34..65781aca0 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactLockingTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactLockingTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 EclipseSource and others. + * Copyright (c) 2011, 2017 EclipseSource 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,7 +19,6 @@ import org.eclipse.equinox.internal.p2.metadata.ArtifactKey; import org.eclipse.equinox.p2.core.ProvisionException; import org.eclipse.equinox.p2.metadata.IArtifactKey; import org.eclipse.equinox.p2.metadata.Version; -import org.eclipse.equinox.p2.repository.IRunnableWithProgress; import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor; import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; @@ -31,6 +30,7 @@ public class ArtifactLockingTest extends AbstractProvisioningTest { private SimpleArtifactRepository repo2 = null; private boolean lockingValue = false; + @Override public void setUp() throws Exception { super.setUp(); lockingValue = Activator.getInstance().enableArtifactLocking(); @@ -56,24 +56,17 @@ public class ArtifactLockingTest extends AbstractProvisioningTest { public void testCancelLoad() throws InterruptedException, ProvisionException { this.canContinue = false; final IProgressMonitor progressMonitor = new NullProgressMonitor(); - new Thread(new Runnable() { - public void run() { - status = repo1.executeBatch(new IRunnableWithProgress() { - - public void run(IProgressMonitor monitor) throws OperationCanceledException { - try { - canContinue = true; - Thread.sleep(3 * 1000); - repo1.addDescriptor(new SimpleArtifactDescriptor(new ArtifactKey("org.eclipse.test", "test2", Version.create("1.0.0"))), new NullProgressMonitor()); - progressMonitor.setCanceled(true); - Thread.sleep(1000); - } catch (InterruptedException e) { - // Do nothing - } - } - }, new NullProgressMonitor()); + new Thread(() -> status = repo1.executeBatch(monitor -> { + try { + canContinue = true; + Thread.sleep(3 * 1000); + repo1.addDescriptor(new SimpleArtifactDescriptor(new ArtifactKey("org.eclipse.test", "test2", Version.create("1.0.0"))), new NullProgressMonitor()); + progressMonitor.setCanceled(true); + Thread.sleep(1000); + } catch (InterruptedException e) { + // Do nothing } - }).start(); + }, new NullProgressMonitor())).start(); while (!canContinue) { Thread.sleep(100); @@ -92,23 +85,16 @@ public class ArtifactLockingTest extends AbstractProvisioningTest { public void testWaitForLoad() throws InterruptedException, ProvisionException { this.canContinue = false; - new Thread(new Runnable() { - public void run() { - status = repo1.executeBatch(new IRunnableWithProgress() { - - public void run(IProgressMonitor monitor) throws OperationCanceledException { - try { - canContinue = true; - Thread.sleep(6 * 1000); - repo1.addDescriptor(new SimpleArtifactDescriptor(new ArtifactKey("org.eclipse.test", "test2", Version.create("1.0.0"))), new NullProgressMonitor()); - - } catch (InterruptedException e) { - // Do nothing - } - } - }, new NullProgressMonitor()); + new Thread(() -> status = repo1.executeBatch(monitor -> { + try { + canContinue = true; + Thread.sleep(6 * 1000); + repo1.addDescriptor(new SimpleArtifactDescriptor(new ArtifactKey("org.eclipse.test", "test2", Version.create("1.0.0"))), new NullProgressMonitor()); + + } catch (InterruptedException e) { + // Do nothing } - }).start(); + }, new NullProgressMonitor())).start(); while (!canContinue) { Thread.sleep(100); @@ -133,43 +119,33 @@ public class ArtifactLockingTest extends AbstractProvisioningTest { final IProgressMonitor progressMonitor = new NullProgressMonitor(); this.keepRunning = true; - new Thread(new Runnable() { - public void run() { - status = repo1.executeBatch(new IRunnableWithProgress() { - - public void run(IProgressMonitor monitor) throws OperationCanceledException { - long start = System.currentTimeMillis(); - while (keepRunning) { - long current = System.currentTimeMillis(); - if (current - start > 1000 * 10) { - fail("Test case never finished. Likely keep running was never set to false."); - return; - } - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - // Do nothing - } - } - } - }, new NullProgressMonitor()); + new Thread(() -> status = repo1.executeBatch(monitor -> { + long start = System.currentTimeMillis(); + while (keepRunning) { + long current = System.currentTimeMillis(); + if (current - start > 1000 * 10) { + fail("Test case never finished. Likely keep running was never set to false."); + return; + } + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + // Do nothing + } } - }).start(); + }, new NullProgressMonitor())).start(); // Give the execute batch thread a chance to start Thread.sleep(1000); // Create a thread that will stop our progress monitor - Thread t = new Thread(new Runnable() { - - public void run() { - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - // Do nothing - } - progressMonitor.setCanceled(true); + Thread t = new Thread(() -> { + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + // Do nothing } + progressMonitor.setCanceled(true); }); t.start(); @@ -186,43 +162,33 @@ public class ArtifactLockingTest extends AbstractProvisioningTest { final IProgressMonitor progressMonitor = new NullProgressMonitor(); this.keepRunning = true; - new Thread(new Runnable() { - public void run() { - status = repo1.executeBatch(new IRunnableWithProgress() { - - public void run(IProgressMonitor monitor) throws OperationCanceledException { - long start = System.currentTimeMillis(); - while (keepRunning) { - long current = System.currentTimeMillis(); - if (current - start > 1000 * 10) { - fail("Test case never finished. Likely keep running was never set to false."); - return; - } - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - // Do nothing - } - } - } - }, new NullProgressMonitor()); + new Thread(() -> status = repo1.executeBatch(monitor -> { + long start = System.currentTimeMillis(); + while (keepRunning) { + long current = System.currentTimeMillis(); + if (current - start > 1000 * 10) { + fail("Test case never finished. Likely keep running was never set to false."); + return; + } + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + // Do nothing + } } - }).start(); + }, new NullProgressMonitor())).start(); // Give the execute batch thread a chance to start Thread.sleep(1000); // Create a thread that will stop our progress monitor - Thread t = new Thread(new Runnable() { - - public void run() { - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - // Do nothing - } - progressMonitor.setCanceled(true); + Thread t = new Thread(() -> { + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + // Do nothing } + progressMonitor.setCanceled(true); }); t.start(); @@ -241,55 +207,42 @@ public class ArtifactLockingTest extends AbstractProvisioningTest { boolean lockAcquired = false; /** - * This tests that two 'executeBatch' operations are not executed in + * This tests that two 'executeBatch' operations are not executed in * parallel, but rather, the second one waits for the first to complete. * @throws InterruptedException */ public void testMultipleExecuteBatch() throws InterruptedException { this.lockAcquired = false; - Thread t1 = new Thread(new Runnable() { - public void run() { - status1 = repo1.executeBatch(new IRunnableWithProgress() { - - public void run(IProgressMonitor monitor) throws OperationCanceledException { - try { - if (lockAcquired) - throw new RuntimeException("Lock already acquired"); - lockAcquired = true; - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - // Do nothing - } - } finally { - lockAcquired = false; - } - } - }, new NullProgressMonitor()); + Thread t1 = new Thread(() -> status1 = repo1.executeBatch(monitor -> { + try { + if (lockAcquired) + throw new RuntimeException("Lock already acquired"); + lockAcquired = true; + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + // Do nothing + } + } finally { + lockAcquired = false; } - }); + }, new NullProgressMonitor())); t1.start(); - Thread t2 = new Thread(new Runnable() { - public void run() { - status2 = repo2.executeBatch(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws OperationCanceledException { - try { - if (lockAcquired) - throw new RuntimeException("Lock already acquired"); - lockAcquired = true; - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - // Do nothing - } - } finally { - lockAcquired = false; - } - } - }, new NullProgressMonitor()); + Thread t2 = new Thread(() -> status2 = repo2.executeBatch(monitor -> { + try { + if (lockAcquired) + throw new RuntimeException("Lock already acquired"); + lockAcquired = true; + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + // Do nothing + } + } finally { + lockAcquired = false; } - }); + }, new NullProgressMonitor())); t2.start(); t1.join(); @@ -305,21 +258,14 @@ public class ArtifactLockingTest extends AbstractProvisioningTest { */ public void testWait() throws InterruptedException { - new Thread(new Runnable() { - public void run() { - status = repo1.executeBatch(new IRunnableWithProgress() { - - public void run(IProgressMonitor monitor) throws OperationCanceledException { - try { - Thread.sleep(5000); - } catch (InterruptedException e) { - // Do nothing - } - - } - }, new NullProgressMonitor()); + new Thread(() -> status = repo1.executeBatch(monitor -> { + try { + Thread.sleep(5000); + } catch (InterruptedException e) { + // Do nothing } - }).start(); + + }, new NullProgressMonitor())).start(); // Give the execute batch thread a chance to start Thread.sleep(1000); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactOutputStreamTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactOutputStreamTest.java index e3281977f..3c2870166 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactOutputStreamTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactOutputStreamTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 compeople AG and others. + * Copyright (c) 2007, 2017 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 @@ -34,6 +34,7 @@ public class ArtifactOutputStreamTest extends AbstractProvisioningTest { private File temp = null; private File tempWritableLocation = null; + @Override protected void setUp() throws Exception { super.setUp(); @@ -52,6 +53,7 @@ public class ArtifactOutputStreamTest extends AbstractProvisioningTest { Destination.baos = null; } + @Override protected void tearDown() throws Exception { AbstractProvisioningTest.delete(temp); AbstractProvisioningTest.delete(tempWritableLocation); @@ -140,6 +142,7 @@ public class ArtifactOutputStreamTest extends AbstractProvisioningTest { static IOException ioe = null; static ByteArrayOutputStream baos = null; + @Override public void close() throws IOException { super.close(); if (ioe != null) { @@ -147,6 +150,7 @@ public class ArtifactOutputStreamTest extends AbstractProvisioningTest { } } + @Override public void write(int b) { if (baos != null) baos.write(b); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactRepositoryManagerTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactRepositoryManagerTest.java index 34045a785..c2b5c2b8a 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactRepositoryManagerTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactRepositoryManagerTest.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2008, 2015 IBM Corporation and others. + * Copyright (c) 2008, 2017 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 * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * IBM Corporation - initial API and implementation * Red Hat Inc. - Bug 460967 @@ -62,6 +62,7 @@ public class ArtifactRepositoryManagerTest extends AbstractProvisioningTest { return false; } + @Override protected void setUp() throws Exception { super.setUp(); manager = getArtifactRepositoryManager(); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactRepositoryMissingSizeData.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactRepositoryMissingSizeData.java index 39bd980b4..ca7d4408a 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactRepositoryMissingSizeData.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactRepositoryMissingSizeData.java @@ -1,20 +1,19 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 IBM Corporation and others. + * Copyright (c) 2009, 2017 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 * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.equinox.p2.tests.artifact.repository; -import org.eclipse.equinox.internal.p2.director.ProfileChangeRequest; - import java.net.URI; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.equinox.internal.p2.director.ProfileChangeRequest; import org.eclipse.equinox.internal.p2.engine.Phase; import org.eclipse.equinox.internal.p2.engine.PhaseSet; import org.eclipse.equinox.internal.p2.engine.phases.Sizing; @@ -39,6 +38,7 @@ public class ArtifactRepositoryMissingSizeData extends AbstractProvisioningTest ProvisioningContext context; IEngine engine; + @Override protected void setUp() throws Exception { super.setUp(); IMetadataRepositoryManager mmgr = getMetadataRepositoryManager(); @@ -56,6 +56,7 @@ public class ArtifactRepositoryMissingSizeData extends AbstractProvisioningTest engine = getEngine(); } + @Override protected void tearDown() throws Exception { super.tearDown(); getMetadataRepositoryManager().removeRepository(uri); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactRepositoryWithReferenceDescriptors.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactRepositoryWithReferenceDescriptors.java index 100beb673..6df6320f7 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactRepositoryWithReferenceDescriptors.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactRepositoryWithReferenceDescriptors.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 IBM Corporation and others. + * Copyright (c) 2005, 2017 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 * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -35,6 +35,7 @@ public class ArtifactRepositoryWithReferenceDescriptors extends AbstractProvisio // </repositoryProperties> // </artifact> + @Override protected void setUp() throws Exception { super.setUp(); repo = createArtifactRepository(getTempFolder().toURI(), null); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/BatchExecuteArtifactRepositoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/BatchExecuteArtifactRepositoryTest.java index 1f863e802..7073c172a 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/BatchExecuteArtifactRepositoryTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/BatchExecuteArtifactRepositoryTest.java @@ -1,5 +1,5 @@ -/******************************************************************************* -* Copyright (c) 2009, 2010 EclipseSource and others. All rights reserved. This +/******************************************************************************* +* Copyright (c) 2009, 2017 EclipseSource 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 @@ -47,14 +47,12 @@ public class BatchExecuteArtifactRepositoryTest extends AbstractProvisioningTest Map properties = new HashMap(); final SimpleArtifactRepository repo = (SimpleArtifactRepository) getArtifactRepositoryManager().createRepository(repositoryURI, "My Repo", IArtifactRepositoryManager.TYPE_SIMPLE_REPOSITORY, properties); final URI artifactXML = new URI(repositoryFile.toURI().toString() + "/artifacts.xml"); - IStatus status = repo.executeBatch(new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) { - repo.addDescriptor(createDescriptor("foo", "foo", Version.emptyVersion)); - try { - assertFalse("1.0", fileContainsString(artifactXML, "foo")); - } catch (IOException e) { - fail("0.99"); - } + IStatus status = repo.executeBatch(monitor -> { + repo.addDescriptor(createDescriptor("foo", "foo", Version.emptyVersion)); + try { + assertFalse("1.0", fileContainsString(artifactXML, "foo")); + } catch (IOException e) { + fail("0.99"); } }, new NullProgressMonitor()); assertTrue(status.isOK()); @@ -76,6 +74,7 @@ public class BatchExecuteArtifactRepositoryTest extends AbstractProvisioningTest final SimpleArtifactRepository repo = (SimpleArtifactRepository) getArtifactRepositoryManager().createRepository(repositoryURI, "My Repo", IArtifactRepositoryManager.TYPE_SIMPLE_REPOSITORY, properties); final URI artifactXML = new URI(repositoryFile.toURI().toString() + "/artifacts.xml"); IStatus status = repo.executeBatch(new IRunnableWithProgress() { + @Override public void run(IProgressMonitor monitor) { repo.addDescriptor(createDescriptor("foo", "foo", Version.emptyVersion)); repo.addDescriptor(createDescriptor("bar", "bar", Version.emptyVersion)); @@ -112,6 +111,7 @@ public class BatchExecuteArtifactRepositoryTest extends AbstractProvisioningTest final SimpleArtifactRepository repo = (SimpleArtifactRepository) getArtifactRepositoryManager().createRepository(repositoryURI, "My Repo", IArtifactRepositoryManager.TYPE_SIMPLE_REPOSITORY, properties); final URI artifactXML = new URI(repositoryFile.toURI().toString() + "/artifacts.xml"); IStatus status = repo.executeBatch(new IRunnableWithProgress() { + @Override public void run(IProgressMonitor monitor) { repo.addDescriptor(createDescriptor("foo", "foo", Version.emptyVersion)); repo.addDescriptor(createDescriptor("bar", "bar", Version.emptyVersion)); @@ -139,6 +139,7 @@ public class BatchExecuteArtifactRepositoryTest extends AbstractProvisioningTest final SimpleArtifactRepository repo = (SimpleArtifactRepository) getArtifactRepositoryManager().createRepository(repositoryURI, "My Repo", IArtifactRepositoryManager.TYPE_SIMPLE_REPOSITORY, properties); final URI artifactXML = new URI(repositoryFile.toURI().toString() + "/artifacts.xml"); IStatus status = repo.executeBatch(new IRunnableWithProgress() { + @Override public void run(IProgressMonitor monitor) { IArtifactDescriptor foo = createDescriptor("foo", "foo", Version.emptyVersion); repo.addDescriptor(foo); @@ -167,6 +168,7 @@ public class BatchExecuteArtifactRepositoryTest extends AbstractProvisioningTest final SimpleArtifactRepository repo = (SimpleArtifactRepository) getArtifactRepositoryManager().createRepository(repositoryURI, "My Repo", IArtifactRepositoryManager.TYPE_SIMPLE_REPOSITORY, properties); final URI artifactXML = new URI(repositoryFile.toURI().toString() + "/artifacts.xml"); IStatus status = repo.executeBatch(new IRunnableWithProgress() { + @Override public void run(IProgressMonitor monitor) { repo.addDescriptor(createDescriptor("1", "1", Version.emptyVersion)); repo.addDescriptor(createDescriptor("2", "2", Version.emptyVersion)); @@ -209,6 +211,7 @@ public class BatchExecuteArtifactRepositoryTest extends AbstractProvisioningTest Map properties = new HashMap(); SimpleArtifactRepository repo = (SimpleArtifactRepository) getArtifactRepositoryManager().createRepository(repositoryURI, "My Repo", IArtifactRepositoryManager.TYPE_SIMPLE_REPOSITORY, properties); IStatus status = repo.executeBatch(new IRunnableWithProgress() { + @Override public void run(IProgressMonitor monitor) { // empty } @@ -231,11 +234,13 @@ public class BatchExecuteArtifactRepositoryTest extends AbstractProvisioningTest super(getAgent(), repositoryName, location, properties); } + @Override public IStatus executeBatch(IRunnableWithProgress runnable, IProgressMonitor monitor) { executeBatch = true; return super.executeBatch(runnable, monitor); } + @Override public void save() { if (executeBatch) throw new RuntimeException("foo"); @@ -254,11 +259,13 @@ public class BatchExecuteArtifactRepositoryTest extends AbstractProvisioningTest super(manager, location, repositoryName, properties); } + @Override public IStatus executeBatch(IRunnableWithProgress runnable, IProgressMonitor monitor) { executeBatch = true; return super.executeBatch(runnable, monitor); } + @Override public void save() { if (executeBatch) throw new RuntimeException("foo"); @@ -266,13 +273,14 @@ public class BatchExecuteArtifactRepositoryTest extends AbstractProvisioningTest } /* - * This tests that exceptions are properly propagated for a SimpleArtifactRepository + * This tests that exceptions are properly propagated for a SimpleArtifactRepository */ public void testBatchProcessingExceptionsSimple() { try { SimpleArtifactRepository simpleArtifactRepository = new FailingSimpleArtifactRepository("foo", new URI("http://foo.bar"), null); IStatus status = simpleArtifactRepository.executeBatch(new IRunnableWithProgress() { + @Override public void run(IProgressMonitor monitor) { throw new RuntimeException("bar"); } @@ -294,6 +302,7 @@ public class BatchExecuteArtifactRepositoryTest extends AbstractProvisioningTest SimpleArtifactRepository simpleArtifactRepository = new FailingSimpleArtifactRepository("foo", new URI("http://foo.bar"), null); IStatus status = simpleArtifactRepository.executeBatch(new IRunnableWithProgress() { + @Override public void run(IProgressMonitor monitor) { // empty } @@ -318,6 +327,7 @@ public class BatchExecuteArtifactRepositoryTest extends AbstractProvisioningTest monitor.setCanceled(true); IStatus status = repo.executeBatch(new IRunnableWithProgress() { + @Override public void run(IProgressMonitor monitor) { if (monitor.isCanceled()) throw new OperationCanceledException(); @@ -339,6 +349,7 @@ public class BatchExecuteArtifactRepositoryTest extends AbstractProvisioningTest IStatus status = compositeArtifactRepository.executeBatch(new IRunnableWithProgress() { + @Override public void run(IProgressMonitor monitor) { throw new RuntimeException("bar"); } @@ -360,6 +371,7 @@ public class BatchExecuteArtifactRepositoryTest extends AbstractProvisioningTest FailingCompositeArtifactRepository compositeArtifactRepository = new FailingCompositeArtifactRepository(getArtifactRepositoryManager(), "foo", new URI("http://foo.bar"), null); IStatus status = compositeArtifactRepository.executeBatch(new IRunnableWithProgress() { + @Override public void run(IProgressMonitor monitor) { // empty } @@ -384,11 +396,13 @@ public class BatchExecuteArtifactRepositoryTest extends AbstractProvisioningTest super(getAgent(), repositoryName, location, properties); } + @Override public IStatus executeBatch(IRunnableWithProgress runnable, IProgressMonitor monitor) { executeBatch = true; return super.executeBatch(runnable, monitor); } + @Override public void save() { if (executeBatch) didSave = true; @@ -403,6 +417,7 @@ public class BatchExecuteArtifactRepositoryTest extends AbstractProvisioningTest try { TrackSavignSimpleArtifactRepository simpleArtifactRepository = new TrackSavignSimpleArtifactRepository("foo", new URI("http://foo.bar"), null); simpleArtifactRepository.executeBatch(new IRunnableWithProgress() { + @Override public void run(IProgressMonitor monitor) { //do nothing; } @@ -421,6 +436,7 @@ public class BatchExecuteArtifactRepositoryTest extends AbstractProvisioningTest try { TrackSavignSimpleArtifactRepository simpleArtifactRepository = new TrackSavignSimpleArtifactRepository("foo", new URI("http://foo.bar"), null); simpleArtifactRepository.executeBatch(new IRunnableWithProgress() { + @Override public void run(IProgressMonitor monitor) { throw new RuntimeException(); } @@ -442,6 +458,7 @@ public class BatchExecuteArtifactRepositoryTest extends AbstractProvisioningTest Map properties = new HashMap(); SimpleArtifactRepository repo = (SimpleArtifactRepository) getArtifactRepositoryManager().createRepository(repositoryURI, "My Repo", IArtifactRepositoryManager.TYPE_SIMPLE_REPOSITORY, properties); repo.executeBatch(new IRunnableWithProgress() { + @Override public void run(IProgressMonitor monitor) { throw new RuntimeException(); } @@ -457,7 +474,7 @@ public class BatchExecuteArtifactRepositoryTest extends AbstractProvisioningTest } /* - * This test ensure that the simple artifact repository disables the + * This test ensure that the simple artifact repository disables the * save flag during the batch process */ public void testDisableSaveFlagDuringExecutionSimple() { @@ -467,6 +484,7 @@ public class BatchExecuteArtifactRepositoryTest extends AbstractProvisioningTest Map properties = new HashMap(); final SimpleArtifactRepository repo = (SimpleArtifactRepository) getArtifactRepositoryManager().createRepository(repositoryURI, "My Repo", IArtifactRepositoryManager.TYPE_SIMPLE_REPOSITORY, properties); repo.executeBatch(new IRunnableWithProgress() { + @Override public void run(IProgressMonitor monitor) { Field field; try { @@ -503,6 +521,7 @@ public class BatchExecuteArtifactRepositoryTest extends AbstractProvisioningTest Map properties = new HashMap(); CompositeArtifactRepository repo = (CompositeArtifactRepository) getArtifactRepositoryManager().createRepository(repositoryURI, "My Repo", IArtifactRepositoryManager.TYPE_COMPOSITE_REPOSITORY, properties); repo.executeBatch(new IRunnableWithProgress() { + @Override public void run(IProgressMonitor monitor) { throw new RuntimeException(); } @@ -527,6 +546,7 @@ public class BatchExecuteArtifactRepositoryTest extends AbstractProvisioningTest Map properties = new HashMap(); final CompositeArtifactRepository repo = (CompositeArtifactRepository) getArtifactRepositoryManager().createRepository(repositoryURI, "My Repo", IArtifactRepositoryManager.TYPE_COMPOSITE_REPOSITORY, properties); repo.executeBatch(new IRunnableWithProgress() { + @Override public void run(IProgressMonitor monitor) { Field field; try { diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/Bug265577.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/Bug265577.java index 0457ce0da..d6d6cd7bd 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/Bug265577.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/Bug265577.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 IBM Corporation and others. + * Copyright (c) 2009, 2017 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 * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -32,6 +32,7 @@ public class Bug265577 extends AbstractProvisioningTest { ProvisioningContext context; IEngine engine; + @Override public void setUp() throws Exception { super.setUp(); profile = createProfile(Bug265577.class.getName()); @@ -102,7 +103,7 @@ public class Bug265577 extends AbstractProvisioningTest { assertTrue(status.getMessage(), status.isOK()); } - // Return expected error message for the attempt to retrieve an artifact if it is a folder from inside a jar + // Return expected error message for the attempt to retrieve an artifact if it is a folder from inside a jar private String getJarFolderMessage(IArtifactKey key) { return "Artifact " + key.toString() + " is a folder but the repository is an archive or remote location."; } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/Bug351944.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/Bug351944.java index a511fc0d1..aa9e033f9 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/Bug351944.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/Bug351944.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2011 Wind River and others. + * Copyright (c) 2011, 2017 Wind River 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: * Wind River - initial API and implementation *******************************************************************************/ @@ -64,7 +64,7 @@ public class Bug351944 extends AbstractProvisioningTest { IQueryResult<IArtifactKey> allArtifactKeys = repo.query(ArtifactKeyQuery.ALL_KEYS, new NullProgressMonitor()); Set<IArtifactKey> keySet = allArtifactKeys.toUnmodifiableSet(); - Collection<IArtifactRequest> requests = new ArrayList<IArtifactRequest>(); + Collection<IArtifactRequest> requests = new ArrayList<>(); for (IArtifactKey key : keySet) requests.add(artifactRepositoryManager.createMirrorRequest(key, repo, null, null)); @@ -90,7 +90,7 @@ public class Bug351944 extends AbstractProvisioningTest { * @return */ private IArtifactRequest[] getRequestsForRepository(IArtifactRepository repository, IArtifactRequest[] requestsToProcess) { - ArrayList<IArtifactRequest> applicable = new ArrayList<IArtifactRequest>(); + ArrayList<IArtifactRequest> applicable = new ArrayList<>(); for (IArtifactRequest request : requestsToProcess) { if (repository.contains(request.getArtifactKey())) applicable.add(request); @@ -100,7 +100,7 @@ public class Bug351944 extends AbstractProvisioningTest { private IArtifactRequest[] getRequestsForRepository2(IArtifactRepository repository, IArtifactRequest[] requestsToProcess) { Set<IArtifactKey> keys = repository.query(ArtifactKeyQuery.ALL_KEYS, new NullProgressMonitor()).toSet(); - ArrayList<IArtifactRequest> applicable = new ArrayList<IArtifactRequest>(); + ArrayList<IArtifactRequest> applicable = new ArrayList<>(); for (IArtifactRequest request : requestsToProcess) { if (keys.contains(request.getArtifactKey())) applicable.add(request); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/CompositeArtifactRepositoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/CompositeArtifactRepositoryTest.java index 506408afd..74f9399a8 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/CompositeArtifactRepositoryTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/CompositeArtifactRepositoryTest.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2008, 2011 IBM Corporation and others. + * Copyright (c) 2008, 2017 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 * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -49,6 +49,7 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest { private int childCount = 0; + @Override protected void tearDown() throws Exception { super.tearDown(); //repository location is not used by all tests @@ -1019,7 +1020,7 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest { } /* - * Test a retry request by a child composite repository + * Test a retry request by a child composite repository */ public void testChildRetryRequest() { class BadMirrorSite extends TestArtifactRepository { @@ -1030,16 +1031,19 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest { addToRepositoryManager(); } + @Override public IStatus getArtifact(IArtifactDescriptor descriptor, OutputStream out, IProgressMonitor monitor) { if (++downloadAttempts == 1) return new MultiStatus(Activator.ID, CODE_RETRY, new IStatus[] {new Status(IStatus.ERROR, "Test", "Test - Download interrupted")}, "Retry another mirror", null); return Status.OK_STATUS; } + @Override public boolean contains(IArtifactDescriptor desc) { return true; } + @Override public boolean contains(IArtifactKey desc) { return true; } @@ -1095,16 +1099,19 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest { super(getAgent(), location); } + @Override public IStatus getArtifact(IArtifactDescriptor descriptor, OutputStream out, IProgressMonitor monitor) { super.getArtifact(descriptor, out, monitor); return new Status(IStatus.ERROR, "Test", "Test - Download interrupted"); } + @Override public void addDescriptor(IArtifactDescriptor descriptor, IProgressMonitor monitor) { super.addDescriptor(descriptor, monitor); super.addArtifact(descriptor.getArtifactKey(), contents); } + @Override public OutputStream getOutputStream(IArtifactDescriptor descriptor) { try { return new FileOutputStream(location); @@ -1364,10 +1371,12 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest { protected IArtifactRepository createChild() { try { TestArtifactRepository repo = new TestArtifactRepository(getAgent(), new URI("memory:/in/memory/" + childCount++)) { + @Override public boolean contains(IArtifactDescriptor desc) { return true; } + @Override public boolean contains(IArtifactKey desc) { return true; } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/FoldersRepositoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/FoldersRepositoryTest.java index 39a355c21..cc030807f 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/FoldersRepositoryTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/FoldersRepositoryTest.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2007, 2015 IBM Corporation and others. + * Copyright (c) 2007, 2017 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 * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * IBM Corporation - initial API and implementation * Red Hat Inc. - Bug 460967 @@ -41,11 +41,13 @@ public class FoldersRepositoryTest extends TestCase { super(""); } + @Override protected void setUp() throws Exception { IProvisioningAgent agent = ServiceHelper.getService(TestActivator.getContext(), IProvisioningAgent.class); manager = (IArtifactRepositoryManager) agent.getService(IArtifactRepositoryManager.SERVICE_NAME); } + @Override protected void tearDown() throws Exception { manager = null; if (testRepo != null) @@ -67,12 +69,7 @@ public class FoldersRepositoryTest extends TestCase { File sourceFolder = new File(FileLocator.toFileURL(sourceBase).getPath()); AbstractProvisioningTest.copy("0.99", sourceFolder, pluginsFolder); - FileFilter filter = new FileFilter() { - - public boolean accept(File pathname) { - return !pathname.getName().equals("CVS"); - } - }; + FileFilter filter = pathname -> !pathname.getName().equals("CVS"); File[] fileList = pluginsFolder.listFiles(filter); assertEquals(2, fileList.length); for (int i = 0; i < fileList.length; i++) { diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/JarURLArtifactRepositoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/JarURLArtifactRepositoryTest.java index 74b46ce99..76b8e7953 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/JarURLArtifactRepositoryTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/JarURLArtifactRepositoryTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2015 IBM Corporation and others. + * Copyright (c) 2007, 2017 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 @@ -36,11 +36,13 @@ public class JarURLArtifactRepositoryTest extends TestCase { super(""); } + @Override protected void setUp() throws Exception { IProvisioningAgent agent = ServiceHelper.getService(TestActivator.getContext(), IProvisioningAgent.class); manager = (IArtifactRepositoryManager) agent.getService(IArtifactRepositoryManager.SERVICE_NAME); } + @Override protected void tearDown() throws Exception { manager = null; } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/LocationTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/LocationTest.java index 0ff0cbe6f..cb517677e 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/LocationTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/LocationTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 IBM Corporation and others. + * Copyright (c) 2011, 2017 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 @@ -8,50 +8,52 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.equinox.p2.tests.artifact.repository;
-
-import java.io.File;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.equinox.internal.p2.artifact.repository.MirrorRequest;
-import org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepository;
-import org.eclipse.equinox.internal.p2.metadata.ArtifactKey;
-import org.eclipse.equinox.p2.metadata.IArtifactKey;
-import org.eclipse.equinox.p2.metadata.Version;
-import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
-import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
-import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
-
-public class LocationTest extends AbstractProvisioningTest {
- private static final String testDataLocation = "testData/artifactRepo/packedSiblingsWithUUID";
- private File targetLocation;
- private IArtifactRepository targetRepository, sourceRepository;
-
- public void setUp() throws Exception {
- super.setUp();
- targetLocation = File.createTempFile("target", ".repo");
- targetLocation.delete();
- targetLocation.mkdirs();
- targetRepository = new SimpleArtifactRepository(getAgent(), "TargetRepo", targetLocation.toURI(), null);
-
- IArtifactRepositoryManager mgr = getArtifactRepositoryManager();
- sourceRepository = mgr.loadRepository((getTestData("EmptyJar repo", testDataLocation).toURI()), null);
-
- }
-
- protected void tearDown() throws Exception {
- getArtifactRepositoryManager().removeRepository(targetLocation.toURI());
- getArtifactRepositoryManager().removeRepository(sourceRepository.getLocation());
- AbstractProvisioningTest.delete(targetLocation);
- super.tearDown();
- }
-
- public void testLocation() throws Exception {
- IArtifactKey key = new ArtifactKey("osgi.bundle", "org.springframework.ide.eclipse", Version.parseVersion("2.3.2.201003220227-RELEASE"));
- assertTrue(sourceRepository.contains(key));
- MirrorRequest req = new MirrorRequest(key, targetRepository, null, null, getTransport());
- req.perform(sourceRepository, new NullProgressMonitor());
- IStatus status = req.getResult();
- assertTrue(status.getMessage(), status.isOK());
- }
-}
+package org.eclipse.equinox.p2.tests.artifact.repository; + +import java.io.File; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.equinox.internal.p2.artifact.repository.MirrorRequest; +import org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepository; +import org.eclipse.equinox.internal.p2.metadata.ArtifactKey; +import org.eclipse.equinox.p2.metadata.IArtifactKey; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository; +import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager; +import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; + +public class LocationTest extends AbstractProvisioningTest { + private static final String testDataLocation = "testData/artifactRepo/packedSiblingsWithUUID"; + private File targetLocation; + private IArtifactRepository targetRepository, sourceRepository; + + @Override + public void setUp() throws Exception { + super.setUp(); + targetLocation = File.createTempFile("target", ".repo"); + targetLocation.delete(); + targetLocation.mkdirs(); + targetRepository = new SimpleArtifactRepository(getAgent(), "TargetRepo", targetLocation.toURI(), null); + + IArtifactRepositoryManager mgr = getArtifactRepositoryManager(); + sourceRepository = mgr.loadRepository((getTestData("EmptyJar repo", testDataLocation).toURI()), null); + + } + + @Override + protected void tearDown() throws Exception { + getArtifactRepositoryManager().removeRepository(targetLocation.toURI()); + getArtifactRepositoryManager().removeRepository(sourceRepository.getLocation()); + AbstractProvisioningTest.delete(targetLocation); + super.tearDown(); + } + + public void testLocation() throws Exception { + IArtifactKey key = new ArtifactKey("osgi.bundle", "org.springframework.ide.eclipse", Version.parseVersion("2.3.2.201003220227-RELEASE")); + assertTrue(sourceRepository.contains(key)); + MirrorRequest req = new MirrorRequest(key, targetRepository, null, null, getTransport()); + req.perform(sourceRepository, new NullProgressMonitor()); + IStatus status = req.getResult(); + assertTrue(status.getMessage(), status.isOK()); + } +} diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/MD5Tests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/MD5Tests.java index 7c09e2854..d4bbedb84 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/MD5Tests.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/MD5Tests.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 IBM Corporation and others. + * Copyright (c) 2005, 2017 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 * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -27,6 +27,7 @@ public class MD5Tests extends AbstractProvisioningTest { File testRepo = null; IArtifactRepository repo = null; + @Override protected void setUp() throws Exception { super.setUp(); testRepo = getTestData("Repository with MD5", "testData/artifactRepo/simpleWithMD5"); @@ -62,6 +63,7 @@ public class MD5Tests extends AbstractProvisioningTest { } } + @Override protected void tearDown() throws Exception { getArtifactRepositoryManager().removeRepository(testRepo.toURI()); super.tearDown(); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/MirrorRequestTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/MirrorRequestTest.java index 43263df1c..6f7b52424 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/MirrorRequestTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/MirrorRequestTest.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 IBM Corporation and others. + * Copyright (c) 2005, 2017 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 * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -41,6 +41,7 @@ public class MirrorRequestTest extends AbstractProvisioningTest { IArtifactRepository targetRepository, sourceRepository; URI destination, failedOptimized, pakedRepositoryLocation; + @Override public void setUp() throws Exception { super.setUp(); targetLocation = File.createTempFile("target", ".repo"); @@ -55,6 +56,7 @@ public class MirrorRequestTest extends AbstractProvisioningTest { destination = getTempFolder().toURI(); } + @Override protected void tearDown() throws Exception { getArtifactRepositoryManager().removeRepository(destination); getArtifactRepositoryManager().removeRepository(failedOptimized); @@ -67,7 +69,7 @@ public class MirrorRequestTest extends AbstractProvisioningTest { public void testInvalidZipFileInTheSource() { IArtifactKey key = new ArtifactKey("org.eclipse.update.feature", "HelloWorldFeature", Version.createOSGi(1, 0, 0)); - Map<String, String> targetProperties = new HashMap<String, String>(); + Map<String, String> targetProperties = new HashMap<>(); targetProperties.put("artifact.folder", "true"); MirrorRequest request = new MirrorRequest(key, targetRepository, null, targetProperties, (Transport) getAgent().getService(Transport.SERVICE_NAME)); request.perform(sourceRepository, new NullProgressMonitor()); @@ -78,7 +80,7 @@ public class MirrorRequestTest extends AbstractProvisioningTest { public void testMissingArtifact() { IArtifactKey key = new ArtifactKey("org.eclipse.update.feature", "Missing", Version.createOSGi(1, 0, 0)); - Map<String, String> targetProperties = new HashMap<String, String>(); + Map<String, String> targetProperties = new HashMap<>(); targetProperties.put("artifact.folder", "true"); MirrorRequest request = new MirrorRequest(key, targetRepository, null, targetProperties, getTransport()); request.perform(sourceRepository, new NullProgressMonitor()); @@ -86,7 +88,7 @@ public class MirrorRequestTest extends AbstractProvisioningTest { assertTrue(request.getResult().matches(IStatus.ERROR)); } - // Test that if MirrorRequest fails to download a packed artifact it attempts the canonical version + // Test that if MirrorRequest fails to download a packed artifact it attempts the canonical version public void testFailToCanonical() { RemoteRepo src = new RemoteRepo((SimpleArtifactRepository) sourceRepository); @@ -99,7 +101,7 @@ public class MirrorRequestTest extends AbstractProvisioningTest { assertTrue("Number of downloads differs from expected attempts.", src.downloadCount == 2); } - // Test that SimpleArtifactRepository & MirrorRequest use mirrors in the event of a failure. + // Test that SimpleArtifactRepository & MirrorRequest use mirrors in the event of a failure. public void testMirrorFailOver() { OrderedMirrorSelector selector = new OrderedMirrorSelector(sourceRepository); try { @@ -138,7 +140,7 @@ public class MirrorRequestTest extends AbstractProvisioningTest { IArtifactKey key = (IArtifactKey) keys.iterator().next(); MirrorRequest req = new MirrorRequest(key, targetRepository, null, null, getTransport()); - // Set Status sequence + // Set Status sequence seq.add(new Status(IStatus.ERROR, "Activator", "Message")); seq.add(new Status(IStatus.WARNING, "Activator", "Message")); req.perform(source, new NullProgressMonitor()); @@ -147,7 +149,7 @@ public class MirrorRequestTest extends AbstractProvisioningTest { // Remove key from repo so the same one can be used targetRepository.removeDescriptor(key); - // Set Status sequence + // Set Status sequence req = new MirrorRequest(key, targetRepository, null, null, getTransport()); seq.add(new Status(IStatus.WARNING, "Activator", "Message")); @@ -158,7 +160,7 @@ public class MirrorRequestTest extends AbstractProvisioningTest { // Remove key from repo so the same one can be used targetRepository.removeDescriptor(key); - // Set Status sequence + // Set Status sequence req = new MirrorRequest(key, targetRepository, null, null, getTransport()); seq.add(new Status(IStatus.INFO, "Activator", "Message")); @@ -168,12 +170,13 @@ public class MirrorRequestTest extends AbstractProvisioningTest { } /* - * + * */ public void testFailedOptimizedMissingCanonical() { try { IArtifactRepository source = new AbstractWrappedArtifactRepository(getArtifactRepositoryManager().loadRepository(failedOptimized, new NullProgressMonitor())) { + @Override public URI getLocation() { try { return new URI("http://nowhere"); @@ -211,6 +214,7 @@ public class MirrorRequestTest extends AbstractProvisioningTest { super(repo); } + @Override public URI getLocation() { // Lie about the location so packed files are used try { @@ -220,6 +224,7 @@ public class MirrorRequestTest extends AbstractProvisioningTest { } } + @Override public IStatus getArtifact(IArtifactDescriptor descriptor, OutputStream destination, IProgressMonitor monitor) { try { destination.write(new byte[] {1, 1, 2}); @@ -260,6 +265,7 @@ public class MirrorRequestTest extends AbstractProvisioningTest { delegate = repo; } + @Override public synchronized URI getLocation() { try { return new URI("http://test/"); @@ -270,39 +276,48 @@ public class MirrorRequestTest extends AbstractProvisioningTest { } } + @Override public boolean contains(IArtifactDescriptor descriptor) { return delegate.contains(descriptor); } + @Override public boolean contains(IArtifactKey key) { return delegate.contains(key); } + @Override public IStatus getArtifact(IArtifactDescriptor descriptor, OutputStream destination, IProgressMonitor monitor) { downloadCount++; return delegate.getArtifact(descriptor, destination, monitor); } + @Override public IArtifactDescriptor[] getArtifactDescriptors(IArtifactKey key) { return delegate.getArtifactDescriptors(key); } + @Override public IStatus getArtifacts(IArtifactRequest[] requests, IProgressMonitor monitor) { return delegate.getArtifacts(requests, monitor); } + @Override public OutputStream getOutputStream(IArtifactDescriptor descriptor) throws ProvisionException { return delegate.getOutputStream(descriptor); } + @Override public IStatus getRawArtifact(IArtifactDescriptor descriptor, OutputStream destination, IProgressMonitor monitor) { return delegate.getRawArtifact(descriptor, destination, monitor); } + @Override public IQueryable<IArtifactDescriptor> descriptorQueryable() { return delegate.descriptorQueryable(); } + @Override public IQueryResult<IArtifactKey> query(IQuery<IArtifactKey> query, IProgressMonitor monitor) { return delegate.query(query, monitor); } @@ -329,7 +344,7 @@ public class MirrorRequestTest extends AbstractProvisioningTest { mirrors = computeMirrors("file:///" + getTestData("Mirror Location", testDataLocation + '/' + repo.getProperties().get(IRepository.PROP_MIRRORS_URL)).toString().replace('\\', '/')); } - // Hijack the source repository's MirrorSelector + // Hijack the source repository's MirrorSelector private void setSelector() { Field mirrorField = null; try { @@ -424,7 +439,7 @@ public class MirrorRequestTest extends AbstractProvisioningTest { || mirrorsURL.startsWith("https://") //$NON-NLS-1$ || mirrorsURL.startsWith("file://") //$NON-NLS-1$ || mirrorsURL.startsWith("ftp://") //$NON-NLS-1$ - || mirrorsURL.startsWith("jar://"))) //$NON-NLS-1$ + || mirrorsURL.startsWith("jar://"))) //$NON-NLS-1$ fail("Error processing mirrors URL: " + mirrorsURL, e); //$NON-NLS-1$ return null; } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/MirrorRequestTest2.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/MirrorRequestTest2.java index b0f6869f4..11698959c 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/MirrorRequestTest2.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/MirrorRequestTest2.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2011 WindRiver Corporation and others. - * All rights reserved. This program and the accompanying materials + * Copyright (c) 2011, 2017 WindRiver 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: * WindRiver Corporation - initial API and implementation *******************************************************************************/ @@ -53,6 +53,7 @@ public class MirrorRequestTest2 extends AbstractTestServerClientCase { sourceRepository = (SimpleArtifactRepository) mgr.loadRepository(location, null); } + @Override public void tearDown() throws Exception { IArtifactRepositoryManager mgr = (IArtifactRepositoryManager) getAgent().getService(IArtifactRepositoryManager.SERVICE_NAME); mgr.removeRepository(targetLocation.toURI()); @@ -121,45 +122,54 @@ public class MirrorRequestTest2 extends AbstractTestServerClientCase { @Override public synchronized Map<String, String> getProperties() { - Map<String, String> newProperties = new HashMap<String, String>(super.getProperties()); + Map<String, String> newProperties = new HashMap<>(super.getProperties()); newProperties.put(IRepository.PROP_MIRRORS_URL, getBaseURL() + "/mirrorrequest/mirrors.xml"); newProperties.put(IRepository.PROP_MIRRORS_BASE_URL, getBaseURL() + "/mirrorrequest"); return newProperties; } + @Override public boolean contains(IArtifactDescriptor descriptor) { return delegate.contains(descriptor); } + @Override public boolean contains(IArtifactKey key) { return delegate.contains(key); } + @Override public IStatus getArtifact(IArtifactDescriptor descriptor, OutputStream destination, IProgressMonitor monitor) { downloadCount++; return delegate.getArtifact(descriptor, destination, monitor); } + @Override public IArtifactDescriptor[] getArtifactDescriptors(IArtifactKey key) { return delegate.getArtifactDescriptors(key); } + @Override public IStatus getArtifacts(IArtifactRequest[] requests, IProgressMonitor monitor) { return delegate.getArtifacts(requests, monitor); } + @Override public OutputStream getOutputStream(IArtifactDescriptor descriptor) throws ProvisionException { return delegate.getOutputStream(descriptor); } + @Override public IStatus getRawArtifact(IArtifactDescriptor descriptor, OutputStream destination, IProgressMonitor monitor) { return delegate.getRawArtifact(descriptor, destination, monitor); } + @Override public IQueryable<IArtifactDescriptor> descriptorQueryable() { return delegate.descriptorQueryable(); } + @Override public IQueryResult<IArtifactKey> query(IQuery<IArtifactKey> query, IProgressMonitor monitor) { return delegate.query(query, monitor); } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/MirrorSelectorTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/MirrorSelectorTest.java index 7202b0fc7..37a48d13e 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/MirrorSelectorTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/MirrorSelectorTest.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2008, 2011 IBM Corporation and others. + * Copyright (c) 2008, 2017 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 * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * IBM Corporation - initial API and implementation * martin.kirst@s1998.tu-chemnitz.de - fixed and improved sort algorithm tests @@ -16,9 +16,6 @@ import junit.framework.TestCase; import org.eclipse.equinox.internal.p2.artifact.repository.MirrorSelector; import org.eclipse.equinox.internal.p2.artifact.repository.MirrorSelector.MirrorInfo; -/** - * - */ public class MirrorSelectorTest extends TestCase { private List<MirrorInfo> originals; @@ -31,7 +28,7 @@ public class MirrorSelectorTest extends TestCase { // This is the expected order of mirrors, // doesn't matter how often you're resorting ;-) - originals = new ArrayList<MirrorSelector.MirrorInfo>(); + originals = new ArrayList<>(); MirrorInfo mi = null; mi = new MirrorInfo("http://ftp.wh2.tu-dresden.de/pub/mirrors/eclipse/", 3); @@ -271,17 +268,17 @@ public class MirrorSelectorTest extends TestCase { // This way we hopefully get sure, that contract of Comparator#compareTo // is fulfilled. for (int x = 0; x < 1000; x++) { - ArrayList<MirrorInfo> templist = new ArrayList<MirrorInfo>(originals); + ArrayList<MirrorInfo> templist = new ArrayList<>(originals); Collections.shuffle(templist); MirrorInfo[] mirrors = templist.toArray(new MirrorInfo[originals.size()]); Arrays.sort(mirrors, comparator); assertList(originals, mirrors); /* * ================================================================ - * - * Because of + * + * Because of * Bug 317785 - Synchronization problem in mirror selection - * + * * We need an implementation of TimSort for this test. * But because of incompatibility of EPL and GPL, the TimSort * algorithm was removed. diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/SimpleArtifactRepositoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/SimpleArtifactRepositoryTest.java index b3a24ec35..7d0fbe176 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/SimpleArtifactRepositoryTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/SimpleArtifactRepositoryTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 compeople AG and others. + * Copyright (c) 2007, 2017 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 @@ -40,6 +40,7 @@ public class SimpleArtifactRepositoryTest extends AbstractProvisioningTest { private File repositoryFile = null; private URI repositoryURI = null; + @Override protected void tearDown() throws Exception { super.tearDown(); //repository location is not used by all tests @@ -173,6 +174,7 @@ public class SimpleArtifactRepositoryTest extends AbstractProvisioningTest { this.myStatus = status; } + @Override public void close() throws IOException { setStatus(myStatus); super.close(); @@ -213,7 +215,7 @@ public class SimpleArtifactRepositoryTest extends AbstractProvisioningTest { status = repo.getRawArtifact(descriptor, okStep, new NullProgressMonitor()); out.close(); - // The first warning step and the error step should be collected + // The first warning step and the error step should be collected assertFalse(status.isOK()); assertTrue("Unexpected Severity", status.matches(IStatus.ERROR)); assertEquals(2, status.getChildren().length); @@ -287,26 +289,32 @@ public class SimpleArtifactRepositoryTest extends AbstractProvisioningTest { this.artifactKey = key; } + @Override public IArtifactKey getArtifactKey() { return artifactKey; } + @Override public IProcessingStepDescriptor[] getProcessingSteps() { return steps; } + @Override public Map getProperties() { return properties; } + @Override public String getProperty(String key) { return properties.getProperty(key); } + @Override public IArtifactRepository getRepository() { return null; } + @Override public boolean equals(Object obj) { if (this == obj) return true; @@ -330,6 +338,7 @@ public class SimpleArtifactRepositoryTest extends AbstractProvisioningTest { return true; } + @Override public int hashCode() { String format = getProperty(FORMAT); @@ -384,6 +393,7 @@ public class SimpleArtifactRepositoryTest extends AbstractProvisioningTest { long start = System.currentTimeMillis(); repo.executeBatch(new IRunnableWithProgress() { + @Override public void run(IProgressMonitor monitor) throws OperationCanceledException { for (int i = 0; i < 10000; i++) { ArtifactDescriptor d = new ArtifactDescriptor(new ArtifactKey("osgi.bundle", "a" + i, Version.create("1.0.0"))); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/Adder.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/Adder.java index 013a93dc3..b39fa0b18 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/Adder.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/Adder.java @@ -1,5 +1,5 @@ /******************************************************************************* -* Copyright (c) 2007, 2010 compeople AG and others. +* Copyright (c) 2007, 2017 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 @@ -33,6 +33,7 @@ public class Adder extends ProcessingStep { this.operand = operand; } + @Override public void initialize(IProvisioningAgent agent, IProcessingStepDescriptor descriptor, IArtifactDescriptor context) { super.initialize(agent, descriptor, context); try { @@ -44,10 +45,12 @@ public class Adder extends ProcessingStep { } } + @Override public void write(int b) throws IOException { getDestination().write(b + operand); } + @Override public void close() throws IOException { super.close(); } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/ByteShifter.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/ByteShifter.java index 35b040a2d..48f27896e 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/ByteShifter.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/ByteShifter.java @@ -1,5 +1,5 @@ /******************************************************************************* -* Copyright (c) 2007, 2010 compeople AG and others. +* Copyright (c) 2007, 2017 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 @@ -40,7 +40,7 @@ public class ByteShifter extends ProcessingStep { return; int code; - // if there is a descriptor, decide if the "bad case" is an error or info. If no + // if there is a descriptor, decide if the "bad case" is an error or info. If no // descriptor then default to error. if (descriptor != null) code = descriptor.isRequired() ? IStatus.ERROR : IStatus.INFO; @@ -52,6 +52,7 @@ public class ByteShifter extends ProcessingStep { setStatus(new Status(code, Activator.ID, "ByteShifter operand invalid: " + operand)); } + @Override public void initialize(IProvisioningAgent agent, IProcessingStepDescriptor descriptor, IArtifactDescriptor context) { super.initialize(agent, descriptor, context); try { @@ -64,10 +65,12 @@ public class ByteShifter extends ProcessingStep { basicInitialize(descriptor); } + @Override public void write(int b) throws IOException { getDestination().write(b == -1 ? b : b << operand); } + @Override public IStatus getStatus() { return Status.OK_STATUS; } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/Counter.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/Counter.java index 0be982ecc..4314a10ad 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/Counter.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/Counter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 IBM Corporation and others. + * Copyright (c) 2007, 2017 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 @@ -40,7 +40,7 @@ public class Counter extends ProcessingStep { return; int code; - // if there is a descriptor, decide if the "bad case" is an error or info. If no + // if there is a descriptor, decide if the "bad case" is an error or info. If no // descriptor then default to error. if (descriptor != null) code = descriptor.isRequired() ? IStatus.ERROR : IStatus.INFO; @@ -52,6 +52,7 @@ public class Counter extends ProcessingStep { setStatus(new Status(code, Activator.ID, "Counter size not set")); } + @Override public void initialize(IProvisioningAgent agent, IProcessingStepDescriptor descriptor, IArtifactDescriptor context) { super.initialize(agent, descriptor, context); String data = descriptor.getData(); @@ -72,11 +73,13 @@ public class Counter extends ProcessingStep { basicInitialize(descriptor); } + @Override public void write(int b) throws IOException { total++; getDestination().write(b); } + @Override public void close() throws IOException { super.close(); if (total != size) diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/Multiplier.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/Multiplier.java index d7dfff306..92f14251c 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/Multiplier.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/Multiplier.java @@ -1,5 +1,5 @@ /******************************************************************************* -* Copyright (c) 2007, 2010 compeople AG and others. +* Copyright (c) 2007, 2017 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 @@ -33,6 +33,7 @@ public class Multiplier extends ProcessingStep { this.operand = operand; } + @Override public void initialize(IProvisioningAgent agent, IProcessingStepDescriptor descriptor, IArtifactDescriptor context) { super.initialize(agent, descriptor, context); try { @@ -44,10 +45,12 @@ public class Multiplier extends ProcessingStep { } } + @Override public void write(int b) throws IOException { getDestination().write(b == -1 ? b : b * operand); } + @Override public void close() throws IOException { super.close(); } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/ProcessingStepHandlerTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/ProcessingStepHandlerTest.java index b7d7aa35b..4489afac3 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/ProcessingStepHandlerTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/ProcessingStepHandlerTest.java @@ -1,5 +1,5 @@ /******************************************************************************* -* Copyright (c) 2007, 2010 compeople AG and others. +* Copyright (c) 2007, 2017 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 @@ -218,11 +218,13 @@ public class ProcessingStepHandlerTest extends AbstractProvisioningTest { public void testPSHgetStatusOK() { ProcessingStep ok1, ok2; ok1 = new ProcessingStep() { + @Override public IStatus getStatus() { return Status.OK_STATUS; } }; ok2 = new ProcessingStep() { + @Override public IStatus getStatus() { return Status.OK_STATUS; } @@ -239,24 +241,28 @@ public class ProcessingStepHandlerTest extends AbstractProvisioningTest { public void testPSHgetStatus() { ProcessingStep ok, info, warning, error; ok = new ProcessingStep() { + @Override public IStatus getStatus() { return Status.OK_STATUS; } }; info = new ProcessingStep() { + @Override public IStatus getStatus() { return new Status(IStatus.INFO, "ID", "INFO"); } }; warning = new ProcessingStep() { + @Override public IStatus getStatus() { return new Status(IStatus.WARNING, "ID", "WARNING"); } }; error = new ProcessingStep() { + @Override public IStatus getStatus() { return new Status(IStatus.ERROR, "ID", "ERROR"); } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/ProcessingStepTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/ProcessingStepTest.java index 15948b184..ba7005f60 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/ProcessingStepTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/ProcessingStepTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 compeople AG and others. + * Copyright (c) 2007, 2017 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 @@ -23,6 +23,7 @@ public class ProcessingStepTest extends TestCase { private boolean flushed; private boolean closed; + @Override protected void setUp() throws Exception { super.setUp(); ps = new ProcessingStep() {}; @@ -67,9 +68,11 @@ public class ProcessingStepTest extends TestCase { public void testFlush() throws IOException { OutputStream destination = new OutputStream() { + @Override public void write(int b) { } + @Override public void flush() { flushed = true; } @@ -82,9 +85,11 @@ public class ProcessingStepTest extends TestCase { public void testCloseSimpleOutputStreamAsDestination() throws IOException { OutputStream destination = new OutputStream() { + @Override public void write(int b) { } + @Override public void close() { closed = true; } @@ -96,6 +101,7 @@ public class ProcessingStepTest extends TestCase { public void testCloseProcessingStepAsDestination() throws IOException { OutputStream destination = new ProcessingStep() { + @Override public void close() { closed = true; } |