source: java/main/src/test/java/com/framsticks/params/FramsClassBuilderTest.java @ 100

Last change on this file since 100 was 100, checked in by psniegowski, 11 years ago

HIGHLIGHTS:

  • add <include/> to configuration
  • add side notes to tree
    • used to store arbitrary information alongside the tree structure
  • migrate to log4j2
    • supports lazy string evaluation of passed arguments
  • improve GUI tree
    • it stays in synchronization with actual state (even in high load test scenario)
  • improve panel management in GUI
  • make loading objects in GUI more lazy
  • offload parsing to connection receiver thread
    • info parsing
    • first step of objects parsing
  • fix connection parsing bug (eof in long values)
  • support zero-arguments procedure in table view

CHANGELOG:
Implement procedure calls from table view.

Refactorization around procedures in tables.

Add table editor for buttons.

Render buttons in the the list view.

Further improve Columns.

Add Column class for TableModel?.

Accept also non-arguments ProcedureParams? in tableView.

Increase maximal TextAreaControl? size.

Add tooltip to ProcedureControl?.

Fix bug of interpreting eofs in long values by connection reader.

Further rework connection parsing.

Simplify client connection processing.

Test ListChange? modification.

Test ListChange? events with java server.

Add TestChild?.

Fix bug with fast deregistering when connecting to running server.

Another minor refactorization in TreeOperations?.

Fix bug in SimpleAbstractAccess? loading routine.

Another minor improvement.

Minor change.

Make reading of List objects two-phase.

Another minor change.

Dispatch parsing into receiver thread.

Another step.

Enclose passing value in ObjectParam? case in closure.

Minor step.

Minor change on way to offload parsing.

Temporarily comment out single ValueParam? get.

It will be generalized to multi ValueParam?.

Process info in receiver thread.

Add DispatchingExceptionHandler?.

Make waits in browser test longer.

Use FETCHED_MARK.

It is honored in GUI, where it used to decide whether to get values

after user action.

It is set in standard algorithm for processing fetched values.

Add remove operation to side notes.

Make loading more lazy.

Improve loading policy.

On node choose load itself, on node expansion, load children.

Minor improvement.

Fix bug with panel interleaving.

Minor improvements.

Improve panel management.

More cleaning around panels.

Reorganize panels.

Further improve tree.

Fix bug in TreeModel?.

Remove children from TreeNode?.

Implement TreeNode? hashCode and equals.

Make TreeNode? delegate equals and hashcode to internal reference.

Move listeners from TreeNode? to side notes.

Store path.textual as a side note.

Side note params instead of accesses for objects.

More refactorizations.

In TreeNode? bindAccess based on side notes.

Minor step.

Hide createAccess.

Rename AccessInterface? to Access.

Minor changes.

Several improvements in high load scenarios.

Change semantics of ArrayListAccess?.set(index, null);

It now removes the element, making list shorter
(it was set to null before).

Add path remove handler.

Handle exceptions in Connection.

Update .gitignore

Configure logging to file.

Move registration to TreeModel?.

Further refactorization.

Minor refactorization.

Minor improvements.

Use specialized event also for Modify action of ListChange?.

Use remove events.

Use the insertion events for tree.

Further improve tree refreshing.

Further improve reacting on events in GUI.

Fix problem with not adding objects on addition list change.

Migrate to log4j lazy String construction interface.

Migrate imports to log4j2.

Drop dependency on adapter to version 1.2.

Switch log4j implementation to log4j2.

Add dirty mark to the NodeAtFrame?.

Make selecting in AccessInterfaces? type safe.

Ignore containers size settings in Model and Genotype.

Use tree side notes to remember local changes and panels.

Add sideNotes to tree.

They will be used to store various accompanying information
right in the tree.

Use ReferenceIdentityMap? from apache in TreeNode?.

It suits the need perfectly (weak semantics on both key and value).

Make ArrayListParam? do not react size changes.

Guard in TableModel? before not yet loaded objects.

Add <include/> clause and AutoInjector?.

Extract common columns configuration to separate xml,
that can be included by other configurations.

