|
9 | 9 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; |
10 | 10 |
|
11 | 11 | import static org.hamcrest.Matchers.equalTo; |
| 12 | +import static org.junit.Assert.assertThat; |
12 | 13 |
|
13 | 14 | @RunWith(SpringJUnit4ClassRunner.class) |
14 | | -@ContextConfiguration(locations = {"/applicationContext.xml"}) |
| 15 | +@ContextConfiguration(locations = {"classpath:applicationContext.xml"}) |
15 | 16 | public class SpelTest { |
16 | 17 |
|
17 | 18 | @Autowired |
18 | 19 | private SpelArithmetic spelArithmetic = new SpelArithmetic(); |
| 20 | + |
19 | 21 | @Autowired |
20 | 22 | private SpelCollections spelCollections = new SpelCollections(); |
| 23 | + |
21 | 24 | @Autowired |
22 | 25 | private SpelConditional spelConditional = new SpelConditional(); |
| 26 | + |
23 | 27 | @Autowired |
24 | 28 | private SpelLogical spelLogical = new SpelLogical(); |
| 29 | + |
25 | 30 | @Autowired |
26 | 31 | private SpelRegex spelRegex = new SpelRegex(); |
| 32 | + |
27 | 33 | @Autowired |
28 | 34 | private SpelRelational spelRelational = new SpelRelational(); |
29 | 35 |
|
30 | 36 | @Test |
31 | 37 | public void testArithmetic() throws Exception { |
32 | | - Assert.assertThat(spelArithmetic.getAdd(), equalTo(20.0)); |
33 | | - Assert.assertThat(spelArithmetic.getAddString(), equalTo("Some string plus other string")); |
34 | | - Assert.assertThat(spelArithmetic.getSubtract(), equalTo(19.0)); |
35 | | - Assert.assertThat(spelArithmetic.getMultiply(), equalTo(20.0)); |
36 | | - Assert.assertThat(spelArithmetic.getDivide(), equalTo(18.0)); |
37 | | - Assert.assertThat(spelArithmetic.getDivideAlphabetic(), equalTo(18.0)); |
38 | | - Assert.assertThat(spelArithmetic.getModulo(), equalTo(7.0)); |
39 | | - Assert.assertThat(spelArithmetic.getModuloAlphabetic(), equalTo(7.0)); |
40 | | - Assert.assertThat(spelArithmetic.getPowerOf(), equalTo(512.0)); |
41 | | - Assert.assertThat(spelArithmetic.getBrackets(), equalTo(17.0)); |
| 38 | + assertThat(spelArithmetic.getAdd(), equalTo(20.0)); |
| 39 | + assertThat(spelArithmetic.getAddString(), equalTo("Some string plus other string")); |
| 40 | + assertThat(spelArithmetic.getSubtract(), equalTo(19.0)); |
| 41 | + assertThat(spelArithmetic.getMultiply(), equalTo(20.0)); |
| 42 | + assertThat(spelArithmetic.getDivide(), equalTo(18.0)); |
| 43 | + assertThat(spelArithmetic.getDivideAlphabetic(), equalTo(18.0)); |
| 44 | + assertThat(spelArithmetic.getModulo(), equalTo(7.0)); |
| 45 | + assertThat(spelArithmetic.getModuloAlphabetic(), equalTo(7.0)); |
| 46 | + assertThat(spelArithmetic.getPowerOf(), equalTo(512.0)); |
| 47 | + assertThat(spelArithmetic.getBrackets(), equalTo(17.0)); |
42 | 48 | } |
43 | 49 |
|
44 | 50 | @Test |
45 | 51 | public void testCollections() throws Exception { |
46 | | - Assert.assertThat(spelCollections.getDriver1Car().getModel(), equalTo("Model1")); |
47 | | - Assert.assertThat(spelCollections.getDriver2Car().getModel(), equalTo("Model2")); |
48 | | - Assert.assertThat(spelCollections.getFirstCarInPark().getModel(), equalTo("Model1")); |
49 | | - Assert.assertThat(spelCollections.getNumberOfCarsInPark(), equalTo(2)); |
| 52 | + assertThat(spelCollections.getDriver1Car().getModel(), equalTo("Model1")); |
| 53 | + assertThat(spelCollections.getDriver2Car().getModel(), equalTo("Model2")); |
| 54 | + assertThat(spelCollections.getFirstCarInPark().getModel(), equalTo("Model1")); |
| 55 | + assertThat(spelCollections.getNumberOfCarsInPark(), equalTo(2)); |
50 | 56 | } |
51 | 57 |
|
52 | 58 | @Test |
53 | 59 | public void testConditional() throws Exception { |
54 | | - Assert.assertThat(spelConditional.getTernary(), equalTo("Something went wrong. There was false value")); |
55 | | - Assert.assertThat(spelConditional.getTernary2(), equalTo("Some model")); |
56 | | - Assert.assertThat(spelConditional.getElvis(), equalTo("Some model")); |
| 60 | + assertThat(spelConditional.getTernary(), equalTo("Something went wrong. There was false value")); |
| 61 | + assertThat(spelConditional.getTernary2(), equalTo("Some model")); |
| 62 | + assertThat(spelConditional.getElvis(), equalTo("Some model")); |
57 | 63 | } |
58 | 64 |
|
59 | 65 | @Test |
60 | 66 | public void testLogical() throws Exception { |
61 | | - Assert.assertThat(spelLogical.isAnd(), equalTo(true)); |
62 | | - Assert.assertThat(spelLogical.isAndAlphabetic(), equalTo(true)); |
63 | | - Assert.assertThat(spelLogical.isOr(), equalTo(true)); |
64 | | - Assert.assertThat(spelLogical.isOrAlphabetic(), equalTo(true)); |
65 | | - Assert.assertThat(spelLogical.isNot(), equalTo(false)); |
66 | | - Assert.assertThat(spelLogical.isNotAlphabetic(), equalTo(false)); |
| 67 | + assertThat(spelLogical.isAnd(), equalTo(true)); |
| 68 | + assertThat(spelLogical.isAndAlphabetic(), equalTo(true)); |
| 69 | + assertThat(spelLogical.isOr(), equalTo(true)); |
| 70 | + assertThat(spelLogical.isOrAlphabetic(), equalTo(true)); |
| 71 | + assertThat(spelLogical.isNot(), equalTo(false)); |
| 72 | + assertThat(spelLogical.isNotAlphabetic(), equalTo(false)); |
67 | 73 | } |
68 | 74 |
|
69 | 75 | @Test |
70 | 76 | public void testRegex() throws Exception { |
71 | | - Assert.assertThat(spelRegex.isValidNumericStringResult(), equalTo(true)); |
72 | | - Assert.assertThat(spelRegex.isInvalidNumericStringResult(), equalTo(false)); |
73 | | - Assert.assertThat(spelRegex.isValidAlphabeticStringResult(), equalTo(true)); |
74 | | - Assert.assertThat(spelRegex.isInvalidAlphabeticStringResult(), equalTo(false)); |
75 | | - Assert.assertThat(spelRegex.isValidFormatOfHorsePower(), equalTo(true)); |
| 77 | + assertThat(spelRegex.isValidNumericStringResult(), equalTo(true)); |
| 78 | + assertThat(spelRegex.isInvalidNumericStringResult(), equalTo(false)); |
| 79 | + assertThat(spelRegex.isValidAlphabeticStringResult(), equalTo(true)); |
| 80 | + assertThat(spelRegex.isInvalidAlphabeticStringResult(), equalTo(false)); |
| 81 | + assertThat(spelRegex.isValidFormatOfHorsePower(), equalTo(true)); |
76 | 82 | } |
77 | 83 |
|
78 | 84 | @Test |
79 | 85 | public void testRelational() throws Exception { |
80 | | - Assert.assertThat(spelRelational.isEqual(), equalTo(true)); |
81 | | - Assert.assertThat(spelRelational.isEqualAlphabetic(), equalTo(true)); |
82 | | - Assert.assertThat(spelRelational.isNotEqual(), equalTo(false)); |
83 | | - Assert.assertThat(spelRelational.isNotEqualAlphabetic(), equalTo(false)); |
84 | | - Assert.assertThat(spelRelational.isLessThan(), equalTo(false)); |
85 | | - Assert.assertThat(spelRelational.isLessThanAlphabetic(), equalTo(false)); |
86 | | - Assert.assertThat(spelRelational.isLessThanOrEqual(), equalTo(true)); |
87 | | - Assert.assertThat(spelRelational.isLessThanOrEqualAlphabetic(), equalTo(true)); |
88 | | - Assert.assertThat(spelRelational.isGreaterThan(), equalTo(false)); |
89 | | - Assert.assertThat(spelRelational.isGreaterThanAlphabetic(), equalTo(false)); |
90 | | - Assert.assertThat(spelRelational.isGreaterThanOrEqual(), equalTo(true)); |
91 | | - Assert.assertThat(spelRelational.isGreaterThanOrEqualAlphabetic(), equalTo(true)); |
92 | | - Assert.assertThat(spelRelational.isAnd(), equalTo(true)); |
93 | | - Assert.assertThat(spelRelational.isAndAlphabetic(), equalTo(true)); |
94 | | - Assert.assertThat(spelRelational.isOr(), equalTo(true)); |
95 | | - Assert.assertThat(spelRelational.isOrAlphabetic(), equalTo(true)); |
96 | | - Assert.assertThat(spelRelational.isNot(), equalTo(false)); |
97 | | - Assert.assertThat(spelRelational.isNotAlphabetic(), equalTo(false)); |
| 86 | + assertThat(spelRelational.isEqual(), equalTo(true)); |
| 87 | + assertThat(spelRelational.isEqualAlphabetic(), equalTo(true)); |
| 88 | + assertThat(spelRelational.isNotEqual(), equalTo(false)); |
| 89 | + assertThat(spelRelational.isNotEqualAlphabetic(), equalTo(false)); |
| 90 | + assertThat(spelRelational.isLessThan(), equalTo(false)); |
| 91 | + assertThat(spelRelational.isLessThanAlphabetic(), equalTo(false)); |
| 92 | + assertThat(spelRelational.isLessThanOrEqual(), equalTo(true)); |
| 93 | + assertThat(spelRelational.isLessThanOrEqualAlphabetic(), equalTo(true)); |
| 94 | + assertThat(spelRelational.isGreaterThan(), equalTo(false)); |
| 95 | + assertThat(spelRelational.isGreaterThanAlphabetic(), equalTo(false)); |
| 96 | + assertThat(spelRelational.isGreaterThanOrEqual(), equalTo(true)); |
| 97 | + assertThat(spelRelational.isGreaterThanOrEqualAlphabetic(), equalTo(true)); |
| 98 | + assertThat(spelRelational.isAnd(), equalTo(true)); |
| 99 | + assertThat(spelRelational.isAndAlphabetic(), equalTo(true)); |
| 100 | + assertThat(spelRelational.isOr(), equalTo(true)); |
| 101 | + assertThat(spelRelational.isOrAlphabetic(), equalTo(true)); |
| 102 | + assertThat(spelRelational.isNot(), equalTo(false)); |
| 103 | + assertThat(spelRelational.isNotAlphabetic(), equalTo(false)); |
98 | 104 | } |
99 | 105 | } |
0 commit comments