comment on a partially broken unit test

This commit is contained in:
James Seibel
2026-02-14 22:34:17 -06:00
parent 0714697e05
commit 3c80c11888
2 changed files with 26 additions and 7 deletions
@@ -36,9 +36,15 @@ import java.util.concurrent.atomic.AtomicInteger;
/**
* A few very basic tests to confirm {@link DelayedDataSourceSaveCache}
* is working properly.
*
* <br><br>
* Note: enabling this test will cause issues for {@link PooledDataSourceCheckoutTest}.
* Probably due to creating additional checkouts in the global static state.
* For now this issue can be ignored since this test is diabled.
*
* @author James Seibel
* @version 2025-10-02
*
* @see PooledDataSourceCheckoutTest
*/
public class DelayedSaveCacheTest
{
@@ -51,9 +57,11 @@ public class DelayedSaveCacheTest
}
// commented out for now since it makes the normal build take longer
@Test
/**
* commented out for now since it makes the normal build take longer
* and due to breaking {@link PooledDataSourceCheckoutTest}
*/
//@Test
public void CacheExpirationAndPoolingTest() throws InterruptedException
{
// how many times any data source has been "written to disk"
@@ -111,7 +119,7 @@ public class DelayedSaveCacheTest
Assert.assertEquals("no new saves should have happened yet", 1, diskSaveCountRef.get());
// wait for the cache to clear
Thread.sleep(2_000);
Thread.sleep(4_000);
Assert.assertEquals("Cache should have automatically cleared due to inactivity", 0, cache.getUnsavedCount());
Assert.assertEquals("second save after timeout expected", 2, diskSaveCountRef.get());
@@ -26,10 +26,15 @@ import org.junit.Assert;
import org.junit.Test;
/**
* @see PhantomArrayListCheckout
*
* Note: this test will have issues if {@link DelayedSaveCacheTest} is also enabled.
* Probably due to creating additional checkouts in the global static state.
* For now this issue can be ignored.
*
* @author James Seibel
* @version 2025-10-02
*
* @see PhantomArrayListCheckout
* @see DelayedSaveCacheTest
*/
public class PooledDataSourceCheckoutTest
{
@@ -37,6 +42,11 @@ public class PooledDataSourceCheckoutTest
@Test
public void TestCheckouts()
{
// something like this should probably be called before starting the test to ensure
// we have a clean slate, otherwise other tests could clutter up the static state
// and cause the test to fail
//FullDataSourceV2.ARRAY_LIST_POOL.clear();
PhantomArrayListCheckout initialCheckout;
try (FullDataSourceV2 initialSource = FullDataSourceV2.createEmpty(DhSectionPos.encode((byte)6, 0, 0)))
{
@@ -46,6 +56,7 @@ public class PooledDataSourceCheckoutTest
try (FullDataSourceV2 outerSource = FullDataSourceV2.createEmpty(DhSectionPos.encode((byte) 6, 0, 0)))
{
PhantomArrayListCheckout outerCheckout = outerSource.getPhantomArrayCheckoutForUnitTesting();
// Note: this can fail if this test is run at the same time as other tasks (generating additional checkouts)
Assert.assertEquals("the first checkout object should be pooled", initialCheckout, outerCheckout);
try (FullDataSourceV2 innerSource = FullDataSourceV2.createEmpty(DhSectionPos.encode((byte) 6, 0, 0)))