Skip to content

Commit

Permalink
Add mechanism to recognize Application Server #605
Browse files Browse the repository at this point in the history
  • Loading branch information
btyanagawamg committed Mar 1, 2017
1 parent 8b4562c commit c184140
Show file tree
Hide file tree
Showing 19 changed files with 101 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
app.redirect.allowed.externalUrl=http://terasolunaorg.github.io
app.redirect.pageTitle.404Error=Page Not Found
application.server.name=interstage
application.server.version=11
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
app.redirect.allowed.externalUrl=http://terasolunaorg.github.io
app.redirect.pageTitle.404Error=Page Not Found
application.server.name=jboss
application.server.version=6
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
app.redirect.allowed.externalUrl=http://terasolunaorg.github.io
app.redirect.pageTitle.404Error=Page Not Found
application.server.name=jboss
application.server.version=7
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
app.redirect.allowed.externalUrl=http://terasolunaorg.github.io
app.redirect.pageTitle.404Error=Page Not Found
application.server.name=tomcat
application.server.version=7
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
app.redirect.allowed.externalUrl=http://terasolunaorg.github.io
app.redirect.pageTitle.404Error=Page Not Found
application.server.name=tomcat
application.server.version=7
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
app.redirect.allowed.externalUrl=http://terasolunaorg.github.io
app.redirect.pageTitle.404Error=Page Not Found
application.server.name=tomcat
application.server.version=8.0
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
app.redirect.allowed.externalUrl=http://terasolunaorg.github.io
app.redirect.pageTitle.404Error=Page Not Found
application.server.name=tomcat
application.server.version=8.0
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
app.redirect.allowed.externalUrl=http://terasolunaorg.github.io
app.redirect.pageTitle.404Error=Page Not Found
application.server.name=tomcat
application.server.version=8.5
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
app.redirect.allowed.externalUrl=http://terasolunaorg.github.io
app.redirect.pageTitle.404Error=Page Not Found
application.server.name=tomcat
application.server.version=8.5
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
app.redirect.allowed.externalUrl=http://terasolunaorg.github.io
app.redirect.pageTitle.404Error=Page Not Found
application.server.name=weblogic
application.server.version=12
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
app.redirect.allowed.externalUrl=http://terasolunaorg.github.io
app.redirect.pageTitle.404Error=Page Not Found
application.server.name=webotx
application.server.version=9
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
app.redirect.allowed.externalUrl=http://terasolunaorg.github.io
app.redirect.pageTitle.404Error=System Error...
application.server.name=webspherelp
application.server.version=16
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
app.redirect.allowed.externalUrl=http://terasolunaorg.github.io
app.redirect.pageTitle.404Error=System Error...
application.server.name=webspheretr
application.server.version=9
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
app.redirect.allowed.externalUrl=http://terasolunaorg.github.io
app.redirect.pageTitle.404Error=Page Not Found
## application server name and version properties are used in order to
## change the assertions in test which depends on application server.
## when the new profile is added, set appropriate values.
application.server.name=tomcat
application.server.version=8.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.terasoluna.gfw.functionaltest.app;

/**
* Enumeration class for identifying application server.
* <p>
* If application server name is not set in application.env.properties, <br/>
* UNKNOWN is set.
* </p>
*/
public enum ApServerName {
UNKNOWN, INTERSTAGE, JBOSS, TOMCAT, WEBLOGIC, WEBOTX, WEBSPHERELP, WEBSPHERETR
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Class that provides a (logic for WebDriver) browser operation.
Expand All @@ -30,6 +32,8 @@ public class WebDriverOperations {

protected long defaultTimeoutSecForImplicitlyWait = 5;

private static final Logger logger = LoggerFactory.getLogger(WebDriverOperations.class);

public WebDriverOperations(WebDriver webDriver) {
this.webDriver = webDriver;
}
Expand All @@ -43,6 +47,15 @@ public void setDefaultTimeoutForImplicitlyWait(
this.defaultTimeoutSecForImplicitlyWait = defaultTimeoutSecForImplicitlyWait;
}

/**
* Get the text (display value) set for the specified element.
* @param by Identifier to look for elements
* @return And returns the text (display value)
*/
public String getText(By by) {
return webDriver.findElement(by).getText();
}

/**
* Check the specified element exists.
* @param by Identifier to look for elements
Expand Down Expand Up @@ -76,4 +89,27 @@ public void setDefaultTimeoutForImplicitlyWait() {
public void setTimeoutForImplicitlyWait(long timeout, TimeUnit timeUnit) {
webDriver.manage().timeouts().implicitlyWait(timeout, timeUnit);
}

/**
* Get application server name.
* @return application server name
*/
public ApServerName getApServerName() {
String serverName = getText(By.id("apServerName")).toUpperCase();
try {
return ApServerName.valueOf(serverName);
} catch (IllegalArgumentException e) {
logger.warn("Unkown application server name:{} is detected.", serverName);
// If server name not defined in the ApServerName class, set it to UNKNOWN.
return ApServerName.UNKNOWN;
}
}

/**
* Get application server version.
* @return application server version
*/
public String getApServerVersion() {
return getText(By.id("apServerVersion"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.terasoluna.gfw.functionaltest.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

/**
* Class that registers the value defined in application-env.properties of each profile in environment.
* <p>
* Passes application server information to WebDriver through JSP so that asserts can be changed for each application server.
* </p>
*/
@Configuration
@PropertySource("classpath:/META-INF/spring/application-env.properties")
public class PropertySourceConfig {
}
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,6 @@
<property name="exceptionLogger" ref="variationExceptionLogger" />
</bean>

<context:component-scan base-package="org.terasoluna.gfw.functionaltest.config" />

</beans>
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
<tiles:insertAttribute name="header" />
<tiles:insertAttribute name="body" />
<hr>
<p align="right">
Application Server :
<span id="apServerName"><spring:eval expression="@environment.getProperty('application.server.name')"/></span>
<span id="apServerVersion"><spring:eval expression="@environment.getProperty('application.server.version')"/></span>
</p>
<p style="text-align: center; background: #e5eCf9;">
<spring:message code="copyright" htmlEscape="false" />
<span id="xtrack">(X-Track:${f:h(requestScope["X-Track"])})</span></p>
Expand Down

0 comments on commit c184140

Please sign in to comment.