Skip to content

Commit

Permalink
Re-enable send() and sendHeartbeat() specs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Asgeir Nilsen committed Dec 20, 2018
1 parent 244a2b1 commit 693beac
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions src/test/groovy/no/fint/provider/events/sse/SseServiceSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package no.fint.provider.events.sse
import no.fint.event.model.Event
import no.fint.provider.events.ProviderProps
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter
import spock.lang.Ignore
import spock.lang.Specification

import java.util.concurrent.ConcurrentHashMap
Expand Down Expand Up @@ -61,8 +60,7 @@ class SseServiceSpec extends Specification {
noExceptionThrown()
}

@Ignore('No longer valid')
def "Remove registered emitter on exception when trying to send message"() {
def "Handle exception when trying to send message"() {
given:
def emitter = Mock(FintSseEmitter)
def emitters = FintSseEmitters.with(5)
Expand All @@ -74,8 +72,7 @@ class SseServiceSpec extends Specification {
sseService.send(new Event(orgId: 'hfk.no'))

then:
1 * emitter.send(_ as SseEmitter.SseEventBuilder) >> { throw new IllegalStateException('Test exception') }
1 * emitter.complete()
1 * emitter.send(_ as SseEmitter.SseEventBuilder) >> { throw new IOException('Test exception') }
}

def "Remove all registered SSE clients"() {
Expand Down Expand Up @@ -106,8 +103,7 @@ class SseServiceSpec extends Specification {
1 * emitter.complete()
}

@Ignore('No longer valid')
def "Run heartbeat and remove failing emitter"() {
def "Run heartbeat"() {
given:
def emitter = Mock(FintSseEmitter) {
getId() >> 'fake'
Expand All @@ -116,13 +112,12 @@ class SseServiceSpec extends Specification {
emitters.add(emitter)
def clients = ['hfk.no': emitters] as ConcurrentHashMap
sseService = new SseService(providerProps: props, clients: clients)
def heartbeat = new Heartbeat(sseService: sseService)

when:
sseService.sendHeartbeat()
heartbeat.sendHeartbeat()

then:
1 * emitter.send(_ as SseEmitter.SseEventBuilder) >> { throw new IllegalStateException('Test exception') }
1 * emitter.complete()

1 * emitter.send(_ as SseEmitter.SseEventBuilder) >> { throw new IOException('Test exception') }
}
}

0 comments on commit 693beac

Please sign in to comment.