This repository has been archived by the owner on Mar 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
626528a
commit ed31a19
Showing
4 changed files
with
140 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
_include("pages/includeAll.js"); | ||
|
||
$Index.goTo(); | ||
|
||
_assertEqual(1266015600000, new Date(2010,1,13).getTime()); | ||
_assertEqual(1263337200000, new Date("2010,1,13").getTime()); | ||
_assertEqual(1263337200000, new Date(["2010","1","13"]).getTime()); | ||
_assertEqual(1263337200000, new Date([2010,1,13]).getTime()); | ||
_assertTrue(1266015600000 <= new Date(2010,1,13).getTime()); | ||
|
||
var $date1=new Date(2010,1,13); | ||
|
||
var $dateText=" 02.02.2010 - 13.01.2010".split("-")[1].split("."); | ||
$dateText = $dateText.reverse(); | ||
var $date2= new Date($dateText[0],$dateText[1],$dateText[2]); | ||
_assertTrue($date1.getTime()<=$date2.getTime()); | ||
|
105 changes: 105 additions & 0 deletions
105
sahi-test-webapp/src/test/java/com/headissue/sahi/integration/SahiIntegrationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
package com.headissue.sahi.integration; | ||
|
||
import com.headissue.demopages.DemoPageServer; | ||
import net.sf.sahi.Proxy; | ||
import net.sf.sahi.command.Suite; | ||
import net.sf.sahi.config.Configuration; | ||
import net.sf.sahi.report.HtmlReporter; | ||
import net.sf.sahi.report.JunitReporter; | ||
import net.sf.sahi.session.Session; | ||
import net.sf.sahi.session.Status; | ||
import net.sf.sahi.test.SahiTestSuite; | ||
import net.sf.sahi.util.BrowserType; | ||
import net.sf.sahi.util.BrowserTypesLoader; | ||
import net.sf.sahi.util.Utils; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
|
||
import java.net.URISyntaxException; | ||
import java.util.Date; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
/** | ||
* Created by wormi on 10/06/14. | ||
*/ | ||
public class SahiIntegrationTest { | ||
|
||
final protected Thread server = new Thread(new DemoPageServer()); | ||
final protected Proxy proxy = new Proxy(); | ||
final protected String base = "http://localhost:7733"; | ||
final protected boolean isSingleSession = true; | ||
final protected int threads = 5; | ||
|
||
protected Session session; | ||
protected BrowserType browserType; | ||
protected String userdata; | ||
protected BrowserTypesLoader browserLoader; | ||
|
||
private void createSession() { | ||
// more random, no while loop | ||
String sessionId = random(); | ||
if (Session.hasInstance(sessionId)) sessionId = random(); | ||
session=Session.getInstance(sessionId); | ||
} | ||
|
||
private static String random() { | ||
double d= Math.random(); | ||
String number = String.valueOf(d); | ||
number = number.substring(number.indexOf( "." ) + 1); | ||
return number; | ||
} | ||
|
||
; | ||
|
||
private void addCertToFirefox(String userdata) { | ||
try { | ||
Utils.executeCommand(Utils.getCommandTokens("certutil -A -n Sahi_Root -t \"C,,\" -i " + userdata + "/certs/ca.crt -d " + userdata + "/browser/ff/profiles/sahi0")); | ||
} catch (Exception e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
protected void runSuite(String suitePath) { | ||
createSession(); | ||
SahiTestSuite suite = new Suite().prepareSuite(suitePath, base, browserType.path(), session.id(), browserType.options(), browserType.processName(), ("" + threads), browserType.useSystemProxy(), isSingleSession, null); | ||
Date d = new Date(); | ||
suite.addReporter(new JunitReporter("./target/junitReporter/")); | ||
suite.addReporter(new HtmlReporter("./target/htmlReporter/")); | ||
suite.loadScripts(); | ||
suite.run(); | ||
// to make sure the status is set | ||
suite.finishCallBack(); | ||
assertEquals(Status.SUCCESS, session.getStatus()); | ||
} | ||
|
||
protected String getSuitePath(String resource) { | ||
String suitePath; | ||
try { | ||
suitePath = this.getClass().getResource(resource).toURI().getPath(); | ||
} catch (URISyntaxException e) { | ||
throw new RuntimeException(e); | ||
} | ||
return suitePath; | ||
} | ||
|
||
|
||
|
||
@Before | ||
public void setup() throws Exception { | ||
Configuration.init("../sahi-core", "./userdata"); | ||
browserLoader = new BrowserTypesLoader(); | ||
browserType = browserLoader.getBrowserType("firefox"); | ||
userdata = Configuration.getUserDataDir(); | ||
proxy.start(true); | ||
server.start(); | ||
addCertToFirefox(userdata); | ||
} | ||
|
||
@After | ||
public void teardown() throws Exception { | ||
server.interrupt(); | ||
proxy.stop(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters