Created
February 26, 2012 11:20
-
-
Save oleg/1916161 to your computer and use it in GitHub Desktop.
Isolation
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
package logic; | |
import org.junit.Assert; | |
import org.junit.Test; | |
import play.Play; | |
import java.util.Properties; | |
public class IsolatedTestV1 extends Assert { | |
static { | |
Play.configuration = new Properties(); | |
} | |
@Test | |
public void should_return_null_if_nothing_added() throws Exception { | |
assertEquals(null, Play.configuration.getProperty("score")); | |
} | |
@Test | |
public void should_return_what_was_added() throws Exception { | |
Play.configuration.setProperty("score", "10"); | |
assertEquals("10", Play.configuration.getProperty("score")); | |
} | |
} |
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
package logic; | |
import org.junit.After; | |
import org.junit.Assert; | |
import org.junit.Before; | |
import org.junit.Test; | |
import play.Play; | |
import java.util.Properties; | |
public class IsolatedTestV2 extends Assert { | |
private Properties originalProps; | |
@Before | |
public void setUp() throws Exception { | |
originalProps = Play.configuration; | |
Play.configuration = new Properties(); | |
} | |
@After | |
public void tearDown() throws Exception { | |
Play.configuration = originalProps; | |
} | |
@Test | |
public void should_return_what_was_added() throws Exception { | |
Play.configuration.setProperty("score", "10"); | |
assertEquals("10", Play.configuration.getProperty("score")); | |
} | |
@Test | |
public void should_return_null_if_nothing_added() throws Exception { | |
assertEquals(null, Play.configuration.getProperty("score")); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment