1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
/**
* RunDescriptionTest.java
*
* Copyright (c) 2012 Galois, Inc.
*/
package com.galois.fiveui;
import static org.junit.Assert.fail;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import junit.framework.Assert;
import org.junit.Test;
import com.google.common.collect.ImmutableList;
/**
* @author creswick
*
*/
public class RunDescriptionTest {
private static final String RUN_DESCRIPTION_DIR = "src/test/resources/runDescriptions/";
/**
* Test method for {@link com.galois.fiveui.RSTestDescription#RunDescription(java.lang.String, java.util.List, com.galois.fiveui.RuleSet)}.
* @throws FileNotFoundException
*/
@Test
public final void testDeserialize_sample0() throws FileNotFoundException {
String jsonFileName = RUN_DESCRIPTION_DIR + "sample0.json";
String ruleSetLoc =
RUN_DESCRIPTION_DIR + "../ruleSets/emptyRuleSet.json";
ImmutableList<Rule> emptyRuleList = ImmutableList.of();
RuleSet rsOracle =
new RuleSet("emptyRuleSet", "", emptyRuleList);
RSTestDescription oracle =
new RSTestDescription(ruleSetLoc,
new ArrayList<RSTestDescription.URIMap>(), rsOracle);
RSTestDescription actual = RSTestDescription.parse(jsonFileName);
assertObjEqual("Object deserialized incorrectly.", oracle, actual);
}
/**
* Test method for {@link com.galois.fiveui.RSTestDescription#RunDescription(java.lang.String, java.util.List, com.galois.fiveui.RuleSet)}.
* @throws FileNotFoundException
*/
@Test
public final void testDeserialize_sample1() throws FileNotFoundException {
String jsonFileName = RUN_DESCRIPTION_DIR + "sample1.json";
String ruleSetLoc =
RUN_DESCRIPTION_DIR + "../ruleSets/simpleRuleSet1.json";
RuleSet rsOracle =
new RuleSet("simpleRuleSet1", "", ImmutableList.of(
new Rule("trivial check", "test desc", "", 42)));
RSTestDescription oracle =
new RSTestDescription(ruleSetLoc,
new ArrayList<RSTestDescription.URIMap>(), rsOracle);
RSTestDescription actual = RSTestDescription.parse(jsonFileName);
assertObjEqual("Object deserialized incorrectly.", oracle, actual);
}
private void assertObjEqual(String msg, Object oracle, Object actual) {
Assert.assertTrue(msg + "; expected: "+oracle+" actual: "+actual,
oracle.equals(actual));
}
}
|