/testsuite/domain/src/test/java/org/jboss/as/test/integration/domain/suites/DomainTestSuite.java

https://github.com/smcgowan/wildfly · Java · 99 lines · 59 code · 12 blank · 28 comment · 5 complexity · 226ab08e413714e561b3f9665e949906 MD5 · raw file

  1. /*
  2. * JBoss, Home of Professional Open Source.
  3. * Copyright 2011, Red Hat, Inc., and individual contributors
  4. * as indicated by the @author tags. See the copyright.txt file in the
  5. * distribution for a full listing of individual contributors.
  6. *
  7. * This is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU Lesser General Public License as
  9. * published by the Free Software Foundation; either version 2.1 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This software is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this software; if not, write to the Free
  19. * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  20. * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  21. */
  22. package org.jboss.as.test.integration.domain.suites;
  23. import org.jboss.as.test.integration.domain.DomainTestSupport;
  24. import org.junit.AfterClass;
  25. import org.junit.BeforeClass;
  26. import org.junit.runner.RunWith;
  27. import org.junit.runners.Suite;
  28. /**
  29. * Simple {@code Suite} test wrapper to start the domain only once for multiple
  30. * test cases using the same domain configuration.
  31. *
  32. * @author Emanuel Muckenhuber
  33. */
  34. @RunWith(Suite.class)
  35. @Suite.SuiteClasses ({
  36. CoreResourceManagementTestCase.class,
  37. ManagementReadsTestCase.class,
  38. DeploymentManagementTestCase.class,
  39. ServerManagementTestCase.class,
  40. ManagementAccessTestCase.class,
  41. ManagementClientContentTestCase.class,
  42. ValidateOperationOperationTestCase.class
  43. })
  44. public class DomainTestSuite {
  45. private static final DomainTestSupport.Configuration CONFIGURATION;
  46. private static boolean initializedLocally = false;
  47. private static volatile DomainTestSupport support;
  48. static {
  49. CONFIGURATION = DomainTestSupport.Configuration.create("domain-configs/domain-standard.xml", "host-configs/host-master.xml", "host-configs/host-slave.xml");
  50. }
  51. static synchronized DomainTestSupport createSupport(final String testName) {
  52. if(support == null) {
  53. start(testName);
  54. }
  55. return support;
  56. }
  57. static synchronized void stopSupport() {
  58. if(! initializedLocally) {
  59. stop();
  60. }
  61. }
  62. private synchronized static void start(final String name) {
  63. try {
  64. final DomainTestSupport testSupport = new DomainTestSupport(name, CONFIGURATION);
  65. // Start!
  66. testSupport.start();
  67. support = testSupport;
  68. } catch (Exception e) {
  69. throw new RuntimeException(e);
  70. }
  71. }
  72. private synchronized static void stop() {
  73. if(support != null) {
  74. support.stop();
  75. support = null;
  76. }
  77. }
  78. @BeforeClass
  79. public synchronized static void beforeClass() {
  80. initializedLocally = true;
  81. start(DomainTestSuite.class.getSimpleName());
  82. }
  83. @AfterClass
  84. public synchronized static void afterClass() {
  85. stop();
  86. }
  87. }