11const { By, Key, until, Builder } = require ( 'selenium-webdriver' )
22require ( 'chromedriver' )
33const assert = require ( 'assert' )
4+ const { open : openAmqp , once : onceAmqp , on : onAmqp , close : closeAmqp } = require ( '../../amqp' )
45const { buildDriver, goToHome, captureScreensFor, teardown, delay } = require ( '../../utils' )
56
67const LoginPage = require ( '../../pageobjects/LoginPage' )
78const OverviewPage = require ( '../../pageobjects/OverviewPage' )
89const ConnectionsPage = require ( '../../pageobjects/ConnectionsPage' )
910const ConnectionPage = require ( '../../pageobjects/ConnectionPage' )
1011
11- var container = require ( 'rhea' ) // https://github.com/amqp/rhea
1212var receivedAmqpMessageCount = 0
1313var untilConnectionEstablished = new Promise ( ( resolve , reject ) => {
14- container . on ( 'connection_open' , function ( context ) {
14+ onAmqp ( 'connection_open' , function ( context ) {
1515 resolve ( )
1616 } )
1717} )
1818
19- container . on ( 'message' , function ( context ) {
19+ onAmqp ( 'message' , function ( context ) {
2020 receivedAmqpMessageCount ++
2121} )
22- container . once ( 'sendable' , function ( context ) {
22+ onceAmqp ( 'sendable' , function ( context ) {
2323 context . sender . send ( { body :'first message' } )
2424} )
2525
@@ -28,7 +28,7 @@ describe('Given an amqp10 connection opened, listed and clicked on it', function
2828 let captureScreen
2929 let connectionsPage
3030 let connectionPage
31- let connection
31+ let amqp
3232
3333 before ( async function ( ) {
3434 driver = buildDriver ( )
@@ -41,24 +41,8 @@ describe('Given an amqp10 connection opened, listed and clicked on it', function
4141 await login . login ( 'monitoring-only' , 'guest' )
4242 await overview . isLoaded ( )
4343
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 ( )
6246 await untilConnectionEstablished
6347 await overview . clickOnConnectionsTab ( )
6448 await connectionsPage . isLoaded ( )
@@ -108,11 +92,11 @@ describe('Given an amqp10 connection opened, listed and clicked on it', function
10892
10993 it ( 'display live link information' , async function ( ) {
11094 var untilMessageReceived = new Promise ( ( resolve , reject ) => {
111- container . on ( 'message' , function ( context ) {
95+ onAmqp ( 'message' , function ( context ) {
11296 resolve ( )
11397 } )
11498 } )
115- sender . send ( { body :'second message' } )
99+ amqp . sender . send ( { body :'second message' } )
116100 await untilMessageReceived
117101 assert . equal ( 2 , receivedAmqpMessageCount )
118102
@@ -121,17 +105,13 @@ describe('Given an amqp10 connection opened, listed and clicked on it', function
121105 let incomingLink = connectionPage . getIncomingLinkInfo ( sessions . incoming_links , 0 )
122106 assert . equal ( 2 , incomingLink . deliveryCount )
123107
124- //console.log("incomingLink: " + JSON.stringify(incomingLink))
125- //console.log("outgoingLink: " + JSON.stringify(outgoingLink))
126108 } )
127109
128110
129111 after ( async function ( ) {
130112 await teardown ( driver , this , captureScreen )
131113 try {
132- if ( connection != null ) {
133- connection . close ( )
134- }
114+ closeAmqp ( amqp . connection )
135115 } catch ( error ) {
136116 console . error ( "Failed to close amqp10 connection due to " + error ) ;
137117 }
0 commit comments