Skip to content

Commit

Permalink
LPS-43702
Browse files Browse the repository at this point in the history
  • Loading branch information
kwanghlee authored and brianchandotcom committed Jan 31, 2014
1 parent 2bda6f2 commit 435fdeb
Show file tree
Hide file tree
Showing 8 changed files with 144 additions and 0 deletions.
70 changes: 70 additions & 0 deletions build-test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,44 @@ create database lportal2 character set utf8;</echo>
</if>
</target>

<target name="change-system-time">
<tstamp>
<format property="future.time" pattern="hh:mm" offset="${hours}" unit="hour" />
</tstamp>

<echo message="Add hours: ${hours}" />
<echo message="current time: ${future.time}" />

<exec executable="/bin/sh" os="${os.unix}">
<arg line="-c date +%T -s ${future.time}" />
</exec>

<exec executable="cmd.exe" os="${os.windows}">
<arg line="/c Time ${future.time}" />
</exec>
</target>

<target name="change-system-time-to-default">
<tstamp>
<format property="current.time" pattern="hh:mm" />
</tstamp>

<echo message="Add hours: ${hours}" />
<echo message="current time: ${current.time}" />

<exec executable="/bin/sh" os="${os.unix}">
<arg line="-c apt-get install ntpdate" />
</exec>

<exec executable="/bin/sh" os="${os.unix}">
<arg line="-c sudo ntpdate pool.ntp.org" />
</exec>

<exec executable="cmd.exe" os="${os.windows}">
<arg line="/c w32tm /resync" />
</exec>
</target>

<target name="clean-up-logs">
<delete file="log" />
<delete file="portal-web/test-ant-scripts/log" />
Expand Down Expand Up @@ -2524,6 +2562,38 @@ custom.sql.function.isnotnull=CONVERT(VARCHAR,?) IS NOT NULL</echo>
</if>
</target>

<target name="shutdown-appserver">
<var name="simple.server.dir" value="${app.server.tomcat.dir}" />
<var name="simple.server.bin.dir" value="${app.server.tomcat.bin.dir}" />
<var name="simple.server.stop.executable" value="shutdown${file.suffix.bat}" />
<var name="simple.server.stop.executable.arg.line" value="" />

<if>
<contains string="${simple.server.dir}" substring="tomcat" />
<then>
<exec dir="${simple.server.bin.dir}" executable="${simple.server.stop.executable}" resolveexecutable="true">
<arg line="${simple.server.stop.executable.arg.line}" />
</exec>
</then>
</if>
</target>

<target name="startup-appserver">
<var name="simple.server.dir" value="${app.server.tomcat.dir}" />
<var name="simple.server.bin.dir" value="${app.server.tomcat.bin.dir}" />
<var name="simple.server.start.executable" value="catalina${file.suffix.bat}" />
<var name="simple.server.start.executable.arg.line" value="run" />

<if>
<contains string="${simple.server.dir}" substring="tomcat" />
<then>
<exec dir="${simple.server.bin.dir}" executable="${simple.server.start.executable}" resolveexecutable="true">
<arg line="${simple.server.start.executable.arg.line}" />
</exec>
</then>
</if>
</target>

<target name="start-chrome-driver">
<if>
<not>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,13 @@ public void clickAtAndWait(String locator, String coordString) {
super.waitForPageToLoad("30000");
}

@Override
public void commandLineAntTarget(String fileName, String target)
throws Exception {

LiferaySeleniumHelper.commandLineAntTarget(this, fileName, target);
}

@Override
public void connectToEmailAccount(String emailAddress, String emailPassword)
throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,13 @@ public void clickAtAndWait(String locator, String coordString) {
super.waitForPageToLoad("30000");
}

@Override
public void commandLineAntTarget(String fileName, String target)
throws Exception {

LiferaySeleniumHelper.commandLineAntTarget(this, fileName, target);
}

@Override
public void connectToEmailAccount(String emailAddress, String emailPassword)
throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ public void assertSelectedLabel(String selectLocator, String pattern)

public void clickAtAndWait(String locator, String coordString);

public void commandLineAntTarget(String fileName, String target)
throws Exception;

public void connectToEmailAccount(String emailAddress, String emailPassword)
throws Exception;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.HtmlUtil;
import com.liferay.portal.kernel.util.LocaleUtil;
import com.liferay.portal.kernel.util.OSDetector;
import com.liferay.portal.kernel.util.StringUtil;
import com.liferay.portal.kernel.xml.Document;
import com.liferay.portal.kernel.xml.Element;
Expand Down Expand Up @@ -355,6 +356,33 @@ public static void assertVisible(
}
}

public static void commandLineAntTarget(
LiferaySelenium liferaySelenium, String fileName, String target)
throws Exception {

Runtime runtime = Runtime.getRuntime();

String projectDir = liferaySelenium.getProjectDir();

if (!OSDetector.isWindows()) {
projectDir = StringUtil.replace(projectDir, "\\", "//");
runtime.exec("bash -c cd " + projectDir);
runtime.exec("bash -c ant -f " + fileName + " " + target);
runtime.exec("bash -c ant -f " + fileName + " " + target);
}
else {
runtime.exec("cmd /c cd " + projectDir);
runtime.exec("cmd /c ant -f " + fileName + " " + target);
}

if (target.contains("startup")) {
Thread.sleep(80000);
}
else {
Thread.sleep(15000);
}
}

public static void connectToEmailAccount(
String emailAddress, String emailPassword)
throws Exception {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<definition component-name="portal-tools">
<command name="changeSystemTime" priority="5">
<var name="hours" value="3" />

<execute action="BaseLiferay#commandLineAntTarget" locator1="build-test.xml" value1="change-system-time -Dhours=${hours}" />

<execute macro="User#firstLoginPG" />

<execute action="BaseLiferay#commandLineAntTarget" locator1="build-test.xml" value1="change-system-time-to-default" />
</command>

<command name="shutDownStartUpAppServer" priority="5">
<execute action="BaseLiferay#commandLineAntTarget" locator1="build-test.xml" value1="shutdown-appserver" />
<execute action="BaseLiferay#commandLineAntTarget" locator1="build-test.xml" value1="startup-appserver" />

<execute macro="User#firstLoginPG" />
</command>
</definition>
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@
</default>
</command>

<command name="commandLineAntTarget">
<default>
<execute function="CommandLineAntTarget#commandLineAntTarget" />
</default>
</command>

<command name="confirm">
<default>
<execute function="Confirm#assertConfirmation" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<definition>
<command name="commandLineAntTarget">
<execute selenium="commandLineAntTarget" />
</command>
</definition>

0 comments on commit 435fdeb

Please sign in to comment.