forked from junit-team/junit4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request junit-team#263 from rojotek/4.9.1
4.9.1
- Loading branch information
Showing
6 changed files
with
51 additions
and
5 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
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
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,37 @@ | ||
package junit.tests.runner; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.io.ByteArrayOutputStream; | ||
import java.io.IOException; | ||
import java.io.ObjectInputStream; | ||
import java.io.ObjectOutputStream; | ||
|
||
import junit.framework.TestCase; | ||
import junit.tests.framework.Success; | ||
import org.junit.runner.JUnitCore; | ||
import org.junit.runner.Result; | ||
import org.junit.tests.running.methods.AnnotationTest; | ||
|
||
public class ResultTest extends TestCase { | ||
|
||
public void testRunFailureResultCanBeSerialised() throws Exception { | ||
JUnitCore runner = new JUnitCore(); | ||
Result result = runner.run(AnnotationTest.FailureTest.class); | ||
assertResultSerializable(result); | ||
} | ||
|
||
public void testRunSuccessResultCanBeSerialised() throws Exception { | ||
JUnitCore runner = new JUnitCore(); | ||
Result result = runner.run(Success.class); | ||
assertResultSerializable(result); | ||
} | ||
|
||
private void assertResultSerializable(Result result) throws IOException, ClassNotFoundException { | ||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); | ||
new ObjectOutputStream(byteArrayOutputStream).writeObject(result); | ||
byte[] bytes = byteArrayOutputStream.toByteArray(); | ||
ObjectInputStream objectInputStream = new ObjectInputStream(new ByteArrayInputStream(bytes)); | ||
Result fromStream = (Result) objectInputStream.readObject(); | ||
assertNotNull(fromStream); | ||
} | ||
} |