-
Notifications
You must be signed in to change notification settings - Fork 574
/
EjbLinkTest.java
526 lines (420 loc) · 15 KB
/
EjbLinkTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
/*******************************************************************************
* Copyright (c) 2020, 2023 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package com.ibm.ws.ejbcontainer.remote.client.fat.tests;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.util.List;
import java.util.Locale;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestWatcher;
import org.junit.runner.Description;
import org.junit.runner.RunWith;
import com.ibm.websphere.simplicity.ShrinkHelper;
import com.ibm.websphere.simplicity.ShrinkHelper.DeployOptions;
import com.ibm.websphere.simplicity.log.Log;
import componenttest.annotation.Server;
import componenttest.custom.junit.runner.FATRunner;
import componenttest.rules.repeater.FeatureReplacementAction;
import componenttest.rules.repeater.JakartaEE10Action;
import componenttest.rules.repeater.JakartaEE9Action;
import componenttest.rules.repeater.RepeatTests;
import componenttest.topology.impl.LibertyClient;
import componenttest.topology.impl.LibertyClientFactory;
import componenttest.topology.impl.LibertyServer;
import componenttest.topology.utils.FATServletClient;
@RunWith(FATRunner.class)
public class EjbLinkTest extends FATServletClient {
@Rule
public TestWatcher watchman = new TestWatcher() {
@Override
protected void failed(Throwable e, Description description) {
try {
System.runFinalization();
System.gc();
server.serverDump("heap");
} catch (Exception e1) {
System.out.println("Failed to dump server");
e1.printStackTrace();
}
}
};
private static final boolean isWindows = System.getProperty("os.name").toLowerCase(Locale.ENGLISH).contains("win");
private static Class<?> c = EjbLinkTest.class;
private static LibertyClient client = LibertyClientFactory.getLibertyClient("com.ibm.ws.ejbcontainer.remote.client.fat.clientInjection");
@Server("com.ibm.ws.ejbcontainer.remote.client.fat.serverInjection")
public static LibertyServer server;
@ClassRule
public static RepeatTests r = RepeatTests.with(FeatureReplacementAction.EE7_FEATURES().fullFATOnly().forServers("com.ibm.ws.ejbcontainer.remote.client.fat.serverInjection")).andWith(FeatureReplacementAction.EE8_FEATURES().forServers("com.ibm.ws.ejbcontainer.remote.client.fat.serverInjection")).andWith(new JakartaEE9Action().forServers("com.ibm.ws.ejbcontainer.remote.client.fat.serverInjection").fullFATOnly()).andWith(new JakartaEE10Action().forServers("com.ibm.ws.ejbcontainer.remote.client.fat.serverInjection"));
@BeforeClass
public static void beforeClass() throws Exception {
// cleanup from prior repeat actions
server.deleteAllDropinApplications();
server.removeAllInstalledAppsForValidation();
// Use ShrinkHelper to build the Ears & Wars
//#################### StatefulAnnRemoteTest.ear
JavaArchive EjbLinkBean = ShrinkHelper.buildJavaArchive("EjbLinkBean.jar", "com.ibm.ws.ejbcontainer.ejblink.ejb.");
EjbLinkBean = (JavaArchive) ShrinkHelper.addDirectory(EjbLinkBean, "test-applications/EjbLinkBean.jar/resources");
JavaArchive EjbLinkOtherBean = ShrinkHelper.buildJavaArchive("EjbLinkOtherBean.jar", "com.ibm.ws.ejbcontainer.ejblink.ejbo.");
EjbLinkOtherBean = (JavaArchive) ShrinkHelper.addDirectory(EjbLinkOtherBean, "test-applications/EjbLinkOtherBean.jar/resources");
WebArchive EjbLinkInWar = ShrinkHelper.buildDefaultApp("EjbLinkInWar.war", "com.ibm.ws.ejbcontainer.ejblink.ejbwar.");
EjbLinkInWar = (WebArchive) ShrinkHelper.addDirectory(EjbLinkInWar, "test-applications/EjbLinkInWar.war/resources");
WebArchive EjbLinkInOtherWar = ShrinkHelper.buildDefaultApp("EjbLinkInOtherWar.war", "com.ibm.ws.ejbcontainer.ejblink.ejbwaro.");
EjbLinkInOtherWar = (WebArchive) ShrinkHelper.addDirectory(EjbLinkInOtherWar, "test-applications/EjbLinkInOtherWar.war/resources");
JavaArchive EjbLinkClient = ShrinkHelper.buildJavaArchive("EjbLinkClient.jar", "com.ibm.ws.ejbcontainer.ejblink.client.");
EjbLinkClient = (JavaArchive) ShrinkHelper.addDirectory(EjbLinkClient, "test-applications/EjbLinkClient.jar/resources");
EnterpriseArchive EjbLinkTest = ShrinkWrap.create(EnterpriseArchive.class, "EjbLinkTest.ear");
EjbLinkTest.addAsModule(EjbLinkBean).addAsModule(EjbLinkOtherBean);
EjbLinkTest.addAsModule(EjbLinkInWar).addAsModule(EjbLinkInOtherWar);
EjbLinkTest.addAsModule(EjbLinkClient);
EjbLinkTest = (EnterpriseArchive) ShrinkHelper.addDirectory(EjbLinkTest, "test-applications/EjbLinkTest.ear/resources");
ShrinkHelper.exportDropinAppToServer(server, EjbLinkTest, DeployOptions.SERVER_ONLY);
ShrinkHelper.exportToClient(client, "dropins", EjbLinkTest, DeployOptions.SERVER_ONLY);
// Start the server and wait for application to start
server.startServer();
// verify the appSecurity-2.0 feature is ready
assertNotNull("Security service did not report it was ready", server.waitForStringInLogUsingMark("CWWKS0008I"));
assertNotNull("LTPA configuration did not report it was ready", server.waitForStringInLogUsingMark("CWWKS4105I"));
server.setMarkToEndOfLog();
//#################### InitTxRecoveryLogApp.ear (Automatically initializes transaction recovery logs)
JavaArchive InitTxRecoveryLogEJBJar = ShrinkHelper.buildJavaArchive("InitTxRecoveryLogEJB.jar", "com.ibm.ws.ejbcontainer.init.recovery.ejb.");
EnterpriseArchive InitTxRecoveryLogApp = ShrinkWrap.create(EnterpriseArchive.class, "InitTxRecoveryLogApp.ear");
InitTxRecoveryLogApp.addAsModule(InitTxRecoveryLogEJBJar);
// Only after the server has started and appSecurity-2.0 feature is ready,
// then allow the @Startup InitTxRecoveryLog bean to start.
ShrinkHelper.exportDropinAppToServer(server, InitTxRecoveryLogApp, DeployOptions.SERVER_ONLY);
// CWNEN1001E - testStyle1BeanInJarAndWarFromClient; ambiguous, cannot lookup
// CWNEN0030E - testStyle1BeanInJarAndWarFromClient; ambiguous, cannot lookup
client.addIgnoreErrors("CWWKC0105W", "CWNEN1001E", "CWNEN0030E");
// CWWKZ0022W: Application ______ has not started in 30 seconds.
if (isWindows) {
client.addIgnoreErrors("CWWKZ0022W");
}
client.startClient();
}
@AfterClass
public static void afterClass() throws Exception {
server.stopServer("CWWKG0033W", "CNTR0019E", "CWNEN0030E", "CWWKO0221E");
}
private void check() throws Exception {
String methodName = getTestMethodSimpleName();
List<String> strings = client.findStringsInCopiedLogs(methodName + "--PASSED");
Log.info(c, methodName, "Found in logs: " + strings);
assertTrue("Did not find expected method message " + methodName + "--PASSED", strings != null && strings.size() >= 1);
// now explicitly check that we do not see messages like this in the log output:
// W CWNEN0057W: The com.ibm.ws.clientcontainer.fat.javacolon.client.InjectionClientMain.mailSessionComp injection target must not be declared static.
// The spec says that injection into client modules MUST be static - this message indicates a bug in how injection is
// processed - usually by the client container injection runtime or CDI.
strings = client.findStringsInCopiedLogs("CWNEN0057W");
assertTrue("Invalid warning message about injecting into static field", 0 == strings.size());
}
@Test
public void testStyle2OtherJarXML() throws Exception {
check();
}
@Test
public void testStyle1OtherJarXML() throws Exception {
check();
}
@Test
public void testStyle3OtherJarXML() throws Exception {
check();
}
@Test
public void testStyle1SameJarXML() throws Exception {
check();
}
@Test
public void testStyle2SameJarXML() throws Exception {
check();
}
@Test
public void testStyle3SameJarXML() throws Exception {
check();
}
@Test
public void testStyle1OtherJarAnn() throws Exception {
check();
}
@Test
public void testStyle2OtherJarAnn() throws Exception {
check();
}
@Test
public void testStyle3OtherJarAnn() throws Exception {
check();
}
@Test
public void testStyle1SameJarAnn() throws Exception {
check();
}
@Test
public void testStyle2SameJarAnn() throws Exception {
check();
}
@Test
public void testStyle3SameJarAnn() throws Exception {
check();
}
@Test
public void testStyle1OtherWarXML() throws Exception {
check();
}
@Test
public void testStyle2OtherWarXML() throws Exception {
check();
}
@Test
public void testStyle3OtherWarXML() throws Exception {
check();
}
@Test
public void testStyle1SameWarXML() throws Exception {
check();
}
@Test
public void testStyle2SameWarXML() throws Exception {
check();
}
@Test
public void testStyle3SameWarXML() throws Exception {
check();
}
@Test
public void testStyle1OtherWarAnn() throws Exception {
check();
}
@Test
public void testStyle2OtherWarAnn() throws Exception {
check();
}
@Test
public void testStyle3OtherWarAnn() throws Exception {
check();
}
@Test
public void testStyle1SameWarAnn() throws Exception {
check();
}
@Test
public void testStyle2SameWarAnn() throws Exception {
check();
}
@Test
public void testStyle3SameWarAnn() throws Exception {
check();
}
@Test
public void testJarStyle1toWarXML() throws Exception {
check();
}
@Test
public void testJarStyle1toWarAnn() throws Exception {
check();
}
@Test
public void testWarStyle1toJarXML() throws Exception {
check();
}
@Test
public void testWarStyle1toJarAnn() throws Exception {
check();
}
@Test
public void testJarStyle2toWarXML() throws Exception {
check();
}
@Test
public void testJarStyle2toWarAnn() throws Exception {
check();
}
@Test
public void testWarStyle2toJarXML() throws Exception {
check();
}
@Test
public void testWarStyle2toJarAnn() throws Exception {
check();
}
@Test
public void testJarStyle3toWarXML() throws Exception {
check();
}
@Test
public void testJarStyle3toWarAnn() throws Exception {
check();
}
@Test
public void testWarStyle3toJarXML() throws Exception {
check();
}
@Test
public void testWarStyle3toJarAnn() throws Exception {
check();
}
@Test
public void testStyle1BeanInJarAndWar() throws Exception {
check();
}
@Test
public void findBeanInSameJar() throws Exception {
check();
}
@Test
public void findBeanInSameWar() throws Exception {
check();
}
@Test
public void findBeanFromJarInOtherJar() throws Exception {
check();
}
@Test
public void findBeanFromWarInJar() throws Exception {
check();
}
@Test
public void findBeanFromJarInWar() throws Exception {
check();
}
@Test
public void findBeanFromWarInOtherWar() throws Exception {
check();
}
@Test
public void findBeanInSameJarAndJar() throws Exception {
check();
}
@Test
public void findBeanInSameJarAndWar() throws Exception {
check();
}
@Test
public void findBeanFromJarInOtherJarAndWar() throws Exception {
check();
}
@Test
public void findBeanFromJarInTwoWars() throws Exception {
check();
}
@Test
public void findBeanInSameWarAndJar() throws Exception {
check();
}
@Test
public void findBeanInSameWarAndWar() throws Exception {
check();
}
@Test
public void findBeanFromWarInOtherJarAndWar() throws Exception {
check();
}
@Test
public void findBeanFromWarInTwoJars() throws Exception {
check();
}
@Test
public void findBeanFromJar2SameJar() throws Exception {
check();
}
@Test
public void findBeanFromJar2OtherJar() throws Exception {
check();
}
@Test
public void findBeanFromJar2War() throws Exception {
check();
}
@Test
public void findBeanFromWar2SameWar() throws Exception {
check();
}
@Test
public void findBeanFromWar2OtherWar() throws Exception {
check();
}
@Test
public void findBeanFromWar2Jar() throws Exception {
check();
}
@Test
public void testStyle1OtherJarXMLFromClient() throws Exception {
check();
}
@Test
public void testStyle2OtherJarXMLFromClient() throws Exception {
check();
}
@Test
public void testStyle3OtherJarXMLFromClient() throws Exception {
check();
}
@Test
public void testStyle1OtherJarAnnFromClient() throws Exception {
check();
}
@Test
public void testStyle2OtherJarAnnFromClient() throws Exception {
check();
}
@Test
public void testStyle3OtherJarAnnFromClient() throws Exception {
check();
}
@Test
public void testStyle1OtherWarXMLFromClient() throws Exception {
check();
}
@Test
public void testStyle2OtherWarXMLFromClient() throws Exception {
check();
}
@Test
public void testStyle3OtherWarXMLFromClient() throws Exception {
check();
}
@Test
public void testStyle1OtherWarAnnFromClient() throws Exception {
check();
}
@Test
public void testStyle2OtherWarAnnFromClient() throws Exception {
check();
}
@Test
public void testStyle3OtherWarAnnFromClient() throws Exception {
check();
}
@Test
public void testStyle1BeanInJarAndWarFromClient() throws Exception {
check();
}
@Test
public void findBeanFromClientInJar() throws Exception {
check();
}
@Test
public void findBeanFromClientInWar() throws Exception {
check();
}
@Test
public void find2xBeanFromClientInJar() throws Exception {
check();
}
}