Skip to content

Commit 43bba83

Browse files
committed
Update 'm2e-core-tests' submodule to remove embedded test artifacts
1 parent 3e31be2 commit 43bba83

File tree

5 files changed

+126
-22
lines changed

5 files changed

+126
-22
lines changed

m2e-core-tests

Submodule m2e-core-tests updated 933 files

org.eclipse.m2e.tests.common/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-Name: M2E Testing Helpers
44
Bundle-SymbolicName: org.eclipse.m2e.tests.common;singleton:=true
5-
Bundle-Version: 2.0.3.qualifier
5+
Bundle-Version: 2.0.4.qualifier
66
Require-Bundle: org.junit;bundle-version="4.0.0",
77
org.eclipse.m2e.core;bundle-version="[2.0.0,3.0.0)",
88
org.eclipse.m2e.maven.runtime;bundle-version="[3.8.6,4.0.0)",

org.eclipse.m2e.tests.common/src/org/eclipse/m2e/tests/common/AbstractMavenProjectTestCase.java

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
import org.eclipse.swt.widgets.Shell;
7777

7878
import org.codehaus.plexus.PlexusContainer;
79+
import org.codehaus.plexus.component.composition.CycleDetectedInComponentGraphException;
7980
import org.codehaus.plexus.component.repository.ComponentDescriptor;
8081

8182
import org.apache.maven.artifact.repository.ArtifactRepository;
@@ -243,8 +244,8 @@ public void setUp() throws Exception {
243244
// Otherwise MavenLaunchDelegate.findMavenProjectBasedir() find this git repos .mvn folder and its content would interfer with the tests.
244245
Files.createDirectories(Path.of(workspace.getRoot().getLocationURI()).resolve(".mvn"));
245246

246-
FilexWagon.setRequestFailPattern(null);
247-
FilexWagon.setRequestFilterPattern(null, true);
247+
FilexWagon.reset();
248+
HttxWagon.reset();
248249
driveEvents();
249250
}
250251

@@ -268,6 +269,7 @@ public void tearDown() throws Exception {
268269
setAutoBuilding(false);
269270
setAutomaticallyUpdateConfiguration(false);
270271
FilexWagon.reset();
272+
HttxWagon.reset();
271273
}
272274

