Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SHRINKRES-319] Resolve deprecated API usage #183

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,10 @@
import org.jboss.shrinkwrap.resolver.api.maven.archive.importer.MavenImporter;
import org.jboss.shrinkwrap.resolver.impl.maven.archive.util.TestFileUtil;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

/**
* JAR import test case with settings.xml configuration
Expand All @@ -49,9 +48,6 @@ public class ConfiguredMavenImporterTestCase {
private static final String LOCAL_REPOSITORY = "target/local-only-repository";
private static final String SETTINGS_FILE = "src/test/resources/settings.xml";

@Rule
public ExpectedException exception = ExpectedException.none();

@BeforeClass
public static void clearLocalRepositoryReference() {
System.clearProperty("maven.repo.local"); // May conflict with release settings
Expand Down Expand Up @@ -112,12 +108,9 @@ public void importJarWithName() {

@Test
public void importJarOffline() {

// if running offline, this would not work
exception.expect(NoResolvedResultException.class);
ShrinkWrap.create(MavenImporter.class).configureFromFile(SETTINGS_FILE).offline()
.loadPomFromFile("src/it/jar-sample/pom.xml").importBuildOutput().as(WebArchive.class);

Assert.assertThrows(NoResolvedResultException.class, () -> ShrinkWrap.create(MavenImporter.class).configureFromFile(SETTINGS_FILE).offline()
.loadPomFromFile("src/it/jar-sample/pom.xml").importBuildOutput().as(WebArchive.class));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public MirrorSelector mirrorSelector() {
for (Mirror mirror : settings.getMirrors()) {
// Repository manager flag is set to false
// Maven does not support specifying it in the settings.xml
dms.add(mirror.getId(), mirror.getUrl(), mirror.getLayout(), false, mirror.getMirrorOf(),
dms.add(mirror.getId(), mirror.getUrl(), mirror.getLayout(), false, false, mirror.getMirrorOf(),
mirror.getMirrorOfLayouts());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

Expand Down Expand Up @@ -39,7 +40,7 @@ public void packageDirectories_singleEntry_canUnzip() throws Exception {
File inputFolder = tempFolder.newFolder("inputFolder");
FileUtils.forceMkdir(inputFolder);
File inputFile = new File(inputFolder, "exampleInput.foo");
FileUtils.write(inputFile, "some data");
FileUtils.write(inputFile, "some data", Charset.defaultCharset());

MavenResolvedArtifactImpl.PackageDirHelper.packageDirectories(output, inputFolder);

Expand All @@ -56,7 +57,7 @@ public void packageDirectories_singleEntryWithSubEntries_canUnzip() throws Excep
FileUtils.forceMkdir(inputSubFolder);

File inputFile = new File(inputSubFolder, "exampleInput.foo");
FileUtils.write(inputFile, "some data");
FileUtils.write(inputFile, "some data", Charset.defaultCharset());

MavenResolvedArtifactImpl.PackageDirHelper.packageDirectories(output, inputRootFolder);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

/**
* Tests resolution of the artifacts without enabling any remote repository
Expand All @@ -62,9 +60,6 @@ public class OfflineRepositoryTestCase {

private static final String OFFLINE_REPOSITORY = "target/offline-repository";

@Rule
public ExpectedException exception = ExpectedException.none();

@BeforeClass
public static void initialize() {
System.clearProperty(MavenSettingsBuilder.ALT_LOCAL_REPOSITORY_LOCATION); // May conflict with release settings
Expand Down Expand Up @@ -107,9 +102,8 @@ public void offlineProgramatically() throws IOException {
this.cleanup();

// Now try in offline mode and ensure we cannot resolve
exception.expect(NoResolvedResultException.class);
Maven.configureResolver().workOffline().fromFile(settingsFile).resolve(artifactWhichShouldNotResolve)
.withTransitivity().asSingle(File.class);
Assert.assertThrows(NoResolvedResultException.class, () -> Maven.configureResolver().workOffline()
.fromFile(settingsFile).resolve(artifactWhichShouldNotResolve).withTransitivity().asSingle(File.class));
}

/**
Expand All @@ -134,10 +128,10 @@ public void offlineProgramaticallyPomBased() throws IOException {

// Now try in offline mode and ensure we cannot resolve because we cannot hit repository defined in pom.xml (working
// offline) and local repository was cleaned
exception.expect(NoResolvedResultException.class);
Maven.configureResolver().workOffline().loadPomFromClassLoaderResource(pomFile)
Assert.assertThrows(NoResolvedResultException.class, () -> Maven.configureResolver().workOffline()
.loadPomFromClassLoaderResource(pomFile)
.importCompileAndRuntimeDependencies()
.resolve().withTransitivity().as(File.class);
.resolve().withTransitivity().as(File.class));
} finally {
System.clearProperty(MavenSettingsBuilder.ALT_LOCAL_REPOSITORY_LOCATION);
}
Expand Down
Loading