mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
Clean up AutoCloseable and other Java warnings (#1866)
This commit is contained in:
@@ -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