Skip to content

Commit

Permalink
Merge pull request #634 from terasolunaorg/issues/605_recognize_ap_se…
Browse files Browse the repository at this point in the history
…rver_5.0.x

[5.0.x]recognize ap server #605
  • Loading branch information
yoshikawaa authored Jun 13, 2017
2 parents 3bbd5f3 + 835d4e8 commit 43ac142
Show file tree
Hide file tree
Showing 13 changed files with 112 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
app.redirect.allowed.externalUrl=http://terasolunaorg.github.io

application.server.name=jboss
application.server.version=6
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
app.redirect.allowed.externalUrl=http://terasolunaorg.github.io

application.server.name=tomcat
application.server.version=7
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
app.redirect.allowed.externalUrl=http://terasolunaorg.github.io

application.server.name=tomcat
application.server.version=7
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
app.redirect.allowed.externalUrl=http://terasolunaorg.github.io

application.server.name=tomcat
application.server.version=8.0
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
app.redirect.allowed.externalUrl=http://terasolunaorg.github.io

application.server.name=tomcat
application.server.version=8.0
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
app.redirect.allowed.externalUrl=http://terasolunaorg.github.io

application.server.name=weblogic
application.server.version=12
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
app.redirect.allowed.externalUrl=http://terasolunaorg.github.io

## 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,26 @@
/*
* Copyright (C) 2013-2017 NTT DATA Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
package org.terasoluna.gfw.functionaltest.app;

/**
* Enumeration class for identifying application server.
* <p>
* If application server name is not set in application-env.properties, {@code UNKNOWN} is set.
* </p>
*/
public enum ApServerName {
UNKNOWN, JBOSS, TOMCAT, WEBLOGIC
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,17 @@
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.
*/
public class WebDriverOperations {

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

protected final WebDriver webDriver;

protected long defaultTimeoutSecForImplicitlyWait = 5;
Expand Down Expand Up @@ -76,4 +81,29 @@ 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 = webDriver.findElement(By.id("apServerName"))
.getText().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 webDriver.findElement(By.id("apServerVersion")).getText();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void test01_01_createDefaultXTrackMDC() {

// cut x-Track MDC
String targetMdc = driver.findElement(By.id("xTrackMDC")).getText();
String footerMdc = driver.findElement(By.cssSelector("p")).getText();
String footerMdc = driver.findElement(By.id("xtrack")).getText();
footerMdc = footerMdc.substring(footerMdc.indexOf(":") + 1, footerMdc
.indexOf(":") + 33);
// check default x-Track MDC
Expand All @@ -67,7 +67,7 @@ public void test01_02_createCustomXTrackMDC() {

// cut x-Track MDC
String targetMdc = driver.findElement(By.id("xTrackMDC")).getText();
String footerMdc = driver.findElement(By.cssSelector("p")).getText();
String footerMdc = driver.findElement(By.id("xtrack")).getText();
footerMdc = footerMdc.substring(footerMdc.indexOf(":") + 1, footerMdc
.indexOf(":") + 33);
// check custom x-Track MDC
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (C) 2013-2017 NTT DATA Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
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 @@ -15,6 +15,8 @@
<context:property-placeholder
location="classpath*:/META-INF/spring/*.properties" />

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

<bean class="org.dozer.spring.DozerBeanMapperFactoryBean">
<property name="mappingFiles"
value="classpath*:/META-INF/dozer/**/*-mapping.xml" />
Expand Down
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 43ac142

Please sign in to comment.