Skip to content
Permalink
Browse files

additional tests for WiThrottle; some JUnit4 conversions

  • Loading branch information...
pabender committed Oct 30, 2018
1 parent cf4da21 commit 269bff319bd3812c5b5c4902f60f3063ffcdb02b
@@ -5,43 +5,23 @@
import jmri.NamedBeanHandleManager;
import jmri.jmrit.consisttool.TestConsistManager;
import jmri.util.JUnitUtil;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.junit.Assert;
import org.junit.*;

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

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

// from here down is testing infrastructure
public ConsistControllerTest(String s) {
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();
@Before
public void setUp() {
jmri.util.JUnitUtil.setUp();

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

@Override
@After
public void tearDown() throws Exception {
super.tearDown();
JUnitUtil.tearDown();
}
}
@@ -2,52 +2,30 @@

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

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

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

// from here down is testing infrastructure
public ConsistFunctionControllerTest(String s) {
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();
@Before
public void setUp() {
jmri.util.JUnitUtil.setUp();
InstanceManager.setDefault(NamedBeanHandleManager.class, new NamedBeanHandleManager());
}

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

}
}
@@ -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;
}

}
@@ -3,18 +3,16 @@
import jmri.InstanceManager;
import jmri.NamedBeanHandleManager;
import jmri.util.JUnitUtil;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.junit.Assert;
import org.junit.*;

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

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

// from here down is testing infrastructure
public DeviceServerTest(String s) {
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();
@Before
public void setUp() {
JUnitUtil.setUp();
InstanceManager.setDefault(NamedBeanHandleManager.class, new NamedBeanHandleManager());
}

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

0 comments on commit 269bff3

Please sign in to comment.
You can’t perform that action at this time.