- Timestamp:
- 07/12/13 23:41:06 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
java/main/src/test/java/com/framsticks/hosting/ServerTest.java
r99 r100 8 8 import org.testng.annotations.Test; 9 9 10 import com.framsticks.core.ListChange; 10 11 import com.framsticks.core.LocalTree; 11 12 import com.framsticks.core.Path; … … 18 19 import com.framsticks.core.Tree; 19 20 import com.framsticks.params.FramsClass; 20 import com.framsticks.params.Access Interface;21 import com.framsticks.params.Access; 21 22 import com.framsticks.params.EventListener; 22 23 import com.framsticks.params.PrimitiveParam; 23 24 import com.framsticks.params.PropertiesAccess; 24 25 import com.framsticks.params.types.EventParam; 26 import com.framsticks.params.types.StringParam; 25 27 // import com.framsticks.params.types.EventParam; 26 28 import com.framsticks.params.types.ProcedureParam; … … 44 46 protected TestClass hostedObject; 45 47 protected EventListener<ChangeEvent> listener; 48 protected EventListener<ListChange> childListener; 49 46 50 protected List<String> listenerArguments = new LinkedList<>(); 51 protected List<ListChange> childrenChanges = new LinkedList<>(); 52 47 53 48 54 @Override … … 90 96 assertThat(path.isResolved()).isTrue(); 91 97 remotePath = path; 92 Access Interfaceaccess = bindAccess(path);98 Access access = bindAccess(path); 93 99 assertThat(access).isInstanceOf(PropertiesAccess.class); 94 100 assertThat(access.get("name", String.class)).isEqualTo("a test name"); … … 167 173 } 168 174 169 @Test(dependsOnMethods = "callMethod") 175 176 @Test(dependsOnMethods = "deregisterListener") 177 public void registerChildListener() { 178 179 childListener = new EventListener<ListChange>() { 180 @Override 181 public void action(ListChange listChange) { 182 childrenChanges.add(listChange); 183 } 184 }; 185 186 addListener(remotePath, remoteTestFramsClass.getParamEntry("children_changed", EventParam.class), childListener, ListChange.class, produceWaiter(1.0).passInFuture(Void.class)); 187 } 188 189 @Test(dependsOnMethods = "registerChildListener") 190 public void createChild() { 191 final Waiter waiter = produceWaiter(2.0); 192 call(remotePath, "createChild", new Object[] { "a child" }, produceWaiter(2.0).passInFuture(Object.class)); 193 call(remotePath, "createChild", new Object[] { "another child" }, produceWaiter(2.0).passInFuture(Object.class)); 194 195 tryGet(remote, "/testClass/children/c0", new FutureHandler<Path>(failOnException) { 196 197 @Override 198 protected void result(Path result) { 199 set(result, getFramsClass(result).getParamEntry("name", StringParam.class), "new_name", new FutureHandler<Integer>(failOnException) { 200 201 @Override 202 protected void result(Integer result) { 203 waiter.pass(); 204 } 205 }); 206 } 207 }); 208 } 209 210 @Test(dependsOnMethods = "createChild") 211 public void deregisterChildListener() { 212 removeListener(remotePath, remoteTestFramsClass.getParamEntry("children_changed", EventParam.class), childListener, produceWaiter(1.0).passInFuture(Void.class)); 213 } 214 215 @Test(dependsOnMethods = "deregisterChildListener") 216 public void checkListChanges() { 217 assertThat(childrenChanges).isEqualTo(Arrays.asList( 218 new ListChange(ListChange.Action.Add, 0, "c0"), 219 new ListChange(ListChange.Action.Add, 1, "c1"), 220 new ListChange(ListChange.Action.Modify, 0, "c0") 221 )); 222 } 223 224 @Test(dependsOnMethods = "checkListChanges") 170 225 public void endWait() { 171 226 monitor.useFor(1.0);
Note: See TracChangeset
for help on using the changeset viewer.