source: java/main/src/test/java/com/framsticks/core/ListChangeTest.java @ 102

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

HIGHLIGHTS:

for Joinables running

CHANGELOG:
Add WorkPackageLogic? and classes representing prime experiment state.

Add classes for PrimeExperiment? state.

Extract single netload routine in Simulator.

Working netload with dummy content in PrimeExperiment?.

More development with NetLoadSaveLogic? and PrimeExperiment?.

Improvement around prime.

Improve BufferedDispatcher?.isActive logic.

Add prime-all.xml configuration.

Manual connecting to existing simulators from GUI.

Guard in SimulatorConnector? against expdef mismatch.

Guard against empty target dispatcher in BufferedDispatcher?.

Make BufferedDispatcher? a Dispatcher (and Joinable).

Minor improvements.

Done StackedJoinable?, improve Experiment.

Develop StackedJoinable?.

Add StackedJoinable? utility joinables controller.

Add dependency on apache-commons-lang.

Add ready ListChange? on Simulators.

Improve hints in ListChange?.

Several improvements.

Found bug with dispatching in Experiment.

Minor improvements.

Fix bug with early finishing Server.

Many changes in Dispatching.

Fix bug with connection.

Do not obfuscate log with socket related exceptions.

Add SocketClosedException?.

Add SimulatorConnector?.

Work out conception of experiment composing of logics building blocks.

Rename SinkInterface? to Sink.

Move saving of Accesses into AccessOperations?.

Some improvements to Experiment.

Improve joinables.

Fix issue with joinables closing.

Add direct and managed consoles to popup menu.

File size: 2.1 KB
Line 
1package com.framsticks.core;
2
3import java.util.Arrays;
4
5import org.testng.annotations.BeforeMethod;
6import org.testng.annotations.Test;
7
8import com.framsticks.core.ListChange.Action;
9import static com.framsticks.params.AccessOperations.*;
10import com.framsticks.params.FramsClass;
11import com.framsticks.params.ListSink;
12import com.framsticks.params.ListSource;
13import com.framsticks.params.ReflectionAccess;
14import com.framsticks.test.TestConfiguration;
15
16import static org.fest.assertions.Assertions.*;
17
18@Test
19public class ListChangeTest extends TestConfiguration {
20
21        FramsClass framsClass;
22        ReflectionAccess access;
23        ListChange listChange;
24
25        @BeforeMethod
26        public void clearListChange() {
27                listChange = new ListChange();
28        }
29
30        // @Test
31        // public void testEnumBehaviour() {
32        //      for (Action a : Action.class.getEnumConstants()) {
33        //              // assertThat(Integer.class.cast(a)).isEqualTo(a.ordinal());
34        //              assertThat(Action.class.cast(a.ordinal())).isEqualTo(a);
35        //      }
36
37        // }
38
39        @Test
40        public void testFramsClass() {
41                framsClass = FramsClass.build().forClass(ListChange.class);
42                assertThat(framsClass.getParamCount()).isEqualTo(4);
43        }
44
45        @Test(dependsOnMethods = "testFramsClass")
46        public void createReflectionAccess() {
47                access = new ReflectionAccess(ListChange.class, framsClass);
48        }
49
50        @Test(dependsOnMethods = "createReflectionAccess")
51        public void manualAccess() {
52                access.select(listChange);
53
54                access.set("type", 2);
55                assertThat(listChange.action).isEqualTo(Action.Modify);
56
57                listChange.action = Action.Remove;
58                assertThat(access.get("type", Integer.class)).isEqualTo(1);
59        }
60
61        @Test(dependsOnMethods = "createReflectionAccess")
62        public void loading() throws Exception {
63                load(access.select(listChange), ListSource.createFrom("type:2", "pos:0", "id:test"));
64
65                assertThat(listChange.action).isEqualTo(Action.Modify);
66                assertThat(listChange.position).isEqualTo(0);
67                assertThat(listChange.identifier).isEqualTo("test");
68
69                ListSink sink = new ListSink();
70                save(access.select(listChange), sink);
71                assertThat(sink.getOut()).isEqualTo(Arrays.asList("ListChange:", "type:2", "pos:0", "id:test", ""));
72        }
73
74}
Note: See TracBrowser for help on using the repository browser.