Skip to content

Commit

Permalink
update unit tests to use junit5
Browse files Browse the repository at this point in the history
  • Loading branch information
wildone committed Mar 9, 2021
1 parent 05f2db5 commit e183eb5
Show file tree
Hide file tree
Showing 29 changed files with 900 additions and 735 deletions.
4 changes: 2 additions & 2 deletions aemdesign-aem-author/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>design.aem</groupId>
<artifactId>aemdesign-aem-core</artifactId>
<version>2.1.118</version>
<version>2.1.196</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand All @@ -17,7 +17,7 @@
<!-- ====================================================================== -->

<artifactId>aemdesign-aem-author</artifactId>
<version>2.1.118</version>
<version>2.1.196</version>
<packaging>content-package</packaging>
<name>AEM Design - Core - AEM Author UI Updates</name>
<description>AEM.Design extensions and libraries that enhance the default authoring UI</description>
Expand Down
4 changes: 2 additions & 2 deletions aemdesign-aem-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>design.aem</groupId>
<artifactId>aemdesign-aem-core</artifactId>
<version>2.1.118</version>
<version>2.1.196</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand All @@ -17,7 +17,7 @@
<!-- ====================================================================== -->

<artifactId>aemdesign-aem-common</artifactId>
<version>2.1.118</version>
<version>2.1.196</version>
<packaging>content-package</packaging>
<name>AEM Design - Core - AEM Common</name>
<description>AEM.Design components and base templates</description>
Expand Down
4 changes: 2 additions & 2 deletions aemdesign-aem-core-deploy/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>design.aem</groupId>
<artifactId>aemdesign-aem-core</artifactId>
<version>2.1.118</version>
<version>2.1.196</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand All @@ -20,7 +20,7 @@
<packaging>content-package</packaging>
<name>AEM Design - Core - Deployment Package</name>
<description>AEM.Design deployment package for all packages</description>
<version>2.1.118</version>
<version>2.1.196</version>
<url>https://aem.design</url>

<developers>
Expand Down
162 changes: 74 additions & 88 deletions aemdesign-aem-services/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>design.aem</groupId>
<artifactId>aemdesign-aem-core</artifactId>
<version>2.1.118</version>
<version>2.1.196</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand All @@ -18,7 +18,7 @@
<!-- ====================================================================== -->

<artifactId>aemdesign-aem-services</artifactId>
<version>2.1.118</version>
<version>2.1.196</version>
<packaging>jar</packaging>
<name>AEM Design - Core - AEM Services</name>
<description>Project for all AEM and OSGI Services</description>
Expand Down Expand Up @@ -261,6 +261,13 @@ com.github.jaiimageio.*
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.bnd.models</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
</plugin>

<plugin>
Expand Down Expand Up @@ -331,6 +338,19 @@ com.github.jaiimageio.*
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.5</version>
</plugin>

<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.2</version>
</plugin>
</plugins>
</build>

Expand Down Expand Up @@ -574,24 +594,58 @@ com.github.jaiimageio.*
<artifactId>org.apache.sling.commons.johnzon</artifactId>
</dependency>


<!-- Testing -->

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.7.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.7.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit-addons</groupId>
<artifactId>junit-addons</artifactId>
<version>1.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>3.8.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.bnd.models</artifactId>
<version>1.0.0</version>
<scope>test</scope>
</dependency>

<!-- Testing dependencies -->
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.api</artifactId>
<version>2.11.0</version>
<scope>test</scope>
</dependency>

<!-- for testing we need the new ResourceTypeBasedResourcePicker -->
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.models.impl</artifactId>
<version>1.4.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.wcm</groupId>
<artifactId>io.wcm.testing.aem-mock.junit4</artifactId>
<artifactId>io.wcm.testing.aem-mock.junit5</artifactId>
<version>2.4.4</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.apache.sling</groupId>
Expand All @@ -601,7 +655,8 @@ com.github.jaiimageio.*
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.testing.sling-mock.junit4</artifactId>
<artifactId>org.apache.sling.testing.sling-mock.junit5</artifactId>
<scope>test</scope>
<exclusions>
<!-- Exclude the older version of the API and use the one from the uber-jar -->
<exclusion>
Expand All @@ -610,63 +665,26 @@ com.github.jaiimageio.*
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.servlet-helpers</artifactId>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.i18n</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-imaging</artifactId>
<version>1.0-R1534292</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>30.0-jre</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-core</artifactId>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.18.2-GA</version>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.testing.caconfig-mock-plugin</artifactId>
<version>1.3.2</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<groupId>org.apache.commons</groupId>
<artifactId>commons-imaging</artifactId>
<version>1.0-alpha2</version>
<scope>test</scope>
</dependency>

