From 9d26ab21030ee0df26b0d7196396884fc4b34561 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Tue, 7 Dec 2021 15:15:21 +1300 Subject: [PATCH] Adjust tests for JDK 18-ea build --- .../profile/BasicProfileLocationTest.java | 13 +++++++--- .../org/tests/basic/TestLoadBeanCache.java | 24 ++++++++----------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/ebean-test/src/test/java/io/ebeaninternal/server/profile/BasicProfileLocationTest.java b/ebean-test/src/test/java/io/ebeaninternal/server/profile/BasicProfileLocationTest.java index 3762cd51b..7eccc8d83 100644 --- a/ebean-test/src/test/java/io/ebeaninternal/server/profile/BasicProfileLocationTest.java +++ b/ebean-test/src/test/java/io/ebeaninternal/server/profile/BasicProfileLocationTest.java @@ -12,14 +12,21 @@ public class BasicProfileLocationTest { DProfileLocation loc = new DTimedProfileLocation(12, "foo", MetricFactory.get().createTimedMetric("junk")); + String javaVersion = System.getProperty("java.version"); assertThat(loc.obtain()).isTrue(); - assertThat(loc.fullLocation()).endsWith(":12)"); - if (System.getProperty("java.version").startsWith("1.8")) { + if (javaVersion.startsWith("1.8")) { + assertThat(loc.fullLocation()).endsWith("jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method:12)"); assertThat(loc.location()).isEqualTo("sun.reflect.NativeMethodAccessorImpl.invoke0"); + assertThat(loc.label()).isEqualTo("NativeMethodAccessorImpl.invoke0"); + } else if (javaVersion.startsWith("18")){ + assertThat(loc.fullLocation()).endsWith("jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)"); + assertThat(loc.location()).isEqualTo("java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke"); + assertThat(loc.label()).isEqualTo("DirectMethodHandleAccessor.invoke"); } else { + assertThat(loc.fullLocation()).endsWith("jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method:12)"); assertThat(loc.location()).isEqualTo("java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0"); + assertThat(loc.label()).isEqualTo("NativeMethodAccessorImpl.invoke0"); } - assertThat(loc.label()).isEqualTo("NativeMethodAccessorImpl.invoke0"); } @Test diff --git a/ebean-test/src/test/java/org/tests/basic/TestLoadBeanCache.java b/ebean-test/src/test/java/org/tests/basic/TestLoadBeanCache.java index 47eb98793..a72f07264 100644 --- a/ebean-test/src/test/java/org/tests/basic/TestLoadBeanCache.java +++ b/ebean-test/src/test/java/org/tests/basic/TestLoadBeanCache.java @@ -13,13 +13,12 @@ import java.util.List; import java.util.Map; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.*; -public class TestLoadBeanCache extends BaseTestCase { +class TestLoadBeanCache extends BaseTestCase { @Test - public void testLoad() { + void testLoad() { ResetBasicData.reset(); @@ -35,32 +34,29 @@ public class TestLoadBeanCache extends BaseTestCase { // this will hit the cache Country nz = DB.find(Country.class, "NZ"); - assertTrue(loadedNz == nz); + assertSame(loadedNz, nz); } - + @Test - public void testLoadWithFindMap() { + void testLoadWithFindMap() { ResetBasicData.reset(); - + List ids = DB.find(Customer.class).findIds(); - assertEquals(ids.size(), 4); + assertThat(ids).isNotEmpty(); DB.getDefault().pluginApi().cacheManager().clearAll(); - + // hit database LoggedSql.start(); DB.find(Customer.class).where().idIn(ids).findMap(); List sql = LoggedSql.stop(); assertThat(sql).hasSize(1); - + // hit beanCache LoggedSql.start(); DB.find(Customer.class).where().idIn(ids).findMap(); sql = LoggedSql.stop(); assertThat(sql).hasSize(0); - } - - }