-
Notifications
You must be signed in to change notification settings - Fork 235
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added tests for FileExtractor , ConfigParser , AuthenticationHelper, SauceConfigReader, FileDownloader and ArtifactDetails. - Updated .gitattributes file
- Loading branch information
Yuvha Secaran
authored and
Doug Simmons
committed
Jun 2, 2015
1 parent
f5cb5e1
commit ecb8519
Showing
11 changed files
with
302 additions
and
1 deletion.
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
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
87 changes: 87 additions & 0 deletions
87
server/src/test/java/com/paypal/selion/grid/FileExtractorTest.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,87 @@ | ||
/*-------------------------------------------------------------------------------------------------------------------*\ | ||
| Copyright (C) 2015 eBay Software Foundation | | ||
| | | ||
| 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 com.paypal.selion.grid; | ||
|
||
import static org.testng.Assert.assertTrue; | ||
|
||
import java.io.File; | ||
import java.util.List; | ||
|
||
import org.apache.commons.lang.SystemUtils; | ||
import org.openqa.selenium.Platform; | ||
import org.testng.annotations.AfterMethod; | ||
import org.testng.annotations.BeforeClass; | ||
import org.testng.annotations.BeforeMethod; | ||
import org.testng.annotations.Test; | ||
|
||
import com.paypal.selion.pojos.SeLionGridConstants; | ||
|
||
public class FileExtractorTest { | ||
File extractedFile = null; | ||
File tarFile = null; | ||
|
||
@BeforeClass | ||
public void mockTestPaths() { | ||
SeLionGridConstants.SELION_HOME_DIR = SystemUtils.USER_DIR + "/"; | ||
tarFile = new File(SeLionGridConstants.SELION_HOME_DIR | ||
+ "src/test/resources/archives/DummyBz2Archive.tar"); | ||
} | ||
|
||
@BeforeMethod | ||
public void initExtractedFile(){ | ||
extractedFile = new File(SeLionGridConstants.SELION_HOME_DIR + getExtractedFileName()); | ||
} | ||
|
||
@Test | ||
public void testExtractingZip() { | ||
List<String> files = FileExtractor.extractArchive(SeLionGridConstants.SELION_HOME_DIR | ||
+ "src/test/resources/archives/DummyArchive.zip"); | ||
assertTrue(extractedFile.exists()); | ||
assertTrue(files.size() == 1); | ||
} | ||
|
||
@Test | ||
public void testExtractingBzip2() { | ||
List<String> files = FileExtractor.extractArchive(SeLionGridConstants.SELION_HOME_DIR | ||
+ "src/test/resources/archives/DummyBz2Archive.tar.bz2"); | ||
assertTrue(extractedFile.exists()); | ||
assertTrue(tarFile.exists()); | ||
assertTrue(files.size() == 2); | ||
} | ||
|
||
@AfterMethod | ||
public void cleanExtractedFiles(){ | ||
extractedFile.delete(); | ||
if(tarFile.exists()){ | ||
tarFile.delete(); | ||
} | ||
} | ||
|
||
private String getExtractedFileName() { | ||
String fileName = null; | ||
switch (Platform.getCurrent()) { | ||
case LINUX: | ||
case MAC: | ||
case UNIX: | ||
fileName = "phantomjs"; | ||
break; | ||
default: | ||
fileName = "phantomjs.exe"; | ||
break; | ||
} | ||
return fileName; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
server/src/test/java/com/paypal/selion/pojos/ArtifactDetailsTest.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,30 @@ | ||
package com.paypal.selion.pojos; | ||
|
||
import java.io.File; | ||
import java.io.FileNotFoundException; | ||
import java.util.List; | ||
|
||
import org.testng.annotations.Test; | ||
import static org.testng.Assert.assertTrue; | ||
import static org.testng.Assert.assertEquals; | ||
import static org.testng.Assert.assertNotNull; | ||
|
||
import com.paypal.selion.pojos.ArtifactDetails.URLChecksumEntity; | ||
|
||
public class ArtifactDetailsTest { | ||
@Test | ||
public void testGetArtifactDetails() throws FileNotFoundException{ | ||
File fileToTest = new File("src/test/resources/config/Dummydownload.json"); | ||
List<URLChecksumEntity> parsedDetails = ArtifactDetails.getArtifactDetailsForCurrentPlatform(fileToTest); | ||
assertTrue(parsedDetails.size()==2); | ||
URLChecksumEntity entity = parsedDetails.get(0); | ||
//Asserting for details read using any key | ||
assertEquals(entity.getUrl().getValue(),"seleniumURL"); | ||
assertEquals(entity.getChecksum().getValue(),"seleniumChecksum"); | ||
//Asserting for details read for a platform | ||
entity =parsedDetails.get(1); | ||
assertNotNull(entity.getUrl().getValue()); | ||
assertNotNull(entity.getChecksum().getValue()); | ||
|
||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
server/src/test/java/com/paypal/selion/utils/AuthenticationHelperTest.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,71 @@ | ||
/*-------------------------------------------------------------------------------------------------------------------*\ | ||
| Copyright (C) 2015 eBay Software Foundation | | ||
| | | ||
| 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 com.paypal.selion.utils; | ||
|
||
import java.io.File; | ||
|
||
import org.apache.commons.lang.SystemUtils; | ||
import org.testng.annotations.AfterClass; | ||
import org.testng.annotations.BeforeClass; | ||
import org.testng.annotations.Test; | ||
import static org.testng.Assert.assertTrue; | ||
import static org.testng.Assert.assertFalse; | ||
|
||
import com.paypal.selion.pojos.SeLionGridConstants; | ||
|
||
public class AuthenticationHelperTest { | ||
|
||
@BeforeClass | ||
public void mockTestPath() { | ||
SeLionGridConstants.SELION_HOME_DIR = SystemUtils.USER_DIR + "/src/test/resources/"; | ||
} | ||
|
||
@Test | ||
public void testAuthentication() { | ||
boolean isValidLogin = AuthenticationHelper.authenticate("admin", "admin"); | ||
assertTrue(isValidLogin); | ||
} | ||
|
||
@Test(dependsOnMethods = "testAuthentication") | ||
public void testPasswordChange() { | ||
boolean isPasswordChanged = AuthenticationHelper.changePassword("admin", "dummy"); | ||
assertTrue(isPasswordChanged); | ||
} | ||
|
||
@Test(dependsOnMethods = "testPasswordChange") | ||
public void authenticateNewPassword() { | ||
boolean val = AuthenticationHelper.authenticate("admin", "dummy"); | ||
assertTrue(val); | ||
} | ||
|
||
@Test(dependsOnMethods = "authenticateNewPassword") | ||
public void authenticateWrongPassword() { | ||
boolean isValidPassword = AuthenticationHelper.authenticate("admin", "dummy123"); | ||
assertFalse(isValidPassword); | ||
} | ||
|
||
@Test(dependsOnMethods = "authenticateWrongPassword") | ||
public void authenticateWrongUsername() { | ||
boolean isValidUser = AuthenticationHelper.authenticate("dummy", "dummy"); | ||
assertFalse(isValidUser); | ||
} | ||
|
||
@AfterClass(alwaysRun=true) | ||
public void cleanUpAuthFile() { | ||
File authFile = new File(SeLionGridConstants.SELION_HOME_DIR + ".authFile"); | ||
authFile.delete(); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
server/src/test/java/com/paypal/selion/utils/ConfigParserTest.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,36 @@ | ||
/*-------------------------------------------------------------------------------------------------------------------*\ | ||
| Copyright (C) 2015 eBay Software Foundation | | ||
| | | ||
| 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 com.paypal.selion.utils; | ||
|
||
import static org.testng.Assert.assertEquals; | ||
|
||
import org.testng.annotations.Test; | ||
|
||
public class ConfigParserTest { | ||
|
||
@Test | ||
public void testSetConfig() { | ||
// Mock the location of the config file | ||
ConfigParser.setConfigFile("src/test/resources/config/DummySeLionConfig.json"); | ||
ConfigParser parser = ConfigParser.getInstance(); | ||
int key1 = parser.getInt("Key1"); | ||
String key2 = parser.getString("Key2"); | ||
long key3 = parser.getLong("Key3"); | ||
assertEquals(1000, key1); | ||
assertEquals("Sample", key2); | ||
assertEquals(250000000, key3); | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
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,5 @@ | ||
{ | ||
"Key1": 1000, | ||
"Key2": "Sample", | ||
"Key3": 250000000 | ||
} |
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,24 @@ | ||
[ | ||
{ | ||
"name": "selenium", | ||
"any": { | ||
"url": "seleniumURL", | ||
"checksum": "seleniumChecksum" | ||
} | ||
}, | ||
{ | ||
"name": "chrome", | ||
"windows": { | ||
"url": "chromeURL", | ||
"checksum": "chromeCheckSum" | ||
}, | ||
"linux": { | ||
"url": "chromeURL_linux", | ||
"checksum": "chromeCheckSum_linux" | ||
}, | ||
"mac": { | ||
"url": "chromeURL_mac", | ||
"checksum": "chromeCheckSum_mac" | ||
} | ||
} | ||
] |