1 package com.sourceforge.jpatterns.core.configuration;
2
3 import com.sourceforge.jpatterns.core.JPConstants;
4 import com.sourceforge.jpatterns.core.configuration.model.JPatternsConfigBean;
5 import com.sourceforge.jpatterns.core.configuration.model.JPatternsConfigsBean;
6 import com.sourceforge.jpatterns.schema.CastorNameScopePriorityType;
7 import com.sourceforge.jpatterns.schema.JPatternsConfig;
8 import com.sourceforge.jpatterns.utils.junit.JPatternsTestUtils;
9 import com.zmicer.utils.ClassPathUtils;
10 import com.zmicer.utils.FileUtils;
11 import com.zmicer.utils.LoggingUtils;
12 import com.zmicer.utils.MagicNumbers;
13 import com.zmicer.utils.ReflexionUtils;
14 import com.zmicer.utils.junit.ZmicerTestUtils;
15 import junit.framework.Test;
16 import junit.framework.TestCase;
17 import junit.framework.TestSuite;
18 import org.apache.log4j.Logger;
19
20 import java.io.File;
21 import java.util.List;
22
23
24
25
26
27
28 public class JPConfiguratorImplTest extends TestCase
29 {
30
31
32
33 final public static Logger LOG = Logger.getLogger(JPConfiguratorImplTest.class);
34
35
36
37
38 private JPConfiguratorImpl m_jpConfiguratorImpl;
39
40
41
42
43 private IPropertiesManager m_propertiesManager = PropertiesBasedFactory.getInstance().getPropertiesManager();
44
45
46
47
48 private static String baseName = ReflexionUtils.getBaseName(JPConfiguratorImplTest.class);
49
50
51
52
53
54
55
56
57
58 String getFullNumberedXMLOrPropertyFileName(int number, boolean isProperty, boolean isDefault)
59 {
60 String name;
61 if (isProperty)
62 {
63 if (isDefault)
64 {
65 name = JPConstants.PropertiesConfigFilesConstants.DEFAULT_PROPERTIES_BASE_NAME;
66 }
67 else
68 {
69 name = JPConstants.PropertiesConfigFilesConstants.CUSTOM_PROPERTIES_BASE_NAME;
70 }
71
72 return name + "_" + number;
73 }
74 else
75 {
76 if (isDefault)
77 {
78 StringBuffer strBuffName = new StringBuffer(
79 JPConstants.XMLConfigFilesConstants.DEFAULT_XML_FRAMEWORK_CONFIG_FILE_NAME);
80 strBuffName.insert(strBuffName.length()-MagicNumbers.FOUR, "_" + number);
81 name = strBuffName.toString();
82 }
83 else
84 {
85 StringBuffer strBuffName = new StringBuffer(
86 JPConstants.XMLConfigFilesConstants.CUSTOM_XML_FRAMEWORK_CONFIG_FILE_NAME);
87 strBuffName.insert(strBuffName.length()-MagicNumbers.FOUR, "_" + number);
88 name = strBuffName.toString();
89 }
90 }
91 return name;
92 }
93
94
95
96
97
98 interface Cases
99 {
100 String ALL_PROPS = "allPropertiesCase";
101 String CUSTOM_XML = "customXML";
102 String NO_PROVIDED_DEFAULT_FILE_NAME = "noProvidedDefaultFileName";
103 String LIST_OF_FILES_CASE1 = "listOfFilesCase\\subcase1";
104 String LIST_OF_FILES_CASE2 = "listOfFilesCase\\subcase2";
105 String LIST_OF_FILES_CASE3 = "listOfFilesCase\\subcase3";
106 String INIT_CONFIGURATION_CASE1 = "InitConfiguration\\subcase1";
107 String INIT_CONFIGURATION_CASE2 = "InitConfiguration\\subcase2";
108
109 }
110
111
112
113
114
115
116 public JPConfiguratorImplTest(String name)
117 {
118 super(name);
119 }
120
121
122
123
124
125
126 public void setUp() throws Exception
127 {
128 super.setUp();
129 JPatternsTestUtils.setJVMPropsParams(JPConfiguratorImplTest.class, false, Cases.ALL_PROPS, null, null, true);
130 JPatternsTestUtils.setJVMXmlParams(JPConfiguratorImplTest.class, false, Cases.ALL_PROPS, null, false);
131 m_jpConfiguratorImpl = new JPConfiguratorImpl();
132 JPatternsTestUtils.resetJVMProps();
133 JPatternsTestUtils.resetJVMXmlParams();
134 }
135
136
137
138
139
140
141 public void tearDown() throws Exception
142 {
143 super.tearDown();
144 }
145
146
147
148
149
150
151 public static Test suite()
152 {
153 return new TestSuite(JPConfiguratorImplTest.class);
154 }
155
156
157
158
159
160
161
162 public void testCreation() throws Exception
163 {
164 assertNotNull(m_jpConfiguratorImpl);
165 }
166
167
168
169
170
171
172
173 public void testInitConfiguration() throws Exception
174 {
175
176 try
177 {
178
179 String propertyFileNameCase1 = getFullNumberedXMLOrPropertyFileName(MagicNumbers.ONE,true,true);
180 String XMLConfigFileNameCase1 = getFullNumberedXMLOrPropertyFileName(MagicNumbers.ONE,false,true);
181
182
183 String propertyFileNameCase2 = getFullNumberedXMLOrPropertyFileName(MagicNumbers.TWO,true,true);
184 String XMLConfigFileNameCase2 = getFullNumberedXMLOrPropertyFileName(MagicNumbers.TWO,false,true);
185
186
187 JPatternsTestUtils.setJVMPropsParams(JPConfiguratorImplTest.class, false, Cases.INIT_CONFIGURATION_CASE1,
188 propertyFileNameCase1, null, true);
189 JPatternsTestUtils.setJVMXmlParams(JPConfiguratorImplTest.class, false, Cases.INIT_CONFIGURATION_CASE1,
190 XMLConfigFileNameCase1, false);
191 m_jpConfiguratorImpl.initConfiguration();
192
193
194 JPatternsConfigsBean frameworkConfig = m_jpConfiguratorImpl.getJPatternsFrameworkConfiguration();
195 JPatternsConfigsBean consumerConfig = m_jpConfiguratorImpl.getJPatternsConsumerConfiguration();
196 CastorNameScopePriorityType itemFromFirstConfigFramework = frameworkConfig.getBusinessItem(
197 "test_scope", "JPatternsGlobalConfiguration_framework", "test_scope", "case");
198 assertNotNull(itemFromFirstConfigFramework);
199
200 CastorNameScopePriorityType itemFromFirstConfigConsumer = consumerConfig.getBusinessItem(
201 "test_scope", "JPatternsGlobalConfiguration_consumer", "test_scope", "case");
202 assertNotNull(itemFromFirstConfigConsumer);
203
204
205 JPatternsTestUtils.setJVMPropsParams(JPConfiguratorImplTest.class, false, Cases.INIT_CONFIGURATION_CASE2,
206 propertyFileNameCase2, null, false);
207 JPatternsTestUtils.setJVMXmlParams(JPConfiguratorImplTest.class, false, Cases.INIT_CONFIGURATION_CASE2,
208 XMLConfigFileNameCase2, false);
209
210
211 frameworkConfig = m_jpConfiguratorImpl.getJPatternsFrameworkConfiguration();
212 consumerConfig = m_jpConfiguratorImpl.getJPatternsConsumerConfiguration();
213 CastorNameScopePriorityType itemFromFirstConfigFrameworkBeforeInit = frameworkConfig.getBusinessItem(
214 "test_scope", "JPatternsGlobalConfiguration_framework", "test_scope", "case");
215 assertNotNull(itemFromFirstConfigFrameworkBeforeInit);
216
217 CastorNameScopePriorityType itemFromFirstConfigConsumerBeforeInit = consumerConfig.getBusinessItem(
218 "test_scope", "JPatternsGlobalConfiguration_consumer", "test_scope", "case");
219 assertNotNull(itemFromFirstConfigConsumerBeforeInit);
220
221
222 assertTrue(itemFromFirstConfigFramework.equals(itemFromFirstConfigFrameworkBeforeInit));
223 assertTrue(itemFromFirstConfigConsumer.equals(itemFromFirstConfigConsumerBeforeInit));
224
225
226 m_jpConfiguratorImpl.initConfiguration();
227
228
229 frameworkConfig = m_jpConfiguratorImpl.getJPatternsFrameworkConfiguration();
230 consumerConfig = m_jpConfiguratorImpl.getJPatternsConsumerConfiguration();
231
232 CastorNameScopePriorityType itemFromSecondConfigFramework = frameworkConfig.getBusinessItem(
233 "test_scope", "JPatternsGlobalConfiguration_framework", "test_scope", "case");
234 CastorNameScopePriorityType itemFromSecondConfigConsumer = consumerConfig.getBusinessItem(
235 "test_scope", "JPatternsGlobalConfiguration_consumer", "test_scope", "case");
236
237
238 assertFalse(itemFromFirstConfigFramework.equals(itemFromSecondConfigFramework));
239 assertFalse(itemFromFirstConfigConsumer.equals(itemFromSecondConfigConsumer));
240 }
241 catch (Exception ex)
242 {
243 LoggingUtils.logException(LOG, ex, null, null);
244 fail("Exception should not occur for that case " + ex.getMessage());
245 }
246 finally
247 {
248 JPatternsTestUtils.resetJVMProps();
249 JPatternsTestUtils.resetJVMXmlParams();
250 }
251 }
252
253
254
255
256
257
258
259
260 public void testGetJPatternsFrameworkConfigurationFileName() throws Exception
261 {
262
263 try
264 {
265
266 JPatternsTestUtils.setJVMPropsParams(JPConfiguratorImplTest.class, false, Cases.NO_PROVIDED_DEFAULT_FILE_NAME, null, null, true);
267 assertNotNull(
268 m_propertiesManager.getBundle(JPConstants.XMLConfigFilesConstants.DEFAULT_XML_FRAMEWORK_CONFIG_FILE_NAME_PROPS_PARAM));
269 String name = m_jpConfiguratorImpl.getJPatternsFrameworkConfigurationFileName();
270 assertNotNull(name);
271 assertEquals(name, "jpatterns_framework_default.xml");
272 JPatternsTestUtils.resetJVMProps();
273
274
275 name = m_jpConfiguratorImpl.getJPatternsFrameworkConfigurationFileName();
276 assertNotNull(name);
277 assertEquals(name, JPConstants.XMLConfigFilesConstants.DEFAULT_XML_FRAMEWORK_CONFIG_FILE_NAME);
278
279
280 System.setProperty(JPConstants.XMLConfigFilesConstants.DEFAULT_XML_FRAMEWORK_CONFIG_FILE_NAME_JVM_PARAM,
281 JPConstants.XMLConfigFilesConstants.DEFAULT_XML_FRAMEWORK_CONFIG_FILE_NAME + "_");
282 name = m_jpConfiguratorImpl.getJPatternsFrameworkConfigurationFileName();
283 assertNotNull(name);
284 assertEquals(name, JPConstants.XMLConfigFilesConstants.DEFAULT_XML_FRAMEWORK_CONFIG_FILE_NAME + "_");
285
286 JPatternsTestUtils.resetJVMProps();
287 }
288 catch (Exception ex)
289 {
290 LoggingUtils.logException(LOG, ex, null, null);
291 fail("Exception should not occur for that case params" + ex.getMessage());
292 }
293 }
294
295
296
297
298
299
300
301 public void testGetJPatternsFrameworkCustomConfigurationFileName() throws Exception
302 {
303
304 try
305 {
306
307 JPatternsTestUtils.setJVMPropsParams(JPConfiguratorImplTest.class, false, Cases.ALL_PROPS, null, null, true);
308 JPatternsTestUtils.resetJVMXmlParams();
309 assertNotNull(
310 m_propertiesManager.getBundle(JPConstants.XMLConfigFilesConstants.CUSTOM_XML_FRAMEWORK_CONFIG_FILE_NAME_PROPS_PARAM));
311 String name = m_jpConfiguratorImpl.getJPatternsFrameworkCustomConfigurationFileName();
312 assertNotNull(name);
313 assertEquals(name, "jpatterns_framework_custom2.xml");
314 JPatternsTestUtils.resetJVMProps();
315
316
317 JPatternsTestUtils.setJVMPropsParams(JPConfiguratorImplTest.class, false, Cases.NO_PROVIDED_DEFAULT_FILE_NAME, null, null, true);
318 JPatternsTestUtils.resetJVMXmlParams();
319 name = m_jpConfiguratorImpl.getJPatternsFrameworkCustomConfigurationFileName();
320 assertNotNull(name);
321 assertEquals(name, JPConstants.XMLConfigFilesConstants.CUSTOM_XML_FRAMEWORK_CONFIG_FILE_NAME);
322 JPatternsTestUtils.resetJVMProps();
323
324
325 System.setProperty(JPConstants.XMLConfigFilesConstants.CUSTOM_XML_FRAMEWORK_CONFIG_FILE_NAME_JVM_PARAM,
326 JPConstants.XMLConfigFilesConstants.CUSTOM_XML_FRAMEWORK_CONFIG_FILE_NAME + "_");
327 name = m_jpConfiguratorImpl.getJPatternsFrameworkCustomConfigurationFileName();
328 assertNotNull(name);
329 assertEquals(name, JPConstants.XMLConfigFilesConstants.CUSTOM_XML_FRAMEWORK_CONFIG_FILE_NAME + "_");
330
331 JPatternsTestUtils.resetJVMProps();
332 }
333 catch (Exception ex)
334 {
335 LoggingUtils.logException(LOG, ex, null, null);
336 fail("Exception should not occur for that case params" + ex.getMessage());
337 }
338 }
339
340
341
342
343
344
345
346
347 public void testGetJPatternsConsumerConfigurationFiles() throws Exception
348 {
349
350 try
351 {
352
353 JPatternsTestUtils.setJVMXmlParams(JPConfiguratorImplTest.class, false, Cases.LIST_OF_FILES_CASE1, null, false);
354 m_jpConfiguratorImpl.initConsumerConfiguration();
355 List<File> fileList = m_jpConfiguratorImpl.getJPatternsConsumerConfigurationFiles();
356 assertNotNull(fileList);
357 assertEquals(MagicNumbers.THREE, fileList.size());
358
359 JPatternsTestUtils.resetJVMXmlParams();
360 }
361 catch (Exception ex)
362 {
363 LoggingUtils.logException(LOG, ex, null, null);
364 fail("Exception should not occur for that case " + ex.getMessage());
365 }
366
367
368 JPatternsTestUtils.setJVMXmlParams(JPConfiguratorImplTest.class, false, Cases.LIST_OF_FILES_CASE2, null, false);
369 try
370 {
371 m_jpConfiguratorImpl.initConsumerConfiguration();
372 fail("Exception should have been occuried before this line.");
373 }
374 catch (Exception ex)
375 {
376 assertTrue (ex instanceof IllegalStateException);
377 }
378 finally
379 {
380 JPatternsTestUtils.resetJVMXmlParams();
381 }
382
383
384 try
385 {
386 JPatternsTestUtils.setJVMXmlParams(JPConfiguratorImplTest.class, false, Cases.LIST_OF_FILES_CASE3, null, false);
387 m_jpConfiguratorImpl.initConsumerConfiguration();
388 List<File> fileList2 = m_jpConfiguratorImpl.getJPatternsConsumerConfigurationFiles();
389 assertNotNull(fileList2);
390 assertEquals("count of consumer files in \'" + Cases.LIST_OF_FILES_CASE1 + "\' directory", MagicNumbers.FOUR, fileList2.size());
391 JPatternsTestUtils.resetJVMProps();
392 JPatternsTestUtils.resetJVMXmlParams();
393 }
394 catch (Exception ex)
395 {
396 LoggingUtils.logException(LOG, ex, null, null);
397 fail("Exception should not occur for that case " + ex.getMessage());
398 }
399 }
400
401
402
403
404
405
406
407
408 public void testJPConfiguratorImpl() throws Exception
409 {
410 assertNotNull(m_jpConfiguratorImpl);
411 }
412
413
414
415
416
417
418
419 public void testObtainJPatternsConfig() throws Exception
420 {
421
422 try
423 {
424 m_jpConfiguratorImpl.obtainJPatternsConfig(null);
425 fail("Exception should have been occuried before this line.");
426 }
427 catch (Exception ex)
428 {
429 assertTrue(ex instanceof IllegalArgumentException);
430 }
431
432 try
433 {
434 final String fullFileName =
435 ZmicerTestUtils.getFullTestDataFileName(JPConfiguratorImplTest.class, false, null, "jpatterns_framework.xml", true);
436 JPatternsConfigBean configBean =
437 m_jpConfiguratorImpl.obtainJPatternsConfig(fullFileName);
438 assertNotNull(configBean);
439 }
440 catch (Exception ex)
441 {
442 LoggingUtils.logException(LOG, ex, null, null);
443 fail("Exception should not occur for that case params" + ex.getMessage());
444 }
445
446 try
447 {
448 final String fullFileName =
449 ZmicerTestUtils.getFullTestDataFileName(JPConfiguratorImplTest.class, false, Cases.ALL_PROPS, "jpatterns_framework.xml", true);
450 assertNotNull(fullFileName);
451 assertNotNull(m_jpConfiguratorImpl.obtainJPatternsConfig(fullFileName));
452 }
453 catch (Exception ex)
454 {
455 LoggingUtils.logException(LOG, ex, null, null);
456 fail("Exception should not occur for that case " + ex.getMessage());
457 }
458 }
459
460
461
462
463
464
465
466 public void testDefaultJPatternsFrameworkConfigurationPresents() throws Exception
467 {
468
469 try
470 {
471 assertTrue(m_jpConfiguratorImpl.defaultJPatternsFrameworkConfigurationPresents());
472 }
473 catch (Exception ex)
474 {
475 LoggingUtils.logException(LOG, ex, null, null);
476 fail("Exception should not occur for that case params" + ex.getMessage());
477 }
478 }
479
480
481
482
483
484
485
486 public void testCustomJPatternsFrameworkConfigurationPresents() throws Exception
487 {
488
489 try
490 {
491 JPatternsTestUtils.setJVMPropsParams(JPConfiguratorImplTest.class, false, Cases.ALL_PROPS, null, null, true);
492 JPatternsTestUtils.setJVMXmlParams(JPConfiguratorImplTest.class, false, Cases.ALL_PROPS, null, false);
493 m_jpConfiguratorImpl.initConfiguration();
494 assertTrue(m_jpConfiguratorImpl.customJPatternsFrameworkConfigurationPresents());
495 JPatternsTestUtils.resetJVMProps();
496 JPatternsTestUtils.resetJVMXmlParams();
497 }
498 catch (Exception ex)
499 {
500 LoggingUtils.logException(LOG, ex, null, null);
501 fail("Exception should not occur for that case params" + ex.getMessage());
502 }
503 }
504
505
506
507
508
509
510
511 public void testObtainJPatternsConfigs() throws Exception
512 {
513
514 try
515 {
516 m_jpConfiguratorImpl.obtainJPatternsConfigs(null);
517 fail("Exception should have been occuried before this line.");
518 }
519 catch (Exception ex)
520 {
521 assertTrue(ex instanceof IllegalArgumentException);
522 }
523
524
525 try
526 {
527
528 final List<String> classPathesStrings = ClassPathUtils.getClassPathes();
529 if (null == classPathesStrings || classPathesStrings.isEmpty())
530 {
531 throw new IllegalStateException("The class path is not set correctly.");
532 }
533 classPathesStrings.add(ZmicerTestUtils.getFolderWithTestData());
534 final List<File> files = FileUtils.findFilesByREInClassPath(classPathesStrings, JPConstants.PATTERN);
535 assertNotNull(files);
536 final int filesCntr = files.size();
537 assertTrue(filesCntr > 0);
538 final List<JPatternsConfig> configs = m_jpConfiguratorImpl.obtainJPatternsConfigs(files);
539 assertNotNull(configs);
540 assertEquals(filesCntr, configs.size());
541 }
542 catch (Exception ex)
543 {
544 LoggingUtils.logException(LOG, ex, null, null);
545 fail("Exception should not occur for that case params" + ex.getMessage());
546 }
547 }
548
549
550
551
552
553
554
555 public void testMergeFrameworkConfigurations() throws Exception
556 {
557
558 try
559 {
560 JPatternsTestUtils.setJVMPropsParams(JPConfiguratorImplTest.class, false, Cases.ALL_PROPS, null, null, true);
561 JPatternsTestUtils.setJVMXmlParams(JPConfiguratorImplTest.class, false, Cases.ALL_PROPS, null, false);
562 m_jpConfiguratorImpl.initFrameworkConfiguration();
563 final JPatternsConfigsBean bean = m_jpConfiguratorImpl.getJPatternsFrameworkConfiguration();
564 assertNotNull(bean);
565 assertNotNull(bean.getListOfSectionItems());
566
567 assertFalse(bean.getListOfSectionItems().isEmpty());
568
569 assertNull(bean.getSection("NOT_DEFAULT_SCOPE", "JPatternsGlobalConfiguration"));
570 assertNull(bean.getBusinessItem("NOT_DEFAULT_SCOPE", "JPatternsGlobalConfiguration",
571 "NOT_DEFAULT_SCOPE", "JPatternsConfigurationFactory"));
572 assertNotNull(bean.getSection("JPConfiguratorImplTest", "GlobalSection1"));
573 JPatternsTestUtils.resetJVMProps();
574 JPatternsTestUtils.resetJVMXmlParams();
575 }
576 catch (Exception ex)
577 {
578 LoggingUtils.logException(LOG, ex, null, null);
579 fail("Exception should not occur for that case " + ex.getMessage());
580 }
581
582 try
583 {
584 System.setProperty(JPConstants.XMLConfigFilesConstants.DEFAULT_XML_FRAMEWORK_CONFIG_FILE_NAME_JVM_PARAM,
585 JPConstants.XMLConfigFilesConstants.DEFAULT_XML_FRAMEWORK_CONFIG_FILE_NAME + "_");
586 System.setProperty(JPConstants.XMLConfigFilesConstants.CUSTOM_XML_FRAMEWORK_CONFIG_FILE_NAME_JVM_PARAM,
587 JPConstants.XMLConfigFilesConstants.CUSTOM_XML_FRAMEWORK_CONFIG_FILE_NAME + "_");
588 m_jpConfiguratorImpl.initFrameworkConfiguration();
589
590 fail("Exception should have been occuried before this line.");
591 }
592 catch (Exception ex)
593 {
594 JPatternsTestUtils.resetJVMProps();
595 assertTrue(ex instanceof IllegalStateException);
596 }
597
598 try
599 {
600 JPatternsTestUtils.setJVMPropsParams(JPConfiguratorImplTest.class, false, Cases.CUSTOM_XML, null, null, true);
601 JPatternsTestUtils.setJVMXmlParams(JPConfiguratorImplTest.class, false, Cases.CUSTOM_XML, null, false);
602 JPConfiguratorImpl.setUseOnlyCustomFrameworkConfigIfPresent(true);
603 m_jpConfiguratorImpl.initFrameworkConfiguration();
604 final JPatternsConfigsBean bean = m_jpConfiguratorImpl.getJPatternsFrameworkConfiguration();
605 assertNotNull(bean);
606 assertNotNull(bean.getListOfSectionItems());
607 assertFalse(bean.getListOfSectionItems().isEmpty());
608
609 assertEquals(bean.getListOfSectionItems().size(), 1);
610
611 assertNotNull(bean.getSection("DEFAULT_SCOPE", "JPatternsGlobalConfiguration"));
612 assertNotNull(bean.getBusinessItem("DEFAULT_SCOPE", "JPatternsGlobalConfiguration",
613 "DEFAULT_SCOPE", "JPatternsConfigurationFactory"));
614 assertNull(bean.getSection("JPConfiguratorImplTest", "GlobalSection1"));
615 JPatternsTestUtils.resetJVMProps();
616 JPatternsTestUtils.resetJVMXmlParams();
617 }
618 catch (Exception ex)
619 {
620 LoggingUtils.logException(LOG, ex, null, null);
621 fail("Exception should not occur for that case " + ex.getMessage());
622 }
623
624 try
625 {
626 JPatternsTestUtils.setJVMPropsParams(JPConfiguratorImplTest.class, false, Cases.CUSTOM_XML, null, null, true);
627 JPatternsTestUtils.setJVMXmlParams(JPConfiguratorImplTest.class, false, Cases.CUSTOM_XML, null, false);
628 JPConfiguratorImpl.setUseOnlyCustomFrameworkConfigIfPresent(false);
629 m_jpConfiguratorImpl.initFrameworkConfiguration();
630 final JPatternsConfigsBean bean = m_jpConfiguratorImpl.getJPatternsFrameworkConfiguration();
631 assertNotNull(bean);
632 assertNotNull(bean.getListOfSectionItems());
633 assertFalse(bean.getListOfSectionItems().isEmpty());
634
635 assertTrue(bean.getListOfSectionItems().size() > 1);
636
637 assertNotNull(bean.getSection("DEFAULT_SCOPE", "JPatternsGlobalConfiguration"));
638 assertNotNull(bean.getBusinessItem("DEFAULT_SCOPE", "JPatternsGlobalConfiguration",
639 "DEFAULT_SCOPE", "JPatternsConfigurationFactory"));
640 assertNotNull(bean.getSection("JPConfiguratorImplTest", "GlobalSection1"));
641 JPatternsTestUtils.resetJVMProps();
642 JPatternsTestUtils.resetJVMXmlParams();
643 }
644 catch (Exception ex)
645 {
646 LoggingUtils.logException(LOG, ex, null, null);
647 fail("Exception should not occur for that case " + ex.getMessage());
648 }
649 }
650
651
652
653
654
655
656
657 public void testInitFrameworkConfiguration() throws Exception
658 {
659
660 try
661 {
662 JPatternsTestUtils.setJVMPropsParams(JPConfiguratorImplTest.class, false, Cases.ALL_PROPS, null, null, true);
663 JPatternsTestUtils.setJVMXmlParams(JPConfiguratorImplTest.class, false, Cases.ALL_PROPS, null, false);
664 m_jpConfiguratorImpl.initFrameworkConfiguration();
665 final JPatternsConfigsBean bean = m_jpConfiguratorImpl.getJPatternsFrameworkConfiguration();
666 assertNotNull(bean);
667 JPatternsTestUtils.resetJVMProps();
668 JPatternsTestUtils.resetJVMXmlParams();
669 }
670 catch (Exception ex)
671 {
672 LoggingUtils.logException(LOG, ex, null, null);
673 fail("Exception should not occur for that case " + ex.getMessage());
674 }
675 }
676 }