@@ -11,6 +11,7 @@ import (
1111 "fmt"
1212 "github.com/onsi/gomega"
1313 "github.com/oracle/coherence-go-client/v2/coherence"
14+ "github.com/oracle/coherence-go-client/v2/coherence/publisher"
1415 "github.com/oracle/coherence-go-client/v2/coherence/topic"
1516 "github.com/oracle/coherence-go-client/v2/test/utils"
1617 "log"
@@ -20,26 +21,18 @@ import (
2021
2122func TestBasicTopicCreatedAndDestroy (t * testing.T ) {
2223 var (
23- g = gomega .NewWithT (t )
24- err error
25- session1 * coherence.Session
26- topic1 coherence.NamedTopic [string ]
27- ctx = context .Background ()
24+ g = gomega .NewWithT (t )
25+ err error
26+ ctx = context .Background ()
2827 )
2928
3029 const topicName = "my-topic"
3130
3231 t .Setenv ("COHERENCE_LOG_LEVEL" , "ALL" )
3332
34- session1 , err = utils .GetSession (coherence .WithRequestTimeout (300 * time .Second ))
35- g .Expect (err ).ShouldNot (gomega .HaveOccurred ())
33+ session1 , topic1 := getSessionAndTopic [string ](g , topicName )
3634 defer session1 .Close ()
3735
38- // get a NamedQueue with name "my-queue"
39- topic1 , err = coherence .GetNamedTopic [string ](ctx , session1 , topicName , topic .WithChannelCount (17 ))
40- g .Expect (err ).ShouldNot (gomega .HaveOccurred ())
41- log .Println (topic1 )
42-
4336 utils .Sleep (5 )
4437
4538 err = topic1 .Destroy (ctx )
@@ -50,26 +43,26 @@ func TestBasicTopicCreatedAndDestroy(t *testing.T) {
5043 g .Expect (err ).Should (gomega .HaveOccurred ())
5144}
5245
53- func TestBasicTopicAnonPubSub (t * testing.T ) {
46+ func TestTopicPublish (t * testing.T ) {
47+ g := gomega .NewWithT (t )
48+
49+ RunTestBasicTopicAnonPubSub (g )
50+ RunTestBasicTopicAnonPubSub (g , publisher .WithDefaultOrdering ())
51+ RunTestBasicTopicAnonPubSub (g , publisher .WithRoundRobinOrdering ())
52+ RunTestBasicTopicAnonPubSub (g , publisher .WithChannelCount (21 ))
53+ }
54+
55+ func RunTestBasicTopicAnonPubSub (g * gomega.WithT , options ... func (cache * publisher.Options )) {
5456 var (
55- g = gomega .NewWithT (t )
56- err error
57- session1 * coherence.Session
58- topic1 coherence.NamedTopic [string ]
59- ctx = context .Background ()
57+ err error
58+ ctx = context .Background ()
6059 )
6160
6261 const topicName = "my-topic-anon"
6362
64- session1 , err = utils .GetSession (coherence .WithRequestTimeout (300 * time .Second ))
65- g .Expect (err ).ShouldNot (gomega .HaveOccurred ())
63+ session1 , topic1 := getSessionAndTopic [string ](g , topicName )
6664 defer session1 .Close ()
6765
68- // get a NamedQueue with name "my-queue"
69- topic1 , err = coherence .GetNamedTopic [string ](ctx , session1 , topicName , topic .WithChannelCount (17 ))
70- g .Expect (err ).ShouldNot (gomega .HaveOccurred ())
71- log .Println (topic1 )
72-
7366 // create a subscriber first
7467 sub1 , err := topic1 .CreateSubscriber (ctx )
7568 g .Expect (err ).ShouldNot (gomega .HaveOccurred ())
@@ -183,3 +176,14 @@ func publishEntriesString(g *gomega.WithT, pub coherence.Publisher[string], coun
183176 g .Expect (status ).ShouldNot (gomega .BeNil ())
184177 }
185178}
179+
180+ func getSessionAndTopic [V any ](g * gomega.WithT , topicName string ) (* coherence.Session , coherence.NamedTopic [V ]) {
181+ session1 , err := utils .GetSession (coherence .WithRequestTimeout (300 * time .Second ))
182+ g .Expect (err ).ShouldNot (gomega .HaveOccurred ())
183+
184+ topic1 , err := coherence .GetNamedTopic [V ](context .Background (), session1 , topicName , topic .WithChannelCount (17 ))
185+ g .Expect (err ).ShouldNot (gomega .HaveOccurred ())
186+ log .Println (topic1 )
187+
188+ return session1 , topic1
189+ }
0 commit comments