Initialisation depot

This commit is contained in:
Serge NOEL
2026-06-17 14:00:51 +02:00
commit efdf1683af
33190 changed files with 5907629 additions and 0 deletions
@@ -0,0 +1,49 @@
package jmri.jmrit.speedometer;
import java.util.Locale;
import org.junit.jupiter.api.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
/**
* Tests for the Bundle class
*
* @author Bob Jacobsen Copyright (C) 2012
*/
public class BundleTest {
@Test
public void testGoodKeyMessage() {
assertEquals("Turnout", Bundle.getMessage("BeanNameTurnout"));
}
@Test
public void testBadKeyMessage() {
assertThrows(java.util.MissingResourceException.class, () -> Bundle.getMessage("FFFFFTTTTTTT"));
}
@Test
public void testGoodKeyMessageArg() {
assertEquals("Turnout", Bundle.getMessage("BeanNameTurnout", new Object[]{}));
assertEquals("About Test", Bundle.getMessage("TitleAbout", "Test"));
}
@Test
public void testBadKeyMessageArg() {
assertThrows(java.util.MissingResourceException.class, () -> Bundle.getMessage("FFFFFTTTTTTT", new Object[]{}));
}
@Test
public void testLocaleMessage() {
assertEquals("Scambio", Bundle.getMessage(Locale.ITALY, "BeanNameTurnout"));
}
@Test
public void testLocaleMessageArg() {
assertEquals("Scambio", Bundle.getMessage(Locale.ITALY, "BeanNameTurnout", new Object[]{}));
assertEquals("Informazioni su Test", Bundle.getMessage(Locale.ITALY, "TitleAbout", "Test"));
}
}
@@ -0,0 +1,70 @@
package jmri.jmrit.speedometer;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import javax.swing.JFrame;
import jmri.util.JUnitUtil;
import jmri.util.junit.annotations.DisabledIfHeadless;
import org.junit.jupiter.api.*;
import org.netbeans.jemmy.operators.JFrameOperator;
/**
* Test simple functioning of SpeedometerAction
*
* @author Paul Bender Copyright (C) 2016
*/
public class SpeedometerActionTest {
@Test
public void testCtor() {
SpeedometerAction action = new SpeedometerAction();
assertNotNull(action, "exists");
}
@Test
public void testStringCtor() {
SpeedometerAction action = new SpeedometerAction("Test SpeedometerAction");
assertNotNull(action, "exists");
}
@Test
public void testMakePanel(){
SpeedometerAction action = new SpeedometerAction("Test SpeedometerAction");
IllegalArgumentException ex = assertThrows(IllegalArgumentException.class, () -> action.makePanel());
assertNotNull(ex);
}
@Test
@DisabledIfHeadless
public void testActionCreateAndFire() {
SpeedometerAction action = new SpeedometerAction("Sensor Group");
action.actionPerformed(null);
// wait for frame with "Speedometer" in title, case insensitive
// first boolean is false for exact to allow substring to match
// second boolean is false to all case insensitive match
JFrame frame = JFrameOperator.waitJFrame("Speedometer", false, false);
assertNotNull(frame);
// verify the action provided the expected frame class
assertEquals(SpeedometerFrame.class.getName(), frame.getClass().getName());
JUnitUtil.dispose(frame);
}
@BeforeEach
public void setUp() {
JUnitUtil.setUp();
JUnitUtil.initInternalSensorManager();
}
@AfterEach
public void tearDown() {
JUnitUtil.clearShutDownManager();
JUnitUtil.tearDown();
}
}
@@ -0,0 +1,92 @@
package jmri.jmrit.speedometer;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import jmri.util.JUnitAppender;
import jmri.util.JUnitUtil;
import jmri.util.junit.annotations.DisabledIfHeadless;
import org.junit.jupiter.api.*;
/**
* Test simple functioning of SpeedometerFrame
*
* @author Paul Bender Copyright (C) 2016
*/
public class SpeedometerFrameTest {
@Test
@DisabledIfHeadless
public void testCtor() {
SpeedometerFrame frame = new SpeedometerFrame();
assertNotNull(frame, "exists");
JUnitUtil.dispose(frame);
}
@Test
@DisabledIfHeadless
public void testSetInputs(){
// this test only checks to see that we don't throw an exception when
// setting the input values.
SpeedometerFrame frame = new SpeedometerFrame();
frame.setInputs("IS1","IS2","IS3","5280","5280");
JUnitUtil.dispose(frame);
}
@Test
@DisabledIfHeadless
public void testVerifyInputsValid() {
SpeedometerFrame frame = new SpeedometerFrame();
// set the input values
frame.setInputs("IS1","IS2","IS3","5280","5280");
int valid = frame.verifyInputs(false);
assertEquals(2,valid, "Expected Valid Sensors");
JUnitUtil.dispose(frame);
}
@Test
@DisabledIfHeadless
public void testVerifyInputsInValid() {
SpeedometerFrame frame = new SpeedometerFrame();
// don't set any values in the inputs.
int valid = frame.verifyInputs(false);
assertEquals(0,valid,"Expected Valid Sensors");
JUnitAppender.assertErrorMessage("Invalid system name for Sensor: System name must start with \"IS\".");
JUnitAppender.assertErrorMessage("Start sensor invalid:");
JUnitUtil.dispose(frame);
}
@Test
@DisabledIfHeadless
public void testStartButton(){
// this test only checks to see that we don't throw an exception when
// pressing the buttons and all information is filled in.
SpeedometerFrame frame = new SpeedometerFrame();
frame.setVisible(true);
SpeedometerScaffold operator = new SpeedometerScaffold();
operator.setStartSensorValue("IS1");
operator.setStopSensor1Value("IS2");
operator.setDistance1Value("200");
operator.setStopSensor2Value("IS3");
operator.setDistance2Value("400");
operator.pushStartButton();
JUnitUtil.dispose(frame);
}
@BeforeEach
public void setUp() {
JUnitUtil.setUp();
JUnitUtil.initInternalSensorManager();
}
@AfterEach
public void tearDown() {
JUnitUtil.tearDown();
}
}
@@ -0,0 +1,74 @@
package jmri.jmrit.speedometer;
import javax.swing.JLabel;
import javax.swing.JTextField;
import org.netbeans.jemmy.operators.JButtonOperator;
import org.netbeans.jemmy.operators.JFrameOperator;
import org.netbeans.jemmy.operators.JLabelOperator;
import org.netbeans.jemmy.operators.JTextFieldOperator;
/*
* Helper class for operating the Speedometer Frame.
*
* @author Paul Bender Copyright (C) 2016
*/
public class SpeedometerScaffold extends JFrameOperator {
public SpeedometerScaffold(){
super(Bundle.getMessage("TitleSpeedometer"));
}
public void pushToMetricButton(){
new JButtonOperator(this,Bundle.getMessage("ButtonToMetric")).push();
}
public void pushToEnglishButton(){
new JButtonOperator(this,Bundle.getMessage("ButtonToMetric")).push();
}
public void pushStartButton(){
new JButtonOperator(this,Bundle.getMessage("ButtonStart")).push();
}
public void pushClearButton(){
new JButtonOperator(this,Bundle.getMessage("ButtonClear")).push();
}
public void pushSaveButton(){
new JButtonOperator(this,Bundle.getMessage("ButtonSave")).push();
}
public void setStartSensorValue(String value){
new JTextFieldOperator((JTextField) new JLabelOperator(this,Bundle.getMessage("LabelStartSensor")).getLabelFor()).setText(value);
}
public void setStopSensor1Value(String value){
new JTextFieldOperator((JTextField) new JLabelOperator(this,Bundle.getMessage("LabelStopSensor1")).getLabelFor()).setText(value);
}
public void setStopSensor2Value(String value){
new JTextFieldOperator((JTextField) new JLabelOperator(this,Bundle.getMessage("LabelStopSensor2")).getLabelFor()).setText(value);
}
public void setDistance1Value(String value){
new JTextFieldOperator((JTextField) new JLabelOperator(this,Bundle.getMessage("Distance1English")).getLabelFor()).setText(value);
}
public void setDistance2Value(String value){
new JTextFieldOperator((JTextField) new JLabelOperator(this,Bundle.getMessage("Distance2English")).getLabelFor()).setText(value);
}
public String getResult1Text(){
return ((JLabel) new JLabelOperator(this,Bundle.getMessage("Speed1English")).getLabelFor()).getText();
}
public String getResult2Text(){
return ((JLabel) new JLabelOperator(this,Bundle.getMessage("Speed2English")).getLabelFor()).getText();
}
// time is problematic. There is only one label text for both time values.
public String getTimeText(){
return ((JLabel) new JLabelOperator(this,Bundle.getMessage("Labeltime")).getLabelFor()).getText();
}
}