Changeset 97 for java/main/src/test
- Timestamp:
- 07/06/13 03:51:11 (11 years ago)
- Location:
- java/main/src/test
- Files:
-
- 9 added
- 3 deleted
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
java/main/src/test/java/com/framsticks/dumping/StreamTest.java
r96 r97 16 16 // public void result(Path result, Exception e) { 17 17 // if (e != null) { 18 // log.error("failed to load file instance " + FileInstance.this + ": " + e);18 // log.error("failed to load file: " + e); 19 19 // fireRun(e); 20 20 // return; 21 21 // } 22 // log.info("loaded file instance " + FileInstance.this);22 // log.info("loaded file"); 23 23 // fireRun(null); 24 24 // } -
java/main/src/test/java/com/framsticks/gui/BrowserBaseTest.java
r96 r97 4 4 5 5 import org.apache.log4j.Logger; 6 import org.fest.swing.core.Robot;7 import org.fest.swing.edt.FailOnThreadViolationRepaintManager;8 6 import org.fest.swing.edt.GuiQuery; 9 7 import org.fest.swing.fixture.FrameFixture; … … 11 9 import org.testng.annotations.Test; 12 10 13 import com.framsticks.test.MonitorBasedTest; 11 12 import org.fest.swing.edt.GuiActionRunner; 13 14 14 import com.framsticks.util.dispatching.Joinable; 15 15 16 import static org.fest.assertions.Assertions.assertThat;17 import static org.fest.swing.edt.GuiActionRunner.executeInEDT;18 import static org.fest.swing.core.BasicRobot.robotWithNewAwtHierarchy;19 import org.fest.swing.edt.GuiActionRunner;20 21 16 @Test 22 public abstract class BrowserBaseTest extends MonitorBasedTest {17 public abstract class BrowserBaseTest extends GuiTest { 23 18 24 19 private static final Logger log = Logger.getLogger(BrowserTest.class); 25 20 26 21 protected Browser browser; 27 protected static Robot robot;28 22 protected FrameFixture frame; 29 23 protected JTreeFixture tree; 30 31 static {32 FailOnThreadViolationRepaintManager.install();33 assertThat(executeInEDT()).isTrue();34 35 robot = robotWithNewAwtHierarchy();36 }37 24 38 25 @Override … … 64 51 } 65 52 66 protected void waitForIdle() {67 robot.waitForIdle();68 }69 53 70 54 } -
java/main/src/test/java/com/framsticks/gui/BrowserTest.java
r96 r97 3 3 import static org.fest.assertions.Assertions.assertThat; 4 4 import static org.fest.swing.edt.GuiActionRunner.execute; 5 6 import java.awt.event.KeyEvent; 5 7 6 8 … … 10 12 11 13 import com.framsticks.model.ModelPackage; 12 import com.framsticks.remote.SimulatorInstance; 14 import com.framsticks.remote.SimulatorTree; 15 import com.framsticks.util.dispatching.Dispatching; 13 16 14 17 public class BrowserTest extends BrowserBaseTest { … … 16 19 private static final Logger log = Logger.getLogger(BrowserTest.class); 17 20 18 Simulator Instance localhost;21 SimulatorTree localhost; 19 22 20 23 @Override … … 22 25 browser = new Browser(); 23 26 24 localhost = new Simulator Instance();27 localhost = new SimulatorTree(); 25 28 localhost.setName("localhost"); 26 29 localhost.setAddress("localhost:9009"); 27 30 localhost.usePackage(new ModelPackage()); 28 31 29 browser.add Instance(localhost);32 browser.addTree(localhost); 30 33 31 34 } 32 35 33 @Test(timeOut = 10000)36 @Test(timeOut = 30000) 34 37 public void testShow() { 35 38 log.info("testing"); 36 39 tree.clickRow(0).expandRow(0); 37 40 robot.waitForIdle(); 41 38 42 tree.clickRow(1).expandRow(1); 39 43 robot.waitForIdle(); … … 47 51 }); 48 52 53 49 54 clickAndExpandPath("localhost/simulator/genepools"); 50 55 clickAndExpandPath("localhost/simulator/genepools/groups"); 51 56 clickAndExpandPath("localhost/simulator/genepools/groups/Genotypes"); 57 clickAndExpandPath("localhost/simulator/genepools/groups/Genotypes/genotypes"); 58 Dispatching.sleep(2.0); 59 clickAndExpandPath("localhost/simulator/genepools/groups/Genotypes/genotypes"); 60 robot.pressAndReleaseKey(KeyEvent.VK_J); 61 waitForIdle(); 62 Dispatching.sleep(2.0); 63 64 frame.panel("Genotype").panel("name").textBox("value").enterText("-Żółw"); 65 clickButton(frame.panel("Genotype").button("apply")); 66 67 Dispatching.sleep(1.0); 52 68 } 53 69 -
java/main/src/test/java/com/framsticks/gui/ProcedureBrowserTest.java
r96 r97 7 7 import org.testng.annotations.Test; 8 8 9 import com.framsticks.core. Instance;10 import com.framsticks.core.Object Instance;9 import com.framsticks.core.Tree; 10 import com.framsticks.core.ObjectTree; 11 11 import com.framsticks.params.AccessInterface; 12 12 import com.framsticks.params.FramsClass; … … 15 15 import com.framsticks.parsers.XmlLoader; 16 16 import com.framsticks.test.TestClass; 17 // import com.framsticks.util.dispatching.Dispatching; 17 18 import com.framsticks.util.dispatching.RunAt; 18 import static com.framsticks.core. InstanceUtils.*;19 import static com.framsticks.core.TreeOperations.*; 19 20 20 21 @Test 21 22 public class ProcedureBrowserTest extends BrowserBaseTest { 22 23 23 Object Instance instance;24 ObjectTree tree; 24 25 25 26 @Override … … 27 28 browser = new XmlLoader().load(Browser.class, getClass().getResourceAsStream("/configs/ProcedureBrowserTest.xml")); 28 29 29 assertThat(browser.get Instances().size()).isEqualTo(1);30 assertThat(browser.get Instances().get("test")).isInstanceOf(ObjectInstance.class);30 assertThat(browser.getTrees().size()).isEqualTo(1); 31 assertThat(browser.getTrees().get("test")).isInstanceOf(ObjectTree.class); 31 32 32 instance = (ObjectInstance) browser.getInstances().get("test");33 tree = (ObjectTree) browser.getTrees().get("test"); 33 34 } 34 35 35 36 @Test(timeOut = 10000) 36 37 public void testShow() { 37 instance.dispatch(new RunAt<Instance>() {38 tree.dispatch(new RunAt<Tree>(failOnException) { 38 39 @Override 39 p ublic void run() {40 assertThat( instance.getRootObject()).isInstanceOf(TestClass.class);40 protected void runAt() { 41 assertThat(tree.getRootObject()).isInstanceOf(TestClass.class); 41 42 } 42 43 }); … … 44 45 clickAndExpandPath("test"); 45 46 46 instance.dispatch(new RunAt<Instance>() {47 tree.dispatch(new RunAt<Tree>(failOnException) { 47 48 @Override 48 p ublic void run() {49 assertThat(bindAccess( instance, "/").getFramsClass().getParam("history")).isInstanceOf(StringParam.class);49 protected void runAt() { 50 assertThat(bindAccess(tree, "/").getFramsClass().getParam("history")).isInstanceOf(StringParam.class); 50 51 } 51 52 }); … … 53 54 // monitor.useFor(4.0); 54 55 55 instance.dispatch(new RunAt<Instance>() {56 tree.dispatch(new RunAt<Tree>(failOnException) { 56 57 @Override 57 p ublic void run() {58 AccessInterface access = bindAccess( instance, "/");58 protected void runAt() { 59 AccessInterface access = bindAccess(tree, "/"); 59 60 assertThat(access).isInstanceOf(ReflectionAccess.class); 60 61 FramsClass framsClass = access.getFramsClass(); … … 65 66 assertThat(framsClass.getParam(3).getId()).isEqualTo("resetHistory"); 66 67 67 assertThat(access.get("history", String.class)).isEqualTo(" ");68 assertThat(access.get("history", String.class)).isEqualTo("initial|"); 68 69 } 69 70 }); 70 71 71 72 // frame.panel("TestClass"); 72 JPanelFixture appendHistory = frame.panel("TestClass").panel("appendHistory"); 73 appendHistory.panel("arg0").textBox("value").enterText("argument"); 74 appendHistory.button("call").click(); 73 final JPanelFixture appendHistory = frame.panel("TestClass").panel("appendHistory"); 74 appendHistory.panel("arg0").textBox("value").enterText("Żółw"); 75 assertThat(appendHistory.panel("arg0").textBox("value").text()).isEqualTo("Żółw"); 76 clickButton(appendHistory.button("call")); 75 77 waitForIdle(); 76 78 77 instance.dispatch(new RunAt<Instance>() { 79 80 tree.dispatch(new RunAt<Tree>(failOnException) { 78 81 @Override 79 p ublic void run() {80 assertThat(bindAccess( instance, "/").get("history", String.class)).isEqualTo("argument|");82 protected void runAt() { 83 assertThat(bindAccess(tree, "/").get("history", String.class)).isEqualTo("initial|Żółw|"); 81 84 } 82 85 }); 83 86 84 frame.panel("TestClass").panel("resetHistory").button("call").click();87 clickButton(frame.panel("TestClass").panel("resetHistory").button("call")); 85 88 waitForIdle(); 86 89 87 instance.dispatch(new RunAt<Instance>() {90 tree.dispatch(new RunAt<Tree>(failOnException) { 88 91 @Override 89 p ublic void run() {90 assertThat(bindAccess( instance, "/").get("history", String.class)).isEqualTo("");92 protected void runAt() { 93 assertThat(bindAccess(tree, "/").get("history", String.class)).isEqualTo(""); 91 94 } 92 95 }); -
java/main/src/test/java/com/framsticks/hosting/ServerTest.java
r96 r97 4 4 import org.testng.annotations.Test; 5 5 6 import com.framsticks.core.ObjectInstance; 6 import com.framsticks.core.Mode; 7 import com.framsticks.core.ObjectTree; 7 8 import com.framsticks.core.Path; 8 9 import com.framsticks.core.XmlBasedTest; 9 import com.framsticks.remote.Remote Instance;10 import com.framsticks.remote.RemoteTree; 10 11 11 12 import com.framsticks.test.TestClass; 12 import com.framsticks.core. Instance;13 import com.framsticks.core.Tree; 13 14 import com.framsticks.params.FramsClass; 14 import com.framsticks.util.AbstractStateFunctor;15 15 import com.framsticks.util.dispatching.Dispatching; 16 16 import com.framsticks.params.AccessInterface; 17 import com.framsticks.params.PrimitiveParam; 17 18 import com.framsticks.params.PropertiesAccess; 18 import com.framsticks.params.ValueParam;19 19 import com.framsticks.params.types.ProcedureParam; 20 20 import com.framsticks.util.dispatching.Dispatching.Waiter; 21 import com.framsticks.util.dispatching.Future ;21 import com.framsticks.util.dispatching.FutureHandler; 22 22 import com.framsticks.util.dispatching.RunAt; 23 23 24 import static com.framsticks.core. InstanceUtils.*;24 import static com.framsticks.core.TreeOperations.*; 25 25 26 26 import static org.fest.assertions.Assertions.*; … … 29 29 public class ServerTest extends XmlBasedTest { 30 30 31 protected Remote Instance remote;31 protected RemoteTree remote; 32 32 protected FramsClass remoteTestFramsClass; 33 33 protected Path remotePath; 34 34 35 35 protected Server server; 36 protected Object Instance hosted;36 protected ObjectTree hosted; 37 37 protected TestClass hostedObject; 38 38 … … 46 46 assertThat(framsticks.size()).isEqualTo(2); 47 47 assertThat(framsticks.get("test")).isInstanceOf(Server.class); 48 assertThat(framsticks.get("remote")).isInstanceOf(Remote Instance.class);48 assertThat(framsticks.get("remote")).isInstanceOf(RemoteTree.class); 49 49 50 50 server = (Server) framsticks.get("test"); 51 remote = (Remote Instance) framsticks.get("remote");52 assertThat(server.getHosted()).isInstanceOf(Object Instance.class);53 hosted = (Object Instance) server.getHosted();51 remote = (RemoteTree) framsticks.get("remote"); 52 assertThat(server.getHosted()).isInstanceOf(ObjectTree.class); 53 hosted = (ObjectTree) server.getHosted(); 54 54 assertThat(hosted.getRootObject()).isInstanceOf(TestClass.class); 55 55 hostedObject = hosted.getRootObject(TestClass.class); … … 58 58 @Test(dependsOnMethods = "runServer") 59 59 public void fetchInfo() { 60 remote.dispatch(new RunAt< Instance>() {60 remote.dispatch(new RunAt<Tree>(failOnException) { 61 61 @Override 62 p ublic void run() {63 remote. fetchInfo(Path.to(remote, "/"), new Future<FramsClass>(failOnException()) {62 protected void runAt() { 63 remote.info(Path.to(remote, "/"), new FutureHandler<FramsClass>(failOnException) { 64 64 @Override 65 65 protected void result(FramsClass result) { … … 78 78 final Waiter waiter = produceWaiter(1.0); 79 79 80 remote.dispatch(new RunAt< Instance>() {80 remote.dispatch(new RunAt<Tree>(failOnException) { 81 81 @Override 82 p ublic void run() {82 protected void runAt() { 83 83 final Path path = Path.to(remote, "/"); 84 84 assertThat(path.isResolved()).isFalse(); 85 85 86 remote.resolve(path, new Future <Path>(failOnException()) {86 remote.resolve(path, new FutureHandler<Path>(failOnException) { 87 87 @Override 88 88 protected void result(final Path result) { 89 89 assertThat(result.isResolved()).isTrue(); 90 90 remotePath = result; 91 remote. fetchValues(result, new AbstractStateFunctor(failOnException()) {91 remote.get(result, Mode.FETCH, new FutureHandler<Object>(failOnException) { 92 92 @Override 93 p ublic void call() {93 protected void result(Object object) { 94 94 AccessInterface access = bindAccess(result); 95 95 assertThat(access).isInstanceOf(PropertiesAccess.class); … … 108 108 final Waiter waiter = produceWaiter(2.0); 109 109 110 s toreValue(remotePath, remoteTestFramsClass.getParamEntry("name", ValueParam.class), "new name", new AbstractStateFunctor(failOnException()) {110 set(remotePath, remoteTestFramsClass.getParamEntry("name", PrimitiveParam.class), "new name", new FutureHandler<Integer>(failOnException) { 111 111 @Override 112 public void call() { 112 protected void result(Integer flags) { 113 // assertThat(flags).isEqualTo(0); 113 114 /** And now check directly whether it was really set. */ 114 hosted.dispatch(new RunAt< Instance>() {115 hosted.dispatch(new RunAt<Tree>(failOnException) { 115 116 @Override 116 p ublic void run() {117 protected void runAt() { 117 118 assertThat(hostedObject.getName()).isEqualTo("new name"); 118 119 waiter.pass(); … … 128 129 final Waiter waiter = produceWaiter(2.0); 129 130 130 call(remotePath, remoteTestFramsClass.getParamEntry("resetHistory", ProcedureParam.class), new Object[] {}, new Future <Object>(failOnException()) {131 call(remotePath, remoteTestFramsClass.getParamEntry("resetHistory", ProcedureParam.class), new Object[] {}, new FutureHandler<Object>(failOnException) { 131 132 @Override 132 133 protected void result(Object result) { … … 135 136 }); 136 137 137 call(remotePath, remoteTestFramsClass.getParamEntry("appendHistory", ProcedureParam.class), new Object[] {"next word"}, new Future <Object>(failOnException()) {138 call(remotePath, remoteTestFramsClass.getParamEntry("appendHistory", ProcedureParam.class), new Object[] {"next word"}, new FutureHandler<Object>(failOnException) { 138 139 @Override 139 140 protected void result(Object result) { 140 hosted.dispatch(new RunAt< Instance>() {141 hosted.dispatch(new RunAt<Tree>(failOnException) { 141 142 @Override 142 p ublic void run() {143 protected void runAt() { 143 144 assertThat(hostedObject.getHistory()).isEqualTo("next word|"); 144 145 waiter.pass(); -
java/main/src/test/java/com/framsticks/model/f0/SchemaTest.java
r90 r97 20 20 assertThat(schema.getNeuroClasses().size()).isEqualTo(21); 21 21 22 assertThat(schema.getFramsClass("m").getName()).isEqualTo("Model"); 23 22 24 assertThat(schema.getNeuroClass("|").getName()).isEqualTo("Bend muscle"); 23 25 assertThat(schema.getNeuroClass("VEye").getParam("p")).isInstanceOf(FloatParam.class); -
java/main/src/test/java/com/framsticks/params/FramsClassBuilderTest.java
r96 r97 82 82 access.select(test); 83 83 84 assertThat(access.get("history", String.class)).isEqualTo(" first|");84 assertThat(access.get("history", String.class)).isEqualTo("initial|first|"); 85 85 Object result = access.call("appendHistory", new Object[] {"second"}); 86 86 87 87 assertThat(result).isInstanceOf(Integer.class); 88 assertThat(result).isEqualTo( 13);89 assertThat(access.get("history", String.class)).isEqualTo(" first|second|");88 assertThat(result).isEqualTo(21); 89 assertThat(access.get("history", String.class)).isEqualTo("initial|first|second|"); 90 90 91 91 result = access.call("resetHistory", null); -
java/main/src/test/java/com/framsticks/test/TestConfiguration.java
r96 r97 88 88 } 89 89 90 public static ExceptionResultHandler failOnException() { 91 return new ExceptionResultHandler() { 92 @Override 93 public void handle(FramsticksException e) { 94 assertThat(e).isNull(); 95 } 96 }; 97 98 } 90 public static final ExceptionResultHandler failOnException = new ExceptionResultHandler() { 91 @Override 92 public void handle(FramsticksException e) { 93 assertThat(e).isNull(); 94 } 95 }; 99 96 } -
java/main/src/test/resources/configs/FramsServerTest.xml
r90 r97 2 2 <Framsticks> 3 3 <import class="com.framsticks.running.FramsServer" /> 4 <import class="com.framsticks.remote.Remote Instance" />4 <import class="com.framsticks.remote.RemoteTree" /> 5 5 <import class="com.framsticks.running.LoggingOutputListener" /> 6 6 <FramsServer name="frams" port="9008"> 7 7 <LoggingOutputListener /> 8 8 </FramsServer> 9 <!-- <Remote Instance name="remote" address="localhost:9008" /> -->9 <!-- <RemoteTree name="remote" address="localhost:9008" /> --> 10 10 </Framsticks> -
java/main/src/test/resources/configs/ProcedureBrowserTest.xml
r90 r97 1 1 <?xml version="1.0" encoding="UTF-8"?> 2 2 <Browser> 3 <import class="com.framsticks.core.Object Instance" />3 <import class="com.framsticks.core.ObjectTree" /> 4 4 <import class="com.framsticks.test.TestClass" /> 5 <Object Instance name="test">5 <ObjectTree name="test"> 6 6 <TestClass /> 7 </Object Instance>7 </ObjectTree> 8 8 </Browser> -
java/main/src/test/resources/configs/ServerTest.xml
r96 r97 2 2 <Framsticks> 3 3 <import class="com.framsticks.hosting.Server" /> 4 <import class="com.framsticks.remote.Remote Instance" />5 <import class="com.framsticks.core.Object Instance" />4 <import class="com.framsticks.remote.RemoteTree" /> 5 <import class="com.framsticks.core.ObjectTree" /> 6 6 <import class="com.framsticks.test.TestClass" /> 7 7 <import class="com.framsticks.running.LoggingOutputListener" /> 8 8 <Server name="server" port="9007"> 9 <Object Instance name="test">9 <ObjectTree name="test"> 10 10 <TestClass name="a test name" /> 11 </Object Instance>11 </ObjectTree> 12 12 </Server> 13 <Remote Instance name="remote" address="localhost:9007" />13 <RemoteTree name="remote" address="localhost:9007" /> 14 14 </Framsticks> -
java/main/src/test/resources/configs/test.xml
r96 r97 2 2 <Framsticks> 3 3 <import class="com.framsticks.gui.Browser" /> 4 <import class="com.framsticks.remote.Simulator Instance" />4 <import class="com.framsticks.remote.SimulatorTree" /> 5 5 <Browser name="browser"> 6 <Simulator Instance name="localhost:9009" address="localhost:9009" />6 <SimulatorTree name="localhost:9009" address="localhost:9009" /> 7 7 </Browser> 8 8 </Framsticks> -
java/main/src/test/resources/log4j.properties
r96 r97 26 26 log4j.appender.STDOUT.layout.ConversionPattern=%d{ABSOLUTE} [%-5p] [%t] %c -- %m%n 27 27 28 log4j.logger.com.framsticks=INFO 29 # log4j.logger.com.framsticks.hosting.Server=DEBUG 28 log4j.logger.com.framsticks=WARN 29 log4j.logger.com.framsticks.test.TestConfiguration=INFO 30 # log4j.logger.com.framsticks.gui.console.TrackConsole=DEBUG 31 # log4j.logger.com.framsticks.gui.controls.ProcedureControl=DEBUG 32 # log4j.logger.com.framsticks.test.TestClass=DEBUG 30 33 # log4j.logger.com.framsticks.communication.ServerConnection=TRACE 31 # log4j.logger.com.framsticks.util.dispatching. AbstractJoinable=DEBUG34 # log4j.logger.com.framsticks.util.dispatching.Dispatching=DEBUG 32 35 # log4j.logger.com.framsticks.parsers.F0Writer=TRACE 33 # log4j.logger.com.framsticks.core.ObjectInstance=DEBUG34 # log4j.logger.com.framsticks.core.Instance=DEBUG35 36 # log4j.logger.com.framsticks.running=DEBUG 36 37 # log4j.logger.com.framsticks.parsers.XmlLoader=DEBUG
Note: See TracChangeset
for help on using the changeset viewer.