@@ -121,14 +121,19 @@ public void setUpDistributor() throws MalformedURLException {
121
121
122
122
stereotype = new ImmutableCapabilities ("browserName" , "gouda" );
123
123
124
- wait = new FluentWait <>(new Object ()).ignoring (Throwable .class ).withTimeout (Duration .ofSeconds (2 ));
124
+ wait = new FluentWait <>(
125
+ new Object ()).ignoring (Throwable .class ).withTimeout (Duration .ofSeconds (2 ));
125
126
}
126
127
127
128
@ Test
128
129
public void shouldBeAbleToRegisterALocalNode () throws URISyntaxException {
129
130
URI sessionUri = new URI ("http://example:1234" );
130
- Node node = LocalNode .builder (tracer , bus , externalUrl .toURI (), externalUrl .toURI (), registrationSecret )
131
- .add (CAPS , new TestSessionFactory ((id , caps ) -> new Session (id , sessionUri , stereotype , caps , Instant .now ())))
131
+ Node node = LocalNode
132
+ .builder (tracer , bus , externalUrl .toURI (), externalUrl .toURI (), registrationSecret )
133
+ .add (
134
+ CAPS ,
135
+ new TestSessionFactory (
136
+ (id , caps ) -> new Session (id , sessionUri , stereotype , caps , Instant .now ())))
132
137
.build ();
133
138
handler .addHandler (node );
134
139
@@ -140,86 +145,15 @@ public void shouldBeAbleToRegisterALocalNode() throws URISyntaxException {
140
145
assertEquals (1 , getStereotypes (status ).get (CAPS ).intValue ());
141
146
}
142
147
143
- @ Test
144
- public void shouldNotRegisterALocalNodeWithWrongRegistrationSecret () throws URISyntaxException {
145
- URI sessionUri = new URI ("http://example:1234" );
146
- HttpClient .Factory clientFactory = new RoutableHttpClientFactory (
147
- externalUrl ,
148
- handler ,
149
- HttpClient .Factory .createDefault ());
150
-
151
- Secret registrationSecret = new Secret ("my_secret" );
152
-
153
- Node node = LocalNode .builder (tracer , bus , externalUrl .toURI (), externalUrl .toURI (), registrationSecret )
154
- .add (CAPS , new TestSessionFactory ((id , caps ) -> new Session (id , sessionUri , stereotype , caps , Instant .now ())))
155
- .build ();
156
- handler .addHandler (node );
157
-
158
- LocalSessionMap sessions = new LocalSessionMap (tracer , bus );
159
- LocalNewSessionQueue localNewSessionQueue = new LocalNewSessionQueue (
160
- tracer ,
161
- bus ,
162
- Duration .ofSeconds (2 ),
163
- Duration .ofSeconds (2 ));
164
- LocalNewSessionQueuer queuer = new LocalNewSessionQueuer (tracer , bus , localNewSessionQueue );
165
- Distributor secretDistributor = new LocalDistributor (
166
- tracer ,
167
- bus ,
168
- clientFactory ,
169
- sessions ,
170
- queuer ,
171
- registrationSecret );
172
-
173
- bus .fire (new NodeStatusEvent (node .getStatus ()));
174
-
175
- assertEquals (0 , secretDistributor .getAvailableNodes ().size ());
176
- }
177
-
178
- @ Test
179
- public void shouldRegisterALocalNodeWithCorrectRegistrationSecret () throws URISyntaxException {
180
- URI sessionUri = new URI ("http://example:1234" );
181
- HttpClient .Factory clientFactory = new RoutableHttpClientFactory (
182
- externalUrl ,
183
- handler ,
184
- HttpClient .Factory .createDefault ());
185
-
186
- Secret registrationSecret = new Secret ("my_secret" );
187
-
188
- Node node = LocalNode .builder (tracer , bus , externalUrl .toURI (), externalUrl .toURI (), registrationSecret )
189
- .add (CAPS , new TestSessionFactory ((id , caps ) -> new Session (id , sessionUri , stereotype , caps , Instant .now ())))
190
- .build ();
191
- handler .addHandler (node );
192
-
193
- LocalSessionMap sessions = new LocalSessionMap (tracer , bus );
194
- LocalNewSessionQueue localNewSessionQueue = new LocalNewSessionQueue (
195
- tracer ,
196
- bus ,
197
- Duration .ofSeconds (2 ),
198
- Duration .ofSeconds (2 ));
199
- LocalNewSessionQueuer queuer = new LocalNewSessionQueuer (tracer , bus , localNewSessionQueue );
200
- Distributor secretDistributor = new LocalDistributor (
201
- tracer ,
202
- bus ,
203
- clientFactory ,
204
- sessions ,
205
- queuer ,
206
- registrationSecret );
207
-
208
- bus .fire (new NodeStatusEvent (node .getStatus ()));
209
-
210
- wait .until (obj -> secretDistributor .getStatus ().hasCapacity ());
211
-
212
- assertEquals (1 , secretDistributor .getAvailableNodes ().size ());
213
- }
214
-
215
148
@ Test
216
149
public void shouldBeAbleToRegisterACustomNode () throws URISyntaxException {
217
150
URI sessionUri = new URI ("http://example:1234" );
218
151
Node node = new CustomNode (
219
152
bus ,
220
153
new NodeId (UUID .randomUUID ()),
221
154
externalUrl .toURI (),
222
- c -> new Session (new SessionId (UUID .randomUUID ()), sessionUri , stereotype , c , Instant .now ()));
155
+ c -> new Session (
156
+ new SessionId (UUID .randomUUID ()), sessionUri , stereotype , c , Instant .now ()));
223
157
handler .addHandler (node );
224
158
225
159
distributor .add (node );
@@ -233,8 +167,12 @@ public void shouldBeAbleToRegisterACustomNode() throws URISyntaxException {
233
167
@ Test
234
168
public void shouldBeAbleToRegisterNodesByListeningForEvents () throws URISyntaxException {
235
169
URI sessionUri = new URI ("http://example:1234" );
236
- Node node = LocalNode .builder (tracer , bus , externalUrl .toURI (), externalUrl .toURI (), registrationSecret )
237
- .add (CAPS , new TestSessionFactory ((id , caps ) -> new Session (id , sessionUri , stereotype , caps , Instant .now ())))
170
+ Node node = LocalNode
171
+ .builder (tracer , bus , externalUrl .toURI (), externalUrl .toURI (), registrationSecret )
172
+ .add (
173
+ CAPS ,
174
+ new TestSessionFactory (
175
+ (id , caps ) -> new Session (id , sessionUri , stereotype , caps , Instant .now ())))
238
176
.build ();
239
177
handler .addHandler (node );
240
178
@@ -247,13 +185,22 @@ public void shouldBeAbleToRegisterNodesByListeningForEvents() throws URISyntaxEx
247
185
}
248
186
249
187
@ Test
250
- public void shouldKeepOnlyOneNodeWhenTwoRegistrationsHaveTheSameUriByListeningForEvents () throws URISyntaxException {
188
+ public void shouldKeepOnlyOneNodeWhenTwoRegistrationsHaveTheSameUriByListeningForEvents ()
189
+ throws URISyntaxException {
251
190
URI sessionUri = new URI ("http://example:1234" );
252
- Node firstNode = LocalNode .builder (tracer , bus , externalUrl .toURI (), externalUrl .toURI (), registrationSecret )
253
- .add (CAPS , new TestSessionFactory ((id , caps ) -> new Session (id , sessionUri , stereotype , caps , Instant .now ())))
191
+ Node firstNode = LocalNode
192
+ .builder (tracer , bus , externalUrl .toURI (), externalUrl .toURI (), registrationSecret )
193
+ .add (
194
+ CAPS ,
195
+ new TestSessionFactory (
196
+ (id , caps ) -> new Session (id , sessionUri , stereotype , caps , Instant .now ())))
254
197
.build ();
255
- Node secondNode = LocalNode .builder (tracer , bus , externalUrl .toURI (), externalUrl .toURI (), registrationSecret )
256
- .add (CAPS , new TestSessionFactory ((id , caps ) -> new Session (id , sessionUri , stereotype , caps , Instant .now ())))
198
+ Node secondNode = LocalNode
199
+ .builder (tracer , bus , externalUrl .toURI (), externalUrl .toURI (), registrationSecret )
200
+ .add (
201
+ CAPS ,
202
+ new TestSessionFactory (
203
+ (id , caps ) -> new Session (id , sessionUri , stereotype , caps , Instant .now ())))
257
204
.build ();
258
205
handler .addHandler (firstNode );
259
206
handler .addHandler (secondNode );
@@ -272,8 +219,12 @@ public void shouldKeepOnlyOneNodeWhenTwoRegistrationsHaveTheSameUriByListeningFo
272
219
public void distributorShouldUpdateStateOfExistingNodeWhenNodePublishesStateChange ()
273
220
throws URISyntaxException {
274
221
URI sessionUri = new URI ("http://example:1234" );
275
- Node node = LocalNode .builder (tracer , bus , externalUrl .toURI (), externalUrl .toURI (), registrationSecret )
276
- .add (CAPS , new TestSessionFactory ((id , caps ) -> new Session (id , sessionUri , stereotype , caps , Instant .now ())))
222
+ Node node = LocalNode
223
+ .builder (tracer , bus , externalUrl .toURI (), externalUrl .toURI (), registrationSecret )
224
+ .add (
225
+ CAPS ,
226
+ new TestSessionFactory (
227
+ (id , caps ) -> new Session (id , sessionUri , stereotype , caps , Instant .now ())))
277
228
.build ();
278
229
handler .addHandler (node );
279
230
@@ -296,7 +247,8 @@ public void distributorShouldUpdateStateOfExistingNodeWhenNodePublishesStateChan
296
247
new SlotId (status .getId (), UUID .randomUUID ()),
297
248
CAPS ,
298
249
Instant .now (),
299
- Optional .of (new Session (new SessionId (UUID .randomUUID ()), sessionUri , CAPS , CAPS , Instant .now ())))),
250
+ Optional .of (new Session (
251
+ new SessionId (UUID .randomUUID ()), sessionUri , CAPS , CAPS , Instant .now ())))),
300
252
UP );
301
253
302
254
bus .fire (new NodeStatusEvent (crafted ));
@@ -396,7 +348,12 @@ public NodeStatus getStatus() {
396
348
Session sess = null ;
397
349
if (running != null ) {
398
350
try {
399
- sess = new Session (running .getId (), new URI ("http://localhost:14568" ), CAPS , running .getCapabilities (), Instant .now ());
351
+ sess = new Session (
352
+ running .getId (),
353
+ new URI ("http://localhost:14568" ),
354
+ CAPS ,
355
+ running .getCapabilities (),
356
+ Instant .now ());
400
357
} catch (URISyntaxException e ) {
401
358
throw new RuntimeException (e );
402
359
}
0 commit comments