/wls-common/src/main/java/org/jboss/arquillian/container/wls/CommonManagedWebLogicConfiguration.java

https://github.com/arquillian/arquillian-container-wls · Java · 185 lines · 99 code · 24 blank · 62 comment · 12 complexity · 14afd052ce2c5a36a322ed8540f21b09 MD5 · raw file

  1. /*
  2. * JBoss, Home of Professional Open Source
  3. * Copyright 2011, Red Hat Middleware LLC, and individual contributors
  4. * by the @authors tag. See the copyright.txt in the distribution for a
  5. * full listing of individual contributors.
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. package org.jboss.arquillian.container.wls;
  18. import org.jboss.arquillian.container.spi.ConfigurationException;
  19. /**
  20. * Arquillian properties for the managed WebLogic container. Properties derived from the
  21. * {@link CommonWebLogicConfiguration} class are added to, here.
  22. *
  23. * @author Vineet Reynolds
  24. */
  25. public class CommonManagedWebLogicConfiguration extends CommonWebLogicConfiguration {
  26. private static final String DEFAULT_WIN_STARTUP_SCRIPT = "bin\\\\startWebLogic.cmd";
  27. private static final String DEFAULT_LINUX_STARTUP_SCRIPT = "./bin/startWebLogic.sh";
  28. private static final String DEFAULT_WIN_SHUTDOWN_SCRIPT = "bin\\\\stopWebLogic.cmd";
  29. private static final String DEFAULT_LINUX_SHUTDOWN_SCRIPT = "./bin/stopWebLogic.sh";
  30. private String middlewareHome = System.getenv("MW_HOME");
  31. private String domainDirectory;
  32. private String jvmOptions;
  33. private int timeout = 60;
  34. private boolean outputToConsole = false;
  35. private boolean allowConnectingToRunningServer = false;
  36. private String startServerScript;
  37. private String stopServerScript;
  38. public CommonManagedWebLogicConfiguration() {
  39. super();
  40. }
  41. @Override
  42. public void validate() throws ConfigurationException {
  43. Validate.directoryExists(middlewareHome,
  44. "The middlewareHome resolved to " + middlewareHome +
  45. " and could not be located. Verify the property in arquillian.xml");
  46. Validate.directoryExists(domainDirectory,
  47. "The domainDirectory resolved to " + domainDirectory +
  48. " and could not be located. Verify the property in arquillian.xml");
  49. if (startServerScript != null && startServerScript.length() > 0) {
  50. Validate.isValidFile(startServerScript, "The startServerScript resolved to " + startServerScript
  51. + " and could not be located. Verify the property in arquillian.xml");
  52. } else {
  53. String os = System.getProperty("os.name").toLowerCase();
  54. if (os.startsWith("windows")) {
  55. startServerScript = DEFAULT_WIN_STARTUP_SCRIPT;
  56. } else {
  57. startServerScript = DEFAULT_LINUX_STARTUP_SCRIPT;
  58. }
  59. }
  60. if (stopServerScript != null && stopServerScript.length() > 0) {
  61. Validate.isValidFile(stopServerScript, "The stopServerScript resolved to " + stopServerScript
  62. + " and could not be located. Verify the property in arquillian.xml");
  63. } else {
  64. String os = System.getProperty("os.name").toLowerCase();
  65. if (os.startsWith("windows")) {
  66. stopServerScript = DEFAULT_WIN_SHUTDOWN_SCRIPT;
  67. } else {
  68. stopServerScript = DEFAULT_LINUX_SHUTDOWN_SCRIPT;
  69. }
  70. }
  71. super.validate();
  72. }
  73. public String getMiddlewareHome() {
  74. return middlewareHome;
  75. }
  76. /**
  77. * @param middlewareHome
  78. * The directory representing the Oracle Middleware Home. Defaults to the MW_HOME environment
  79. * variable.
  80. */
  81. public void setMiddlewareHome(String middlewareHome) {
  82. this.middlewareHome = middlewareHome;
  83. }
  84. public String getDomainDirectory() {
  85. return domainDirectory;
  86. }
  87. /**
  88. * @param domainDirectory
  89. * The WebLogic Server domain directory.
  90. */
  91. public void setDomainDirectory(String domainDirectory) {
  92. this.domainDirectory = domainDirectory;
  93. }
  94. public String getJvmOptions() {
  95. return jvmOptions;
  96. }
  97. /**
  98. * @param jvmOptions
  99. * Used to set the JAVA_OPTIONS environment variable for the shell environment. The environment variable
  100. * can then be used in the script used to start the server.
  101. */
  102. public void setJvmOptions(String jvmOptions) {
  103. this.jvmOptions = jvmOptions;
  104. }
  105. public int getTimeout() {
  106. return timeout;
  107. }
  108. /**
  109. * @param timeout
  110. * The duration in number of seconds, by which the startup and shutdown script should complete. Defaults to
  111. * 60. If the server is not detected to have started or shutdown by this interval, the container action is deemed
  112. * to
  113. * have failed.
  114. */
  115. public void setTimeout(int timeout) {
  116. this.timeout = timeout;
  117. }
  118. public boolean isOutputToConsole() {
  119. return outputToConsole;
  120. }
  121. /**
  122. * @param outputToConsole
  123. * Whether the output from the execution of the shell scripts should be logged to the console.
  124. */
  125. public void setOutputToConsole(boolean outputToConsole) {
  126. this.outputToConsole = outputToConsole;
  127. }
  128. public boolean isAllowConnectingToRunningServer() {
  129. return allowConnectingToRunningServer;
  130. }
  131. /**
  132. * @param allowConnectingToRunningServer
  133. * Whether Arquillian should be allowed to connect and run tests in an already running
  134. * WebLogic Server instance.
  135. */
  136. public void setAllowConnectingToRunningServer(boolean allowConnectingToRunningServer) {
  137. this.allowConnectingToRunningServer = allowConnectingToRunningServer;
  138. }
  139. public String getStartServerScript() {
  140. return startServerScript;
  141. }
  142. /**
  143. * @param startServerScript
  144. * The script used to start the WebLogic Server instance. Defaults to the startWebLogic script in
  145. * the bin sub-directory of the domain home.
  146. */
  147. public void setStartServerScript(String startServerScript) {
  148. this.startServerScript = startServerScript;
  149. }
  150. public String getStopServerScript() {
  151. return stopServerScript;
  152. }
  153. /**
  154. * @param stopServerScript
  155. * The script used to stop the WebLogic Server instance. Defaults to the stopWebLogic script in the
  156. * bin sub-directory of the domain home.
  157. */
  158. public void setStopServerScript(String stopServerScript) {
  159. this.stopServerScript = stopServerScript;
  160. }
  161. }