Skip to content

Commit 29fca14

Browse files
authored
YARN-11864. [JDK17] Remove Usage of org.hamcrest in Unit Tests. (#7987)
1 parent 01c9d4b commit 29fca14

File tree

9 files changed

+37
-52
lines changed

9 files changed

+37
-52
lines changed

hadoop-project/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2002,11 +2002,6 @@
20022002
<artifactId>snakeyaml</artifactId>
20032003
<version>${snakeyaml.version}</version>
20042004
</dependency>
2005-
<dependency>
2006-
<groupId>org.hamcrest</groupId>
2007-
<artifactId>hamcrest-library</artifactId>
2008-
<version>1.3</version>
2009-
</dependency>
20102005
<dependency>
20112006
<groupId>org.assertj</groupId>
20122007
<artifactId>assertj-core</artifactId>

hadoop-tools/hadoop-aws/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -573,11 +573,6 @@
573573
<artifactId>hadoop-minikdc</artifactId>
574574
<scope>test</scope>
575575
</dependency>
576-
<dependency>
577-
<groupId>org.hamcrest</groupId>
578-
<artifactId>hamcrest-library</artifactId>
579-
<scope>test</scope>
580-
</dependency>
581576
<!-- Used to create SSL certs for a secure Keystore -->
582577
<dependency>
583578
<groupId>org.bouncycastle</groupId>

hadoop-tools/hadoop-azure/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -339,11 +339,6 @@
339339
<artifactId>assertj-core</artifactId>
340340
<scope>test</scope>
341341
</dependency>
342-
<dependency>
343-
<groupId>org.hamcrest</groupId>
344-
<artifactId>hamcrest-library</artifactId>
345-
<scope>test</scope>
346-
</dependency>
347342
<dependency>
348343
<groupId>org.junit.jupiter</groupId>
349344
<artifactId>junit-jupiter-api</artifactId>

hadoop-tools/hadoop-distcp/pom.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,6 @@
109109
<artifactId>assertj-core</artifactId>
110110
<scope>test</scope>
111111
</dependency>
112-
<dependency>
113-
<groupId>org.hamcrest</groupId>
114-
<artifactId>hamcrest-library</artifactId>
115-
<version>1.3</version>
116-
<scope>test</scope>
117-
</dependency>
118112
<dependency>
119113
<groupId>org.junit.jupiter</groupId>
120114
<artifactId>junit-jupiter-api</artifactId>

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-catalog/hadoop-yarn-applications-catalog-webapp/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@
8181
<artifactId>junit-platform-launcher</artifactId>
8282
<scope>test</scope>
8383
</dependency>
84+
<dependency>
85+
<groupId>org.assertj</groupId>
86+
<artifactId>assertj-core</artifactId>
87+
<scope>test</scope>
88+
</dependency>
8489

8590
<dependency>
8691
<groupId>org.apache.solr</groupId>

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-catalog/hadoop-yarn-applications-catalog-webapp/src/test/java/org/apache/hadoop/yarn/appcatalog/controller/AppDetailsControllerTest.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@
2222
import org.apache.hadoop.yarn.appcatalog.model.AppEntry;
2323
import org.apache.hadoop.yarn.service.api.records.Component;
2424
import org.apache.hadoop.yarn.service.api.records.Container;
25+
2526
import org.junit.jupiter.api.BeforeEach;
2627
import org.junit.jupiter.api.Test;
2728
import org.mockito.Mockito;
2829

2930
import javax.ws.rs.Path;
3031
import javax.ws.rs.core.Response;
3132

32-
import static org.hamcrest.MatcherAssert.assertThat;
33-
import static org.hamcrest.core.Is.is;
33+
import static org.assertj.core.api.Assertions.assertThat;
3434
import static org.junit.jupiter.api.Assertions.assertEquals;
3535
import static org.junit.jupiter.api.Assertions.assertNotNull;
3636
import static org.mockito.Mockito.when;
@@ -126,14 +126,15 @@ void testRestartApp() throws Exception {
126126
void testPathAnnotation() throws Exception {
127127
assertNotNull(this.controller.getClass()
128128
.getAnnotations());
129-
assertThat("The controller has the annotation Path",
130-
this.controller.getClass()
131-
.isAnnotationPresent(Path.class));
132-
133-
final Path path = this.controller.getClass()
134-
.getAnnotation(Path.class);
135-
assertThat("The path is /app_details", path.value(),
136-
is("/app_details"));
129+
130+
assertThat(this.controller.getClass().isAnnotationPresent(Path.class))
131+
.as("The controller has the annotation Path")
132+
.isTrue();
133+
134+
final Path path = this.controller.getClass().getAnnotation(Path.class);
135+
assertThat(path.value())
136+
.as("The path is /app_details")
137+
.isEqualTo("/app_details");
137138
}
138139

139140
@Test

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-catalog/hadoop-yarn-applications-catalog-webapp/src/test/java/org/apache/hadoop/yarn/appcatalog/controller/AppListControllerTest.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@
2727
import javax.ws.rs.Path;
2828
import javax.ws.rs.core.Response;
2929

30-
import static org.hamcrest.MatcherAssert.assertThat;
31-
import static org.hamcrest.core.Is.is;
30+
import static org.assertj.core.api.Assertions.assertThat;
3231
import static org.junit.jupiter.api.Assertions.assertEquals;
3332
import static org.junit.jupiter.api.Assertions.assertNotNull;
3433
import static org.mockito.Mockito.when;
@@ -85,12 +84,15 @@ void testDeploy() throws Exception {
8584
void testPathAnnotation() throws Exception {
8685
assertNotNull(this.controller.getClass()
8786
.getAnnotations());
88-
assertThat("The controller has the annotation Path",
89-
this.controller.getClass().isAnnotationPresent(Path.class));
9087

91-
final Path path = this.controller.getClass()
92-
.getAnnotation(Path.class);
93-
assertThat("The path is /app_list", path.value(), is("/app_list"));
88+
assertThat(this.controller.getClass().isAnnotationPresent(Path.class))
89+
.as("The controller has the annotation Path")
90+
.isTrue();
91+
92+
final Path path = this.controller.getClass().getAnnotation(Path.class);
93+
assertThat(path.value())
94+
.as("The path is /app_list")
95+
.isEqualTo("/app_list");
9496
}
9597

9698
}

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-catalog/hadoop-yarn-applications-catalog-webapp/src/test/java/org/apache/hadoop/yarn/appcatalog/controller/AppStoreControllerTest.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@
2727
import javax.ws.rs.Path;
2828
import javax.ws.rs.core.Response;
2929

30-
import static org.hamcrest.MatcherAssert.assertThat;
31-
import static org.hamcrest.core.Is.is;
30+
import static org.assertj.core.api.Assertions.assertThat;
3231
import static org.junit.jupiter.api.Assertions.assertEquals;
3332
import static org.junit.jupiter.api.Assertions.assertNotNull;
3433
import static org.mockito.Mockito.when;
@@ -86,13 +85,14 @@ void testRegister() throws Exception {
8685
void testPathAnnotation() throws Exception {
8786
assertNotNull(this.controller.getClass()
8887
.getAnnotations());
89-
assertThat("The controller has the annotation Path",
90-
this.controller.getClass()
91-
.isAnnotationPresent(Path.class));
9288

93-
final Path path = this.controller.getClass()
94-
.getAnnotation(Path.class);
95-
assertThat("The path is /app_store", path.value(), is("/app_store"));
96-
}
89+
assertThat(this.controller.getClass().isAnnotationPresent(Path.class))
90+
.as("The controller has the annotation Path")
91+
.isTrue();
9792

93+
final Path path = this.controller.getClass().getAnnotation(Path.class);
94+
assertThat(path.value())
95+
.as("The path is /app_store")
96+
.isEqualTo("/app_store");
97+
}
9898
}

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestResourceCalculatorProcessTree.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@
2121

2222
import org.apache.hadoop.conf.Configuration;
2323

24-
import static org.hamcrest.MatcherAssert.assertThat;
25-
import static org.hamcrest.core.IsInstanceOf.instanceOf;
26-
import static org.hamcrest.core.IsSame.sameInstance;
24+
import static org.assertj.core.api.Assertions.assertThat;
2725
import static org.junit.jupiter.api.Assertions.assertNotNull;
2826

2927
/**
@@ -80,7 +78,7 @@ void testCreateInstance() {
8078
ResourceCalculatorProcessTree tree;
8179
tree = ResourceCalculatorProcessTree.getResourceCalculatorProcessTree("1", EmptyProcessTree.class, new Configuration());
8280
assertNotNull(tree);
83-
assertThat(tree, instanceOf(EmptyProcessTree.class));
81+
assertThat(tree).isInstanceOf(EmptyProcessTree.class);
8482
}
8583

8684
@Test
@@ -89,6 +87,6 @@ void testCreatedInstanceConfigured() {
8987
Configuration conf = new Configuration();
9088
tree = ResourceCalculatorProcessTree.getResourceCalculatorProcessTree("1", EmptyProcessTree.class, conf);
9189
assertNotNull(tree);
92-
assertThat(tree.getConf(), sameInstance(conf));
90+
assertThat(tree).isInstanceOf(EmptyProcessTree.class);
9391
}
9492
}

0 commit comments

Comments
 (0)