Skip to content

Commit

Permalink
additional tests for WiThrottle; some JUnit4 conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
pabender committed Oct 30, 2018
1 parent cf4da21 commit 269bff3
Show file tree
Hide file tree
Showing 14 changed files with 293 additions and 312 deletions.
33 changes: 6 additions & 27 deletions java/test/jmri/jmrit/withrottle/ConsistControllerTest.java
Expand Up @@ -5,43 +5,23 @@
import jmri.NamedBeanHandleManager; import jmri.NamedBeanHandleManager;
import jmri.jmrit.consisttool.TestConsistManager; import jmri.jmrit.consisttool.TestConsistManager;
import jmri.util.JUnitUtil; import jmri.util.JUnitUtil;
import junit.framework.Test; import org.junit.*;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.junit.Assert;


/** /**
* Test simple functioning of ConsistController * Test simple functioning of ConsistController
* *
* @author Paul Bender Copyright (C) 2016 * @author Paul Bender Copyright (C) 2016
*/ */
public class ConsistControllerTest extends TestCase { public class ConsistControllerTest {


@Test
public void testCtor() { public void testCtor() {
ConsistController panel = new ConsistController(); ConsistController panel = new ConsistController();
Assert.assertNotNull("exists", panel ); Assert.assertNotNull("exists", panel );
} }


// from here down is testing infrastructure @Before
public ConsistControllerTest(String s) { public void setUp() {
super(s);
}

// Main entry point
static public void main(String[] args) {
String[] testCaseName = {"-noloading", ConsistControllerTest.class.getName()};
junit.textui.TestRunner.main(testCaseName);
}

// test suite from all defined tests
public static Test suite() {
TestSuite suite = new TestSuite(ConsistControllerTest.class);
return suite;
}

@Override
public void setUp() throws Exception {
super.setUp();
jmri.util.JUnitUtil.setUp(); jmri.util.JUnitUtil.setUp();


jmri.util.JUnitUtil.resetProfileManager(); jmri.util.JUnitUtil.resetProfileManager();
Expand All @@ -51,9 +31,8 @@ public void setUp() throws Exception {
InstanceManager.setDefault(NamedBeanHandleManager.class, new NamedBeanHandleManager()); InstanceManager.setDefault(NamedBeanHandleManager.class, new NamedBeanHandleManager());
} }


@Override @After
public void tearDown() throws Exception { public void tearDown() throws Exception {
super.tearDown();
JUnitUtil.tearDown(); JUnitUtil.tearDown();
} }
} }
36 changes: 7 additions & 29 deletions java/test/jmri/jmrit/withrottle/ConsistFunctionControllerTest.java
Expand Up @@ -2,52 +2,30 @@


import jmri.InstanceManager; import jmri.InstanceManager;
import jmri.NamedBeanHandleManager; import jmri.NamedBeanHandleManager;
import junit.framework.Test; import org.junit.*;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.junit.Assert;


/** /**
* Test simple functioning of ConsistFunctionController * Test simple functioning of ConsistFunctionController
* *
* @author Paul Bender Copyright (C) 2016 * @author Paul Bender Copyright (C) 2016
*/ */
public class ConsistFunctionControllerTest extends TestCase { public class ConsistFunctionControllerTest {


@Test
public void testCtor() { public void testCtor() {
ThrottleController tc = new ThrottleController(); ThrottleController tc = new ThrottleController();
ConsistFunctionController panel = new ConsistFunctionController(tc); ConsistFunctionController panel = new ConsistFunctionController(tc);
Assert.assertNotNull("exists", panel ); Assert.assertNotNull("exists", panel );
} }


// from here down is testing infrastructure @Before
public ConsistFunctionControllerTest(String s) { public void setUp() {
super(s);
}

// Main entry point
static public void main(String[] args) {
String[] testCaseName = {"-noloading", ConsistFunctionControllerTest.class.getName()};
junit.textui.TestRunner.main(testCaseName);
}

// test suite from all defined tests
public static Test suite() {
TestSuite suite = new TestSuite(ConsistFunctionControllerTest.class);
return suite;
}

@Override
public void setUp() throws Exception {
super.setUp();
jmri.util.JUnitUtil.setUp(); jmri.util.JUnitUtil.setUp();
InstanceManager.setDefault(NamedBeanHandleManager.class, new NamedBeanHandleManager()); InstanceManager.setDefault(NamedBeanHandleManager.class, new NamedBeanHandleManager());
} }


@Override @After
public void tearDown() throws Exception { public void tearDown() {
super.tearDown();
jmri.util.JUnitUtil.tearDown(); jmri.util.JUnitUtil.tearDown();

} }
} }
39 changes: 39 additions & 0 deletions java/test/jmri/jmrit/withrottle/ControllerInterfaceScaffold.java
@@ -0,0 +1,39 @@
package jmri.jmrit.withrottle;

/**
* Provide a dummy controller interface so that functionallity can
* be tested.
*
* @author Paul Bender Copyright (C) 2018
*/
public class ControllerInterfaceScaffold implements ControllerInterface {

private String lastPacket = null;
private String lastAlert = null;
private String lastInfo = null;

public void sendPacketToDevice(String message){
lastPacket = message;
}

public String getLastPacket(){
return lastPacket;
}

public void sendAlertMessage(String message){
lastAlert = message;
}

public String getLastAlert(){
return lastAlert;
}

public void sendInfoMessage(String message){
lastInfo = message;
}

public String getLastInfo(){
return lastInfo;
}

}
35 changes: 7 additions & 28 deletions java/test/jmri/jmrit/withrottle/DeviceServerTest.java
Expand Up @@ -3,18 +3,16 @@
import jmri.InstanceManager; import jmri.InstanceManager;
import jmri.NamedBeanHandleManager; import jmri.NamedBeanHandleManager;
import jmri.util.JUnitUtil; import jmri.util.JUnitUtil;
import junit.framework.Test; import org.junit.*;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.junit.Assert;


/** /**
* Test simple functioning of DeviceServer * Test simple functioning of DeviceServer
* *
* @author Paul Bender Copyright (C) 2016 * @author Paul Bender Copyright (C) 2016
*/ */
public class DeviceServerTest extends TestCase { public class DeviceServerTest {


@Test
public void testCtor() { public void testCtor() {
java.net.Socket s = new java.net.Socket(); java.net.Socket s = new java.net.Socket();
FacelessServer f = new FacelessServer(){ FacelessServer f = new FacelessServer(){
Expand All @@ -27,33 +25,14 @@ public void listen(){
Assert.assertNotNull("exists", panel ); Assert.assertNotNull("exists", panel );
} }


// from here down is testing infrastructure @Before
public DeviceServerTest(String s) { public void setUp() {
super(s);
}

// Main entry point
static public void main(String[] args) {
String[] testCaseName = {"-noloading", DeviceServerTest.class.getName()};
junit.textui.TestRunner.main(testCaseName);
}

// test suite from all defined tests
public static Test suite() {
TestSuite suite = new TestSuite(DeviceServerTest.class);
return suite;
}

@Override
public void setUp() throws Exception {
super.setUp();
JUnitUtil.setUp(); JUnitUtil.setUp();
InstanceManager.setDefault(NamedBeanHandleManager.class, new NamedBeanHandleManager()); InstanceManager.setDefault(NamedBeanHandleManager.class, new NamedBeanHandleManager());
} }


@Override @After
public void tearDown() throws Exception { public void tearDown() {
super.tearDown();
JUnitUtil.tearDown(); JUnitUtil.tearDown();
} }
} }

0 comments on commit 269bff3

Please sign in to comment.