1
1
const { By, Key, until, Builder } = require ( 'selenium-webdriver' )
2
2
require ( 'chromedriver' )
3
3
const assert = require ( 'assert' )
4
+ const { open : openAmqp , once : onceAmqp , on : onAmqp , close : closeAmqp } = require ( '../../amqp' )
4
5
const { buildDriver, goToHome, captureScreensFor, teardown, delay } = require ( '../../utils' )
5
6
6
7
const LoginPage = require ( '../../pageobjects/LoginPage' )
7
8
const OverviewPage = require ( '../../pageobjects/OverviewPage' )
8
9
const ConnectionsPage = require ( '../../pageobjects/ConnectionsPage' )
9
10
const ConnectionPage = require ( '../../pageobjects/ConnectionPage' )
10
11
11
- var container = require ( 'rhea' ) // https://github.com/amqp/rhea
12
12
var receivedAmqpMessageCount = 0
13
13
var untilConnectionEstablished = new Promise ( ( resolve , reject ) => {
14
- container . on ( 'connection_open' , function ( context ) {
14
+ onAmqp ( 'connection_open' , function ( context ) {
15
15
resolve ( )
16
16
} )
17
17
} )
18
18
19
- container . on ( 'message' , function ( context ) {
19
+ onAmqp ( 'message' , function ( context ) {
20
20
receivedAmqpMessageCount ++
21
21
} )
22
- container . once ( 'sendable' , function ( context ) {
22
+ onceAmqp ( 'sendable' , function ( context ) {
23
23
context . sender . send ( { body :'first message' } )
24
24
} )
25
25
@@ -28,7 +28,7 @@ describe('Given an amqp10 connection opened, listed and clicked on it', function
28
28
let captureScreen
29
29
let connectionsPage
30
30
let connectionPage
31
- let connection
31
+ let amqp
32
32
33
33
before ( async function ( ) {
34
34
driver = buildDriver ( )
@@ -41,24 +41,8 @@ describe('Given an amqp10 connection opened, listed and clicked on it', function
41
41
await login . login ( 'monitoring-only' , 'guest' )
42
42
await overview . isLoaded ( )
43
43
44
- connection = container . connect (
45
- { 'host' : process . env . RABBITMQ_HOSTNAME || 'rabbitmq' ,
46
- 'port' : process . env . RABBITMQ_AMQP_PORT || 5672 ,
47
- 'username' : process . env . RABBITMQ_AMQP_USERNAME || 'guest' ,
48
- 'password' : process . env . RABBITMQ_AMQP_PASSWORD || 'guest' ,
49
- 'id' : "selenium-connection-id" ,
50
- 'container_id' : "selenium-container-id"
51
- } )
52
- connection . open_receiver ( {
53
- source : 'examples' ,
54
- target : 'receiver-target' ,
55
- name : 'receiver-link'
56
- } )
57
- sender = connection . open_sender ( {
58
- target : 'examples' ,
59
- source : 'sender-source' ,
60
- name : 'sender-link'
61
- } )
44
+
45
+ amqp = openAmqp ( )
62
46
await untilConnectionEstablished
63
47
await overview . clickOnConnectionsTab ( )
64
48
await connectionsPage . isLoaded ( )
@@ -108,11 +92,11 @@ describe('Given an amqp10 connection opened, listed and clicked on it', function
108
92
109
93
it ( 'display live link information' , async function ( ) {
110
94
var untilMessageReceived = new Promise ( ( resolve , reject ) => {
111
- container . on ( 'message' , function ( context ) {
95
+ onAmqp ( 'message' , function ( context ) {
112
96
resolve ( )
113
97
} )
114
98
} )
115
- sender . send ( { body :'second message' } )
99
+ amqp . sender . send ( { body :'second message' } )
116
100
await untilMessageReceived
117
101
assert . equal ( 2 , receivedAmqpMessageCount )
118
102
@@ -121,17 +105,13 @@ describe('Given an amqp10 connection opened, listed and clicked on it', function
121
105
let incomingLink = connectionPage . getIncomingLinkInfo ( sessions . incoming_links , 0 )
122
106
assert . equal ( 2 , incomingLink . deliveryCount )
123
107
124
- //console.log("incomingLink: " + JSON.stringify(incomingLink))
125
- //console.log("outgoingLink: " + JSON.stringify(outgoingLink))
126
108
} )
127
109
128
110
129
111
after ( async function ( ) {
130
112
await teardown ( driver , this , captureScreen )
131
113
try {
132
- if ( connection != null ) {
133
- connection . close ( )
134
- }
114
+ closeAmqp ( amqp . connection )
135
115
} catch ( error ) {
136
116
console . error ( "Failed to close amqp10 connection due to " + error ) ;
137
117
}
0 commit comments