Issue #23507 admin-util uses junit5 instead of junit4
diff --git a/nucleus/admin/util/pom.xml b/nucleus/admin/util/pom.xml
index ad578e5..fd96b1d 100755
--- a/nucleus/admin/util/pom.xml
+++ b/nucleus/admin/util/pom.xml
@@ -123,15 +123,19 @@
</dependency>
<dependency>
- <groupId>org.glassfish.main.tests</groupId>
- <artifactId>utils</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.glassfish.main.tests</groupId>
+ <artifactId>utils</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
diff --git a/nucleus/admin/util/src/test/java/com/sun/enterprise/admin/progress/CommandProgressImplTest.java b/nucleus/admin/util/src/test/java/com/sun/enterprise/admin/progress/CommandProgressImplTest.java
index a520037..4a8c3c6 100644
--- a/nucleus/admin/util/src/test/java/com/sun/enterprise/admin/progress/CommandProgressImplTest.java
+++ b/nucleus/admin/util/src/test/java/com/sun/enterprise/admin/progress/CommandProgressImplTest.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -19,37 +20,25 @@
import org.glassfish.api.admin.ProgressStatus;
import org.glassfish.api.admin.progress.ProgressStatusImpl;
import org.glassfish.api.admin.progress.ProgressStatusMirroringImpl;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
- *
* @author mmares
*/
public class CommandProgressImplTest {
- public CommandProgressImplTest() {
- }
-
-// @BeforeClass
-// public static void setUpClass() throws Exception {
-// }
-//
-// @AfterClass
-// public static void tearDownClass() throws Exception {
-// }
-
-
@Test
public void testCreateMirroringChild() {
CommandProgressImpl cp = new CommandProgressImpl("first", "a");
cp.setTotalStepCount(2);
- ProgressStatusMirroringImpl ch1 = cp.createMirroringChild(1);
+ final ProgressStatusMirroringImpl ch1 = cp.createMirroringChild(1);
assertNotNull(ch1);
- ProgressStatus ch2 = cp.createChild(1);
+ final ProgressStatus ch2 = cp.createChild(1);
assertNotNull(ch1);
- assertTrue(ch2 instanceof ProgressStatusImpl);
+ assertThat(ch2, instanceOf(ProgressStatusImpl.class));
}
-
}
diff --git a/nucleus/admin/util/src/test/java/com/sun/enterprise/admin/remote/reader/.gitkeep_empty_dir b/nucleus/admin/util/src/test/java/com/sun/enterprise/admin/remote/reader/.gitkeep_empty_dir
deleted file mode 100644
index e69de29..0000000
--- a/nucleus/admin/util/src/test/java/com/sun/enterprise/admin/remote/reader/.gitkeep_empty_dir
+++ /dev/null
diff --git a/nucleus/admin/util/src/test/java/com/sun/enterprise/admin/util/CachedCommandModelTest.java b/nucleus/admin/util/src/test/java/com/sun/enterprise/admin/util/CachedCommandModelTest.java
index 8be9319..e78a6c5 100644
--- a/nucleus/admin/util/src/test/java/com/sun/enterprise/admin/util/CachedCommandModelTest.java
+++ b/nucleus/admin/util/src/test/java/com/sun/enterprise/admin/util/CachedCommandModelTest.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -16,23 +17,23 @@
package com.sun.enterprise.admin.util;
-import jakarta.xml.bind.DatatypeConverter;
-import org.junit.Test;
-import static org.junit.Assert.*;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
- *
* @author mmares
*/
public class CachedCommandModelTest {
- public CachedCommandModelTest() {
- }
-
public static CachedCommandModel createBeateles() {
CachedCommandModel result = new CachedCommandModel("TheBeatles");
result.dashOk = true;
- CommandModelData.ParamModelData prm = new CommandModelData.ParamModelData("Lennon", String.class, false, "John Winston Ono Lennon", "J", false, null);
+ CommandModelData.ParamModelData prm = new CommandModelData.ParamModelData("Lennon", String.class, false,
+ "John Winston Ono Lennon", "J", false, null);
prm.param._primary = true;
prm.param._multiple = true;
result.add(prm);
@@ -51,9 +52,9 @@
assertEquals(beatles1.getETag(), beatles2.getETag());
CachedCommandModel beatles3 = createBeateles();
beatles3.add(new CommandModelData.ParamModelData("Sutcliffe", String.class, true, "R.I.P.", null, true, "Stuart"));
- assertFalse(beatles1.getETag().equals(beatles3.getETag()));
+ assertNotEquals(beatles1.getETag(), beatles3.getETag());
CachedCommandModel beatles4 = createBeateles();
beatles4.dashOk = false;
- assertFalse(beatles1.getETag().equals(beatles4.getETag()));
+ assertNotEquals(beatles1.getETag(), beatles4.getETag());
}
}
diff --git a/nucleus/admin/util/src/test/java/com/sun/enterprise/admin/util/cache/AdminCacheFileStoreTest.java b/nucleus/admin/util/src/test/java/com/sun/enterprise/admin/util/cache/AdminCacheFileStoreTest.java
index edd9b64..c29af60 100644
--- a/nucleus/admin/util/src/test/java/com/sun/enterprise/admin/util/cache/AdminCacheFileStoreTest.java
+++ b/nucleus/admin/util/src/test/java/com/sun/enterprise/admin/util/cache/AdminCacheFileStoreTest.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -17,7 +18,6 @@
package com.sun.enterprise.admin.util.cache;
/**
- *
* @author mmares
*/
public class AdminCacheFileStoreTest extends AdminCacheTstBase {
@@ -25,5 +25,4 @@
public AdminCacheFileStoreTest() {
super(AdminCacheFileStore.getInstance());
}
-
}
diff --git a/nucleus/admin/util/src/test/java/com/sun/enterprise/admin/util/cache/AdminCacheMemStoreTest.java b/nucleus/admin/util/src/test/java/com/sun/enterprise/admin/util/cache/AdminCacheMemStoreTest.java
index f131bed..04df5d4 100644
--- a/nucleus/admin/util/src/test/java/com/sun/enterprise/admin/util/cache/AdminCacheMemStoreTest.java
+++ b/nucleus/admin/util/src/test/java/com/sun/enterprise/admin/util/cache/AdminCacheMemStoreTest.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -17,7 +18,6 @@
package com.sun.enterprise.admin.util.cache;
/**
- *
* @author mmares
*/
public class AdminCacheMemStoreTest extends AdminCacheTstBase {
@@ -25,5 +25,4 @@
public AdminCacheMemStoreTest() {
super(AdminCacheMemStore.getInstance());
}
-
}
diff --git a/nucleus/admin/util/src/test/java/com/sun/enterprise/admin/util/cache/AdminCacheTstBase.java b/nucleus/admin/util/src/test/java/com/sun/enterprise/admin/util/cache/AdminCacheTstBase.java
index edadf22..d88e3eb 100644
--- a/nucleus/admin/util/src/test/java/com/sun/enterprise/admin/util/cache/AdminCacheTstBase.java
+++ b/nucleus/admin/util/src/test/java/com/sun/enterprise/admin/util/cache/AdminCacheTstBase.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -17,16 +18,23 @@
package com.sun.enterprise.admin.util.cache;
import com.sun.enterprise.security.store.AsadminSecurityUtil;
+
import java.io.File;
import java.io.FileOutputStream;
import java.util.Date;
-import org.glassfish.tests.utils.Utils;
-import org.junit.AfterClass;
-import static org.junit.Assert.*;
-import org.junit.BeforeClass;
-import org.junit.Test;
-/** General test for AdminCache implementations which has file system
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
+/**
+ * General test for AdminCache implementations which has file system
* on background
*
* @author mmares
@@ -34,94 +42,43 @@
public abstract class AdminCacheTstBase {
public static final String TEST_CACHE_COTEXT = "junit-test-temp/";
- private static boolean skipThisTest = false;
- private AdminCache cache;
+ private final AdminCache cache;
- public AdminCacheTstBase(AdminCache cache) {
+ public AdminCacheTstBase(final AdminCache cache) {
this.cache = cache;
}
- @BeforeClass
+ @BeforeAll
public static void setUpClass() throws Exception {
- //Clean up temp directory
- File dir = AsadminSecurityUtil.getDefaultClientDir();
- dir = new File(dir, TEST_CACHE_COTEXT);
- try {
- recursiveDelete(dir);
- if (dir.exists()) {
- skipThisTest = true;
- System.out.println("JUNIT: AdminCache tests: Can not do this test, because can not purify " + dir.getPath() + " directory.");
- } else {
- //Test to create and write data
- if (!dir.mkdirs()) {
- skipThisTest = true;
- System.out.println("JUNIT: AdminCache tests: Can not do this test. Can not create " + dir.getPath() + " directory.");
- return;
- }
- File f = new File(dir, "qeen.junit");
- FileOutputStream fos = null;
- try {
- fos = new FileOutputStream(f);
- fos.write("Another One Bites the Dust".getBytes());
- } finally {
- try {
- fos.close();
- } catch (Exception ex) {
- }
- }
- if (!f.exists()) {
- skipThisTest = true;
- System.out.println("JUNIT: AdminCache tests: Can not do this test. Can not write to files in " + dir.getPath() + " directory.");
- }
- recursiveDelete(dir);
- }
- } catch (Exception ex) {
- skipThisTest = true;
- System.out.println("JUNIT: AdminCache tests: Can not do this test. Can not write to files in " + dir.getPath() + " directory.");
+ // Clean up temp directory
+ final File dir = new File(AsadminSecurityUtil.getDefaultClientDir(), TEST_CACHE_COTEXT);
+ recursiveDelete(dir);
+ // Test to create and write data
+ if (!dir.mkdirs()) {
+ fail("AdminCache tests: Can not do this test. Can not create " + dir.getPath() + " directory.");
+ return;
}
- }
-
- @AfterClass
- public static void tearDownClass() throws Exception {
- File dir = AsadminSecurityUtil.getDefaultClientDir();
- dir = new File(dir, TEST_CACHE_COTEXT);
+ final File f = new File(dir, "qeen.junit");
+ try (FileOutputStream fos = new FileOutputStream(f)) {
+ fos.write("Another One Bites the Dust".getBytes());
+ }
+ if (!f.exists()) {
+ fail("AdminCache tests: Can not do this test. Can not write to files in " + dir.getPath() + " directory.");
+ }
recursiveDelete(dir);
}
- public static void recursiveDelete(File f) {
- if (f == null || !f.exists()) {
- return;
- }
- if (".".equals(f.getName()) || "..".equals(f.getName())) {
- return;
- }
- if (f.isDirectory()) {
- File[] subFiles = f.listFiles();
- for (File subFile : subFiles) {
- recursiveDelete(subFile);
- }
- }
- f.delete();
+ @AfterAll
+ public static void tearDownClass() throws Exception {
+ recursiveDelete(new File(AsadminSecurityUtil.getDefaultClientDir(), TEST_CACHE_COTEXT));
}
- protected static boolean isSkipThisTest() {
- return skipThisTest;
- }
-
- public AdminCache getCache() {
- return cache;
- }
@Test
public void testPutGet() {
- if (isSkipThisTest()) {
- System.out.println(this.getClass().getName() + ".testPutGet(): Must skip this unit test, because something is wrong with file cache writing during build");
- } else {
- System.out.println(this.getClass().getName() + ".testPutGet()");
- }
- //1
- String qeen1 = "Crazy Little Thing Called Love";
- String qeen1Key = TEST_CACHE_COTEXT + "Qeen1";
+ // 1
+ final String qeen1 = "Crazy Little Thing Called Love";
+ final String qeen1Key = TEST_CACHE_COTEXT + "Qeen1";
cache.put(qeen1Key, qeen1);
File f = new File(AsadminSecurityUtil.getDefaultClientDir(), qeen1Key);
assertTrue(f.exists());
@@ -129,9 +86,10 @@
String str = cache.get(qeen1Key, String.class);
assertNotNull(str);
assertEquals(qeen1, str);
- //2
- String qeen2 = "You\'re My Best Friend";
- String qeen2Key = TEST_CACHE_COTEXT + "A-Night-at-the-Opera/Qeen2";
+
+ // 2
+ final String qeen2 = "You\'re My Best Friend";
+ final String qeen2Key = TEST_CACHE_COTEXT + "A-Night-at-the-Opera/Qeen2";
cache.put(qeen2Key, qeen2);
f = new File(AsadminSecurityUtil.getDefaultClientDir(), qeen2Key);
assertTrue(f.exists());
@@ -139,48 +97,67 @@
str = cache.get(qeen2Key, String.class);
assertNotNull(str);
assertEquals(qeen2, str);
- //1 - re read
+
+ // 1 - re read
str = cache.get(qeen1Key, String.class);
assertNotNull(str);
assertEquals(qeen1, str);
- //2 - update
- String qeen2b = "Bohemian Rhapsody";
+
+ // 2 - update
+ final String qeen2b = "Bohemian Rhapsody";
cache.put(qeen2Key, qeen2b);
str = cache.get(qeen2Key, String.class);
assertNotNull(str);
assertEquals(qeen2b, str);
- //Done
- System.out.println(this.getClass().getName() + ".testPutGet(): Done");
}
+
@Test
public void testExistence() throws InterruptedException {
- if (isSkipThisTest()) {
- System.out.println(this.getClass().getName() + ".testExistence(): Must skip this unit test, because something is wrong with file cache writing during build");
- } else {
- System.out.println(this.getClass().getName() + ".testExistence()");
- }
- //1
- String stones1 = "Paint it black";
- String stones1Key = TEST_CACHE_COTEXT + "Rolling.Stones.1";
+ // 1
+ final String stones1 = "Paint it black";
+ final String stones1Key = TEST_CACHE_COTEXT + "Rolling.Stones.1";
cache.put(stones1Key, stones1);
- //2
- String stones2 = "Jumpin\' Jack Flash";
- String stones2Key = TEST_CACHE_COTEXT + "Rolling.Stones.2";
+
+ // 2
+ final String stones2 = "Jumpin\' Jack Flash";
+ final String stones2Key = TEST_CACHE_COTEXT + "Rolling.Stones.2";
cache.put(stones2Key, stones2);
- //contains
+
+ // contains
assertTrue(cache.contains(stones1Key));
assertTrue(cache.contains(stones2Key));
- assertFalse(cache.contains(stones1Key+"ooops"));
- //lastUpdated
- Date lastUpdated1 = cache.lastUpdated(stones1Key);
+ assertFalse(cache.contains(stones1Key + "ooops"));
+
+ // lastUpdated
+ final Date lastUpdated1 = cache.lastUpdated(stones1Key);
assertNotNull(lastUpdated1);
- Thread.sleep(2000L);
- String stones1b = "Good times, bad times";
+ Thread.sleep(50L);
+ final String stones1b = "Good times, bad times";
cache.put(stones1Key, stones1b);
- Date lastUpdated2 = cache.lastUpdated(stones1Key);
+ final Date lastUpdated2 = cache.lastUpdated(stones1Key);
assertNotNull(lastUpdated2);
assertTrue(lastUpdated1.getTime() < lastUpdated2.getTime());
- System.out.println(this.getClass().getName() + ".testExistence()");
+ }
+
+
+ protected static void recursiveDelete(final File f) {
+ if (f == null || !f.exists()) {
+ return;
+ }
+ if (".".equals(f.getName()) || "..".equals(f.getName())) {
+ return;
+ }
+ if (f.isDirectory()) {
+ final File[] subFiles = f.listFiles();
+ for (final File subFile : subFiles) {
+ recursiveDelete(subFile);
+ }
+ }
+ f.delete();
+ }
+
+ protected AdminCache getCache() {
+ return cache;
}
}
diff --git a/nucleus/admin/util/src/test/java/com/sun/enterprise/admin/util/cache/AdminCacheUtilsTest.java b/nucleus/admin/util/src/test/java/com/sun/enterprise/admin/util/cache/AdminCacheUtilsTest.java
index 6fd4f4f..60a06d2 100644
--- a/nucleus/admin/util/src/test/java/com/sun/enterprise/admin/util/cache/AdminCacheUtilsTest.java
+++ b/nucleus/admin/util/src/test/java/com/sun/enterprise/admin/util/cache/AdminCacheUtilsTest.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -18,67 +19,56 @@
import com.sun.enterprise.admin.util.CachedCommandModel;
import com.sun.enterprise.admin.util.CachedCommandModelTest;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
+
import org.glassfish.api.admin.CommandModel;
-import static org.junit.Assert.*;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
- *
* @author mmares
*/
public class AdminCacheUtilsTest {
- private AdminCacheUtils acu = AdminCacheUtils.getInstance();
-
- public AdminCacheUtilsTest() {
- }
-
-// @BeforeClass
-// public static void setUpClass() throws Exception {
-// }
-
-// @AfterClass
-// public static void tearDownClass() throws Exception {
-// }
+ private final AdminCacheUtils acu = AdminCacheUtils.getInstance();
@Test
- public void testSimpleGetProvider() throws IOException {
- DataProvider provider;
- byte[] data;
- //String
- Object o = "The Man Who Sold The World";
- assertNotNull(provider = acu.getProvider(o.getClass()));
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- provider.writeToStream(o, baos);
- assertNotNull(data = baos.toByteArray());
- assertTrue(o.equals(provider.toInstance(new ByteArrayInputStream(data),
- o.getClass())));
- //byte array
- o = "The Man Who Sold The World".getBytes();
- assertNotNull(provider = acu.getProvider(o.getClass()));
- baos = new ByteArrayOutputStream();
- provider.writeToStream(o, baos);
- assertNotNull(data = baos.toByteArray());
- assertArrayEquals((byte[]) o, data);
- assertArrayEquals((byte[]) o, (byte[]) provider.toInstance(
- new ByteArrayInputStream(data), byte[].class));
+ public void testSimpleGetProvider_String() throws IOException {
+ final String string = "The Man Who Sold The World";
+ final DataProvider provider = acu.getProvider(string.getClass());
+ assertNotNull(provider);
+ final byte[] data = toByteArray(string, provider);
+ assertNotNull(data);
+ assertEquals(string, toInstance(data, String.class, provider));
+ }
+
+ @Test
+ public void testSimpleGetProvider_byteArray() throws IOException {
+ final byte[] byteArray = "The Man Who Sold The World".getBytes();
+ final DataProvider provider = acu.getProvider(byteArray.getClass());
+ assertNotNull(provider);
+ final byte[] data = toByteArray(byteArray, provider);
+ assertNotNull(data);
+ assertArrayEquals(byteArray, data);
+ assertArrayEquals(byteArray, toInstance(data, byte[].class, provider));
}
@Test
public void testGetProvider4CommandModel() throws Exception {
- DataProvider provider;
- byte[] data;
- assertNotNull(provider = acu.getProvider(CommandModel.class));
- CachedCommandModel beatles1 = CachedCommandModelTest.createBeateles();
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- provider.writeToStream(beatles1, baos);
- assertNotNull(data = baos.toByteArray());
- System.out.println("BTW: " + new String(data, "UTF-8"));
- CachedCommandModel beatles2 = (CachedCommandModel) provider.toInstance(
- new ByteArrayInputStream(data), CachedCommandModel.class);
+ final DataProvider provider = acu.getProvider(CommandModel.class);
+ assertNotNull(provider);
+ final CachedCommandModel beatles1 = CachedCommandModelTest.createBeateles();
+ final byte[] data = toByteArray(beatles1, provider);
+ assertNotNull(data);
+ final CachedCommandModel beatles2 = toInstance(data, CachedCommandModel.class, provider);
beatles2.setETag(null);
assertEquals(beatles1.getETag(), CachedCommandModel.computeETag(beatles2));
}
@@ -96,4 +86,17 @@
assertTrue(acu.validateKey("kurt.cobain/smells.like.teen.spirit/"));
}
+
+ private byte[] toByteArray(final Object object, final DataProvider provider) throws IOException {
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ provider.writeToStream(object, baos);
+ return baos.toByteArray();
+ }
+
+
+ @SuppressWarnings("unchecked") // yeah, we know that
+ private <T> T toInstance(final byte[] data, final Class<T> targetClass, final DataProvider provider)
+ throws IOException {
+ return (T) provider.toInstance(new ByteArrayInputStream(data), targetClass);
+ }
}
diff --git a/nucleus/admin/util/src/test/java/com/sun/enterprise/admin/util/cache/AdminCacheWeakReferenceTest.java b/nucleus/admin/util/src/test/java/com/sun/enterprise/admin/util/cache/AdminCacheWeakReferenceTest.java
index eff2e91..ae62352 100644
--- a/nucleus/admin/util/src/test/java/com/sun/enterprise/admin/util/cache/AdminCacheWeakReferenceTest.java
+++ b/nucleus/admin/util/src/test/java/com/sun/enterprise/admin/util/cache/AdminCacheWeakReferenceTest.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -17,12 +18,14 @@
package com.sun.enterprise.admin.util.cache;
import com.sun.enterprise.security.store.AsadminSecurityUtil;
+
import java.io.File;
-import static org.junit.Assert.assertEquals;
-import org.junit.Test;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
- *
* @author mmares
*/
public class AdminCacheWeakReferenceTest extends AdminCacheTstBase {
@@ -33,19 +36,12 @@
@Test
public void testWithFileDelete() {
- if (isSkipThisTest()) {
- System.out.println(this.getClass().getName() + ".testWithFileDelete(): Must skip this unit test, because something is wrong with file cache writing during build");
- } else {
- System.out.println(this.getClass().getName() + ".testWithFileDelete()");
- }
- String floyd1 = "Wish You Were Here";
- String floyd1Key = TEST_CACHE_COTEXT + "Pink.Floyd.1";
+ final String floyd1 = "Wish You Were Here";
+ final String floyd1Key = TEST_CACHE_COTEXT + "Pink.Floyd.1";
getCache().put(floyd1Key, floyd1);
- String holder = getCache().get(floyd1Key, String.class); //To be shure that it stay in memory
+ final String holder = getCache().get(floyd1Key, String.class); // to be sure that it stay in memory
assertEquals(floyd1, holder);
recursiveDelete(new File(AsadminSecurityUtil.getDefaultClientDir(), TEST_CACHE_COTEXT));
assertEquals(floyd1, getCache().get(floyd1Key, String.class));
- System.out.println(this.getClass().getName() + ".testWithFileDelete(): Done");
}
-
}