Skip to content

Commit

Permalink
[SHIBUI-660]
Browse files Browse the repository at this point in the history
Added simple test to check for index writer hashmap usage.
Scope appears to be as intended!
  • Loading branch information
Bill Smith committed Aug 22, 2018
1 parent d8e2830 commit b9259cf
Showing 1 changed file with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package edu.internet2.tier.shibboleth.admin.ui.service

import edu.internet2.tier.shibboleth.admin.ui.configuration.CoreShibUiConfiguration
import edu.internet2.tier.shibboleth.admin.ui.configuration.InternationalizationConfiguration
import edu.internet2.tier.shibboleth.admin.ui.configuration.SearchConfiguration
import edu.internet2.tier.shibboleth.admin.ui.configuration.TestConfiguration
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.autoconfigure.domain.EntityScan
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest
import org.springframework.data.jpa.repository.config.EnableJpaRepositories
import org.springframework.test.context.ContextConfiguration
import spock.lang.Specification

/**
* @author Bill Smith (wsmith@unicon.net)
*/
@DataJpaTest
@ContextConfiguration(classes=[CoreShibUiConfiguration, SearchConfiguration, TestConfiguration, InternationalizationConfiguration])
@EnableJpaRepositories(basePackages = ["edu.internet2.tier.shibboleth.admin.ui"])
@EntityScan("edu.internet2.tier.shibboleth.admin.ui")
class IndexWriterServiceTests extends Specification {

@Autowired
IndexWriterService service

def "retrieving index writer for the same resource id multiple times results in the same index writer being returned"() {
given:
def resourceId = "12345"

when:
def firstIndexWriter = service.getIndexWriter(resourceId) // causes new index writer to be created and added to map
def secondIndexWriter = service.getIndexWriter(resourceId) // retrieves the same index writer from above

then:
firstIndexWriter == secondIndexWriter
}
}

0 comments on commit b9259cf

Please sign in to comment.