Skip to content

Commit

Permalink
[SHRINKRES-314] Replace the deprecated Assert methods
Browse files Browse the repository at this point in the history
  • Loading branch information
petrberan committed Nov 3, 2023
1 parent c2de181 commit 292b460
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.jboss.shrinkwrap.resolver.impl.maven.archive.importer.ArchiveContentMatchers.contains;
import static org.jboss.shrinkwrap.resolver.impl.maven.archive.importer.ArchiveContentMatchers.size;
import static org.junit.Assert.assertThat;

import java.io.File;
import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@
import org.junit.Test;

import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.jboss.shrinkwrap.resolver.impl.maven.archive.importer.ArchiveContentMatchers.contains;
import static org.jboss.shrinkwrap.resolver.impl.maven.archive.importer.ArchiveContentMatchers.size;

import static org.junit.Assert.assertThat;

/**
* JAR import test case
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

import static org.jboss.shrinkwrap.resolver.impl.maven.archive.importer.ArchiveContentMatchers.contains;
import static org.jboss.shrinkwrap.resolver.impl.maven.archive.importer.ArchiveContentMatchers.hasManifestEntry;
import static org.junit.Assert.assertThat;

import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat;

import java.io.File;
import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.jboss.shrinkwrap.resolver.impl.maven.archive.importer.ArchiveContentMatchers.contains;
import static org.jboss.shrinkwrap.resolver.impl.maven.archive.importer.ArchiveContentMatchers.size;
import static org.junit.Assert.assertThat;

import java.io.File;
import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
import org.junit.Test;

import static org.hamcrest.CoreMatchers.hasItems;

import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;

/**
* Test Compiler Plugin configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
import java.io.File;

import org.eclipse.aether.artifact.DefaultArtifact;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.contrib.java.lang.system.RestoreSystemProperties;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.jboss.shrinkwrap.resolver.impl.maven.aether.ClasspathWorkspaceReader.FLATTENED_POM_PATH_KEY;
import static org.jboss.shrinkwrap.resolver.impl.maven.aether.ClasspathWorkspaceReader.SUREFIRE_CLASS_PATH_KEY;

Expand All @@ -51,7 +51,7 @@ public void classpathWithDanglingDirs() throws Exception {

// this should not fail
File file = reader.findArtifact(new DefaultArtifact("foo:bar:1"));
Assert.assertThat(file, is(nullValue()));
assertThat(file, is(nullValue()));
}

// create a classpath that contain entries that does not have parent directories
Expand Down Expand Up @@ -121,6 +121,6 @@ private void testFindArtifactReturnsNotNull(String testDirName) {
ClasspathWorkspaceReader reader = new ClasspathWorkspaceReader();

File file = reader.findArtifact(new DefaultArtifact("org.jboss.shrinkwrap.test:" + testDirName + "-child:1.0.0"));
Assert.assertThat(file, is(notNullValue()));
assertThat(file, is(notNullValue()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;

import java.io.File;
import java.lang.reflect.InvocationTargetException;
Expand Down Expand Up @@ -52,9 +53,9 @@ public void loadDefaultUserSettingsXmlLocation() {
Assume.assumeThat(System.getProperty("user.home"), is(not(nullValue())));

SettingsBuildingRequest request = createBuildingRequest();
Assert.assertThat(request.getUserSettingsFile(), is(not(nullValue())));
assertThat(request.getUserSettingsFile(), is(not(nullValue())));

Assert.assertThat(removeDoubledSeparator(request.getUserSettingsFile().getPath()),
assertThat(removeDoubledSeparator(request.getUserSettingsFile().getPath()),
is(removeDoubledSeparator(System.getProperty("user.home") + "/.m2/settings.xml".replace('/', File.separatorChar))));
}

Expand All @@ -65,9 +66,9 @@ public void loadDefaultGlobalSettingsXmlLocation() {
Assume.assumeThat(System.getenv("M2_HOME"), is(not(nullValue())));

SettingsBuildingRequest request = createBuildingRequest();
Assert.assertThat(request.getGlobalSettingsFile(), is(not(nullValue())));
assertThat(request.getGlobalSettingsFile(), is(not(nullValue())));

Assert.assertThat(removeDoubledSeparator(request.getGlobalSettingsFile().getPath()),
assertThat(removeDoubledSeparator(request.getGlobalSettingsFile().getPath()),
is(removeDoubledSeparator(System.getenv("M2_HOME") + "/conf/settings.xml".replaceAll("//", "/").replace('/', File.separatorChar))));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.jboss.shrinkwrap.resolver.impl.maven.integration;

import static org.hamcrest.CoreMatchers.hasItem;
import static org.hamcrest.MatcherAssert.assertThat;

import java.util.List;

Expand All @@ -9,7 +10,6 @@
import org.jboss.shrinkwrap.resolver.api.maven.coordinate.MavenCoordinates;
import org.jboss.shrinkwrap.resolver.impl.maven.bootstrap.MavenSettingsBuilder;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;

Expand Down Expand Up @@ -45,7 +45,7 @@ public void asMavenCoordinates() {
final List<MavenCoordinate> coordinates = Maven.resolver().resolve(artifactCanonicalFormA)
.withTransitivity().asList(MavenCoordinate.class);

Assert.assertThat(coordinates,
assertThat(coordinates,
hasItem(MavenCoordinates.createCoordinate("org.jboss.shrinkwrap.test:test-deps-b:jar:1.0.0")));
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.jboss.shrinkwrap.resolver.impl.maven.integration;

import static org.hamcrest.CoreMatchers.hasItem;
import static org.hamcrest.MatcherAssert.assertThat;

import java.io.File;
import java.net.URL;
Expand All @@ -9,7 +10,6 @@
import org.jboss.shrinkwrap.resolver.api.maven.Maven;
import org.jboss.shrinkwrap.resolver.impl.maven.bootstrap.MavenSettingsBuilder;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;

Expand Down Expand Up @@ -48,6 +48,6 @@ public void asURLs() throws Exception {
System.getProperty(MavenSettingsBuilder.ALT_LOCAL_REPOSITORY_LOCATION),
"org/jboss/shrinkwrap/test/test-deps-i/1.0.0/test-deps-i-1.0.0.jar").toURI().toURL();

Assert.assertThat(coordinates, hasItem(target));
assertThat(coordinates, hasItem(target));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
import org.jboss.shrinkwrap.resolver.impl.maven.bootstrap.MavenSettingsBuilder;
import org.jboss.shrinkwrap.resolver.impl.maven.util.ValidationUtil;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;

/**
* Various tests for EJB packaging
Expand Down Expand Up @@ -57,10 +57,10 @@ public void resolveEjbFromCentral() {
.withoutTransitivity()
.asSingleResolvedArtifact();

Assert.assertThat(ejb, not(nullValue()));
Assert.assertThat(ejb.asFile(), not(nullValue()));
Assert.assertThat(ejb.getExtension(), is("jar"));
Assert.assertThat(ejb.getCoordinate().getPackaging(), is(PackagingType.EJB));
assertThat(ejb, not(nullValue()));
assertThat(ejb.asFile(), not(nullValue()));
assertThat(ejb.getExtension(), is("jar"));
assertThat(ejb.getCoordinate().getPackaging(), is(PackagingType.EJB));
}

// SHRINKRES-182
Expand All @@ -71,10 +71,10 @@ public void resolveEjbFromLocalRepository() {
.withoutTransitivity()
.asSingleResolvedArtifact();

Assert.assertThat(ejb, not(nullValue()));
Assert.assertThat(ejb.asFile(), not(nullValue()));
Assert.assertThat(ejb.getExtension(), is("jar"));
Assert.assertThat(ejb.getCoordinate().getPackaging(), is(PackagingType.EJB));
assertThat(ejb, not(nullValue()));
assertThat(ejb.asFile(), not(nullValue()));
assertThat(ejb.getExtension(), is("jar"));
assertThat(ejb.getCoordinate().getPackaging(), is(PackagingType.EJB));
}

// SHRINKRES-182
Expand All @@ -85,10 +85,10 @@ public void resolveEjbFromPom() {
.importCompileAndRuntimeDependencies()
.resolve().withTransitivity().asSingleResolvedArtifact();

Assert.assertThat(ejb, not(nullValue()));
Assert.assertThat(ejb.asFile(), not(nullValue()));
Assert.assertThat(ejb.getExtension(), is("jar"));
Assert.assertThat(ejb.getCoordinate().getPackaging(), is(PackagingType.EJB));
assertThat(ejb, not(nullValue()));
assertThat(ejb.asFile(), not(nullValue()));
assertThat(ejb.getExtension(), is("jar"));
assertThat(ejb.getCoordinate().getPackaging(), is(PackagingType.EJB));
new ValidationUtil("test-ejb").validate(ejb.asFile());

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import static org.hamcrest.CoreMatchers.hasItem;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;

import java.io.File;
import java.util.Properties;
Expand Down Expand Up @@ -176,8 +177,8 @@ public void testSystemPropertyOverrideFromProfile() {

Properties props = session.getParsedPomFile().getProperties();

Assert.assertThat(props.keySet(), hasItem("myproperty"));
Assert.assertThat(props.getProperty("myproperty"), is("hello"));
assertThat(props.keySet(), hasItem("myproperty"));
assertThat(props.getProperty("myproperty"), is("hello"));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import org.junit.Assert;
import org.junit.Test;

import static org.hamcrest.MatcherAssert.assertThat;

/**
* This is a reproducer for SHRINKRES-232 - Resolve from pom.xml: old version is picked
*
Expand All @@ -26,7 +28,7 @@ public void testVersionOfAOP() {
boolean found = false;
for (File file : libs){
if (file.getName().startsWith("spring-aop")) {
Assert.assertThat(file.getName(), CoreMatchers.containsString("4.2.1.RELEASE"));
assertThat(file.getName(), CoreMatchers.containsString("4.2.1.RELEASE"));
found = true;
break;
}
Expand Down

0 comments on commit 292b460

Please sign in to comment.