mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-29 02:21:44 +00:00
Clean up AutoCloseable and other Java warnings (#1866)
This commit is contained in:
@@ -100,16 +100,16 @@ class LinearFilterTest {
|
||||
static Stream<Arguments> outputFilterProvider() {
|
||||
return Stream.of(
|
||||
arguments(LinearFilter.singlePoleIIR(kSinglePoleIIRTimeConstant, kFilterStep),
|
||||
(DoubleFunction) LinearFilterTest::getData,
|
||||
(DoubleFunction<Double>) LinearFilterTest::getData,
|
||||
kSinglePoleIIRExpectedOutput),
|
||||
arguments(LinearFilter.highPass(kHighPassTimeConstant, kFilterStep),
|
||||
(DoubleFunction) LinearFilterTest::getData,
|
||||
(DoubleFunction<Double>) LinearFilterTest::getData,
|
||||
kHighPassExpectedOutput),
|
||||
arguments(LinearFilter.movingAverage(kMovAvgTaps),
|
||||
(DoubleFunction) LinearFilterTest::getData,
|
||||
(DoubleFunction<Double>) LinearFilterTest::getData,
|
||||
kMovAvgExpectedOutput),
|
||||
arguments(LinearFilter.movingAverage(kMovAvgTaps),
|
||||
(DoubleFunction) LinearFilterTest::getPulseData,
|
||||
(DoubleFunction<Double>) LinearFilterTest::getPulseData,
|
||||
0.0)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
package edu.wpi.first.wpilibj;
|
||||
|
||||
class RobotControllerTest extends UtilityClassTest {
|
||||
class RobotControllerTest extends UtilityClassTest<RobotController> {
|
||||
RobotControllerTest() {
|
||||
super(RobotController.class);
|
||||
}
|
||||
|
||||
@@ -24,10 +24,10 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.DynamicTest.dynamicTest;
|
||||
|
||||
@SuppressWarnings("PMD.AbstractClassWithoutAbstractMethod")
|
||||
public abstract class UtilityClassTest {
|
||||
private final Class m_clazz;
|
||||
public abstract class UtilityClassTest<T> {
|
||||
private final Class<T> m_clazz;
|
||||
|
||||
protected UtilityClassTest(Class clazz) {
|
||||
protected UtilityClassTest(Class<T> clazz) {
|
||||
m_clazz = clazz;
|
||||
}
|
||||
|
||||
@@ -39,14 +39,14 @@ public abstract class UtilityClassTest {
|
||||
|
||||
@Test
|
||||
public void constructorPrivateTest() {
|
||||
Constructor constructor = m_clazz.getDeclaredConstructors()[0];
|
||||
Constructor<?> constructor = m_clazz.getDeclaredConstructors()[0];
|
||||
|
||||
assertFalse(constructor.isAccessible(), "Constructor is not private");
|
||||
assertFalse(constructor.canAccess(null), "Constructor is not private");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void constructorReflectionTest() {
|
||||
Constructor constructor = m_clazz.getDeclaredConstructors()[0];
|
||||
Constructor<?> constructor = m_clazz.getDeclaredConstructors()[0];
|
||||
constructor.setAccessible(true);
|
||||
assertThrows(InvocationTargetException.class, constructor::newInstance);
|
||||
}
|
||||
|
||||
@@ -61,6 +61,8 @@ class WatchdogTest {
|
||||
|
||||
assertEquals(1, watchdogCounter.get(),
|
||||
"Watchdog either didn't trigger or triggered more than once");
|
||||
|
||||
watchdog.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -84,6 +86,8 @@ class WatchdogTest {
|
||||
watchdog.disable();
|
||||
|
||||
assertEquals(0, watchdogCounter.get(), "Watchdog triggered early");
|
||||
|
||||
watchdog.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -112,6 +116,8 @@ class WatchdogTest {
|
||||
|
||||
assertEquals(1, watchdogCounter.get(),
|
||||
"Watchdog either didn't trigger or triggered more than once");
|
||||
|
||||
watchdog.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -134,6 +140,8 @@ class WatchdogTest {
|
||||
|
||||
watchdog.reset();
|
||||
assertFalse(watchdog.isExpired());
|
||||
|
||||
watchdog.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -179,6 +187,8 @@ class WatchdogTest {
|
||||
watchdog.disable();
|
||||
|
||||
assertEquals(0, watchdogCounter.get(), "Watchdog triggered early");
|
||||
|
||||
watchdog.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -211,5 +221,8 @@ class WatchdogTest {
|
||||
assertEquals(1, watchdogCounter1.get(),
|
||||
"Watchdog either didn't trigger or triggered more than once");
|
||||
assertEquals(0, watchdogCounter2.get(), "Watchdog triggered early");
|
||||
|
||||
watchdog1.close();
|
||||
watchdog2.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -51,6 +51,7 @@ class CommandParallelGroupTest extends AbstractCommandTest {
|
||||
assertCommandState(command1, 1, 3, 3, 1, 0);
|
||||
assertCommandState(command2, 1, 5, 5, 1, 0);
|
||||
|
||||
commandGroup.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -88,6 +88,8 @@ class CommandSequentialGroupTest extends AbstractCommandTest {
|
||||
assertCommandState(command1, 1, 1, 1, 0, 1);
|
||||
assertCommandState(command2, 1, 2, 2, 0, 1);
|
||||
assertCommandState(command3, 1, 3, 3, 1, 0);
|
||||
|
||||
commandGroup.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -9,7 +9,7 @@ package edu.wpi.first.wpilibj.livewindow;
|
||||
|
||||
import edu.wpi.first.wpilibj.UtilityClassTest;
|
||||
|
||||
class LiveWindowTest extends UtilityClassTest {
|
||||
class LiveWindowTest extends UtilityClassTest<LiveWindow> {
|
||||
LiveWindowTest() {
|
||||
super(LiveWindow.class);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -13,7 +13,7 @@ import edu.wpi.first.wpilibj.UtilityClassTest;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertSame;
|
||||
|
||||
public class ShuffleboardTest extends UtilityClassTest {
|
||||
public class ShuffleboardTest extends UtilityClassTest<Shuffleboard> {
|
||||
public ShuffleboardTest() {
|
||||
super(Shuffleboard.class);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -40,7 +40,7 @@ class AnalogInputSimTest {
|
||||
|
||||
}
|
||||
|
||||
|
||||
input.close();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -67,5 +67,7 @@ class AnalogOutputSimTest {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
output.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import edu.wpi.first.wpilibj.UtilityClassTest;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
class SmartDashboardTest extends UtilityClassTest {
|
||||
class SmartDashboardTest extends UtilityClassTest<SmartDashboard> {
|
||||
private final NetworkTable m_table = NetworkTableInstance.getDefault().getTable("SmartDashboard");
|
||||
|
||||
SmartDashboardTest() {
|
||||
|
||||
@@ -15,7 +15,7 @@ import static edu.wpi.first.wpilibj.util.ErrorMessages.requireNonNullParam;
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
class ErrorMessagesTest extends UtilityClassTest {
|
||||
class ErrorMessagesTest extends UtilityClassTest<ErrorMessages> {
|
||||
ErrorMessagesTest() {
|
||||
super(ErrorMessages.class);
|
||||
}
|
||||
|
||||
@@ -33,6 +33,8 @@ class CommandDecoratorTest extends CommandTestBase {
|
||||
scheduler.run();
|
||||
|
||||
assertFalse(scheduler.isScheduled(timeout));
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -49,6 +51,8 @@ class CommandDecoratorTest extends CommandTestBase {
|
||||
condition.setCondition(true);
|
||||
scheduler.run();
|
||||
assertFalse(scheduler.isScheduled(command));
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -63,6 +67,8 @@ class CommandDecoratorTest extends CommandTestBase {
|
||||
scheduler.schedule(command.beforeStarting(() -> condition.setCondition(true)));
|
||||
|
||||
assertTrue(condition.getCondition());
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -81,6 +87,8 @@ class CommandDecoratorTest extends CommandTestBase {
|
||||
scheduler.run();
|
||||
|
||||
assertTrue(condition.getCondition());
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -100,6 +108,8 @@ class CommandDecoratorTest extends CommandTestBase {
|
||||
scheduler.run();
|
||||
|
||||
assertTrue(condition.getCondition());
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -124,6 +134,8 @@ class CommandDecoratorTest extends CommandTestBase {
|
||||
scheduler.run();
|
||||
|
||||
assertFalse(scheduler.isScheduled(group));
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -147,6 +159,8 @@ class CommandDecoratorTest extends CommandTestBase {
|
||||
scheduler.run();
|
||||
|
||||
assertFalse(scheduler.isScheduled(group));
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -162,6 +176,8 @@ class CommandDecoratorTest extends CommandTestBase {
|
||||
scheduler.run();
|
||||
|
||||
assertFalse(scheduler.isScheduled(group));
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -178,5 +194,7 @@ class CommandDecoratorTest extends CommandTestBase {
|
||||
scheduler.run();
|
||||
|
||||
assertTrue(scheduler.isScheduled(perpetual));
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,8 @@ class CommandGroupErrorTest extends CommandTestBase {
|
||||
|
||||
assertThrows(IllegalArgumentException.class,
|
||||
() -> scheduler.schedule(command1));
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -41,6 +41,8 @@ class CommandRequirementsTest extends CommandTestBase {
|
||||
|
||||
assertFalse(scheduler.isScheduled(interrupted));
|
||||
assertTrue(scheduler.isScheduled(interrupter));
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -59,6 +61,8 @@ class CommandRequirementsTest extends CommandTestBase {
|
||||
|
||||
assertTrue(scheduler.isScheduled(notInterrupted));
|
||||
assertFalse(scheduler.isScheduled(interrupter));
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -75,5 +79,7 @@ class CommandRequirementsTest extends CommandTestBase {
|
||||
() -> scheduler.setDefaultCommand(system, missingRequirement));
|
||||
assertThrows(IllegalArgumentException.class,
|
||||
() -> scheduler.setDefaultCommand(system, ends));
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,8 @@ class CommandScheduleTest extends CommandTestBase {
|
||||
verify(mockCommand).end(false);
|
||||
|
||||
assertFalse(scheduler.isScheduled(mockCommand));
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -57,6 +59,8 @@ class CommandScheduleTest extends CommandTestBase {
|
||||
verify(mockCommand).end(false);
|
||||
|
||||
assertFalse(scheduler.isScheduled(mockCommand));
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -88,6 +92,8 @@ class CommandScheduleTest extends CommandTestBase {
|
||||
command3Holder.setFinished(true);
|
||||
scheduler.run();
|
||||
assertFalse(scheduler.isScheduled(command1, command2, command3));
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -108,6 +114,8 @@ class CommandScheduleTest extends CommandTestBase {
|
||||
verify(mockCommand, never()).end(false);
|
||||
|
||||
assertFalse(scheduler.isScheduled(mockCommand));
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -118,5 +126,7 @@ class CommandScheduleTest extends CommandTestBase {
|
||||
Command mockCommand = holder.getMock();
|
||||
|
||||
assertDoesNotThrow(() -> scheduler.cancel(mockCommand));
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,8 @@ class ConditionalCommandTest extends CommandTestBase {
|
||||
verify(command2, never()).initialize();
|
||||
verify(command2, never()).execute();
|
||||
verify(command2, never()).end(false);
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -61,5 +63,7 @@ class ConditionalCommandTest extends CommandTestBase {
|
||||
|
||||
verify(command1).end(true);
|
||||
verify(command2, never()).end(true);
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@ class DefaultCommandTest extends CommandTestBase {
|
||||
scheduler.run();
|
||||
|
||||
assertTrue(scheduler.isScheduled(defaultCommand));
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -52,6 +54,8 @@ class DefaultCommandTest extends CommandTestBase {
|
||||
|
||||
assertTrue(scheduler.isScheduled(defaultCommand));
|
||||
assertFalse(scheduler.isScheduled(interrupter));
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -79,5 +83,7 @@ class DefaultCommandTest extends CommandTestBase {
|
||||
assertTrue(scheduler.isScheduled(defaultCommand));
|
||||
|
||||
verify(defaultCommand).end(true);
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,5 +39,7 @@ class FunctionalCommandTest extends CommandTestBase {
|
||||
assertTrue(cond1.getCondition());
|
||||
assertTrue(cond2.getCondition());
|
||||
assertTrue(cond3.getCondition());
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,5 +26,7 @@ class InstantCommandTest extends CommandTestBase {
|
||||
|
||||
assertTrue(cond.getCondition());
|
||||
assertFalse(scheduler.isScheduled(command));
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,5 +30,7 @@ class NotifierCommandTest extends CommandTestBase {
|
||||
scheduler.cancel(command);
|
||||
|
||||
assertEquals(.25, 0.01 * counter.m_counter, .025);
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,6 +45,8 @@ class ParallelCommandGroupTest extends CommandTestBase {
|
||||
verify(command2).end(false);
|
||||
|
||||
assertFalse(scheduler.isScheduled(group));
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -73,6 +75,8 @@ class ParallelCommandGroupTest extends CommandTestBase {
|
||||
verify(command2).end(true);
|
||||
|
||||
assertFalse(scheduler.isScheduled(group));
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -87,6 +91,8 @@ class ParallelCommandGroupTest extends CommandTestBase {
|
||||
Command group = new ParallelCommandGroup(command1, command2);
|
||||
|
||||
assertDoesNotThrow(() -> scheduler.cancel(group));
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -112,6 +118,8 @@ class ParallelCommandGroupTest extends CommandTestBase {
|
||||
|
||||
assertFalse(scheduler.isScheduled(group));
|
||||
assertTrue(scheduler.isScheduled(command3));
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -55,6 +55,8 @@ class ParallelDeadlineGroupTest extends CommandTestBase {
|
||||
verify(command3, times(2)).execute();
|
||||
verify(command3, never()).end(false);
|
||||
verify(command3).end(true);
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -84,6 +86,8 @@ class ParallelDeadlineGroupTest extends CommandTestBase {
|
||||
verify(command2, never()).end(true);
|
||||
|
||||
assertFalse(scheduler.isScheduled(group));
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
|
||||
|
||||
@@ -110,6 +114,8 @@ class ParallelDeadlineGroupTest extends CommandTestBase {
|
||||
|
||||
assertFalse(scheduler.isScheduled(group));
|
||||
assertTrue(scheduler.isScheduled(command3));
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -46,6 +46,8 @@ class ParallelRaceGroupTest extends CommandTestBase {
|
||||
verify(command2, never()).end(false);
|
||||
|
||||
assertFalse(scheduler.isScheduled(group));
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -74,6 +76,8 @@ class ParallelRaceGroupTest extends CommandTestBase {
|
||||
verify(command2).end(true);
|
||||
|
||||
assertFalse(scheduler.isScheduled(group));
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -88,6 +92,8 @@ class ParallelRaceGroupTest extends CommandTestBase {
|
||||
Command group = new ParallelRaceGroup(command1, command2);
|
||||
|
||||
assertDoesNotThrow(() -> scheduler.cancel(group));
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
|
||||
|
||||
@@ -114,6 +120,8 @@ class ParallelRaceGroupTest extends CommandTestBase {
|
||||
|
||||
assertFalse(scheduler.isScheduled(group));
|
||||
assertTrue(scheduler.isScheduled(command3));
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -22,5 +22,7 @@ class PerpetualCommandTest extends CommandTestBase {
|
||||
scheduler.run();
|
||||
|
||||
assertTrue(scheduler.isScheduled(command));
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,5 +33,7 @@ class PrintCommandTest extends CommandTestBase {
|
||||
assertEquals(testOut.toString(), "Test!" + System.lineSeparator());
|
||||
|
||||
System.setOut(originalOut);
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,8 @@ class ProxyScheduleCommandTest extends CommandTestBase {
|
||||
scheduler.schedule(scheduleCommand);
|
||||
|
||||
verify(command1).schedule();
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -47,5 +49,7 @@ class ProxyScheduleCommandTest extends CommandTestBase {
|
||||
scheduler.run();
|
||||
scheduler.run();
|
||||
assertFalse(scheduler.isScheduled(scheduleCommand));
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,8 @@ class RobotDisabledCommandTest extends CommandTestBase {
|
||||
assertFalse(scheduler.isScheduled(mockCommand));
|
||||
|
||||
setDSEnabled(true);
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -52,6 +54,8 @@ class RobotDisabledCommandTest extends CommandTestBase {
|
||||
scheduler.run();
|
||||
|
||||
assertTrue(scheduler.isScheduled(mockCommand));
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -79,6 +83,8 @@ class RobotDisabledCommandTest extends CommandTestBase {
|
||||
|
||||
assertTrue(scheduler.isScheduled(runWhenDisabled));
|
||||
assertFalse(scheduler.isScheduled(dontRunWhenDisabled));
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -106,6 +112,8 @@ class RobotDisabledCommandTest extends CommandTestBase {
|
||||
|
||||
assertTrue(scheduler.isScheduled(runWhenDisabled));
|
||||
assertFalse(scheduler.isScheduled(dontRunWhenDisabled));
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -130,6 +138,8 @@ class RobotDisabledCommandTest extends CommandTestBase {
|
||||
|
||||
assertTrue(scheduler.isScheduled(runWhenDisabled));
|
||||
assertFalse(scheduler.isScheduled(dontRunWhenDisabled));
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -154,6 +164,8 @@ class RobotDisabledCommandTest extends CommandTestBase {
|
||||
|
||||
assertTrue(scheduler.isScheduled(runWhenDisabled));
|
||||
assertFalse(scheduler.isScheduled(dontRunWhenDisabled));
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -179,5 +191,7 @@ class RobotDisabledCommandTest extends CommandTestBase {
|
||||
scheduler.schedule(parallel);
|
||||
|
||||
assertFalse(scheduler.isScheduled(runWhenDisabled));
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,5 +26,7 @@ class RunCommandTest extends CommandTestBase {
|
||||
scheduler.run();
|
||||
|
||||
assertEquals(3, counter.m_counter);
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,5 +27,7 @@ class ScheduleCommandTest extends CommandTestBase {
|
||||
|
||||
verify(command1).schedule();
|
||||
verify(command2).schedule();
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@ class SchedulerTest extends CommandTestBase {
|
||||
scheduler.run();
|
||||
|
||||
assertEquals(counter.m_counter, 3);
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -43,6 +45,8 @@ class SchedulerTest extends CommandTestBase {
|
||||
scheduler.cancel(command);
|
||||
|
||||
assertEquals(counter.m_counter, 1);
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -53,5 +57,7 @@ class SchedulerTest extends CommandTestBase {
|
||||
|
||||
scheduler.registerSubsystem(system);
|
||||
assertDoesNotThrow(() -> scheduler.unregisterSubsystem(system));
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,6 +50,8 @@ class SelectCommandTest extends CommandTestBase {
|
||||
verify(command3, never()).initialize();
|
||||
verify(command3, never()).execute();
|
||||
verify(command3, never()).end(false);
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -72,6 +74,8 @@ class SelectCommandTest extends CommandTestBase {
|
||||
() -> "four");
|
||||
|
||||
assertDoesNotThrow(() -> scheduler.schedule(selectCommand));
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
|
||||
|
||||
@@ -104,5 +108,7 @@ class SelectCommandTest extends CommandTestBase {
|
||||
verify(command1).end(true);
|
||||
verify(command2, never()).end(true);
|
||||
verify(command3, never()).end(true);
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,6 +50,8 @@ class SequentialCommandGroupTest extends CommandTestBase {
|
||||
verify(command2).end(false);
|
||||
|
||||
assertFalse(scheduler.isScheduled(group));
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -84,6 +86,8 @@ class SequentialCommandGroupTest extends CommandTestBase {
|
||||
verify(command3, never()).end(false);
|
||||
|
||||
assertFalse(scheduler.isScheduled(group));
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -98,6 +102,8 @@ class SequentialCommandGroupTest extends CommandTestBase {
|
||||
Command group = new SequentialCommandGroup(command1, command2);
|
||||
|
||||
assertDoesNotThrow(() -> scheduler.cancel(group));
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
|
||||
|
||||
@@ -124,5 +130,7 @@ class SequentialCommandGroupTest extends CommandTestBase {
|
||||
|
||||
assertFalse(scheduler.isScheduled(group));
|
||||
assertTrue(scheduler.isScheduled(command3));
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,5 +33,7 @@ class StartEndCommandTest extends CommandTestBase {
|
||||
assertFalse(scheduler.isScheduled(command));
|
||||
assertTrue(cond1.getCondition());
|
||||
assertTrue(cond2.getCondition());
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,8 @@ class WaitCommandTest extends CommandTestBase {
|
||||
scheduler.run();
|
||||
|
||||
assertFalse(scheduler.isScheduled(waitCommand));
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -63,5 +65,7 @@ class WaitCommandTest extends CommandTestBase {
|
||||
verify(command1).end(true);
|
||||
verify(command1, never()).end(false);
|
||||
assertFalse(scheduler.isScheduled(timeout));
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,5 +27,7 @@ class WaitUntilCommandTest extends CommandTestBase {
|
||||
condition.setCondition(true);
|
||||
scheduler.run();
|
||||
assertFalse(scheduler.isScheduled(command));
|
||||
|
||||
scheduler.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,6 +132,8 @@ public class AnalogCrossConnectTest extends AbstractInterruptTest {
|
||||
|
||||
// Then the counter should be at 50
|
||||
assertEquals("Analog trigger counter did not count 50 ticks", 50, counter.get());
|
||||
|
||||
counter.close();
|
||||
}
|
||||
|
||||
@Test(expected = RuntimeException.class)
|
||||
|
||||
@@ -192,6 +192,7 @@ public class MotorEncoderTest extends AbstractComsSetup {
|
||||
"PID loop did not reach reference within 10 seconds. The current error was" + pidController
|
||||
.getPositionError(), pidController.atSetpoint());
|
||||
|
||||
pidRunner.close();
|
||||
pidController.close();
|
||||
}
|
||||
|
||||
@@ -213,6 +214,7 @@ public class MotorEncoderTest extends AbstractComsSetup {
|
||||
assertTrue("PID loop did not reach reference within 10 seconds. The error was: " + pidController
|
||||
.getPositionError(), pidController.atSetpoint());
|
||||
|
||||
pidRunner.close();
|
||||
pidController.close();
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ public class PDPTest extends AbstractComsSetup {
|
||||
public static Collection<Object[]> generateData() {
|
||||
// logger.fine("Loading the MotorList");
|
||||
return Arrays.asList(new Object[][]{
|
||||
{TestBench.getInstance().getTalonPair(), new Double(0.0)}});
|
||||
{TestBench.getInstance().getTalonPair(), 0.0}});
|
||||
}
|
||||
|
||||
@After
|
||||
|
||||
@@ -48,7 +48,7 @@ public class PIDTest extends AbstractComsSetup {
|
||||
private static final double outputRange = 0.25;
|
||||
|
||||
private PIDController m_controller = null;
|
||||
private static MotorEncoderFixture me = null;
|
||||
private static MotorEncoderFixture<?> me = null;
|
||||
|
||||
@SuppressWarnings({"MemberName", "EmptyLineSeparator", "MultipleVariableDeclarations"})
|
||||
private final Double k_p, k_i, k_d;
|
||||
@@ -60,7 +60,7 @@ public class PIDTest extends AbstractComsSetup {
|
||||
|
||||
|
||||
@SuppressWarnings({"ParameterName", "JavadocMethod"})
|
||||
public PIDTest(Double p, Double i, Double d, MotorEncoderFixture mef) {
|
||||
public PIDTest(Double p, Double i, Double d, MotorEncoderFixture<?> mef) {
|
||||
logger.fine("Constructor with: " + mef.getType());
|
||||
if (PIDTest.me != null && !PIDTest.me.equals(mef)) {
|
||||
PIDTest.me.teardown();
|
||||
@@ -166,6 +166,8 @@ public class PIDTest extends AbstractComsSetup {
|
||||
pidRunner.stop();
|
||||
assertTrue(pidData() + "Was not on Target. Controller Error: "
|
||||
+ m_controller.getPositionError(), m_controller.atSetpoint());
|
||||
|
||||
pidRunner.close();
|
||||
}
|
||||
|
||||
private String pidData() {
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
package edu.wpi.first.wpilibj.test;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -107,11 +108,12 @@ public abstract class AbstractTestSuite {
|
||||
if (areAnySuperClassesOfTypeAbstractTestSuite(c)) {
|
||||
// Create a new instance of this class so that we can retrieve its data
|
||||
try {
|
||||
AbstractTestSuite suite = (AbstractTestSuite) c.newInstance();
|
||||
AbstractTestSuite suite = (AbstractTestSuite) c.getDeclaredConstructor().newInstance();
|
||||
// Add the tests from this suite that match the regex to the list of
|
||||
// tests to run
|
||||
runningList = suite.getAllContainedBaseTests(runningList);
|
||||
} catch (InstantiationException | IllegalAccessException ex) {
|
||||
} catch (NoSuchMethodException | InvocationTargetException | InstantiationException
|
||||
| IllegalAccessException ex) {
|
||||
// This shouldn't happen unless the constructor is changed in some
|
||||
// way.
|
||||
logger.log(Level.SEVERE, "Test suites can not take paramaters in their constructors.",
|
||||
@@ -200,13 +202,14 @@ public abstract class AbstractTestSuite {
|
||||
if (areAnySuperClassesOfTypeAbstractTestSuite(c)) {
|
||||
// Create a new instance of this class so that we can retrieve its
|
||||
// data.
|
||||
suite = (AbstractTestSuite) c.newInstance();
|
||||
suite = (AbstractTestSuite) c.getDeclaredConstructor().newInstance();
|
||||
// Add the tests from this suite that match the regex to the list of
|
||||
// tests to run
|
||||
runningList = suite.getSuiteOrTestMatchingRegex(regex, runningList);
|
||||
}
|
||||
|
||||
} catch (InstantiationException | IllegalAccessException ex) {
|
||||
} catch (NoSuchMethodException | InvocationTargetException | InstantiationException
|
||||
| IllegalAccessException ex) {
|
||||
// This shouldn't happen unless the constructor is changed in some
|
||||
// way.
|
||||
logger.log(Level.SEVERE, "Test suites can not take paramaters in their constructors.",
|
||||
|
||||
@@ -208,14 +208,14 @@ public final class TestBench {
|
||||
List<List<Integer[]>> pairs = new ArrayList<List<Integer[]>>();
|
||||
List<Integer[]> setA =
|
||||
Arrays.asList(new Integer[][]{
|
||||
{new Integer(DIOCrossConnectA1), new Integer(DIOCrossConnectA2)},
|
||||
{new Integer(DIOCrossConnectA2), new Integer(DIOCrossConnectA1)}});
|
||||
{DIOCrossConnectA1, DIOCrossConnectA2},
|
||||
{DIOCrossConnectA2, DIOCrossConnectA1}});
|
||||
pairs.add(setA);
|
||||
|
||||
List<Integer[]> setB =
|
||||
Arrays.asList(new Integer[][]{
|
||||
{new Integer(DIOCrossConnectB1), new Integer(DIOCrossConnectB2)},
|
||||
{new Integer(DIOCrossConnectB2), new Integer(DIOCrossConnectB1)}});
|
||||
{DIOCrossConnectB1, DIOCrossConnectB2},
|
||||
{DIOCrossConnectB2, DIOCrossConnectB1}});
|
||||
pairs.add(setB);
|
||||
// NOTE: IF MORE DIOCROSSCONNECT PAIRS ARE ADDED ADD THEM HERE
|
||||
return pairs;
|
||||
|
||||
Reference in New Issue
Block a user