- Timestamp:
- 07/10/13 22:41:02 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
java/main/src/test/java/com/framsticks/params/FramsClassBuilderTest.java
r97 r99 6 6 import org.testng.annotations.Test; 7 7 8 import com.framsticks.params.types.EventParam; 8 9 import com.framsticks.params.types.ProcedureParam; 9 10 import com.framsticks.params.types.StringParam; 10 11 import com.framsticks.parsers.Savers; 12 import com.framsticks.test.ChangeEvent; 11 13 import com.framsticks.test.TestClass; 12 14 import com.framsticks.test.TestConfiguration; 15 import com.framsticks.util.lang.Holder; 16 13 17 import static org.fest.assertions.Assertions.*; 14 18 … … 30 34 @Test 31 35 public void checkProcedureParams() { 32 assertThat(framsClass.getParamCount()).isEqualTo( 4);36 assertThat(framsClass.getParamCount()).isEqualTo(5); 33 37 34 38 assertThat(framsClass.getParam("name")).isInstanceOf(StringParam.class); 35 39 assertThat(framsClass.getParam("history")).isInstanceOf(StringParam.class); 40 assertThat(framsClass.getParam("history_changed")).isInstanceOf(EventParam.class); 36 41 37 42 assertThat(framsClass.getParam("appendHistory")).isInstanceOf(ProcedureParam.class); … … 62 67 "", 63 68 "prop:", 69 "id:history_changed", 70 "name:HistoryListener", 71 "type:e ChangeEvent", 72 "", 73 "prop:", 64 74 "id:appendHistory", 65 75 "name:AppendHistory", … … 75 85 } 76 86 87 @Test(dependsOnMethods = "print") 88 public void createAccess() { 89 access = new ReflectionAccess(TestClass.class, framsClass); 90 access.select(test); 91 } 77 92 78 @Test(dependsOnMethods = " print")93 @Test(dependsOnMethods = "createAccess") 79 94 public void callProcedures() { 80 access = new ReflectionAccess(TestClass.class, framsClass);81 82 access.select(test);83 95 84 96 assertThat(access.get("history", String.class)).isEqualTo("initial|first|"); … … 93 105 94 106 assertThat(access.get("history", String.class)).isEqualTo(""); 107 } 95 108 109 @Test(dependsOnMethods = "callProcedures") 110 public void listeners() { 111 112 final Holder<String> called = new Holder<>(); 113 114 final EventListener<ChangeEvent> listener = new EventListener<ChangeEvent>() { 115 116 @Override 117 public void action(ChangeEvent argument) { 118 called.set(argument.history); 119 } 120 }; 121 122 final EventParam eventParam = access.getFramsClass().getParamEntry("history_changed", EventParam.class); 123 access.reg(eventParam, listener); 124 125 final String currentHistory = access.get("history", String.class); 126 final String addition = "test"; 127 128 access.call("appendHistory", new Object[] { addition }); 129 130 String expected = currentHistory + addition + "|"; 131 assertThat(access.get("history", String.class)).isEqualTo(expected); 132 assertThat(called.get()).isEqualTo(expected); 133 access.regRemove(eventParam, listener); 96 134 } 97 135
Note: See TracChangeset
for help on using the changeset viewer.