event test

This commit is contained in:
geek 2017-04-28 11:11:37 +09:00
parent d5815eb71a
commit fffeb2ff41
2 changed files with 10 additions and 6 deletions

View File

@ -40,6 +40,7 @@ func (es *EventSender) Start() {
func (es *EventSender) Stop() {
if es.sc != nil {
close(es.sc)
es.sc = nil
}
}
@ -59,7 +60,7 @@ func (es *EventSender) checkQueue() {
collectedData := tempCollectedData.Value.(*Data)
collectedData.AgentId = agentIdentifier()
result = append(result, collectedData)
log.Println("Result Len: ", len(result))
//log.Println("Result Len: ", len(result))
}
es.send(result)
result = nil

View File

@ -6,6 +6,7 @@ import (
"log"
"testing"
"time"
"strconv"
)
func TestEventSender_Start(t *testing.T) {
@ -14,23 +15,25 @@ func TestEventSender_Start(t *testing.T) {
es.Start()
testNotify()
time.Sleep(time.Second * 100)
time.Sleep(time.Second * 1000)
}
func testNotify() {
//time.Sleep(time.Second * 5)
for i := 0; i < 20; i ++{
result := make(map[string]string)
result["ab"] = "123"
result["cd"] = "456"
result["ef"] = "789"
result["ab"] = "123 ( " + strconv.Itoa(i) + ")"
result["cd"] = "456 ( "+ strconv.Itoa(i) + ")"
result["ef"] = "789 ( "+ strconv.Itoa(i) + ")"
cd := &Data{
SensorId: "insanity",
Data: result,
}
log.Println("New data Notify")
observer.Notify(messages.QUEUE_EVENT, cd)
}
log.Println("New data Notify")
}