Changeset 103 for java/main/src/test


Ignore:
Timestamp:
07/18/13 23:52:25 (11 years ago)
Author:
psniegowski
Message:

HIGHLIGHTS:

  • add auto loading and saving algorithms between

frams files format and Java classes

  • respect ValueChange? events in GUI (do not reload object)
  • support results of procedures in Java server
  • make Experiment automatically convert between frams file and NetFile? object
  • add MessageLogger? (compatible with original frams server messages)
  • WorkPackageLogic? now validates results, is able to discard them, reschedule

whole package, or only uncomputed remainder

CHANGELOG:
Show just a short description in PrimeExperiment?.

Add primes_changed event to the PrimeExperiment?.

Make WorkPackageLogic? robust to frams server returning invalid results.

Add MessageLogger? to logics.

Add NetFile? interface. Support Messages from server.

Minor changes to connections.

Merge results in the PrimeExperiment?.

More netload class->file conversion to Simulator.

Move netsave parsing to Simulator.

Fix bug with inverted ordering of events firing in Experiment.

Minor changes.

Minor logging changes.

Use AccessOperations?.convert in NetLoadSaveLogic?

NetLoadSaveLogic? now encloses the conversion.

Use more generic AccessOperations? saveAll and loadAll in PrimePackage?.

Add Result class for enclosing of call invocations' results.

Improve feature request handling in Connections.

Use AccessOperations?.convert in RemoteTree? events parsing.

Minor change.

Add some information params to Java server root and CLI objects.

A draft implementation of loadAll algorithm.

That algorithm tries to load objects into a tree structure.

Add AccessOperationsTest? test.

Develop WorkPackageLogic?.

  • add state tracking fields
  • add work package generation

Add utility class SimplePrimitive?.

Meant for Java backend classes, enclose a single primitive value
and set of listeners.

Improve primitive value refresh in GUI.

When ValueChange? found in called event, do not reload whole
object, but only update GUI (no communication is performed).

Use ValueChange? in the TestClass? test.

Minor changes.

Sending all packages in PrimeExperiment? to the frams servers.

Develop AccessOperations?.loadComposites().

Remove addAccess from MultiParamLoader? interface.

There is now no default AccessProvider? in MultiParamLoader?.
User must explicitely set AccessStash? or Registry.