File size: 4.1 KB
Line 
1package com.framsticks.params;
2
3import java.util.Arrays;
4
5import org.testng.annotations.BeforeClass;
6import org.testng.annotations.Test;
7
8import com.framsticks.params.types.EventParam;
9import com.framsticks.params.types.ProcedureParam;
10import com.framsticks.params.types.StringParam;
11import com.framsticks.parsers.Savers;
12import com.framsticks.test.ChangeEvent;
13import com.framsticks.test.TestClass;
14import com.framsticks.test.TestConfiguration;
15import com.framsticks.util.lang.Holder;
16
17import static org.fest.assertions.Assertions.*;
18
19@Test
20public class FramsClassBuilderTest extends TestConfiguration {
21
22        FramsClass framsClass;
23        ReflectionAccess access;
24        TestClass test;
25
26        @BeforeClass
27        public void setUp() {
28                test = new TestClass();
29                test.setName("test");
30                test.appendHistory("first");
31                framsClass = FramsClass.build().forClass(TestClass.class);
32        }
33
34        @Test
35        public void checkProcedureParams() {
36                assertThat(framsClass.getParamCount()).isEqualTo(8);
37
38                assertThat(framsClass.getParam("name")).isInstanceOf(StringParam.class);
39                assertThat(framsClass.getParam("history")).isInstanceOf(StringParam.class);
40                assertThat(framsClass.getParam("history_changed")).isInstanceOf(EventParam.class);
41
42                assertThat(framsClass.getParam("appendHistory")).isInstanceOf(ProcedureParam.class);
43                assertThat(framsClass.getParam("resetHistory")).isInstanceOf(ProcedureParam.class);
44
45                ProcedureParam appendHistory = framsClass.getParamEntry("appendHistory", ProcedureParam.class);
46                assertThat(appendHistory.getArgumentsType().size()).isEqualTo(1);
47                assertThat(appendHistory.getArgumentsType().get(0).getId()).isEqualTo("arg0");
48        }
49
50        @Test(dependsOnMethods = "checkProcedureParams")
51        public void print() {
52                assertThat(Savers.saveFramsClass(new ListSink(), framsClass).getOut()).isEqualTo(
53                                Arrays.asList(
54                                        "class:",
55                                        "name:TestClass",
56                                        "id:TestClass",
57                                        "",
58                                        "prop:",
59                                        "id:name",
60                                        "name:Name",
61                                        "type:s",
62                                        "",
63                                        "prop:",
64                                        "id:history",
65                                        "name:History",
66                                        "type:s",
67                                        "",
68                                        "prop:",
69                                        "id:history_changed",
70                                        "name:HistoryListener",
71                                        "type:e ChangeEvent",
72                                        "",
73                                        "prop:",
74                                        "id:appendHistory",
75                                        "name:AppendHistory",
76                                        "type:p d(s arg0)",
77                                        "",
78                                        "prop:",
79                                        "id:resetHistory",
80                                        "name:ResetHistory",
81                                        "type:p()",
82                                        "",
83                                        "prop:",
84                                        "id:children",
85                                        "name:Children",
86                                        "type:l TestChild uid",
87                                        "flags:1",
88                                        "",
89                                        "prop:",
90                                        "id:createChild",
91                                        "name:CreateChild",
92                                        "type:p(s arg0)",
93                                        "",
94                                        "prop:",
95                                        "id:children_changed",
96                                        "name:ChildrenListener",
97                                        "type:e ListChange",
98                                        ""
99                                )
100                        );
101        }
102
103        @Test(dependsOnMethods = "print")
104        public void createAccess() {
105                access = new ReflectionAccess(TestClass.class, framsClass);
106                access.select(test);
107        }
108
109        @Test(dependsOnMethods = "createAccess")
110        public void callProcedures() {
111
112                assertThat(access.get("history", String.class)).isEqualTo("initial|first|");
113                Object result = access.call("appendHistory", new Object[] {"second"});
114
115                assertThat(result).isInstanceOf(Integer.class);
116                assertThat(result).isEqualTo(21);
117                assertThat(access.get("history", String.class)).isEqualTo("initial|first|second|");
118
119                result = access.call("resetHistory", null);
120                assertThat(result).isNull();
121
122                assertThat(access.get("history", String.class)).isEqualTo("");
123        }
124
125        @Test(dependsOnMethods = "callProcedures")
126        public void listeners() {
127
128                final Holder<String> called = new Holder<>();
129
130                final EventListener<ChangeEvent> listener = new EventListener<ChangeEvent>() {
131
132                        @Override
133                        public void action(ChangeEvent argument) {
134                                called.set(argument.history);
135                        }
136                };
137
138                final EventParam eventParam = access.getFramsClass().getParamEntry("history_changed", EventParam.class);
139                access.reg(eventParam, listener);
140
141                final String currentHistory = access.get("history", String.class);
142                final String addition = "test";
143
144                access.call("appendHistory", new Object[] { addition });
145
146                String expected = currentHistory + addition + "|";
147                assertThat(access.get("history", String.class)).isEqualTo(expected);
148                assertThat(called.get()).isEqualTo(expected);
149                access.regRemove(eventParam, listener);
150        }
151
152}
Note: See TracBrowser for help on using the repository browser.