-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
343 additions
and
392 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#Thu May 06 13:38:17 MDT 2021 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip | ||
distributionPath=wrapper/dists | ||
zipStorePath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 0 additions & 106 deletions
106
mage/tests/src/mil/nga/giat/mage/map/cache/CacheProviderTest.java
This file was deleted.
Oops, something went wrong.
86 changes: 86 additions & 0 deletions
86
mage/tests/src/mil/nga/giat/mage/map/cache/CacheProviderTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package mil.nga.giat.mage.map.cache | ||
|
||
import io.mockk.mockk | ||
import junit.framework.TestCase | ||
import java.util.concurrent.Semaphore | ||
|
||
class CacheProviderTest : TestCase() { | ||
private lateinit var cacheProvider: CacheProvider | ||
private lateinit var testOverlay: CacheOverlay | ||
|
||
@Throws(Exception::class) | ||
public override fun setUp() { | ||
super.setUp() | ||
|
||
cacheProvider = CacheProvider( | ||
application = mockk(), | ||
layerLocalDataSource = mockk(), | ||
eventLocalDataSource = mockk(), | ||
preferences = mockk() | ||
) | ||
|
||
testOverlay = object : CacheOverlay("test", CacheOverlayType.XYZ_DIRECTORY, false) { | ||
override fun removeFromMap() {} | ||
} | ||
|
||
ourLock.drainPermits() | ||
} | ||
|
||
public override fun tearDown() {} | ||
|
||
fun testGetOverlay() { | ||
val overlay = cacheProvider.getOverlay("doesNotExist") | ||
assertNull(overlay) | ||
} | ||
|
||
@Throws(Exception::class) | ||
fun testAddCacheOverlay() { | ||
cacheProvider.addCacheOverlay(testOverlay) | ||
assertNotNull(cacheProvider.getOverlay(testOverlay.cacheName)) | ||
|
||
val foundOverlays: MutableList<CacheOverlay> = ArrayList() | ||
val listener = object : CacheProvider.OnCacheOverlayListener { | ||
override fun onCacheOverlay(cacheOverlays: List<CacheOverlay>) { | ||
foundOverlays.addAll(cacheOverlays) | ||
ourLock.release() | ||
} | ||
} | ||
cacheProvider.registerCacheOverlayListener(listener) | ||
ourLock.acquire() | ||
assertTrue(foundOverlays.size == 1) | ||
assertTrue(foundOverlays[0] === testOverlay) | ||
cacheProvider.unregisterCacheOverlayListener(listener) | ||
} | ||
|
||
@Throws(Exception::class) | ||
fun testRemoveCacheOverlay() { | ||
cacheProvider.addCacheOverlay(testOverlay) | ||
assertNotNull(cacheProvider.getOverlay(testOverlay.cacheName)) | ||
|
||
val foundOverlays: MutableList<CacheOverlay> = ArrayList() | ||
val listener = object : CacheProvider.OnCacheOverlayListener { | ||
override fun onCacheOverlay(cacheOverlays: List<CacheOverlay>) { | ||
foundOverlays.addAll(cacheOverlays) | ||
ourLock.release() | ||
} | ||
} | ||
cacheProvider.registerCacheOverlayListener(listener) | ||
ourLock.acquire() | ||
assertTrue(foundOverlays.size == 1) | ||
assertTrue(foundOverlays[0] === testOverlay) | ||
foundOverlays.clear() | ||
cacheProvider.unregisterCacheOverlayListener(listener) | ||
cacheProvider.removeCacheOverlay(testOverlay.cacheName) | ||
cacheProvider.registerCacheOverlayListener(listener) | ||
ourLock.acquire() | ||
assertTrue(foundOverlays.isEmpty()) | ||
cacheProvider.unregisterCacheOverlayListener(listener) | ||
} | ||
|
||
companion object { | ||
/** | ||
* Used to control synchronization with the callbacks | ||
*/ | ||
private val ourLock = Semaphore(1) | ||
} | ||
} |
Oops, something went wrong.