| 1 |
/* |
| 2 |
Licensed to the Apache Software Foundation (ASF) under one |
| 3 |
or more contributor license agreements. See the NOTICE file |
| 4 |
distributed with this work for additional information |
| 5 |
regarding copyright ownership. The ASF licenses this file |
| 6 |
to you under the Apache License, Version 2.0 (the |
| 7 |
"License"); you may not use this file except in compliance |
| 8 |
with the License. You may obtain a copy of the License at |
| 9 |
|
| 10 |
http://www.apache.org/licenses/LICENSE-2.0 |
| 11 |
|
| 12 |
Unless required by applicable law or agreed to in writing, |
| 13 |
software distributed under the License is distributed on an |
| 14 |
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 |
KIND, either express or implied. See the License for the |
| 16 |
specific language governing permissions and limitations |
| 17 |
under the License. |
| 18 |
*/ |
| 19 |
|
| 20 |
// Test that link settings are propagated correctly |
| 21 |
package electron |
| 22 |
|
| 23 |
import ( |
| 24 |
"net" |
| 25 |
"testing" |
| 26 |
"time" |
| 27 |
|
| 28 |
"github.com/apache/qpid-proton/go/pkg/amqp" |
| 29 |
"github.com/apache/qpid-proton/go/pkg/internal/test" |
| 30 |
"github.com/apache/qpid-proton/go/pkg/proton" |
| 31 |
) |
| 32 |
|
| 33 |
func TestLinkSettings(t *testing.T) { |
| 34 |
cConn, sConn := net.Pipe() |
| 35 |
done := make(chan error) |
| 36 |
settings := TerminusSettings{Durability: 1, Expiry: 2, Timeout: 42 * time.Second, Dynamic: true} |
| 37 |
filterMap := map[amqp.Symbol]interface{}{"int": int32(33), "str": "hello"} |
| 38 |
go func() { // Server |
| 39 |
close(done) |
| 40 |
defer sConn.Close() |
| 41 |
c, err := NewConnection(sConn, Server()) |
| 42 |
test.FatalIf(t, err) |
| 43 |
for in := range c.Incoming() { |
| 44 |
ep := in.Accept() |
| 45 |
switch ep := ep.(type) { |
| 46 |
case Receiver: |
| 47 |
test.ErrorIf(t, test.Differ("one.source", ep.Source())) |
| 48 |
test.ErrorIf(t, test.Differ(TerminusSettings{}, ep.SourceSettings())) |
| 49 |
test.ErrorIf(t, test.Differ("one.target", ep.Target())) |
| 50 |
test.ErrorIf(t, test.Differ(settings, ep.TargetSettings())) |
| 51 |
case Sender: |
| 52 |
test.ErrorIf(t, test.Differ("two", ep.LinkName())) |
| 53 |
test.ErrorIf(t, test.Differ("two.source", ep.Source())) |
| 54 |
test.ErrorIf(t, test.Differ(TerminusSettings{Durability: proton.Deliveries, Expiry: proton.ExpireNever}, ep.SourceSettings())) |
| 55 |
test.ErrorIf(t, test.Differ(filterMap, ep.Filter())) |
| 56 |
} |
| 57 |
} |
| 58 |
}() |
| 59 |
|
| 60 |
// Client |
| 61 |
c, err := NewConnection(cConn) |
| 62 |
test.FatalIf(t, err) |
| 63 |
c.Sender(Source("one.source"), Target("one.target"), TargetSettings(settings)) |
| 64 |
|
| 65 |
c.Receiver(Source("two.source"), DurableSubscription("two"), Filter(filterMap)) |
| 66 |
c.Close(nil) |
| 67 |
<-done |
| 68 |
} |