-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Feature/#728
- Loading branch information
Showing
7 changed files
with
166 additions
and
4 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
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,43 @@ | ||
<config xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' | ||
xmlns='http://www.ehcache.org/v3' | ||
xmlns:jsr107='http://www.ehcache.org/v3/jsr107'> | ||
|
||
<persistence directory="/data/profile-hub/ehcache"/> | ||
|
||
<cache alias="userDetailsCache"> | ||
<expiry> | ||
<ttl unit="days">1</ttl> | ||
</expiry> | ||
<resources> | ||
<heap unit="entries">2000</heap> | ||
</resources> | ||
</cache> | ||
|
||
<cache alias="userDetailsByIdCache"> | ||
<expiry> | ||
<ttl unit="days">1</ttl> | ||
</expiry> | ||
<resources> | ||
<heap unit="entries">2000</heap> | ||
</resources> | ||
</cache> | ||
|
||
<cache alias="userListCache"> | ||
<expiry> | ||
<ttl unit="days">1</ttl> | ||
</expiry> | ||
<resources> | ||
<heap unit="entries">2000</heap> | ||
</resources> | ||
</cache> | ||
|
||
<cache alias="vocabListCache"> | ||
<expiry> | ||
<ttl unit="days">1</ttl> | ||
</expiry> | ||
<resources> | ||
<heap unit="entries">20000</heap> | ||
</resources> | ||
</cache> | ||
|
||
</config> |
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
49 changes: 49 additions & 0 deletions
49
src/test/groovy/au/org/ala/profile/hub/AdminControllerSpec.groovy
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,49 @@ | ||
package au.org.ala.profile.hub | ||
|
||
import grails.testing.web.controllers.ControllerUnitTest | ||
import org.apache.http.HttpStatus | ||
import org.grails.plugin.cache.GrailsCacheManager | ||
import org.springframework.cache.Cache | ||
import spock.lang.Specification | ||
|
||
class AdminControllerSpec extends Specification implements ControllerUnitTest<AdminController> { | ||
|
||
def setup() { | ||
controller.grailsCacheManager = Mock(GrailsCacheManager) | ||
} | ||
|
||
def "cache management should display to the admin controller when admin mode"() { | ||
when: | ||
controller.grailsCacheManager.getCacheNames() >> ["Cache1","Cache2"] | ||
controller.cacheManagement() | ||
|
||
then: | ||
def cacheNames = '["Cache1","Cache2"]' | ||
|
||
assert response.getContentAsString() == cacheNames | ||
} | ||
|
||
def "clearCache() should return a 200 (OK_REQUEST) if id has been provided"() { | ||
when: | ||
params.id = "userDetailsCache" | ||
|
||
Cache cache = Mock(Cache.class); | ||
controller.grailsCacheManager.getCache(params.id) >> cache | ||
controller.clearCache() | ||
|
||
then: | ||
response.status == HttpStatus.SC_OK | ||
def successMessage = '{"resp":"Successfully cleared cache - userDetailsCache","statusCode":200}' | ||
assert response.getContentAsString() == successMessage | ||
} | ||
|
||
def "clearCache() should return a 400 (BAD_REQUEST) if id has not been provided"() { | ||
when: | ||
params.id = "" | ||
controller.clearCache() | ||
|
||
then: | ||
response.status != HttpStatus.SC_OK | ||
assert response.errorMessage == "Failed to clear cache the job" | ||
} | ||
} |