Skip to content

Commit

Permalink
migrate from junit 4 to junit 5
Browse files Browse the repository at this point in the history
  • Loading branch information
sullis committed Jul 2, 2024
1 parent 8708a4a commit b84a144
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 14 deletions.
22 changes: 19 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,32 @@
<url>https://github.com/webjars/webjars-locator-lite/actions</url>
</ciManagement>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.10.3</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.jspecify</groupId>
<artifactId>jspecify</artifactId>
<version>0.3.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<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>

Expand Down
22 changes: 11 additions & 11 deletions src/test/java/org/webjars/WebJarVersionLocatorTest.java
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
package org.webjars;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;

import org.jspecify.annotations.NullMarked;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;

public class WebJarVersionLocatorTest {
class WebJarVersionLocatorTest {

@Test
public void invalid_webjar_path_should_return_null() {
void invalid_webjar_path_should_return_null() {
assertNull(new WebJarVersionLocator().version("foo"));
}

@Test
public void should_get_a_webjar_version() {
void should_get_a_webjar_version() {
assertEquals("3.1.1", new WebJarVersionLocator().version("bootswatch-yeti"));
}

@Test
public void webjar_version_doesnt_match_path() {
void webjar_version_doesnt_match_path() {
assertEquals("3.1.1", new WebJarVersionLocator().version("bootstrap"));
}

@Test
public void full_path_exists_version_not_supplied() {
void full_path_exists_version_not_supplied() {
assertEquals(WebJarVersionLocator.WEBJARS_PATH_PREFIX + "/bootstrap/3.1.1/js/bootstrap.js", new WebJarVersionLocator().fullPath("bootstrap", "js/bootstrap.js"));
}

@Test
public void path_exists_version_not_supplied() {
void path_exists_version_not_supplied() {
assertEquals("bootstrap/3.1.1/js/bootstrap.js", new WebJarVersionLocator().path("bootstrap", "js/bootstrap.js"));
}

@Test
public void full_path_exists_version_supplied() {
void full_path_exists_version_supplied() {
assertEquals(WebJarVersionLocator.WEBJARS_PATH_PREFIX + "/bootstrap/3.1.1/js/bootstrap.js", new WebJarVersionLocator().fullPath("bootstrap", "3.1.1/js/bootstrap.js"));
}

@Test
public void cache_is_populated_on_lookup() {
void cache_is_populated_on_lookup() {
AtomicInteger numLookups = new AtomicInteger(0);

@NullMarked
Expand Down

0 comments on commit b84a144

Please sign in to comment.