diff --git a/src/test/java/emissary/EmissaryTest.java b/src/test/java/emissary/EmissaryTest.java index 518ff52da1..3b36681f63 100644 --- a/src/test/java/emissary/EmissaryTest.java +++ b/src/test/java/emissary/EmissaryTest.java @@ -175,7 +175,7 @@ public void addReturnCodeToOutContent(String retOutput) { @Command() static class JunkCommand implements EmissaryCommand { - final Logger LOG = LoggerFactory.getLogger(JunkCommand.class); + static final Logger LOG = LoggerFactory.getLogger(JunkCommand.class); @Override public String getCommandName() { @@ -227,7 +227,7 @@ public void outputBanner() { @Command() static class AnotherBaseCommand extends BaseCommand { // need to extend BaseCommand to get verbose options - final Logger LOG = LoggerFactory.getLogger(AnotherBaseCommand.class); + static final Logger LOG = LoggerFactory.getLogger(AnotherBaseCommand.class); @Override public String getCommandName() { diff --git a/src/test/java/emissary/core/BaseDataObjectTest.java b/src/test/java/emissary/core/BaseDataObjectTest.java index 0f5dc9ed75..f42de51d05 100755 --- a/src/test/java/emissary/core/BaseDataObjectTest.java +++ b/src/test/java/emissary/core/BaseDataObjectTest.java @@ -1164,7 +1164,7 @@ void testCanRetrieveChannelFactoryFromByteArray() throws IOException { @Test void testBothDataFieldsHaveValue() - throws IOException, NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + throws IOException, NoSuchFieldException, IllegalAccessException { final BaseDataObject bdo = new BaseDataObject(); final String testData = "This is a test"; bdo.setChannelFactory(SeekableByteChannelHelper.memory(testData.getBytes())); diff --git a/src/test/java/emissary/core/ExtendedDataObject.java b/src/test/java/emissary/core/ExtendedDataObject.java index dca546a356..6f6b22b9a1 100644 --- a/src/test/java/emissary/core/ExtendedDataObject.java +++ b/src/test/java/emissary/core/ExtendedDataObject.java @@ -19,7 +19,7 @@ public class ExtendedDataObject extends BaseDataObject implements Serializable, private static final Logger logger = LoggerFactory.getLogger(ExtendedDataObject.class); - protected String[] NEW_FILETYPE_EMPTY = {"FOO", "BAR", "QUUX", "UNKNOWN"}; + protected static final String[] NEW_FILETYPE_EMPTY = {"FOO", "BAR", "QUUX", "UNKNOWN"}; protected int intVar = -1; protected long longVar = 100L; @@ -29,7 +29,7 @@ public class ExtendedDataObject extends BaseDataObject implements Serializable, public ExtendedDataObject() { super(); this.theData = null; - FILETYPE_EMPTY = this.NEW_FILETYPE_EMPTY; + FILETYPE_EMPTY = NEW_FILETYPE_EMPTY; this.intVar = 37; } diff --git a/src/test/java/emissary/core/FactoryTest.java b/src/test/java/emissary/core/FactoryTest.java index 2290a75887..5d074b2f23 100755 --- a/src/test/java/emissary/core/FactoryTest.java +++ b/src/test/java/emissary/core/FactoryTest.java @@ -208,7 +208,7 @@ public String getKey() { } static class DemoClassThatThrowsThrowableFromConstructor { - public DemoClassThatThrowsThrowableFromConstructor() throws Throwable { + public DemoClassThatThrowsThrowableFromConstructor() { throw new AssertionError("Bogus"); } } diff --git a/src/test/java/emissary/core/HDMobileAgentBugIT.java b/src/test/java/emissary/core/HDMobileAgentBugIT.java index 940969fac4..6a6c0c1bf2 100644 --- a/src/test/java/emissary/core/HDMobileAgentBugIT.java +++ b/src/test/java/emissary/core/HDMobileAgentBugIT.java @@ -54,15 +54,15 @@ void testTearDown() { validate.shutDown(); } - private IServiceProviderPlace addDir(String key, String clsName) { + private static IServiceProviderPlace addDir(String key, String clsName) { return PlaceStarter.createPlace(key, null, clsName, null, new EmissaryNode()); } - private IServiceProviderPlace addPlace(String key, String clsName) { + private static IServiceProviderPlace addPlace(String key, String clsName) { return PlaceStarter.createPlace(key, null, clsName, null); } - private IBaseDataObject generateIbdo(int index, String form) { + private static IBaseDataObject generateIbdo(int index, String form) { IBaseDataObject ibdo = DataObjectFactory.getInstance(new byte[] {}, "testing_file" + Family.getSep(index), form, "TST"); ibdo.pushCurrentForm("FRM-PROCESSED-alternative"); ibdo.appendTransformHistory("*.FAKE_ANALYZE.ANALYZE.http://localhost:8543/VisitedHereFirstPlace"); diff --git a/src/test/java/emissary/core/InterruptibleCharSequenceTest.java b/src/test/java/emissary/core/InterruptibleCharSequenceTest.java index a512ac7051..080c149dd6 100644 --- a/src/test/java/emissary/core/InterruptibleCharSequenceTest.java +++ b/src/test/java/emissary/core/InterruptibleCharSequenceTest.java @@ -15,8 +15,8 @@ import static org.junit.jupiter.api.Assertions.fail; class InterruptibleCharSequenceTest extends UnitTest { - public static String BACKTRACKER = "^(((((a+)*)*)*)*)*$"; - public static String INPUT = "aaaaab"; + public static final String BACKTRACKER = "^(((((a+)*)*)*)*)*$"; + public static final String INPUT = "aaaaab"; // Enable to test overhead. This method does not perform any assertions. @Test diff --git a/src/test/java/emissary/core/channels/FileChannelFactoryTest.java b/src/test/java/emissary/core/channels/FileChannelFactoryTest.java index 9e0cb52224..f06d5c6f29 100644 --- a/src/test/java/emissary/core/channels/FileChannelFactoryTest.java +++ b/src/test/java/emissary/core/channels/FileChannelFactoryTest.java @@ -80,7 +80,7 @@ void testImmutability() throws IOException { final SeekableByteChannel sbc = sbcf.create(); final ByteBuffer buff = ByteBuffer.wrap("New data".getBytes()); assertThrows(NonWritableChannelException.class, () -> sbc.write(buff), "Can't write to byte channel as it's immutable"); - assertThrows(NonWritableChannelException.class, () -> sbc.truncate(5l), "Can't truncate byte channel as it's immutable"); + assertThrows(NonWritableChannelException.class, () -> sbc.truncate(5L), "Can't truncate byte channel as it's immutable"); } @Test diff --git a/src/test/java/emissary/core/channels/InMemoryChannelFactoryTest.java b/src/test/java/emissary/core/channels/InMemoryChannelFactoryTest.java index fefcf3f845..6713f4d3ee 100644 --- a/src/test/java/emissary/core/channels/InMemoryChannelFactoryTest.java +++ b/src/test/java/emissary/core/channels/InMemoryChannelFactoryTest.java @@ -36,7 +36,7 @@ void testImmutability() throws IOException { final SeekableByteChannel sbc = sbcf.create(); final ByteBuffer buff = ByteBuffer.wrap("New data".getBytes()); assertThrows(NonWritableChannelException.class, () -> sbc.write(buff), "Can't write to byte channel as it's immutable"); - assertThrows(NonWritableChannelException.class, () -> sbc.truncate(5l), "Can't truncate byte channel as it's immutable"); + assertThrows(NonWritableChannelException.class, () -> sbc.truncate(5L), "Can't truncate byte channel as it's immutable"); assertThrows(ClassCastException.class, () -> ((SeekableInMemoryByteChannel) sbc).array(), "Can't get different variant of SBC as we've abstracted it away"); } diff --git a/src/test/java/emissary/core/channels/SegmentChannelFactoryTest.java b/src/test/java/emissary/core/channels/SegmentChannelFactoryTest.java index 668acad77c..8ee7ae7373 100644 --- a/src/test/java/emissary/core/channels/SegmentChannelFactoryTest.java +++ b/src/test/java/emissary/core/channels/SegmentChannelFactoryTest.java @@ -91,17 +91,17 @@ public SeekableByteChannel create() { final int myInstanceNumber = instanceNumber.getAndIncrement(); @Override - protected void closeImpl() throws IOException { + protected void closeImpl() { isClosedList.set(myInstanceNumber, true); } @Override - protected int readImpl(ByteBuffer byteBuffer) throws IOException { + protected int readImpl(ByteBuffer byteBuffer) { return 0; } @Override - protected long sizeImpl() throws IOException { + protected long sizeImpl() { return 1; } }; diff --git a/src/test/java/emissary/core/sentinel/protocols/ProtocolTest.java b/src/test/java/emissary/core/sentinel/protocols/ProtocolTest.java index a33a90777e..41ffff9d26 100644 --- a/src/test/java/emissary/core/sentinel/protocols/ProtocolTest.java +++ b/src/test/java/emissary/core/sentinel/protocols/ProtocolTest.java @@ -148,10 +148,10 @@ void protocolValidJson() { @Nested class RunTest extends UnitTest { - final String TO_UPPER_LOWER_PATTERN = "To(?:Lower|Upper)Place"; - final String TO_LOWER_PLACE = "ToLowerPlace"; - final String TO_UPPER_PLACE = "ToUpperPlace"; - final int DEFAULT_POOL_SIZE = 5; + final String toUpperLowerPattern = "To(?:Lower|Upper)Place"; + final String toLowerPlace = "ToLowerPlace"; + final String toUpperPlace = "ToUpperPlace"; + final int defaultPoolSize = 5; Action action; AgentPool pool; @@ -170,57 +170,57 @@ public void setUp() throws Exception { void protocol1() { Protocol protocol = new Protocol(); protocol.action = action; - protocol.rules.put("TEST_RULE1", new AllMaxTime("rule1", TO_UPPER_LOWER_PATTERN, 5, 1.0)); - protocol.rules.put("TEST_RULE2", new AnyMaxTime("rule2", TO_UPPER_LOWER_PATTERN, 30, 0.2)); + protocol.rules.put("TEST_RULE1", new AllMaxTime("rule1", toUpperLowerPattern, 5, 1.0)); + protocol.rules.put("TEST_RULE2", new AnyMaxTime("rule2", toUpperLowerPattern, 30, 0.2)); - testProtocol(protocol, DEFAULT_POOL_SIZE, 1); + testProtocol(protocol, defaultPoolSize, 1); } @Test void protocol2() { Protocol protocol = new Protocol(); protocol.action = action; - protocol.rules.put("TEST_RULE1", new AllMaxTime("rule1", TO_UPPER_LOWER_PATTERN, 5, 1.0)); - protocol.rules.put("TEST_RULE2", new AnyMaxTime("rule2", TO_UPPER_LOWER_PATTERN, 40, 0.2)); + protocol.rules.put("TEST_RULE1", new AllMaxTime("rule1", toUpperLowerPattern, 5, 1.0)); + protocol.rules.put("TEST_RULE2", new AnyMaxTime("rule2", toUpperLowerPattern, 40, 0.2)); - testProtocol(protocol, DEFAULT_POOL_SIZE, 0); + testProtocol(protocol, defaultPoolSize, 0); } @Test void protocol3() { Protocol protocol = new Protocol(); protocol.action = action; - protocol.rules.put("TEST_RULE", new AnyMaxTime("LongRunning", TO_UPPER_LOWER_PATTERN, 30, 0.01)); + protocol.rules.put("TEST_RULE", new AnyMaxTime("LongRunning", toUpperLowerPattern, 30, 0.01)); - testProtocol(protocol, DEFAULT_POOL_SIZE, 1); + testProtocol(protocol, defaultPoolSize, 1); } @Test void protocol4() { Protocol protocol = new Protocol(); protocol.action = action; - protocol.rules.put("TEST_RULE", new AnyMaxTime("LongRunning", TO_LOWER_PLACE, 30, 0.01)); + protocol.rules.put("TEST_RULE", new AnyMaxTime("LongRunning", toLowerPlace, 30, 0.01)); - testProtocol(protocol, DEFAULT_POOL_SIZE, 0); + testProtocol(protocol, defaultPoolSize, 0); } @Test void protocol5() { Protocol protocol = new Protocol(); protocol.action = action; - protocol.rules.put("TEST_RULE", new AnyMaxTime("LongRunning", TO_UPPER_PLACE, 30, 0.01)); + protocol.rules.put("TEST_RULE", new AnyMaxTime("LongRunning", toUpperPlace, 30, 0.01)); - testProtocol(protocol, DEFAULT_POOL_SIZE, 1); + testProtocol(protocol, defaultPoolSize, 1); } @Test void protocol6() { Protocol protocol = new Protocol(); protocol.action = action; - protocol.rules.put("TEST_RULE1", new AllMaxTime("rule1", TO_UPPER_LOWER_PATTERN, 5, 1.0)); - protocol.rules.put("TEST_RULE2", new AnyMaxTime("rule2", TO_UPPER_LOWER_PATTERN, 30, 0.2)); + protocol.rules.put("TEST_RULE1", new AllMaxTime("rule1", toUpperLowerPattern, 5, 1.0)); + protocol.rules.put("TEST_RULE2", new AnyMaxTime("rule2", toUpperLowerPattern, 30, 0.2)); - testProtocol(protocol, DEFAULT_POOL_SIZE + 1, 0); + testProtocol(protocol, defaultPoolSize + 1, 0); } void testProtocol(Protocol protocol, int poolSize, int expected) { diff --git a/src/test/java/emissary/core/sentinel/protocols/rules/AllMaxTimeTest.java b/src/test/java/emissary/core/sentinel/protocols/rules/AllMaxTimeTest.java index 8ae151a3ac..1464e5c910 100644 --- a/src/test/java/emissary/core/sentinel/protocols/rules/AllMaxTimeTest.java +++ b/src/test/java/emissary/core/sentinel/protocols/rules/AllMaxTimeTest.java @@ -66,11 +66,11 @@ void notOverTimeLimit() { @Nested class ConditionTest extends UnitTest { - final String TO_UPPER_LOWER_PATTERN = "To(?:Lower|Upper)Place"; - final String TO_LOWER_PLACE = "ToLowerPlace"; - final String TO_UPPER_PLACE = "ToUpperPlace"; - final int DEFAULT_POOL_SIZE = 5; - final int DEFAULT_TIME_LIMIT = 5; + final String toUpperLowerPattern = "To(?:Lower|Upper)Place"; + final String toLowerPlace = "ToLowerPlace"; + final String toUpperPlace = "ToUpperPlace"; + final int defaultPoolSize = 5; + final int defaultTimeLimit = 5; AgentPool pool; List stats; @@ -85,42 +85,42 @@ public void setUp() throws Exception { @Test void condition1() { - assertTrue(testRule(TO_UPPER_LOWER_PATTERN, DEFAULT_TIME_LIMIT, 1.0, DEFAULT_POOL_SIZE)); + assertTrue(testRule(toUpperLowerPattern, defaultTimeLimit, 1.0, defaultPoolSize)); } @Test void condition2() { - assertFalse(testRule(TO_UPPER_LOWER_PATTERN, DEFAULT_TIME_LIMIT, 1.0, DEFAULT_POOL_SIZE + 1)); + assertFalse(testRule(toUpperLowerPattern, defaultTimeLimit, 1.0, defaultPoolSize + 1)); } @Test void condition3() { - assertTrue(testRule(TO_LOWER_PLACE, DEFAULT_TIME_LIMIT, 0.5, DEFAULT_POOL_SIZE)); + assertTrue(testRule(toLowerPlace, defaultTimeLimit, 0.5, defaultPoolSize)); } @Test void condition4() { - assertFalse(testRule(TO_UPPER_PLACE, DEFAULT_TIME_LIMIT, 0.75, DEFAULT_POOL_SIZE)); + assertFalse(testRule(toUpperPlace, defaultTimeLimit, 0.75, defaultPoolSize)); } @Test void condition5() { - assertFalse(testRule(TO_UPPER_LOWER_PATTERN, DEFAULT_TIME_LIMIT + 1, 1.0, DEFAULT_POOL_SIZE)); + assertFalse(testRule(toUpperLowerPattern, defaultTimeLimit + 1, 1.0, defaultPoolSize)); } @Test void condition6() { - assertFalse(testRule(TO_UPPER_LOWER_PATTERN, DEFAULT_TIME_LIMIT + 1, 0.75, DEFAULT_POOL_SIZE)); + assertFalse(testRule(toUpperLowerPattern, defaultTimeLimit + 1, 0.75, defaultPoolSize)); } @Test void condition7() { - assertTrue(testRule(TO_UPPER_LOWER_PATTERN, DEFAULT_TIME_LIMIT, 0.5, DEFAULT_POOL_SIZE)); + assertTrue(testRule(toUpperLowerPattern, defaultTimeLimit, 0.5, defaultPoolSize)); } @Test void condition8() { - assertFalse(testRule(TO_LOWER_PLACE, DEFAULT_TIME_LIMIT, 1.0, DEFAULT_POOL_SIZE)); + assertFalse(testRule(toLowerPlace, defaultTimeLimit, 1.0, defaultPoolSize)); } boolean testRule(String matcher, int time, double threshold, int poolSize) { @@ -134,13 +134,13 @@ boolean testRule(String matcher, int time, double threshold, int poolSize) { List stats() { Protocol.PlaceAgentStats lowerStats = new Protocol.PlaceAgentStats("ToLowerPlace"); - lowerStats.update(DEFAULT_TIME_LIMIT); // MobileAgent-01 - lowerStats.update(DEFAULT_TIME_LIMIT + 1); // MobileAgent-02 - lowerStats.update(DEFAULT_TIME_LIMIT + 4); // MobileAgent-03 + lowerStats.update(defaultTimeLimit); // MobileAgent-01 + lowerStats.update(defaultTimeLimit + 1); // MobileAgent-02 + lowerStats.update(defaultTimeLimit + 4); // MobileAgent-03 Protocol.PlaceAgentStats upperStats = new Protocol.PlaceAgentStats("ToUpperPlace"); - upperStats.update(DEFAULT_TIME_LIMIT); // MobileAgent-04 - upperStats.update(DEFAULT_TIME_LIMIT + 3); // MobileAgent-05 + upperStats.update(defaultTimeLimit); // MobileAgent-04 + upperStats.update(defaultTimeLimit + 3); // MobileAgent-05 return List.of(lowerStats, upperStats); } diff --git a/src/test/java/emissary/core/sentinel/protocols/rules/AnyMaxTimeTest.java b/src/test/java/emissary/core/sentinel/protocols/rules/AnyMaxTimeTest.java index a05d10d1c4..33138e5c2b 100644 --- a/src/test/java/emissary/core/sentinel/protocols/rules/AnyMaxTimeTest.java +++ b/src/test/java/emissary/core/sentinel/protocols/rules/AnyMaxTimeTest.java @@ -66,11 +66,11 @@ void notOverTimeLimit() { @Nested class ConditionTest extends UnitTest { - final String TO_UPPER_LOWER_PATTERN = "To(?:Lower|Upper)Place"; - final String TO_LOWER_PLACE = "ToLowerPlace"; - final String TO_UPPER_PLACE = "ToUpperPlace"; - final int DEFAULT_POOL_SIZE = 5; - final int DEFAULT_TIME_LIMIT = 5; + final String toUpperLowerPattern = "To(?:Lower|Upper)Place"; + final String toLowerPlace = "ToLowerPlace"; + final String toUpperPlace = "ToUpperPlace"; + final int defaultPoolSize = 5; + final int defaultTimeLimit = 5; AgentPool pool; List stats; @@ -85,47 +85,47 @@ public void setUp() throws Exception { @Test void condition1() { - assertTrue(testRule(TO_UPPER_LOWER_PATTERN, DEFAULT_TIME_LIMIT, 1.0, DEFAULT_POOL_SIZE)); + assertTrue(testRule(toUpperLowerPattern, defaultTimeLimit, 1.0, defaultPoolSize)); } @Test void condition2() { - assertFalse(testRule(TO_UPPER_LOWER_PATTERN, DEFAULT_TIME_LIMIT, 1.0, DEFAULT_POOL_SIZE + 1)); + assertFalse(testRule(toUpperLowerPattern, defaultTimeLimit, 1.0, defaultPoolSize + 1)); } @Test void condition3() { - assertFalse(testRule(TO_UPPER_LOWER_PATTERN, DEFAULT_TIME_LIMIT + 1, 1.0, DEFAULT_POOL_SIZE)); + assertFalse(testRule(toUpperLowerPattern, defaultTimeLimit + 1, 1.0, defaultPoolSize)); } @Test void condition4() { - assertFalse(testRule(TO_UPPER_LOWER_PATTERN, DEFAULT_TIME_LIMIT + 1, 1.0, DEFAULT_POOL_SIZE + 1)); + assertFalse(testRule(toUpperLowerPattern, defaultTimeLimit + 1, 1.0, defaultPoolSize + 1)); } @Test void condition5() { - assertTrue(testRule(TO_LOWER_PLACE, DEFAULT_TIME_LIMIT - 1, 0.5, DEFAULT_POOL_SIZE)); + assertTrue(testRule(toLowerPlace, defaultTimeLimit - 1, 0.5, defaultPoolSize)); } @Test void condition6() { - assertFalse(testRule(TO_LOWER_PLACE, DEFAULT_TIME_LIMIT, 0.5, DEFAULT_POOL_SIZE)); + assertFalse(testRule(toLowerPlace, defaultTimeLimit, 0.5, defaultPoolSize)); } @Test void condition7() { - assertFalse(testRule(TO_LOWER_PLACE, DEFAULT_TIME_LIMIT - 1, 0.75, DEFAULT_POOL_SIZE)); + assertFalse(testRule(toLowerPlace, defaultTimeLimit - 1, 0.75, defaultPoolSize)); } @Test void condition8() { - assertTrue(testRule(TO_UPPER_PLACE, DEFAULT_TIME_LIMIT, 0.2, DEFAULT_POOL_SIZE)); + assertTrue(testRule(toUpperPlace, defaultTimeLimit, 0.2, defaultPoolSize)); } @Test void condition9() { - assertFalse(testRule(TO_UPPER_PLACE, DEFAULT_TIME_LIMIT, 0.5, DEFAULT_POOL_SIZE)); + assertFalse(testRule(toUpperPlace, defaultTimeLimit, 0.5, defaultPoolSize)); } boolean testRule(String matcher, int time, double threshold, int poolSize) { @@ -139,13 +139,13 @@ boolean testRule(String matcher, int time, double threshold, int poolSize) { List stats() { Protocol.PlaceAgentStats lowerStats = new Protocol.PlaceAgentStats("ToLowerPlace"); - lowerStats.update(DEFAULT_TIME_LIMIT - 4); // MobileAgent-01 - lowerStats.update(DEFAULT_TIME_LIMIT - 2); // MobileAgent-02 - lowerStats.update(DEFAULT_TIME_LIMIT - 1); // MobileAgent-03 + lowerStats.update(defaultTimeLimit - 4); // MobileAgent-01 + lowerStats.update(defaultTimeLimit - 2); // MobileAgent-02 + lowerStats.update(defaultTimeLimit - 1); // MobileAgent-03 Protocol.PlaceAgentStats upperStats = new Protocol.PlaceAgentStats("ToUpperPlace"); - upperStats.update(DEFAULT_TIME_LIMIT - 3); // MobileAgent-04 - upperStats.update(DEFAULT_TIME_LIMIT); // MobileAgent-05 + upperStats.update(defaultTimeLimit - 3); // MobileAgent-04 + upperStats.update(defaultTimeLimit); // MobileAgent-05 return List.of(lowerStats, upperStats); } diff --git a/src/test/java/emissary/kff/KffMemcachedTest.java b/src/test/java/emissary/kff/KffMemcachedTest.java index f7fd18b077..1ea546a9c0 100644 --- a/src/test/java/emissary/kff/KffMemcachedTest.java +++ b/src/test/java/emissary/kff/KffMemcachedTest.java @@ -106,7 +106,7 @@ void testHitWithStoreIdDupe() throws Exception { assertTrue(mcdFilter.check(TEST_ID_WITH_SPACES, createSums(mcdFilter)), "Filter should hit"); } - private ChecksumResults createSums(KffMemcached mcd) throws NoSuchAlgorithmException { + private static ChecksumResults createSums(KffMemcached mcd) throws NoSuchAlgorithmException { List kffalgs = new ArrayList<>(); kffalgs.add(mcd.getPreferredAlgorithm()); return new ChecksumCalculator(kffalgs).digest(TEST_PAYLOAD.getBytes()); diff --git a/src/test/java/emissary/output/roller/JournaledCoalescerTest.java b/src/test/java/emissary/output/roller/JournaledCoalescerTest.java index 69d37716f3..92d23f1ed7 100644 --- a/src/test/java/emissary/output/roller/JournaledCoalescerTest.java +++ b/src/test/java/emissary/output/roller/JournaledCoalescerTest.java @@ -52,8 +52,8 @@ class JournaledCoalescerTest extends UnitTest { private static final String BUD1_NAME = "bud1"; private Path tempBud2; private static final String BUD2_NAME = "bud2"; - private final List BUD1_LINES = Arrays.asList("Line1", "Line2"); - private final List BUD2_LINES = Arrays.asList("Line3", "Line4"); + private static final List BUD1_LINES = Arrays.asList("Line1", "Line2"); + private static final List BUD2_LINES = Arrays.asList("Line3", "Line4"); @BeforeEach public void setUp(@TempDir final Path tempFilesPath) throws IOException, InterruptedException { diff --git a/src/test/java/emissary/parser/DecomposedSessionTest.java b/src/test/java/emissary/parser/DecomposedSessionTest.java index 8c83fd975e..925b70f0ca 100644 --- a/src/test/java/emissary/parser/DecomposedSessionTest.java +++ b/src/test/java/emissary/parser/DecomposedSessionTest.java @@ -22,7 +22,7 @@ class DecomposedSessionTest extends UnitTest { - byte[] DATA = new byte[1000]; + static final byte[] DATA = new byte[1000]; @Override @BeforeEach diff --git a/src/test/java/emissary/parser/MyDataIdentifierTest.java b/src/test/java/emissary/parser/MyDataIdentifierTest.java index f604c955a5..b068cad0bd 100644 --- a/src/test/java/emissary/parser/MyDataIdentifierTest.java +++ b/src/test/java/emissary/parser/MyDataIdentifierTest.java @@ -18,7 +18,7 @@ class DataIdentifierTest extends UnitTest { - byte[] DATA = new byte[1000]; + static final byte[] DATA = new byte[1000]; @Override @BeforeEach @@ -72,12 +72,12 @@ public int checkSize() { return DATA_ID_STR_SZ; } - public String checkString(byte[] data) { - return super.getTestString(data); + public String checkString(byte[] DATA) { + return super.getTestString(DATA); } - public String checkString(byte[] data, int limit) { - return super.getTestString(data, limit); + public String checkString(byte[] DATA, int limit) { + return super.getTestString(DATA, limit); } } diff --git a/src/test/java/emissary/pickup/FTestWorkSpaceMaxBundleSize.java b/src/test/java/emissary/pickup/FTestWorkSpaceMaxBundleSize.java index f39dd3b421..315a92d5a9 100644 --- a/src/test/java/emissary/pickup/FTestWorkSpaceMaxBundleSize.java +++ b/src/test/java/emissary/pickup/FTestWorkSpaceMaxBundleSize.java @@ -188,7 +188,7 @@ public MyWorkSpace() throws Exception { super(); } - public MyWorkSpace(FeedCommand command) throws Exception { + public MyWorkSpace(FeedCommand command) { super(command); } diff --git a/src/test/java/emissary/pickup/WorkBundleTest.java b/src/test/java/emissary/pickup/WorkBundleTest.java index 32f816ffe2..9e098655e5 100644 --- a/src/test/java/emissary/pickup/WorkBundleTest.java +++ b/src/test/java/emissary/pickup/WorkBundleTest.java @@ -145,7 +145,7 @@ void testBundleXml() { String xml = null; try { xml = w.toXml(); - } catch (Exception ex) { + } catch (RuntimeException ex) { fail("Cannot generate xml", ex); } assertNotNull(xml, "Generated xml"); @@ -180,7 +180,7 @@ void testBundleXmlWithDefaultTimes() { String xml = null; try { xml = w.toXml(); - } catch (Exception ex) { + } catch (RuntimeException ex) { fail("Cannot generate xml", ex); } assertNotNull(xml, "Generated xml"); @@ -212,7 +212,7 @@ void testBundleXmlWithNullFields() { String xml = null; try { xml = w.toXml(); - } catch (Exception ex) { + } catch (RuntimeException ex) { fail("Cannot generate xml", ex); } assertNotNull(xml, "Generated xml"); diff --git a/src/test/java/emissary/place/ComparisonPlaceTestProcessHDPlace.java b/src/test/java/emissary/place/ComparisonPlaceTestProcessHDPlace.java index c666615421..602ee43e59 100644 --- a/src/test/java/emissary/place/ComparisonPlaceTestProcessHDPlace.java +++ b/src/test/java/emissary/place/ComparisonPlaceTestProcessHDPlace.java @@ -4,19 +4,20 @@ import emissary.core.IBaseDataObject; import emissary.core.ResourceException; +import com.google.common.collect.ImmutableMap; + import java.io.IOException; import java.util.ArrayList; import java.util.List; -import java.util.Map; import java.util.Map.Entry; public class ComparisonPlaceTestProcessHDPlace extends ServiceProviderPlace { - private final Map metadataKeyValueMap; + private final ImmutableMap metadataKeyValueMap; public ComparisonPlaceTestProcessHDPlace(String configFile, String theDir, String thePlaceLocation) throws IOException { super(configFile, theDir, thePlaceLocation); - metadataKeyValueMap = configG.findStringMatchMap("METADATA_"); + metadataKeyValueMap = ImmutableMap.copyOf(configG.findStringMatchMap("METADATA_")); } @Override diff --git a/src/test/java/emissary/place/ComparisonPlaceTestProcessPlace.java b/src/test/java/emissary/place/ComparisonPlaceTestProcessPlace.java index f08468f79a..4820a371f9 100644 --- a/src/test/java/emissary/place/ComparisonPlaceTestProcessPlace.java +++ b/src/test/java/emissary/place/ComparisonPlaceTestProcessPlace.java @@ -3,17 +3,18 @@ import emissary.core.IBaseDataObject; import emissary.core.ResourceException; +import com.google.common.collect.ImmutableMap; + import java.io.IOException; -import java.util.Map; import java.util.Map.Entry; public class ComparisonPlaceTestProcessPlace extends ServiceProviderPlace { - private final Map metadataKeyValueMap; + private final ImmutableMap metadataKeyValueMap; public ComparisonPlaceTestProcessPlace(String configFile, String theDir, String thePlaceLocation) throws IOException { super(configFile, theDir, thePlaceLocation); - metadataKeyValueMap = configG.findStringMatchMap("METADATA_"); + metadataKeyValueMap = ImmutableMap.copyOf(configG.findStringMatchMap("METADATA_")); } @Override diff --git a/src/test/java/emissary/place/ServiceProviderPlaceTest.java b/src/test/java/emissary/place/ServiceProviderPlaceTest.java index b1897f7ef2..44f3885615 100644 --- a/src/test/java/emissary/place/ServiceProviderPlaceTest.java +++ b/src/test/java/emissary/place/ServiceProviderPlaceTest.java @@ -84,7 +84,7 @@ class ServiceProviderPlaceTest extends UnitTest { + "SERVICE_QUALITY = 90\n" + "SERVICE_PROXY = \"TEST_SERVICE_PROXY\"\n" + "SERVICE_PROXY_DENY = \"TEST_SERVICE_PROXY\"\n" + "SERVICE_PROXY_DENY != \"*\"\n").getBytes(); - String CFGDIR = System.getProperty(ConfigUtil.CONFIG_DIR_PROPERTY); + static final String CFGDIR = System.getProperty(ConfigUtil.CONFIG_DIR_PROPERTY); @Override @BeforeEach diff --git a/src/test/java/emissary/pool/AgentPoolTest.java b/src/test/java/emissary/pool/AgentPoolTest.java index 164d516e90..96b0ac97d5 100644 --- a/src/test/java/emissary/pool/AgentPoolTest.java +++ b/src/test/java/emissary/pool/AgentPoolTest.java @@ -33,7 +33,7 @@ void testComputePoolSize(long maxMemoryInBytes, Integer propertyOverride, int expectedPoolSize, @Nullable Class expectedException, - String expectedExceptionMsg) throws IllegalArgumentException { + String expectedExceptionMsg) { // setup expected exception if (expectedException != null) { Exception e = assertThrows(expectedException, () -> AgentPool.computePoolSize(maxMemoryInBytes, propertyOverride)); diff --git a/src/test/java/emissary/test/core/junit5/RegressionTest.java b/src/test/java/emissary/test/core/junit5/RegressionTest.java index 6ed32f359d..7351eddcd8 100644 --- a/src/test/java/emissary/test/core/junit5/RegressionTest.java +++ b/src/test/java/emissary/test/core/junit5/RegressionTest.java @@ -240,7 +240,9 @@ protected Optional hashBytesIfNonPrintable(byte[] bytes) { return Optional.empty(); } - protected class ClearDataBaseDataObject extends BaseDataObject { + protected static class ClearDataBaseDataObject extends BaseDataObject { + private static final long serialVersionUID = -8728006876784881020L; + protected void clearData() { theData = null; seekableByteChannelFactory = null; diff --git a/src/test/java/emissary/util/DependencyCheckTest.java b/src/test/java/emissary/util/DependencyCheckTest.java index 443474fb1e..896da46d71 100644 --- a/src/test/java/emissary/util/DependencyCheckTest.java +++ b/src/test/java/emissary/util/DependencyCheckTest.java @@ -15,7 +15,7 @@ class DependencyCheckTest extends UnitTest { - private final String BIN_DIR = System.getProperty(ConfigUtil.CONFIG_BIN_PROPERTY); + private static final String BIN_DIR = System.getProperty(ConfigUtil.CONFIG_BIN_PROPERTY); @Test void testExecutableExist() { diff --git a/src/test/java/emissary/util/ShortNameComparatorTest.java b/src/test/java/emissary/util/ShortNameComparatorTest.java index 3178b61d68..26bb9f4c74 100644 --- a/src/test/java/emissary/util/ShortNameComparatorTest.java +++ b/src/test/java/emissary/util/ShortNameComparatorTest.java @@ -76,7 +76,7 @@ void testSubclassedComparator() { fillList(l); l.sort(new ShortNameComparator()); checkList(l); - } catch (Exception ex) { + } catch (RuntimeException ex) { fail("Cannot operate Comparator in subclass", ex); } finally { DataObjectFactory.setImplementingClass(defaultPayloadClass); diff --git a/src/test/java/emissary/util/io/LoggingPrintStreamTest.java b/src/test/java/emissary/util/io/LoggingPrintStreamTest.java index 6d15760287..1830175384 100644 --- a/src/test/java/emissary/util/io/LoggingPrintStreamTest.java +++ b/src/test/java/emissary/util/io/LoggingPrintStreamTest.java @@ -254,7 +254,7 @@ void testMultiThread() throws InterruptedException { final String message = "Message from instance " + i; final Exception exception = new Exception("Exception from instance " + i); - executorService.submit(() -> { + var unused = executorService.submit(() -> { for (int j = 0; j < iterations; j++) { loggingPrintStream.println(message); exception.printStackTrace(loggingPrintStream); diff --git a/src/test/java/emissary/util/search/KeywordScannerTest.java b/src/test/java/emissary/util/search/KeywordScannerTest.java index 527b89e7ad..88a14fc493 100644 --- a/src/test/java/emissary/util/search/KeywordScannerTest.java +++ b/src/test/java/emissary/util/search/KeywordScannerTest.java @@ -13,13 +13,13 @@ import static org.junit.jupiter.api.Assertions.assertTrue; class KeywordScannerTest extends UnitTest { - private final byte[] DATA = "THIS is a test of the Emergency broadcasting system.".getBytes(); + private static final byte[] DATA = "THIS is a test of the Emergency broadcasting system.".getBytes(); private KeywordScanner ks; @Override @BeforeEach public void setUp() throws Exception { - this.ks = new KeywordScanner(this.DATA); + this.ks = new KeywordScanner(DATA); } @Test @@ -72,7 +72,7 @@ void testBeginningOfRegion() { @Test void testEndOfRegion() { - assertEquals(this.DATA.length - 1, this.ks.indexOf(".".getBytes()), "Hit at end of region"); + assertEquals(DATA.length - 1, this.ks.indexOf(".".getBytes()), "Hit at end of region"); } @Test @@ -102,23 +102,23 @@ void testIndexOf() { assertEquals(22, this.ks.indexOf("Emergency".getBytes(), 0)); assertEquals(-1, this.ks.indexOf("Emergency".getBytes(), 40)); assertEquals(12, this.ks.indexOf("st".getBytes(), 0, 30)); - assertEquals(12, this.ks.indexOf("st".getBytes(), 0, this.DATA.length)); - assertEquals(12, this.ks.indexOf("st".getBytes(), 12, this.DATA.length)); + assertEquals(12, this.ks.indexOf("st".getBytes(), 0, DATA.length)); + assertEquals(12, this.ks.indexOf("st".getBytes(), 12, DATA.length)); assertEquals(39, this.ks.indexOf("st".getBytes(), 30, 41)); - assertEquals(39, this.ks.indexOf("st".getBytes(), 39, this.DATA.length)); + assertEquals(39, this.ks.indexOf("st".getBytes(), 39, DATA.length)); // no matches in this range assertEquals(-1, this.ks.indexOf("st".getBytes(), 30, 40)); - assertEquals(22, this.ks.indexOf("E".getBytes(), 0, this.DATA.length)); + assertEquals(22, this.ks.indexOf("E".getBytes(), 0, DATA.length)); // start offset < 0 - assertEquals(22, this.ks.indexOf("E".getBytes(), -1, this.DATA.length)); + assertEquals(22, this.ks.indexOf("E".getBytes(), -1, DATA.length)); // stop index > data length - assertEquals(-1, this.ks.indexOf("st".getBytes(), 0, this.DATA.length + 1)); + assertEquals(-1, this.ks.indexOf("st".getBytes(), 0, DATA.length + 1)); // start offset == data length - assertEquals(-1, this.ks.indexOf("st".getBytes(), this.DATA.length, this.DATA.length)); + assertEquals(-1, this.ks.indexOf("st".getBytes(), DATA.length, DATA.length)); // start offset > data length - assertEquals(-1, this.ks.indexOf("st".getBytes(), this.DATA.length + 1, this.DATA.length)); + assertEquals(-1, this.ks.indexOf("st".getBytes(), DATA.length + 1, DATA.length)); // pattern is null - assertEquals(-1, this.ks.indexOf(null, 0, this.DATA.length)); + assertEquals(-1, this.ks.indexOf(null, 0, DATA.length)); // stop index is exclusive assertEquals(-1, this.ks.indexOf("HI".getBytes(), 0, 2)); assertEquals(1, this.ks.indexOf("HI".getBytes(), 0, 3)); @@ -132,7 +132,7 @@ void testIndexOf() { // pattern is longer than stop - start assertEquals(-1, this.ks.indexOf("Emergency".getBytes(), 0, 5)); // pattern is longer than the data - assertEquals(-1, this.ks.indexOf(new byte[75], 0, this.DATA.length)); + assertEquals(-1, this.ks.indexOf(new byte[75], 0, DATA.length)); // try using an array of negative byte values and a negative byte pattern this.ks = new KeywordScanner(new byte[] {-1, -1, -1, -3, -5, -7}); @@ -160,8 +160,8 @@ void testFindNext() { // stop < previous position assertEquals(-1, this.ks.findNext(5)); // stop == data length - assertEquals(-1, this.ks.findNext(this.DATA.length)); - assertEquals(35, this.ks.findNext(this.DATA.length - 1)); + assertEquals(-1, this.ks.findNext(DATA.length)); + assertEquals(35, this.ks.findNext(DATA.length - 1)); // changing the pattern, we should have reset the position assertEquals(6, this.ks.indexOf("s".getBytes())); // stop is exclusive