Changeset 103 for java/main/src/test
- Timestamp:
- 07/18/13 23:52:25 (11 years ago)
- Location:
- java/main/src/test
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
java/main/src/test/java/com/framsticks/gui/ProcedureBrowserTest.java
r101 r103 10 10 import com.framsticks.core.Tree; 11 11 import com.framsticks.core.LocalTree; 12 import com.framsticks.core.ValueChange; 12 13 import com.framsticks.params.Access; 13 14 import com.framsticks.params.EventListener; … … 17 18 import com.framsticks.params.types.StringParam; 18 19 import com.framsticks.parsers.XmlLoader; 19 import com.framsticks.test.TestChangeEvent;20 20 import com.framsticks.test.TestClass; 21 21 import com.framsticks.util.dispatching.FutureHandler; … … 82 82 waitForIdle(); 83 83 84 final EventListener< TestChangeEvent> listener = new EventListener<TestChangeEvent>() {84 final EventListener<ValueChange> listener = new EventListener<ValueChange>() { 85 85 86 86 @Override 87 public void action( TestChangeEventargument) {88 assertThat(argument. history).isEqualTo("");87 public void action(ValueChange argument) { 88 assertThat(argument.value).isEqualTo(""); 89 89 } 90 90 }; … … 96 96 assertThat(access.get("history", String.class)).isEqualTo("initial|Żółw|"); 97 97 98 tree.addListener(Path.to(tree, "/"), access.getFramsClass().getParamEntry("history_changed", EventParam.class), listener, TestChangeEvent.class, FutureHandler.doNothing(Void.class, failOnException));98 tree.addListener(Path.to(tree, "/"), access.getFramsClass().getParamEntry("history_changed", EventParam.class), listener, ValueChange.class, FutureHandler.doNothing(Void.class, failOnException)); 99 99 } 100 100 }); -
java/main/src/test/java/com/framsticks/hosting/ServerTest.java
r101 r103 11 11 import com.framsticks.core.LocalTree; 12 12 import com.framsticks.core.Path; 13 import com.framsticks.core.Result; 13 14 import com.framsticks.core.TreeOperations; 15 import com.framsticks.core.ValueChange; 14 16 import com.framsticks.core.XmlBasedTest; 15 17 import com.framsticks.remote.RemoteTree; 16 18 17 import com.framsticks.test.TestChangeEvent;18 19 import com.framsticks.test.TestClass; 19 20 import com.framsticks.core.Tree; … … 45 46 protected LocalTree hosted; 46 47 protected TestClass hostedObject; 47 protected EventListener< TestChangeEvent> listener;48 protected EventListener<ValueChange> listener; 48 49 protected EventListener<ListChange> childListener; 49 50 … … 123 124 public void registerListener() { 124 125 final Waiter waiter = produceWaiter(1.0); 125 listener = new EventListener< TestChangeEvent>() {126 127 @Override 128 public void action( TestChangeEventargument) {129 listenerArguments.add(argument. history);126 listener = new EventListener<ValueChange>() { 127 128 @Override 129 public void action(ValueChange argument) { 130 listenerArguments.add(argument.value.toString()); 130 131 } 131 132 }; … … 138 139 }); 139 140 140 addListener(remotePath, remoteTestFramsClass.getParamEntry("history_changed", EventParam.class), listener, TestChangeEvent.class, produceWaiter(1.0).passInFuture(Void.class));141 addListener(remotePath, remoteTestFramsClass.getParamEntry("history_changed", EventParam.class), listener, ValueChange.class, produceWaiter(1.0).passInFuture(Void.class)); 141 142 } 142 143 … … 145 146 final Waiter waiter = produceWaiter(2.0); 146 147 147 call(remotePath, remoteTestFramsClass.getParamEntry("resetHistory", ProcedureParam.class), new Object[] {}, produceWaiter(2.0).passInFuture(Object.class));148 149 call(remotePath, remoteTestFramsClass.getParamEntry("appendHistory", ProcedureParam.class), new Object[] {"next word"}, new FutureHandler<Object>(failOnException) {150 @Override 151 protected void result( Object result) {148 call(remotePath, remoteTestFramsClass.getParamEntry("resetHistory", ProcedureParam.class), new Object[] {}, Object.class, produceWaiter(2.0).passInFuture(Object.class)); 149 150 call(remotePath, remoteTestFramsClass.getParamEntry("appendHistory", ProcedureParam.class), new Object[] {"next word"}, Result.class, new FutureHandler<Result>(failOnException) { 151 @Override 152 protected void result(final Result result) { 152 153 hosted.dispatch(new RunAt<Tree>(failOnException) { 153 154 @Override 154 155 protected void runAt() { 156 // assert 157 155 158 assertThat(hostedObject.getHistory()).isEqualTo("next word|"); 156 159 waiter.pass(); … … 186 189 public void createChild() { 187 190 final Waiter waiter = produceWaiter(2.0); 188 call(remotePath, "createChild", new Object[] { "a child" }, produceWaiter(2.0).passInFuture(Object.class));189 call(remotePath, "createChild", new Object[] { "another child" }, produceWaiter(2.0).passInFuture(Object.class));191 call(remotePath, "createChild", new Object[] { "a child" }, Object.class, produceWaiter(2.0).passInFuture(Object.class)); 192 call(remotePath, "createChild", new Object[] { "another child" }, Object.class, produceWaiter(2.0).passInFuture(Object.class)); 190 193 191 194 tryGet(remote, "/testClass/children/c0", new FutureHandler<Path>(failOnException) { -
java/main/src/test/java/com/framsticks/params/FramsClassBuilderTest.java
r101 r103 6 6 import org.testng.annotations.Test; 7 7 8 import com.framsticks.core.ValueChange; 8 9 import com.framsticks.params.types.EventParam; 9 10 import com.framsticks.params.types.ProcedureParam; 10 11 import com.framsticks.params.types.StringParam; 11 12 import com.framsticks.parsers.Savers; 12 import com.framsticks.test.TestChangeEvent;13 13 import com.framsticks.test.TestClass; 14 14 import com.framsticks.test.TestConfiguration; … … 69 69 "id:history_changed", 70 70 "name:HistoryListener", 71 "type:e TestChangeEvent",71 "type:e ValueChange", 72 72 "", 73 73 "prop:", … … 128 128 final Holder<String> called = new Holder<>(); 129 129 130 final EventListener< TestChangeEvent> listener = new EventListener<TestChangeEvent>() {130 final EventListener<ValueChange> listener = new EventListener<ValueChange>() { 131 131 132 132 @Override 133 public void action( TestChangeEventargument) {134 called.set(argument. history);133 public void action(ValueChange argument) { 134 called.set(argument.value.toString()); 135 135 } 136 136 }; -
java/main/src/test/java/com/framsticks/params/ParamBuilderTest.java
r101 r103 5 5 import com.framsticks.params.types.FloatParam; 6 6 import com.framsticks.params.types.StringParam; 7 import com.framsticks.parsers.AccessStash; 7 8 import com.framsticks.parsers.MultiParamLoader; 8 9 import com.framsticks.test.TestConfiguration; … … 34 35 MultiParamLoader loader = new MultiParamLoader(); 35 36 loader.setNewSource(source); 36 loader. addAccess(access);37 loader.setAccessProvider(new AccessStash().add(access)); 37 38 loader.addBreakCondition(MultiParamLoader.Status.AfterObject); 38 39 -
java/main/src/test/java/com/framsticks/test/prime/PrimePackageTest.java
r102 r103 1 1 package com.framsticks.test.prime; 2 2 3 //import static org.fest.assertions.Assertions.*;3 import static org.fest.assertions.Assertions.*; 4 4 5 import java.util.Arrays; 6 import java.util.List; 7 8 import org.testng.annotations.BeforeClass; 5 9 import org.testng.annotations.Test; 6 10 11 import com.framsticks.params.AccessOperations; 12 import com.framsticks.params.FramsClass; 13 import com.framsticks.params.ListSink; 14 import com.framsticks.params.ListSource; 15 // import com.framsticks.params.ListSource; 16 import com.framsticks.params.Registry; 17 import com.framsticks.params.types.ObjectParam; 7 18 import com.framsticks.test.TestConfiguration; 8 19 … … 10 21 public class PrimePackageTest extends TestConfiguration { 11 22 23 Registry registry; 12 24 25 protected final List<String> printedPrimePackage = Arrays.asList( 26 "ExpParams:", 27 "from_number:100", 28 "to_number:200", 29 "", 30 "ExpState:", 31 "current_number:201", 32 "result:151,157,163,167,173,179,181,191,193,197,199", 33 "" 34 ); 13 35 36 @BeforeClass 37 public void setupRegistry() { 38 registry = new Registry(); 39 registry.registerAndBuild(PrimePackage.class); 40 } 14 41 15 42 @Test 43 public void primePackageFramsClass() { 44 FramsClass framsClass = registry.getFramsClassForJavaClass(PrimePackage.class); 45 assertThat(framsClass).isNotNull(); 46 assertThat(framsClass.getParamCount()).isEqualTo(2); 47 assertThat(framsClass.getParam(0)).isInstanceOf(ObjectParam.class); 48 assertThat(framsClass.getParam(1)).isInstanceOf(ObjectParam.class); 49 } 50 51 @Test(dependsOnMethods = "primePackageFramsClass") 16 52 public void printPrimePackage() { 53 PrimePackage primePackage = new PrimePackage(); 54 primePackage.params.from_number = 100; 55 primePackage.params.to_number = 200; 56 57 primePackage.state.current_number = 201; 58 primePackage.state.getResultList().addAll(Arrays.asList(151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199)); 59 60 assertThat(primePackage.state.getResult()).isEqualTo("151,157,163,167,173,179,181,191,193,197,199"); 61 62 ListSink sink = new ListSink(); 63 64 AccessOperations.saveAll(registry.createAccess(PrimePackage.class).select(primePackage), sink, registry); 65 66 assertThat(sink.getOut()).isEqualTo(printedPrimePackage); 17 67 } 18 // ExpParams:19 // from_number:10020 // to_number:20021 68 22 // ExpState: 23 // current_number:201 24 // result:151,157,163,167,173,179,181,191,193,197,199 69 @Test(dependsOnMethods = "printPrimePackage") 70 public void loadPrimePackage() { 71 72 // PrimePackage primePackage = new PrimePackage(); 73 74 ListSource source = new ListSource(printedPrimePackage); 75 76 Object result = AccessOperations.loadAll(registry.createAccess(PrimePackage.class), source, registry).getSelected(); 77 assertThat(result).isInstanceOf(PrimePackage.class); 78 PrimePackage primePackage = (PrimePackage) result; 79 80 assertThat(primePackage.params.from_number).isEqualTo(100); 81 assertThat(primePackage.params.to_number).isEqualTo(200); 82 83 assertThat(primePackage.state.current_number).isEqualTo(201); 84 assertThat(primePackage.state.getResultList()).isEqualTo(Arrays.asList(151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199)); 85 86 } 25 87 } -
java/main/src/test/resources/log4j2.xml
r102 r103 8 8 <loggers> 9 9 <logger name="com.framsticks" level="info" /> 10 <logger name="com.framsticks.running.ExternalProcess" level="debug" />11 10 <logger name="com.framsticks.test.TestConfiguration" level="info" /> 12 <logger name="com.framsticks.experiment" level="debug" /> 13 <logger name="com.framsticks.test.PrimeExperiment" level="debug" /> 11 12 <!-- <logger name="com.framsticks.running.ExternalProcess" level="debug" /> --> 13 <!-- <logger name="com.framsticks.experiment" level="debug" /> --> 14 <!-- <logger name="com.framsticks.test.PrimeExperiment" level="debug" /> --> 15 <!-- <logger name="com.framsticks.experiment.NetLoadSaveLogic" level="debug" /> --> 16 <!-- <logger name="com.framsticks.experiment.WorkPackageLogic" level="debug" /> --> 17 <!-- <logger name="com.framsticks.params.AccessOperations" level="debug" /> --> 14 18 <!-- <logger name="com.framsticks.util.dispatching.AbstractJoinable" level="debug" /> --> 15 19 <!-- <logger name="com.framsticks.util.dispatching.AbstractJoinable.Report" level="info" /> -->
Note: See TracChangeset
for help on using the changeset viewer.