273275
/**
@@ -683,15 +685,21 @@ protected static Set<IProject> getProjectsFromEvents(Collection<MavenProjectChan
683685
return projects;
684686
}
685687

686-
protected void injectFilexWagon() throws Exception {
688+
protected void injectRedirectingWagons() throws Exception {
689+
injectWagon(FilexWagon.class, FilexWagon.PROTOCOL);
690+
injectWagon(HttxWagon.class, HttxWagon.PROTOCOL);
691+
}
692+
693+
private void injectWagon(Class<? extends Wagon> wagonClass, String wagonRoleHint)
694+
throws CoreException, CycleDetectedInComponentGraphException {
687695
PlexusContainer container = MavenPlugin.getMaven().lookup(PlexusContainer.class);
688-
if(container.getContainerRealm().getResource(FilexWagon.class.getName().replace('.', '/') + ".class") == null) {
689-
container.getContainerRealm().importFrom(FilexWagon.class.getClassLoader(), FilexWagon.class.getName());
696+
if(container.getContainerRealm().getResource(wagonClass.getName().replace('.', '/') + ".class") == null) {
697+
container.getContainerRealm().importFrom(wagonClass.getClassLoader(), wagonClass.getName());
690698
ComponentDescriptor<Wagon> descriptor = new ComponentDescriptor<>();
691699
descriptor.setRealm(container.getContainerRealm());
692700
descriptor.setRoleClass(Wagon.class);
693-
descriptor.setImplementationClass(FilexWagon.class);
694-
descriptor.setRoleHint("filex");
701+
descriptor.setImplementationClass(wagonClass);
702+
descriptor.setRoleHint(wagonRoleHint);
695703
descriptor.setInstantiationStrategy("per-lookup");
696704
container.addComponentDescriptor(descriptor);
697705
}

org.eclipse.m2e.tests.common/src/org/eclipse/m2e/tests/common/FilexWagon.java

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2008-2010 Sonatype, Inc.
2+
* Copyright (c) 2008-2023 Sonatype, Inc.
33
* All rights reserved. This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License 2.0
55
* which accompanies this distribution, and is available at
@@ -36,6 +36,8 @@
3636
*/
3737
public class FilexWagon extends FileWagon {
3838

39+
static final String PROTOCOL = "filex";
40+
3941
private static List<String> requests = new ArrayList<>();
4042

4143
private static String requestFilterPattern;
@@ -57,39 +59,33 @@ public static void setRequestFailPattern(String regex) {
5759
requestFailPattern = regex;
5860
}
5961

62+
@Override
6063
public void connect(Repository repository, AuthenticationInfo authenticationInfo, ProxyInfoProvider proxyInfoProvider)
6164
throws ConnectionException, AuthenticationException {
6265
String basedir = repository.getBasedir();
6366
if(basedir != null && basedir.startsWith("/")) {
6467
repository.setBasedir(basedir.substring(1));
6568
}
66-
6769
super.connect(repository, authenticationInfo, proxyInfoProvider);
6870
}
6971

72+
@Override
7073
public void fillInputData(InputData inputData) throws TransferFailedException, ResourceDoesNotExistException {
71-
record("GET", inputData.getResource());
72-
fail(inputData.getResource());
73-
74+
recordOperation("GET", inputData.getResource());
7475
super.fillInputData(inputData);
7576
}
7677

78+
@Override
7779
public void fillOutputData(OutputData outputData) throws TransferFailedException {
78-
record("PUT", outputData.getResource());
79-
fail(outputData.getResource());
80-
80+
recordOperation("PUT", outputData.getResource());
8181
super.fillOutputData(outputData);
8282
}
8383

84-
private static void record(String op, Resource resource) {
84+
private static void recordOperation(String op, Resource resource) throws TransferFailedException {
8585
String name = resource.getName();
8686
if(requestFilterPattern == null || name.matches(requestFilterPattern)) {
8787
requests.add(op + " " + name);
8888
}
89-
}
90-
91-
private static void fail(Resource resource) throws TransferFailedException {
92-
String name = resource.getName();
9389
if(requestFailPattern != null && name.matches(requestFailPattern)) {
9490
throw new TransferFailedException("Test failure");
9591
}
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2008-2023 Sonatype, Inc.
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License 2.0
5+
* which accompanies this distribution, and is available at
6+
* https://www.eclipse.org/legal/epl-2.0/
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
*
10+
* Contributors:
11+
* Sonatype, Inc. - initial API and implementation
12+
* Hannes Wellmann - Create HttxWagon based on FilexWagon
13+
*******************************************************************************/
14+
15+
package org.eclipse.m2e.tests.common;
16+
17+
import java.io.InputStream;
18+
import java.util.ArrayList;
19+
import java.util.List;
20+
21+
import org.apache.maven.wagon.ConnectionException;
22+
import org.apache.maven.wagon.OutputData;
23+
import org.apache.maven.wagon.ResourceDoesNotExistException;
24+
import org.apache.maven.wagon.TransferFailedException;
25+
import org.apache.maven.wagon.authentication.AuthenticationException;
26+
import org.apache.maven.wagon.authentication.AuthenticationInfo;
27+
import org.apache.maven.wagon.authorization.AuthorizationException;
28+
import org.apache.maven.wagon.proxy.ProxyInfoProvider;
29+
import org.apache.maven.wagon.repository.Repository;
30+
import org.apache.maven.wagon.resource.Resource;
31+
32+
import io.takari.aether.wagon.OkHttpsWagon;
33+
34+
35+
/**
36+
* A special wagon for testing that allows to record the requests made to a repository. Use
37+
* {@link #setRequestFilterPattern(String, boolean)} to configure what to record and to optionally clear previous
38+
* records. The repository URL to use with this wagon looks like {@code httx://localhost/<path-relative-to-project>}.
39+
*/
40+
public class HttxWagon extends OkHttpsWagon {
41+
42+
//MUST NOT start with "http", because otherwise the io.takari.aether.connector.AetherRepositoryConnector will consider it as default http(s) and will handle the connection.
43+
static String PROTOCOL = "httx";
44+
45+
private static List<String> requests = new ArrayList<>();
46+
47+
private static String requestFilterPattern;
48+
49+
private static String requestFailPattern;
50+
51+
public static List<String> getRequests() {
52+
return requests;
53+
}
54+
55+
public static void setRequestFilterPattern(String regex, boolean clear) {
56+
requestFilterPattern = regex;
57+
if(clear) {
58+
requests.clear();
59+
}
60+
}
61+
62+
public static void setRequestFailPattern(String regex) {
63+
requestFailPattern = regex;
64+
}
65+
66+
public void connect(Repository repository, AuthenticationInfo authenticationInfo, ProxyInfoProvider proxyInfoProvider)
67+
throws ConnectionException, AuthenticationException {
68+
if(PROTOCOL.equals(repository.getProtocol())) {
69+
repository.setUrl("https" + repository.getUrl().substring(PROTOCOL.length()));
70+
}
71+
super.connect(repository, authenticationInfo, proxyInfoProvider);
72+
}
73+
74+
protected InputStream getInputStream(Resource resource)
75+
throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException {
76+
recordOperation("GET", resource);
77+
return super.getInputStream(resource);
78+
}
79+
80+
public void fillOutputData(OutputData outputData) throws TransferFailedException {
81+
recordOperation("PUT", outputData.getResource());
82+
super.fillOutputData(outputData);
83+
}
84+
85+
private static void recordOperation(String op, Resource resource) throws TransferFailedException {
86+
String name = resource.getName();
87+
if(requestFilterPattern == null || name.matches(requestFilterPattern)) {
88+
requests.add(op + " " + name);
89+
}
90+
if(requestFailPattern != null && name.matches(requestFailPattern)) {
91+
throw new TransferFailedException("Test failure");
92+
}
93+
}
94+
95+
public static void reset() {
96+
requestFailPattern = null;
97+
requestFilterPattern = null;
98+
requests.clear();
99+
}
100+
}

0 commit comments

Comments
 (0)