YARN-11336. Upgrade Junit 4 to 5 in hadoop-yarn-applications-catalog-webapp (#4992)
Co-authored-by: Ashutosh Gupta <ashugpt@amazon.com> Signed-off-by: Akira Ajisaka <aajisaka@apache.org>
This commit is contained in:
parent
454157a384
commit
21b7790866
@ -40,11 +40,6 @@
|
|||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
|
||||||
<groupId>junit</groupId>
|
|
||||||
<artifactId>junit</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.swagger</groupId>
|
<groupId>io.swagger</groupId>
|
||||||
<artifactId>swagger-annotations</artifactId>
|
<artifactId>swagger-annotations</artifactId>
|
||||||
@ -60,6 +55,12 @@
|
|||||||
<artifactId>powermock-module-junit4</artifactId>
|
<artifactId>powermock-module-junit4</artifactId>
|
||||||
<version>${powermock.version}</version>
|
<version>${powermock.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.powermock</groupId>
|
<groupId>org.powermock</groupId>
|
||||||
@ -90,6 +91,21 @@
|
|||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.junit.jupiter</groupId>
|
||||||
|
<artifactId>junit-jupiter-api</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.junit.jupiter</groupId>
|
||||||
|
<artifactId>junit-jupiter-engine</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.junit.platform</groupId>
|
||||||
|
<artifactId>junit-platform-launcher</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.pjfanning</groupId>
|
<groupId>com.github.pjfanning</groupId>
|
||||||
|
@ -22,14 +22,15 @@
|
|||||||
import org.apache.hadoop.yarn.appcatalog.model.AppStoreEntry;
|
import org.apache.hadoop.yarn.appcatalog.model.AppStoreEntry;
|
||||||
import org.apache.hadoop.yarn.appcatalog.model.Application;
|
import org.apache.hadoop.yarn.appcatalog.model.Application;
|
||||||
import org.apache.solr.client.solrj.SolrClient;
|
import org.apache.solr.client.solrj.SolrClient;
|
||||||
import org.junit.After;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.powermock.api.mockito.PowerMockito;
|
import org.powermock.api.mockito.PowerMockito;
|
||||||
import static org.powermock.api.mockito.PowerMockito.when;
|
import static org.powermock.api.mockito.PowerMockito.when;
|
||||||
import static org.powermock.api.support.membermodification.MemberMatcher.method;
|
import static org.powermock.api.support.membermodification.MemberMatcher.method;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -42,7 +43,7 @@ public class TestAppCatalogSolrClient {
|
|||||||
private static SolrClient solrClient;
|
private static SolrClient solrClient;
|
||||||
private static AppCatalogSolrClient spy;
|
private static AppCatalogSolrClient spy;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setup() throws Exception {
|
public void setup() throws Exception {
|
||||||
String targetLocation = EmbeddedSolrServerFactory.class
|
String targetLocation = EmbeddedSolrServerFactory.class
|
||||||
.getProtectionDomain().getCodeSource().getLocation().getFile() + "/..";
|
.getProtectionDomain().getCodeSource().getLocation().getFile() + "/..";
|
||||||
@ -55,7 +56,7 @@ public void setup() throws Exception {
|
|||||||
.withNoArguments().thenReturn(solrClient);
|
.withNoArguments().thenReturn(solrClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@AfterEach
|
||||||
public void teardown() throws Exception {
|
public void teardown() throws Exception {
|
||||||
try {
|
try {
|
||||||
solrClient.close();
|
solrClient.close();
|
||||||
@ -64,7 +65,7 @@ public void teardown() throws Exception {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRegister() throws Exception {
|
void testRegister() throws Exception {
|
||||||
Application example = new Application();
|
Application example = new Application();
|
||||||
example.setOrganization("jenkins-ci.org");
|
example.setOrganization("jenkins-ci.org");
|
||||||
example.setName("jenkins");
|
example.setName("jenkins");
|
||||||
@ -76,7 +77,7 @@ public void testRegister() throws Exception {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSearch() throws Exception {
|
void testSearch() throws Exception {
|
||||||
Application example = new Application();
|
Application example = new Application();
|
||||||
example.setOrganization("jenkins-ci.org");
|
example.setOrganization("jenkins-ci.org");
|
||||||
example.setName("jenkins");
|
example.setName("jenkins");
|
||||||
@ -90,7 +91,7 @@ public void testSearch() throws Exception {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNotFoundSearch() throws Exception {
|
void testNotFoundSearch() throws Exception {
|
||||||
Application example = new Application();
|
Application example = new Application();
|
||||||
example.setOrganization("jenkins-ci.org");
|
example.setOrganization("jenkins-ci.org");
|
||||||
example.setName("jenkins");
|
example.setName("jenkins");
|
||||||
@ -104,7 +105,7 @@ public void testNotFoundSearch() throws Exception {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetRecommendedApps() throws Exception {
|
void testGetRecommendedApps() throws Exception {
|
||||||
AppStoreEntry example = new AppStoreEntry();
|
AppStoreEntry example = new AppStoreEntry();
|
||||||
example.setOrg("jenkins-ci.org");
|
example.setOrg("jenkins-ci.org");
|
||||||
example.setName("jenkins");
|
example.setName("jenkins");
|
||||||
@ -121,15 +122,15 @@ public void testGetRecommendedApps() throws Exception {
|
|||||||
spy.register(example2);
|
spy.register(example2);
|
||||||
List<AppStoreEntry> actual = spy.getRecommendedApps();
|
List<AppStoreEntry> actual = spy.getRecommendedApps();
|
||||||
long previous = 1000L;
|
long previous = 1000L;
|
||||||
for (AppStoreEntry app: actual) {
|
for (AppStoreEntry app : actual) {
|
||||||
assertTrue("Recommend app is not sort by download count.",
|
assertTrue(previous > app.getDownload(),
|
||||||
previous > app.getDownload());
|
"Recommend app is not sort by download count.");
|
||||||
previous = app.getDownload();
|
previous = app.getDownload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpgradeApp() throws Exception {
|
void testUpgradeApp() throws Exception {
|
||||||
Application example = new Application();
|
Application example = new Application();
|
||||||
String expected = "2.0";
|
String expected = "2.0";
|
||||||
String actual = "";
|
String actual = "";
|
||||||
@ -143,7 +144,7 @@ public void testUpgradeApp() throws Exception {
|
|||||||
example.setVersion("2.0");
|
example.setVersion("2.0");
|
||||||
spy.upgradeApp(example);
|
spy.upgradeApp(example);
|
||||||
List<AppEntry> appEntries = spy.listAppEntries();
|
List<AppEntry> appEntries = spy.listAppEntries();
|
||||||
actual = appEntries.get(appEntries.size() -1).getYarnfile().getVersion();
|
actual = appEntries.get(appEntries.size() - 1).getYarnfile().getVersion();
|
||||||
assertEquals(expected, actual);
|
assertEquals(expected, actual);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,8 +22,8 @@
|
|||||||
import org.apache.hadoop.yarn.appcatalog.model.AppEntry;
|
import org.apache.hadoop.yarn.appcatalog.model.AppEntry;
|
||||||
import org.apache.hadoop.yarn.service.api.records.Component;
|
import org.apache.hadoop.yarn.service.api.records.Component;
|
||||||
import org.apache.hadoop.yarn.service.api.records.Container;
|
import org.apache.hadoop.yarn.service.api.records.Container;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
@ -31,8 +31,9 @@
|
|||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.hamcrest.core.Is.is;
|
import static org.hamcrest.core.Is.is;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.mockito.Mockito.*;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -44,14 +45,14 @@ public class AppDetailsControllerTest {
|
|||||||
|
|
||||||
private AppDetailsController controller;
|
private AppDetailsController controller;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
this.controller = new AppDetailsController();
|
this.controller = new AppDetailsController();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetDetails() throws Exception {
|
void testGetDetails() throws Exception {
|
||||||
String id = "application 1";
|
String id = "application 1";
|
||||||
AppDetailsController ac = Mockito.mock(AppDetailsController.class);
|
AppDetailsController ac = Mockito.mock(AppDetailsController.class);
|
||||||
|
|
||||||
@ -63,7 +64,7 @@ public void testGetDetails() throws Exception {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetStatus() throws Exception {
|
void testGetStatus() throws Exception {
|
||||||
String id = "application 1";
|
String id = "application 1";
|
||||||
AppDetailsController ac = Mockito.mock(AppDetailsController.class);
|
AppDetailsController ac = Mockito.mock(AppDetailsController.class);
|
||||||
|
|
||||||
@ -84,7 +85,7 @@ public void testGetStatus() throws Exception {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testStopApp() throws Exception {
|
void testStopApp() throws Exception {
|
||||||
String id = "application 1";
|
String id = "application 1";
|
||||||
AppDetailsController ac = Mockito.mock(AppDetailsController.class);
|
AppDetailsController ac = Mockito.mock(AppDetailsController.class);
|
||||||
|
|
||||||
@ -103,7 +104,7 @@ public void testStopApp() throws Exception {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRestartApp() throws Exception {
|
void testRestartApp() throws Exception {
|
||||||
String id = "application 1";
|
String id = "application 1";
|
||||||
AppDetailsController ac = Mockito.mock(AppDetailsController.class);
|
AppDetailsController ac = Mockito.mock(AppDetailsController.class);
|
||||||
|
|
||||||
@ -122,7 +123,7 @@ public void testRestartApp() throws Exception {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPathAnnotation() throws Exception {
|
void testPathAnnotation() throws Exception {
|
||||||
assertNotNull(this.controller.getClass()
|
assertNotNull(this.controller.getClass()
|
||||||
.getAnnotations());
|
.getAnnotations());
|
||||||
assertThat("The controller has the annotation Path",
|
assertThat("The controller has the annotation Path",
|
||||||
@ -136,7 +137,7 @@ public void testPathAnnotation() throws Exception {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpgradeApp() throws Exception {
|
void testUpgradeApp() throws Exception {
|
||||||
String id = "application1";
|
String id = "application1";
|
||||||
AppDetailsController ac = Mockito.mock(AppDetailsController.class);
|
AppDetailsController ac = Mockito.mock(AppDetailsController.class);
|
||||||
|
|
||||||
|
@ -20,8 +20,8 @@
|
|||||||
|
|
||||||
import org.apache.hadoop.yarn.appcatalog.model.AppEntry;
|
import org.apache.hadoop.yarn.appcatalog.model.AppEntry;
|
||||||
import org.apache.hadoop.yarn.service.api.records.Service;
|
import org.apache.hadoop.yarn.service.api.records.Service;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
@ -29,8 +29,9 @@
|
|||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.hamcrest.core.Is.is;
|
import static org.hamcrest.core.Is.is;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.mockito.Mockito.*;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -42,14 +43,14 @@ public class AppListControllerTest {
|
|||||||
|
|
||||||
private AppListController controller;
|
private AppListController controller;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
this.controller = new AppListController();
|
this.controller = new AppListController();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetList() throws Exception {
|
void testGetList() throws Exception {
|
||||||
AppListController ac = Mockito.mock(AppListController.class);
|
AppListController ac = Mockito.mock(AppListController.class);
|
||||||
|
|
||||||
List<AppEntry> actual = new ArrayList<AppEntry>();
|
List<AppEntry> actual = new ArrayList<AppEntry>();
|
||||||
@ -59,7 +60,7 @@ public void testGetList() throws Exception {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDelete() throws Exception {
|
void testDelete() throws Exception {
|
||||||
String id = "application 1";
|
String id = "application 1";
|
||||||
AppListController ac = Mockito.mock(AppListController.class);
|
AppListController ac = Mockito.mock(AppListController.class);
|
||||||
|
|
||||||
@ -70,7 +71,7 @@ public void testDelete() throws Exception {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDeploy() throws Exception {
|
void testDeploy() throws Exception {
|
||||||
String id = "application 1";
|
String id = "application 1";
|
||||||
AppListController ac = Mockito.mock(AppListController.class);
|
AppListController ac = Mockito.mock(AppListController.class);
|
||||||
Service service = new Service();
|
Service service = new Service();
|
||||||
@ -81,7 +82,7 @@ public void testDeploy() throws Exception {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPathAnnotation() throws Exception {
|
void testPathAnnotation() throws Exception {
|
||||||
assertNotNull(this.controller.getClass()
|
assertNotNull(this.controller.getClass()
|
||||||
.getAnnotations());
|
.getAnnotations());
|
||||||
assertThat("The controller has the annotation Path",
|
assertThat("The controller has the annotation Path",
|
||||||
|
@ -20,8 +20,8 @@
|
|||||||
|
|
||||||
import org.apache.hadoop.yarn.appcatalog.model.AppStoreEntry;
|
import org.apache.hadoop.yarn.appcatalog.model.AppStoreEntry;
|
||||||
import org.apache.hadoop.yarn.appcatalog.model.Application;
|
import org.apache.hadoop.yarn.appcatalog.model.Application;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
@ -29,8 +29,9 @@
|
|||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.hamcrest.core.Is.is;
|
import static org.hamcrest.core.Is.is;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.mockito.Mockito.*;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -42,14 +43,14 @@ public class AppStoreControllerTest {
|
|||||||
|
|
||||||
private AppStoreController controller;
|
private AppStoreController controller;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
this.controller = new AppStoreController();
|
this.controller = new AppStoreController();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetRecommended() throws Exception {
|
void testGetRecommended() throws Exception {
|
||||||
AppStoreController ac = Mockito.mock(AppStoreController.class);
|
AppStoreController ac = Mockito.mock(AppStoreController.class);
|
||||||
List<AppStoreEntry> actual = new ArrayList<AppStoreEntry>();
|
List<AppStoreEntry> actual = new ArrayList<AppStoreEntry>();
|
||||||
when(ac.get()).thenReturn(actual);
|
when(ac.get()).thenReturn(actual);
|
||||||
@ -58,7 +59,7 @@ public void testGetRecommended() throws Exception {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSearch() throws Exception {
|
void testSearch() throws Exception {
|
||||||
String keyword = "jenkins";
|
String keyword = "jenkins";
|
||||||
AppStoreController ac = Mockito.mock(AppStoreController.class);
|
AppStoreController ac = Mockito.mock(AppStoreController.class);
|
||||||
List<AppStoreEntry> expected = new ArrayList<AppStoreEntry>();
|
List<AppStoreEntry> expected = new ArrayList<AppStoreEntry>();
|
||||||
@ -68,7 +69,7 @@ public void testSearch() throws Exception {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRegister() throws Exception {
|
void testRegister() throws Exception {
|
||||||
AppStoreController ac = Mockito.mock(AppStoreController.class);
|
AppStoreController ac = Mockito.mock(AppStoreController.class);
|
||||||
Application app = new Application();
|
Application app = new Application();
|
||||||
app.setName("jenkins");
|
app.setName("jenkins");
|
||||||
@ -82,7 +83,7 @@ public void testRegister() throws Exception {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPathAnnotation() throws Exception {
|
void testPathAnnotation() throws Exception {
|
||||||
assertNotNull(this.controller.getClass()
|
assertNotNull(this.controller.getClass()
|
||||||
.getAnnotations());
|
.getAnnotations());
|
||||||
assertThat("The controller has the annotation Path",
|
assertThat("The controller has the annotation Path",
|
||||||
|
Loading…
Reference in New Issue
Block a user