Merge pull request #11584 from hkhan/JAVA-8679-fix-module-test
[JAVA-8679] Fix test for JDK 17
This commit is contained in:
commit
8693c82fc5
|
@ -2,12 +2,21 @@ package com.baeldung.java9.modules;
|
||||||
|
|
||||||
import static org.hamcrest.CoreMatchers.is;
|
import static org.hamcrest.CoreMatchers.is;
|
||||||
import static org.hamcrest.CoreMatchers.nullValue;
|
import static org.hamcrest.CoreMatchers.nullValue;
|
||||||
import static org.hamcrest.Matchers.*;
|
|
||||||
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.hasItem;
|
||||||
|
import static org.hamcrest.Matchers.hasItems;
|
||||||
import static org.hamcrest.collection.IsEmptyCollection.empty;
|
import static org.hamcrest.collection.IsEmptyCollection.empty;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import java.lang.module.ModuleDescriptor;
|
import java.lang.module.ModuleDescriptor;
|
||||||
import java.lang.module.ModuleDescriptor.*;
|
|
||||||
|
import java.lang.module.ModuleDescriptor.Builder;
|
||||||
|
import java.lang.module.ModuleDescriptor.Exports;
|
||||||
|
import java.lang.module.ModuleDescriptor.Opens;
|
||||||
|
import java.lang.module.ModuleDescriptor.Provides;
|
||||||
|
import java.lang.module.ModuleDescriptor.Requires;
|
||||||
import java.sql.Date;
|
import java.sql.Date;
|
||||||
import java.sql.Driver;
|
import java.sql.Driver;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -16,7 +25,7 @@ import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.Ignore;
|
|
||||||
|
|
||||||
public class ModuleAPIUnitTest {
|
public class ModuleAPIUnitTest {
|
||||||
|
|
||||||
|
@ -28,14 +37,9 @@ public class ModuleAPIUnitTest {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
Class<HashMap> hashMapClass = HashMap.class;
|
javaBaseModule = HashMap.class.getModule();
|
||||||
javaBaseModule = hashMapClass.getModule();
|
javaSqlModule = Date.class.getModule();
|
||||||
|
module = Person.class.getModule();
|
||||||
Class<Date> dateClass = Date.class;
|
|
||||||
javaSqlModule = dateClass.getModule();
|
|
||||||
|
|
||||||
Class<Person> personClass = Person.class;
|
|
||||||
module = personClass.getModule();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -111,7 +115,6 @@ public class ModuleAPIUnitTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore // fixing in http://team.baeldung.com/browse/JAVA-8679
|
|
||||||
public void givenModules_whenAccessingModuleDescriptorProvides_thenProvidesAreReturned() {
|
public void givenModules_whenAccessingModuleDescriptorProvides_thenProvidesAreReturned() {
|
||||||
Set<Provides> javaBaseProvides = javaBaseModule.getDescriptor().provides();
|
Set<Provides> javaBaseProvides = javaBaseModule.getDescriptor().provides();
|
||||||
Set<Provides> javaSqlProvides = javaSqlModule.getDescriptor().provides();
|
Set<Provides> javaSqlProvides = javaSqlModule.getDescriptor().provides();
|
||||||
|
@ -120,7 +123,7 @@ public class ModuleAPIUnitTest {
|
||||||
.map(Provides::service)
|
.map(Provides::service)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
assertThat(javaBaseProvidesService, contains("java.nio.file.spi.FileSystemProvider"));
|
assertThat(javaBaseProvidesService, hasItem("java.nio.file.spi.FileSystemProvider"));
|
||||||
assertThat(javaSqlProvides, empty());
|
assertThat(javaSqlProvides, empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,10 +140,9 @@ public class ModuleAPIUnitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenModules_whenAccessingModuleDescriptorUses_thenUsesAreReturned() {
|
public void givenModules_whenAccessingModuleDescriptorUses_thenUsesAreReturned() {
|
||||||
Set<String> javaBaseUses = javaBaseModule.getDescriptor().uses();
|
|
||||||
Set<String> javaSqlUses = javaSqlModule.getDescriptor().uses();
|
Set<String> javaSqlUses = javaSqlModule.getDescriptor().uses();
|
||||||
|
|
||||||
assertThat(javaSqlUses, contains("java.sql.Driver"));
|
assertThat(javaSqlUses, hasItem("java.sql.Driver"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue