Ignore:
Timestamp:
07/10/13 22:41:02 (11 years ago)
Author:
psniegowski
Message:

HIGHLIGTS:

  • complete events implementation
  • add CLI in Java Framsticks server
  • add automatic registration for events in GUI
  • improve objects fetching (object are never overwritten with new instances)
  • properly react for ListChange? events
  • add ListPanel? with table view
    • columns to be shown may be statically specified in configuration
    • currently modyfying data through tables is not available
  • improve maven configuration
    • configuration file may be specified without touching pom.xml

CHANGELOG:
Extract constants from Flags into ParamFlags? and SetStateFlags?.

Extract flags I/O to FlagsUtils? class.

Configured maven to exec given resource configuration.

For example:
mvn exec:exec -Dframsticks.config=/configs/managed-console.xml

Cleanup pom.xml

Rename ObjectTree? to LocalTree? (also make LocalTree? and RemoteTree? final).

Minor change.

Add maximum number of columns in ListPanelProvider?.

Improve ColumnsConfig? interpretation.

Automatically fill FramsClass?.name if trying to construct empty.

Improve identitifer case mangling in XmlLoader?.

Introduce configurable ColumnsConfig?.

Draft working version of ListPanel?.

Table is being shown (although empty).

More improvements to table building.

Move some functionality from Frame to TreeModel?.

Move tree classes in gui to separate package.

Remove old table related classes.

Add draft implementation of TableModel?.

Redirect ParamBuilder?.forAccess to AccessInterface?.

Optimize ParamBuilder?.forAccess()

Do not clear list when loading.

Do not load fetched values directly.

Implement different AccessInterface? copying policy.

Optimize fetching values routine.

Remove Mode enum (work out get semantics).

Some improvements to ListChange? handling.

Improve UniqueListAccess?.

Add reaction for ListChanges? in the TreeNode?.

EventListeners? are being added in the TreeNode?.

Listeners for ListParams? are now very naive (they download
whole list).

Automatially register on events in GUI.

Events are working in RemoteTree? and Server.

Move listeners to the ClientSideManagedConnection?.

Remove old classes responsible for event subscriptions.

Improve event reading.

Improve events handling at server side.

Add register attribute in FramsClassAnnotation?
to automatically also register other classes.

Registering events works.

Setup for remote listeners registration.

More improvements.

Minor changes.

Add rootTree to the ClientAtServer?.

Moving CLI to the ClientAtServer?.

Fix bug: use Void.TYPE instead of Void.class

More development around CLI.

  • Improve Path resolving.

Add synthetic root to ObjectTree?.

It is needed to allow sybling for the original root
that would containg CLI.

Some work with registering events in RemoteTree?.

Draft implementation of listener registering in RemoteTree?.

Support events registration in the ObjectTree?.

Add events support to ReflectionAccess?.

EventParam? is recognized by ParamCandidate?.

Prepare interface for Events across project.

Add EventListener? and API for listeners in Tree.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • java/main/src/test/java/com/framsticks/hosting/ServerTest.java

    r98 r99  
    22
    33// import org.apache.log4j.Logger;
     4import java.util.Arrays;
     5import java.util.LinkedList;
     6import java.util.List;
     7
    48import org.testng.annotations.Test;
    59
    6 import com.framsticks.core.Mode;
    7 import com.framsticks.core.ObjectTree;
     10import com.framsticks.core.LocalTree;
    811import com.framsticks.core.Path;
     12import com.framsticks.core.TreeOperations;
    913import com.framsticks.core.XmlBasedTest;
    1014import com.framsticks.remote.RemoteTree;
    1115
     16import com.framsticks.test.ChangeEvent;
    1217import com.framsticks.test.TestClass;
    1318import com.framsticks.core.Tree;
    1419import com.framsticks.params.FramsClass;
    15 import com.framsticks.util.dispatching.Dispatching;
    1620import com.framsticks.params.AccessInterface;
     21import com.framsticks.params.EventListener;
    1722import com.framsticks.params.PrimitiveParam;
    1823import com.framsticks.params.PropertiesAccess;
     24import com.framsticks.params.types.EventParam;
     25// import com.framsticks.params.types.EventParam;
    1926import com.framsticks.params.types.ProcedureParam;
    2027import com.framsticks.util.dispatching.Dispatching.Waiter;
     
    3441
    3542        protected Server server;
    36         protected ObjectTree hosted;
     43        protected LocalTree hosted;
    3744        protected TestClass hostedObject;
     45        protected EventListener<ChangeEvent> listener;
     46        protected List<String> listenerArguments = new LinkedList<>();
    3847
    3948        @Override
     
    5059                server = (Server) framsticks.get("test");
    5160                remote = (RemoteTree) framsticks.get("remote");
    52                 assertThat(server.getHosted()).isInstanceOf(ObjectTree.class);
    53                 hosted = (ObjectTree) server.getHosted();
     61                assertThat(server.getHosted()).isInstanceOf(LocalTree.class);
     62                hosted = (LocalTree) server.getHosted();
    5463                assertThat(hosted.getRootObject()).isInstanceOf(TestClass.class);
    5564                hostedObject = hosted.getRootObject(TestClass.class);
     
    5867        @Test(dependsOnMethods = "runServer")
    5968        public void fetchInfo() {
    60                 remote.dispatch(new RunAt<Tree>(failOnException) {
     69                final Waiter waiter = produceWaiter(1.0);
     70
     71                TreeOperations.tryGet(remote, "/testClass", new FutureHandler<Path>(failOnException) {
    6172                        @Override
    62                         protected void runAt() {
    63                                 remote.info(Path.to(remote, "/"), new FutureHandler<FramsClass>(failOnException) {
    64                                         @Override
    65                                         protected void result(FramsClass result) {
    66                                                 remoteTestFramsClass = result;
    67                                                 assertThat(result.getId()).isEqualTo("TestClass");
    68                                         }
    69                                 });
     73                        protected void result(Path path) {
     74                                assertThat(path.isResolved()).isTrue();
     75                                remoteTestFramsClass = bindAccess(path).getFramsClass();
     76                                assertThat(remoteTestFramsClass.getName()).isEqualTo("TestClass");
     77                                waiter.pass();
    7078                        }
    7179                });
    7280
    73                 Dispatching.synchronize(remote, 1.0);
    7481        }
    7582
     
    7885                final Waiter waiter = produceWaiter(1.0);
    7986
    80                 remote.dispatch(new RunAt<Tree>(failOnException) {
     87                TreeOperations.tryGet(remote, "/testClass", new FutureHandler<Path>(failOnException) {
    8188                        @Override
    82                         protected void runAt() {
    83                                 final Path path = Path.to(remote, "/");
    84                                 assertThat(path.isResolved()).isFalse();
    85 
    86                                 remote.get(path, Mode.FETCH, new FutureHandler<Path>(failOnException) {
    87                                         @Override
    88                                         protected void result(Path path) {
    89                                                 assertThat(path.isResolved()).isTrue();
    90                                                 remotePath = path;
    91                                                 AccessInterface access = bindAccess(path);
    92                                                 assertThat(access).isInstanceOf(PropertiesAccess.class);
    93                                                 assertThat(access.get("name", String.class)).isEqualTo("a test name");
    94                                                 waiter.pass();
    95                                         }
    96                                 });
     89                        protected void result(Path path) {
     90                                assertThat(path.isResolved()).isTrue();
     91                                remotePath = path;
     92                                AccessInterface access = bindAccess(path);
     93                                assertThat(access).isInstanceOf(PropertiesAccess.class);
     94                                assertThat(access.get("name", String.class)).isEqualTo("a test name");
     95                                waiter.pass();
    9796                        }
    9897                });
     
    120119
    121120        @Test(dependsOnMethods = "setValueName")
     121        public void registerListener() {
     122                final Waiter waiter = produceWaiter(1.0);
     123                listener = new EventListener<ChangeEvent>() {
     124
     125                        @Override
     126                        public void action(ChangeEvent argument) {
     127                                listenerArguments.add(argument.history);
     128                        }
     129                };
     130
     131                TreeOperations.tryGet(remote, "/cli/events", new FutureHandler<Path>(failOnException) {
     132                        @Override
     133                        protected void result(Path path) {
     134                                waiter.pass();
     135                        }
     136                });
     137
     138                addListener(remotePath, remoteTestFramsClass.getParamEntry("history_changed", EventParam.class), listener, ChangeEvent.class, produceWaiter(1.0).passInFuture(Void.class));
     139        }
     140
     141        @Test(dependsOnMethods = "registerListener")
    122142        public void callMethod() {
    123                 final Waiter firstWaiter = produceWaiter(2.0);
    124143                final Waiter waiter = produceWaiter(2.0);
    125144
    126                 call(remotePath, remoteTestFramsClass.getParamEntry("resetHistory", ProcedureParam.class), new Object[] {}, new FutureHandler<Object>(failOnException) {
    127                         @Override
    128                         protected void result(Object result) {
    129                                 firstWaiter.pass();
    130                         }
    131                 });
     145                call(remotePath, remoteTestFramsClass.getParamEntry("resetHistory", ProcedureParam.class), new Object[] {}, produceWaiter(2.0).passInFuture(Object.class));
    132146
    133147                call(remotePath, remoteTestFramsClass.getParamEntry("appendHistory", ProcedureParam.class), new Object[] {"next word"}, new FutureHandler<Object>(failOnException) {
     
    143157                        }
    144158                });
     159        }
    145160
     161
     162        @Test(dependsOnMethods = "callMethod")
     163        public void deregisterListener() {
     164                removeListener(remotePath, remoteTestFramsClass.getParamEntry("history_changed", EventParam.class), listener, produceWaiter(1.0).passInFuture(Void.class));
     165
     166                assertThat(listenerArguments).isEqualTo(Arrays.asList("", "next word|"));
    146167        }
    147168
Note: See TracChangeset for help on using the changeset viewer.