Skip to content
This repository has been archived by the owner on Apr 5, 2019. It is now read-only.

Commit

Permalink
improving coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
klieber committed Dec 16, 2013
1 parent f209b75 commit 3fd9b52
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 12 deletions.
Expand Up @@ -26,6 +26,7 @@
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.internal.util.reflection.Whitebox;
import org.mockito.runners.MockitoJUnitRunner;

import static com.googlecode.catchexception.CatchException.catchException;
Expand Down Expand Up @@ -84,4 +85,11 @@ public void testBuildInvalidPlatform() {
hasMessage("unknown platform: invalid")
));
}

@Test
public void testConstructWithSystemValues() {
builder = new PhantomJSArchiveBuilder("1.9.2");
assertEquals(System.getProperty("os.name").toLowerCase(), Whitebox.getInternalState(builder,"platform"));
assertEquals(System.getProperty("os.arch").toLowerCase(), Whitebox.getInternalState(builder,"arch"));
}
}
Expand Up @@ -34,6 +34,7 @@ public class PhantomJSArchiveTest {
private static final String EXTENSION = "zip";
private static final String PLATFORM = "windows";
private static final String EXECUTABLE = "phantomjs.exe";
private static final String ARCH = "i686";

private static final String ARCHIVE_NAME_WITHOUT_EXTENSION = "phantomjs-"+VERSION+"-"+PLATFORM;
private static final String ARCHIVE_NAME = ARCHIVE_NAME_WITHOUT_EXTENSION + "."+EXTENSION;
Expand All @@ -42,7 +43,32 @@ public class PhantomJSArchiveTest {

@Before
public void before() {
archive = new PhantomJSArchive(VERSION) {
archive = createPhantomJSArchive();
}

@Test
public void testGetArchiveName() {
assertEquals(ARCHIVE_NAME, archive.getArchiveName());
}

@Test
public void testGetPathToExecutable() {
assertEquals(ARCHIVE_NAME+"/"+ARCHIVE_NAME_WITHOUT_EXTENSION+"/"+EXECUTABLE,archive.getPathToExecutable());
}

@Test
public void testGetExtractToPath() {
assertEquals(ARCHIVE_NAME_WITHOUT_EXTENSION+"/"+EXECUTABLE,archive.getExtractToPath());
}

@Test
public void testGetExtractToPathWithArch() {
archive = createPhantomJSArchive(ARCH);
assertEquals(ARCHIVE_NAME_WITHOUT_EXTENSION+"-"+ARCH+"/"+EXECUTABLE,archive.getExtractToPath());
}

private static PhantomJSArchive createPhantomJSArchive() {
return new PhantomJSArchive(VERSION) {
@Override
protected String getExtension() {
return EXTENSION;
Expand All @@ -60,18 +86,27 @@ protected String getExecutable() {
};
}

@Test
public void testGetArchiveName() {
assertEquals(ARCHIVE_NAME, archive.getArchiveName());
}
private static PhantomJSArchive createPhantomJSArchive(final String arch) {
return new PhantomJSArchive(VERSION) {
@Override
protected String getExtension() {
return EXTENSION;
}

@Test
public void testGetPathToExecutable() {
assertEquals(ARCHIVE_NAME+"/"+ARCHIVE_NAME_WITHOUT_EXTENSION+"/"+EXECUTABLE,archive.getPathToExecutable());
}
@Override
protected String getPlatform() {
return PLATFORM;
}

@Test
public void testGetExtractToPath() {
assertEquals(ARCHIVE_NAME_WITHOUT_EXTENSION+"/"+EXECUTABLE,archive.getExtractToPath());
@Override
protected String getExecutable() {
return EXECUTABLE;
}

@Override
protected String getArch() {
return arch;
}
};
}
}

0 comments on commit 3fd9b52

Please sign in to comment.