/
ParseAndMarshalModelsTestCase.java
539 lines (453 loc) · 19 KB
/
ParseAndMarshalModelsTestCase.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
527
528
529
530
531
532
533
534
535
536
537
538
539
/*
* JBoss, Home of Professional Open Source.
* Copyright 2006, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.manualmode.parse;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.PROFILE;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUBSYSTEM;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.InputStream;
import org.jboss.arquillian.container.test.api.ContainerController;
import org.jboss.arquillian.container.test.api.Deployer;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.container.test.api.TargetsContainer;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.junit.InSequence;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.as.test.shared.FileUtils;
import org.jboss.as.test.shared.ModelParserUtils;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.Property;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.Asset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* Tests the ability to parse the config files we ship or have shipped in the past, as well as the ability
* to marshal them back to xml in a manner such that reparsing them produces a consistent in-memory configuration model.
* <p/>
* <b>Note:</b>The standard {@code build/src/main/resources/standalone/configuration} and
* {@code build/src/main/resources/domain/configuration} files are tested in the smoke integration module ParseAndMarshalModelsTestCase.
*
* @author <a href="kabir.khan@jboss.com">Kabir Khan</a>
* @author <a href="mailto:darran.lofthouse@jboss.com">Darran Lofthouse</a>
* @author Brian Stansberry (c) 2011 Red Hat Inc.
* @see org.jboss.as.test.parsing.ModelParserUtils
*/
@RunWith(Arquillian.class)
public class ParseAndMarshalModelsTestCase {
@Deployment(name = "test", managed = false, testable = true)
public static Archive<?> getDeployment() {
JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "bogus.jar");
archive.addPackage(ParseAndMarshalModelsTestCase.class.getPackage());
archive.addClass(FileUtils.class);
archive.addClass(ModelParserUtils.class);
archive.add(new Asset() {
public InputStream openStream() {
return new ByteArrayInputStream("Dependencies: org.jboss.staxmapper,org.jboss.as.controller,org.jboss.as.deployment-repository,org.jboss.as.server,org.jboss.as.host-controller,org.jboss.as.domain-management,org.jboss.as.security\n\n".getBytes());
}
}, "META-INF/MANIFEST.MF");
return archive;
}
@Test
@InSequence(-1)
@RunAsClient
public void start(@ArquillianResource ContainerController cc, @ArquillianResource Deployer deployer) {
cc.start("default-jbossas");
deployer.deploy("test");
}
@Test
@InSequence(1)
@RunAsClient
public void stop(@ArquillianResource ContainerController cc, @ArquillianResource Deployer deployer) {
deployer.undeploy("test");
cc.stop("default-jbossas");
}
@Test
public void testStandaloneXml() throws Exception {
standaloneXmlTest(getOriginalStandaloneXml("standalone.xml"));
}
@Test
public void testStandaloneHAXml() throws Exception {
standaloneXmlTest(getOriginalStandaloneXml("standalone-ha.xml"));
}
@Test
public void testStandaloneFullXml() throws Exception {
standaloneXmlTest(getOriginalStandaloneXml("standalone-full.xml"));
}
@Test
public void testStandaloneFullHAXml() throws Exception {
standaloneXmlTest(getOriginalStandaloneXml("standalone-full-ha.xml"));
}
@Test
public void testStandaloneMinimalisticXml() throws Exception {
standaloneXmlTest(getDocsExampleConfigFile("standalone-minimalistic.xml"));
}
@Test
public void testStandalonePicketLinkXml() throws Exception {
standaloneXmlTest(getGeneratedExampleConfigFile("standalone-picketlink.xml"));
}
@Test
public void testStandaloneXtsXml() throws Exception {
standaloneXmlTest(getGeneratedExampleConfigFile("standalone-xts.xml"));
}
@Test
public void testStandaloneHornetqColocatedXml() throws Exception {
standaloneXmlTest(getGeneratedExampleConfigFile("standalone-hornetq-colocated.xml"));
}
@Test
public void testStandaloneJtsXml() throws Exception {
standaloneXmlTest(getGeneratedExampleConfigFile("standalone-jts.xml"));
}
@Test
public void testStandaloneGenericJMSXml() throws Exception {
standaloneXmlTest(getGeneratedExampleConfigFile("standalone-genericjms.xml"));
}
@Test
public void test710StandaloneXml() throws Exception {
standaloneXmlTest(getLegacyConfigFile("standalone", "7-1-0.xml"));
}
@Test
public void test710StandaloneFullHaXml() throws Exception {
standaloneXmlTest(getLegacyConfigFile("standalone", "7-1-0-full-ha.xml"));
}
@Test
public void test710StandaloneFullXml() throws Exception {
standaloneXmlTest(getLegacyConfigFile("standalone", "7-1-0-full.xml"));
}
@Test
public void test710StandaloneHornetQCollocatedXml() throws Exception {
standaloneXmlTest(getLegacyConfigFile("standalone", "7-1-0-hornetq-colocated.xml"));
}
@Test
public void test710StandaloneJtsXml() throws Exception {
standaloneXmlTest(getLegacyConfigFile("standalone", "7-1-0-jts.xml"));
}
@Test
public void test710StandaloneMinimalisticXml() throws Exception {
standaloneXmlTest(getLegacyConfigFile("standalone", "7-1-0-minimalistic.xml"));
}
@Test
public void test710StandaloneXtsXml() throws Exception {
standaloneXmlTest(getLegacyConfigFile("standalone", "7-1-0-xts.xml"));
}
@Test
public void test711StandaloneXml() throws Exception {
standaloneXmlTest(getLegacyConfigFile("standalone", "7-1-1.xml"));
}
@Test
public void test711StandaloneFullHaXml() throws Exception {
standaloneXmlTest(getLegacyConfigFile("standalone", "7-1-1-full-ha.xml"));
}
@Test
public void test711StandaloneFullXml() throws Exception {
standaloneXmlTest(getLegacyConfigFile("standalone", "7-1-1-full.xml"));
}
@Test
public void test711StandaloneHornetQCollocatedXml() throws Exception {
standaloneXmlTest(getLegacyConfigFile("standalone", "7-1-1-hornetq-colocated.xml"));
}
@Test
public void test711StandaloneJtsXml() throws Exception {
standaloneXmlTest(getLegacyConfigFile("standalone", "7-1-1-jts.xml"));
}
@Test
public void test711StandaloneMinimalisticXml() throws Exception {
standaloneXmlTest(getLegacyConfigFile("standalone", "7-1-1-minimalistic.xml"));
}
@Test
public void test711StandaloneXtsXml() throws Exception {
standaloneXmlTest(getLegacyConfigFile("standalone", "7-1-1-xts.xml"));
}
@Test
public void test712StandaloneXml() throws Exception {
ModelNode model = standaloneXmlTest(getLegacyConfigFile("standalone", "7-1-2.xml"));
validateJsfSubsystem(model);
}
@Test
public void test712StandaloneFullHaXml() throws Exception {
ModelNode model = standaloneXmlTest(getLegacyConfigFile("standalone", "7-1-2-full-ha.xml"));
validateJsfSubsystem(model);
}
@Test
public void test712StandaloneFullXml() throws Exception {
ModelNode model = standaloneXmlTest(getLegacyConfigFile("standalone", "7-1-2-full.xml"));
validateJsfSubsystem(model);
}
@Test
public void test712StandaloneHornetQCollocatedXml() throws Exception {
standaloneXmlTest(getLegacyConfigFile("standalone", "7-1-2-hornetq-colocated.xml"));
}
@Test
public void test712StandaloneJtsXml() throws Exception {
standaloneXmlTest(getLegacyConfigFile("standalone", "7-1-2-jts.xml"));
}
@Test
public void test712StandaloneMinimalisticXml() throws Exception {
standaloneXmlTest(getLegacyConfigFile("standalone", "7-1-2-minimalistic.xml"));
}
@Test
public void test712StandaloneXtsXml() throws Exception {
standaloneXmlTest(getLegacyConfigFile("standalone", "7-1-2-xts.xml"));
}
@Test
public void test713StandaloneXml() throws Exception {
ModelNode model = standaloneXmlTest(getLegacyConfigFile("standalone", "7-1-3.xml"));
validateJsfSubsystem(model);
}
@Test
public void test713StandaloneFullHaXml() throws Exception {
ModelNode model = standaloneXmlTest(getLegacyConfigFile("standalone", "7-1-3-full-ha.xml"));
validateJsfSubsystem(model);
}
@Test
public void test713StandaloneFullXml() throws Exception {
ModelNode model = standaloneXmlTest(getLegacyConfigFile("standalone", "7-1-3-full.xml"));
validateJsfSubsystem(model);
}
@Test
public void test713StandaloneHornetQCollocatedXml() throws Exception {
standaloneXmlTest(getLegacyConfigFile("standalone", "7-1-3-hornetq-colocated.xml"));
}
@Test
public void test713StandaloneJtsXml() throws Exception {
standaloneXmlTest(getLegacyConfigFile("standalone", "7-1-3-jts.xml"));
}
@Test
public void test713StandaloneMinimalisticXml() throws Exception {
standaloneXmlTest(getLegacyConfigFile("standalone", "7-1-3-minimalistic.xml"));
}
@Test
public void test713StandaloneXtsXml() throws Exception {
standaloneXmlTest(getLegacyConfigFile("standalone", "7-1-3-xts.xml"));
}
@Test
public void test720StandaloneFullHaXml() throws Exception {
ModelNode model = standaloneXmlTest(getLegacyConfigFile("standalone", "7-2-0-full-ha.xml"));
validateJsfSubsystem(model);
}
@Test
public void test720StandaloneFullXml() throws Exception {
ModelNode model = standaloneXmlTest(getLegacyConfigFile("standalone", "7-2-0-full.xml"));
validateJsfSubsystem(model);
}
@Test
public void test720StandaloneHornetQCollocatedXml() throws Exception {
standaloneXmlTest(getLegacyConfigFile("standalone", "7-2-0-hornetq-colocated.xml"));
}
@Test
public void test720StandaloneJtsXml() throws Exception {
standaloneXmlTest(getLegacyConfigFile("standalone", "7-2-0-jts.xml"));
}
@Test
public void test720StandaloneMinimalisticXml() throws Exception {
standaloneXmlTest(getLegacyConfigFile("standalone", "7-2-0-minimalistic.xml"));
}
@Test
public void test720StandaloneXtsXml() throws Exception {
standaloneXmlTest(getLegacyConfigFile("standalone", "7-2-0-xts.xml"));
}
@Test
public void testEAP620StandaloneFullHaXml() throws Exception {
ModelNode model = standaloneXmlTest(getLegacyConfigFile("standalone", "eap-6-2-0-full-ha.xml"));
validateJsfSubsystem(model);
}
@Test
public void testEAP620StandaloneFullXml() throws Exception {
ModelNode model = standaloneXmlTest(getLegacyConfigFile("standalone", "eap-6-2-0-full.xml"));
validateJsfSubsystem(model);
}
@Test
public void testEAP620StandaloneHornetQCollocatedXml() throws Exception {
standaloneXmlTest(getLegacyConfigFile("standalone", "eap-6-2-0-hornetq-colocated.xml"));
}
@Test
public void testEAP620StandaloneJtsXml() throws Exception {
standaloneXmlTest(getLegacyConfigFile("standalone", "eap-6-2-0-jts.xml"));
}
@Test
public void testEAP620StandaloneMinimalisticXml() throws Exception {
standaloneXmlTest(getLegacyConfigFile("standalone", "eap-6-2-0-minimalistic.xml"));
}
@Test
public void testEAP620StandaloneXtsXml() throws Exception {
standaloneXmlTest(getLegacyConfigFile("standalone", "eap-6-2-0-xts.xml"));
}
private ModelNode standaloneXmlTest(File original) throws Exception {
File file = new File("target/standalone-copy.xml");
if (file.exists()) {
file.delete();
}
return ModelParserUtils.standaloneXmlTest(original, file);
}
@Test
public void testHostXml() throws Exception {
hostXmlTest(getOriginalHostXml("host.xml"));
}
@Test
public void test710HostXml() throws Exception {
hostXmlTest(getLegacyConfigFile("host", "7-1-0.xml"));
}
@Test
public void test711HostXml() throws Exception {
hostXmlTest(getLegacyConfigFile("host", "7-1-1.xml"));
}
@Test
public void test712HostXml() throws Exception {
hostXmlTest(getLegacyConfigFile("host", "7-1-2.xml"));
}
@Test
public void test713HostXml() throws Exception {
hostXmlTest(getLegacyConfigFile("host", "7-1-3.xml"));
}
@Test
public void test720HostXml() throws Exception {
hostXmlTest(getLegacyConfigFile("host", "7-2-0.xml"));
}
@Test
public void testEAP620HostXml() throws Exception {
hostXmlTest(getLegacyConfigFile("host", "eap-6-2-0.xml"));
}
private void hostXmlTest(final File original) throws Exception {
File file = new File("target/host-copy.xml");
if (file.exists()) {
file.delete();
}
ModelParserUtils.hostXmlTest(original, file);
}
@Test
@TargetsContainer("class-jbossas")
public void testDomainXml() throws Exception {
domainXmlTest(getOriginalDomainXml("domain.xml"));
}
@Test
@TargetsContainer("class-jbossas")
public void test710DomainXml() throws Exception {
ModelNode model = domainXmlTest(getLegacyConfigFile("domain", "7-1-0.xml"));
validateJsfProfiles(model);
}
@Test
@TargetsContainer("class-jbossas")
public void test711DomainXml() throws Exception {
domainXmlTest(getLegacyConfigFile("domain", "7-1-1.xml"));
}
@Test
@TargetsContainer("class-jbossas")
public void test712DomainXml() throws Exception {
ModelNode model = domainXmlTest(getLegacyConfigFile("domain", "7-1-2.xml"));
validateJsfProfiles(model);
}
@Test
@TargetsContainer("class-jbossas")
public void test713DomainXml() throws Exception {
ModelNode model = domainXmlTest(getLegacyConfigFile("domain", "7-1-3.xml"));
validateJsfProfiles(model);
}
@Test
@TargetsContainer("class-jbossas")
public void test720DomainXml() throws Exception {
ModelNode model = domainXmlTest(getLegacyConfigFile("domain", "7-2-0.xml"));
validateJsfProfiles(model);
}
@Test
@TargetsContainer("class-jbossas")
public void testEAP620DomainXml() throws Exception {
ModelNode model = domainXmlTest(getLegacyConfigFile("domain", "eap-6-2-0.xml"));
validateJsfProfiles(model);
}
private ModelNode domainXmlTest(final File original) throws Exception {
File file = new File("target/domain-copy.xml");
if (file.exists()) {
file.delete();
}
return ModelParserUtils.domainXmlTest(original, file);
}
private static void validateJsfProfiles(ModelNode model) {
Assert.assertTrue(model.hasDefined(PROFILE));
for (Property prop : model.get(PROFILE).asPropertyList()) {
validateJsfSubsystem(prop.getValue());
}
}
private static void validateJsfSubsystem(ModelNode model) {
Assert.assertTrue(model.hasDefined(SUBSYSTEM));
//Assert.assertTrue(model.get(SUBSYSTEM).hasDefined("jsf")); //we cannot check for it as web subsystem is not present to add jsf one
}
// Get-config methods
private File getOriginalStandaloneXml(String profile) throws FileNotFoundException {
return FileUtils.getFileOrCheckParentsIfNotFound(
System.getProperty("jboss.inst", "../../.."),
"standalone/configuration/" + profile
);
}
private File getOriginalHostXml(final String profile) throws FileNotFoundException {
//Get the standalone.xml from the build/src directory, since the one in the
//built server could have changed during running of tests
File f = getHostConfigDir();
f = new File(f, profile);
Assert.assertTrue("Not found: " + f.getPath(), f.exists());
return f;
}
private File getOriginalDomainXml(final String profile) throws FileNotFoundException {
//Get the standalone.xml from the build/src directory, since the one in the
//built server could have changed during running of tests
File f = getDomainConfigDir();
f = new File(f, profile);
Assert.assertTrue("Not found: " + f.getPath(), f.exists());
return f;
}
private File getLegacyConfigFile(String type, String profile) throws FileNotFoundException {
return FileUtils.getFileOrCheckParentsIfNotFound(
System.getProperty("jbossas.ts.submodule.dir"),
"src/test/resources/legacy-configs/" + type + File.separator + profile
);
}
private File getDocsExampleConfigFile(String name) throws FileNotFoundException {
return FileUtils.getFileOrCheckParentsIfNotFound(
System.getProperty("jboss.inst", "../../.."),
"docs/examples/configs" + File.separator + name
);
}
private File getGeneratedExampleConfigFile(String name) throws FileNotFoundException {
return FileUtils.getFileOrCheckParentsIfNotFound(
System.getProperty("jboss.inst", "../../.."),
"docs/examples/configs" + File.separator + name
);
}
private File getHostConfigDir() throws FileNotFoundException {
//Get the standalone.xml from the build/src directory, since the one in the
//built server could have changed during running of tests
return FileUtils.getFileOrCheckParentsIfNotFound(
System.getProperty("jboss.inst", "../../.."),
"domain/configuration"
);
}
private File getDomainConfigDir() throws FileNotFoundException {
return FileUtils.getFileOrCheckParentsIfNotFound(
System.getProperty("jboss.inst", "../../.."),
"domain/configuration"
);
}
}