Skip to content

Commit

Permalink
Fix MirrorRequestTest to not manually set statuses
Browse files Browse the repository at this point in the history
That way actually returned statuses are tested.
  • Loading branch information
akurtakov committed Aug 23, 2023
1 parent e3066f1 commit 0a64b90
Showing 1 changed file with 7 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
import java.util.LinkedList;
import java.util.Map;
import java.util.Queue;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
Expand Down Expand Up @@ -179,7 +181,6 @@ public void testStatusFromFailover() {
} catch (ProvisionException e) {
fail("Failed to load source repository");
}
// Set status sequence, actual Statuses added later
source.setSequence(seq);
// Grab an ArtifactKey to mirror, doesn't matter which
IQueryResult<IArtifactKey> keys = source.query(ArtifactKeyQuery.ALL_KEYS, null);
Expand All @@ -188,35 +189,29 @@ public void testStatusFromFailover() {
IArtifactKey key = keys.iterator().next();
MirrorRequest req = new MirrorRequest(key, targetRepository, null, null, getTransport());

// Set Status sequence
seq.add(new Status(IStatus.ERROR, "Activator", "Message"));
seq.add(new Status(IStatus.WARNING, "Activator", "Message"));
req.perform(source, new NullProgressMonitor());

// packed artifact is ignored as Java 14 removed pack200
assertEquals("Expected ERROR status", IStatus.ERROR, req.getResult().getSeverity());
assertEquals("Expected OK status", IStatus.OK, req.getResult().getSeverity());

// Remove key from repo so the same one can be used
targetRepository.removeDescriptor(key, new NullProgressMonitor());
// Set Status sequence

req = new MirrorRequest(key, targetRepository, null, null, getTransport());

seq.add(new Status(IStatus.WARNING, "Activator", "Message"));
seq.add(new Status(IStatus.INFO, "Activator", "Message"));
req.perform(source, new NullProgressMonitor());

// packed artifact is ignored as Java 14 removed pack200
assertEquals("Expected WARNING status", IStatus.WARNING, req.getResult().getSeverity());
assertEquals("Expected OK status", IStatus.OK, req.getResult().getSeverity());

// Remove key from repo so the same one can be used
targetRepository.removeDescriptor(key, new NullProgressMonitor());
// Set Status sequence

req = new MirrorRequest(key, targetRepository, null, null, getTransport());

seq.add(new Status(IStatus.INFO, "Activator", "Message"));
req.perform(source, new NullProgressMonitor());
// packed artifact is ignored as Java 14 removed pack200
assertEquals("Expected WARNING status", IStatus.WARNING, req.getResult().getSeverity());
assertEquals("Expected OK status", IStatus.OK, req.getResult().getSeverity());
}

protected static void assertStatusContains(String message, IStatus status, String statusString) {
Expand Down

0 comments on commit 0a64b90

Please sign in to comment.