Improve saving algorithms in AccessOperations?.

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  
    1010import com.framsticks.core.Tree;
    1111import com.framsticks.core.LocalTree;
     12import com.framsticks.core.ValueChange;
    1213import com.framsticks.params.Access;
    1314import com.framsticks.params.EventListener;
     
    1718import com.framsticks.params.types.StringParam;
    1819import com.framsticks.parsers.XmlLoader;
    19 import com.framsticks.test.TestChangeEvent;
    2020import com.framsticks.test.TestClass;
    2121import com.framsticks.util.dispatching.FutureHandler;
     
    8282                waitForIdle();
    8383
    84                 final EventListener<TestChangeEvent> listener = new EventListener<TestChangeEvent>() {
     84                final EventListener<ValueChange> listener = new EventListener<ValueChange>() {
    8585
    8686                        @Override
    87                         public void action(TestChangeEvent argument) {
    88                                 assertThat(argument.history).isEqualTo("");
     87                        public void action(ValueChange argument) {
     88                                assertThat(argument.value).isEqualTo("");
    8989                        }
    9090                };
     
    9696                                assertThat(access.get("history", String.class)).isEqualTo("initial|Żółw|");
    9797
    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));
    9999                        }
    100100                });
  • java/main/src/test/java/com/framsticks/hosting/ServerTest.java

    r101 r103  
    1111import com.framsticks.core.LocalTree;
    1212import com.framsticks.core.Path;
     13import com.framsticks.core.Result;
    1314import com.framsticks.core.TreeOperations;
     15import com.framsticks.core.ValueChange;
    1416import com.framsticks.core.XmlBasedTest;
    1517import com.framsticks.remote.RemoteTree;
    1618
    17 import com.framsticks.test.TestChangeEvent;
    1819import com.framsticks.test.TestClass;
    1920import com.framsticks.core.Tree;
     
    4546        protected LocalTree hosted;
    4647        protected TestClass hostedObject;
    47         protected EventListener<TestChangeEvent> listener;
     48        protected EventListener<ValueChange> listener;
    4849        protected EventListener<ListChange> childListener;
    4950
     
    123124        public void registerListener() {
    124125                final Waiter waiter = produceWaiter(1.0);
    125                 listener = new EventListener<TestChangeEvent>() {
    126 
    127                         @Override
    128                         public void action(TestChangeEvent argument) {
    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());
    130131                        }
    131132                };
     
    138139                });
    139140
    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));
    141142        }
    142143
     
    145146                final Waiter waiter = produceWaiter(2.0);
    146147
    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) {
    152153                                hosted.dispatch(new RunAt<Tree>(failOnException) {
    153154                                        @Override
    154155                                        protected void runAt() {
     156                                                // assert
     157
    155158                                                assertThat(hostedObject.getHistory()).isEqualTo("next word|");
    156159                                                waiter.pass();
     
    186189        public void createChild() {
    187190                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));
    190193
    191194                tryGet(remote, "/testClass/children/c0", new FutureHandler<Path>(failOnException) {
  • java/main/src/test/java/com/framsticks/params/FramsClassBuilderTest.java

    r101 r103  
    66import org.testng.annotations.Test;
    77
     8import com.framsticks.core.ValueChange;
    89import com.framsticks.params.types.EventParam;
    910import com.framsticks.params.types.ProcedureParam;
    1011import com.framsticks.params.types.StringParam;
    1112import com.framsticks.parsers.Savers;
    12 import com.framsticks.test.TestChangeEvent;
    1313import com.framsticks.test.TestClass;
    1414import com.framsticks.test.TestConfiguration;
     
    6969                                        "id:history_changed",
    7070                                        "name:HistoryListener",
    71                                         "type:e TestChangeEvent",
     71                                        "type:e ValueChange",
    7272                                        "",
    7373                                        "prop:",
     
    128128                final Holder<String> called = new Holder<>();
    129129
    130                 final EventListener<TestChangeEvent> listener = new EventListener<TestChangeEvent>() {
     130                final EventListener<ValueChange> listener = new EventListener<ValueChange>() {
    131131
    132132                        @Override
    133                         public void action(TestChangeEvent argument) {
    134                                 called.set(argument.history);
     133                        public void action(ValueChange argument) {
     134                                called.set(argument.value.toString());
    135135                        }
    136136                };
  • java/main/src/test/java/com/framsticks/params/ParamBuilderTest.java

    r101 r103  
    55import com.framsticks.params.types.FloatParam;
    66import com.framsticks.params.types.StringParam;
     7import com.framsticks.parsers.AccessStash;
    78import com.framsticks.parsers.MultiParamLoader;
    89import com.framsticks.test.TestConfiguration;
     
    3435                MultiParamLoader loader = new MultiParamLoader();
    3536                loader.setNewSource(source);
    36                 loader.addAccess(access);
     37                loader.setAccessProvider(new AccessStash().add(access));
    3738                loader.addBreakCondition(MultiParamLoader.Status.AfterObject);
    3839
  • java/main/src/test/java/com/framsticks/test/prime/PrimePackageTest.java

    r102 r103  
    11package com.framsticks.test.prime;
    22
    3 // import static org.fest.assertions.Assertions.*;
     3import static org.fest.assertions.Assertions.*;
    44
     5import java.util.Arrays;
     6import java.util.List;
     7
     8import org.testng.annotations.BeforeClass;
    59import org.testng.annotations.Test;
    610
     11import com.framsticks.params.AccessOperations;
     12import com.framsticks.params.FramsClass;
     13import com.framsticks.params.ListSink;
     14import com.framsticks.params.ListSource;
     15// import com.framsticks.params.ListSource;
     16import com.framsticks.params.Registry;
     17import com.framsticks.params.types.ObjectParam;
    718import com.framsticks.test.TestConfiguration;
    819
     
    1021public class PrimePackageTest extends TestConfiguration {
    1122
     23        Registry registry;
    1224
     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        );
    1335
     36        @BeforeClass
     37        public void setupRegistry() {
     38                registry = new Registry();
     39                registry.registerAndBuild(PrimePackage.class);
     40        }
    1441
    1542        @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")
    1652        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);
    1767        }
    18         // ExpParams:
    19         // from_number:100
    20         // to_number:200
    2168
    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        }
    2587}
  • java/main/src/test/resources/log4j2.xml

    r102 r103  
    88        <loggers>
    99                <logger name="com.framsticks" level="info" />
    10                 <logger name="com.framsticks.running.ExternalProcess" level="debug" />
    1110                <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" /> -->
    1418                <!-- <logger name="com.framsticks.util.dispatching.AbstractJoinable" level="debug" /> -->
    1519                <!-- <logger name="com.framsticks.util.dispatching.AbstractJoinable.Report" level="info" /> -->
Note: See TracChangeset for help on using the changeset viewer.