<!-- AEM JAR -->
<dependency>
<groupId>com.adobe.aem</groupId>
<artifactId>uber-jar</artifactId>
Expand Down Expand Up @@ -730,28 +748,7 @@ com.github.jaiimageio.*
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit-addons</groupId>
<artifactId>junit-addons</artifactId>
<version>1.4</version>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>xercesImpl</artifactId>
<groupId>xerces</groupId>
</exclusion>
<exclusion>
<artifactId>xmlParserAPIs</artifactId>
<groupId>xerces</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jmockit</groupId>
<artifactId>jmockit</artifactId>
<version>1.18</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.jcr.api</artifactId>
Expand Down Expand Up @@ -803,23 +800,12 @@ com.github.jaiimageio.*
<version>3.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.3.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.adobe.cq</groupId>
<artifactId>core.wcm.components.core</artifactId>
<scope>provided</scope>
<version>2.5.0</version>
<version>2.15.0</version>
</dependency>
<dependency>
<groupId>com.adobe.cq</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,41 @@
package design.aem;

import design.aem.utils.components.I18nUtilTest;
import org.junit.Before;
import org.junit.Test;
import design.aem.context.CoreComponentTestContext;
import org.apache.sling.testing.mock.sling.servlet.MockSlingHttpServletRequest;
import org.apache.sling.testing.mock.sling.servlet.MockSlingHttpServletResponse;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.MockitoAnnotations.openMocks;


public class CustomSearchResultTest {

private static final Logger LOGGER = LoggerFactory.getLogger(CustomSearchResultTest.class);

private CustomSearchResult customSearchResultUnderTest;

final String path = "path";
final String excerpt = "excerpt";
final String title = "title";
final String subtitle = "subtitle";
final String detailspath = "/content";
final String thumbnalurl = "/content/thumbnailurl";
final String pathurl = "/content/pathurl";
final static String path = "path";
final static String excerpt = "excerpt";
final static String title = "title";
final static String subtitle = "subtitle";
final static String detailspath = "/content";
final static String thumbnalurl = "/content/thumbnailurl";
final static String pathurl = "/content/pathurl";


private AutoCloseable closeable;

@BeforeEach
void setup() {
closeable = openMocks(this);

@Before
public void setUp() {
customSearchResultUnderTest = new CustomSearchResult(path);
customSearchResultUnderTest.setIsPage(true);
customSearchResultUnderTest.setIsAsset(true);
Expand All @@ -37,18 +48,23 @@ public void setUp() {
customSearchResultUnderTest.setPath(path);
}

@AfterEach
void close() throws Exception {
closeable.close();
}

@Test
public void testClass() {
void testClass() {
// Run the test
assertTrue(customSearchResultUnderTest.getIsPage());
assertTrue(customSearchResultUnderTest.getIsAsset());
assertEquals(customSearchResultUnderTest.getExcerpt(),excerpt);
assertEquals(customSearchResultUnderTest.getTitle(),title);
assertEquals(customSearchResultUnderTest.getSubTitle(),subtitle);
assertEquals(customSearchResultUnderTest.getDetailsPath(),detailspath);
assertEquals(customSearchResultUnderTest.getThumbnailUrl(),thumbnalurl);
assertEquals(customSearchResultUnderTest.getPathUrl(),pathurl);
assertEquals(customSearchResultUnderTest.getPath(),path);
assertEquals(customSearchResultUnderTest.getExcerpt(), excerpt);
assertEquals(customSearchResultUnderTest.getTitle(), title);
assertEquals(customSearchResultUnderTest.getSubTitle(), subtitle);
assertEquals(customSearchResultUnderTest.getDetailsPath(), detailspath);
assertEquals(customSearchResultUnderTest.getThumbnailUrl(), thumbnalurl);
assertEquals(customSearchResultUnderTest.getPathUrl(), pathurl);
assertEquals(customSearchResultUnderTest.getPath(), path);
}

}
Loading

0 comments on commit e183eb5

Please sign in to comment.