source: java/main/src/test/java/com/framsticks/running/ExternalProcessTest.java @ 88

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

HIGHLIGHTS:

  • loading f0 schema with XmlLoader?
  • use XmlLoader? to load configuration
  • introduce unified fork-join model of various entities

(Instances, Connections, GUI Frames, etc.),
all those entities clean up gracefully on
shutdown, which may be initialized by user
or by some entity

  • basing on above, simplify several organizing classes

(Observer, main class)

(to host native frams server process from Java level)

CHANGELOG:
Remove redundant Observer class.

Clean up in AbstractJoinable?.

Update ExternalProcess? class to changes in joining model.

Another sweep through code with FindBugs?.

Find bug with not joining RemoteInstance?.

Joining almost works.

Much improved joining model.

More improvement to joining model.

Add logging messages around joinable operations.

Rename methods in AbstractJoinable?.

Improve Joinable.

Rewrite of entity structure.

More simplifications with entities.

Further improve joinables.

Let Frame compose from JFrame instead of inheriting.

Add join classes.

Improvements of closing.

Add Builder interface.

Add FramsServerTest?.xml

FramsServer? may be configured through xml.

Make Framsticks main class an Observer of Entities.

Make Observer a generic type.

Remove variables regarding to removed endpoint.

Simplify observer (remove endpoints).

More changes to Observer and Endpoint.

Minor improvements.

Add OutputListener? to ExternalProcess?.

Improve testing of ExternalProcess?.

Add ExternalProcess? runner.

Rename the Program class to Framsticks.

Migrate Program to use XmlLoader? configuration.

First steps with configuration using XmlLoader?.

Fix several bugs.

Move all f0 classes to apriopriate package.

XmlLoader? is able to load Schema.

XmlLoader? is loading classes and props.

Add GroupBuilder?.

File size: 1.1 KB
Line 
1package com.framsticks.running;
2
3
4// import java.util.Arrays;
5import java.util.Arrays;
6import java.util.LinkedList;
7import java.util.List;
8
9import org.testng.annotations.Test;
10
11import com.framsticks.test.TestConfiguration;
12import com.framsticks.util.dispatching.JoinableMonitor;
13
14import static org.fest.assertions.Assertions.*;
15
16@Test
17public class ExternalProcessTest extends TestConfiguration {
18
19        @Test
20        public void runBash() throws InterruptedException {
21                final ExternalProcess process = new ExternalProcess();
22                process.setCommand("bash");
23
24                final List<String> input = Arrays.asList("test", "another line");
25                final List<String> output = new LinkedList<>();
26
27                process.addListener(new OutputListener() {
28                        @Override
29                        public void onLineRead(String line) {
30                                output.add(line);
31                        }
32                });
33                JoinableMonitor monitor = new JoinableMonitor(process);
34                monitor.use();
35
36                for (String l : input) {
37                        process.getInput().println("echo " + l);
38                }
39
40                process.getInput().close();
41
42                monitor.waitFor();
43                monitor.drop();
44                monitor.join();
45
46                assertThat(output).isEqualTo(input);
47        }
48
49}
Note: See TracBrowser for help on using the repository browser.