Skip to content

Commit

Permalink
Clean up tests
Browse files Browse the repository at this point in the history
Clean up various code style issues in tests.

JIRA: LIGHTY-299
Signed-off-by: Ivan Hrasko <[email protected]>
(cherry picked from commit eb36f82)
  • Loading branch information
ihrasko committed Oct 31, 2024
1 parent b152833 commit b204d73
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
import org.testng.annotations.Test;

public class DataInitTest {
// value from .xml/.json file
private static int EXPECTED_DARKNESS_FACTOR = 200;
private static final String PATH_TO_JSON_INIT_CONFIG = "/DataInitJsonConfig.json";
private static final String PATH_TO_XML_INIT_CONFIG = "/DataInitXmlConfig.json";
private static final String PATH_TO_INVALID_PATH_TO_INIT_CONFIG = "/DataInitInvalidInitPathConfig.json";
Expand Down Expand Up @@ -86,7 +84,6 @@ public void testInvalidInitFilePath() throws Exception {
.build();
boolean result = lightyController.start().get(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
Assert.assertEquals(result,false);

}

@Test
Expand Down Expand Up @@ -114,10 +111,11 @@ public void shutdownLighty() {
lightyController.shutdown(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
}

private ToasterListener registerToasterListener(DataBroker dataBroker,
InstanceIdentifier<Toaster> instanceIdentifier,
CountDownLatch listenerLatch) {
ToasterListener listener = new ToasterListener(listenerLatch, EXPECTED_DARKNESS_FACTOR);
private ToasterListener registerToasterListener(final DataBroker dataBroker,
final InstanceIdentifier<Toaster> instanceIdentifier, final CountDownLatch listenerLatch) {
// value from .xml/.json file
final int expectedDarknessFactor = 200;
ToasterListener listener = new ToasterListener(listenerLatch, expectedDarknessFactor);
dataBroker.registerDataTreeChangeListener(
DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION, instanceIdentifier),
listener);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,12 @@
import java.net.Socket;
import java.net.SocketAddress;
import java.util.concurrent.TimeUnit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

@Test
public class CallhomePluginTest {

private static final Logger LOG = LoggerFactory.getLogger(CallhomePluginTest.class);
public static final long SHUTDOWN_TIMEOUT_MILLIS = 60_000;

private LightyController lightyController;
Expand All @@ -47,7 +43,6 @@ public void beforeClass() throws ConfigurationException {
NetconfConfigUtils.injectServicesToTopologyConfig(configuration, lightyController.getServices());
netconfPlugin = NetconfCallhomePluginBuilder.from(configuration, lightyController.getServices(),
restConfConfig.getInetAddress().getHostAddress(), restConfConfig.getHttpPort()).build();

}

@AfterClass
Expand All @@ -73,5 +68,4 @@ public void testStart() throws Exception {
socket.connect(endpoint);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at https://www.eclipse.org/legal/epl-v10.html
*/

package io.lighty.gnmi.southbound.lightymodule;

import static org.mockito.Mockito.when;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at https://www.eclipse.org/legal/epl-v10.html
*/

package io.lighty.modules.gnmi.test.gnmi;

import static org.junit.jupiter.api.Assertions.assertEquals;
Expand Down Expand Up @@ -153,17 +152,14 @@ public class GnmiWithoutRestconfTest {
private static final QName YANG_VERSION_QN = QName.create(GNMI_YANG_MODEL_QN, "version");
private static final QName YANG_BODY_QN = QName.create(GNMI_YANG_MODEL_QN, "body");


private static LightyController lightyController;
private static GnmiSouthboundModule gnmiSouthboundModule;
private static SimulatedGnmiDevice gnmiDevice;


@BeforeAll
public static void startUp() throws ConfigurationException, ExecutionException, InterruptedException, IOException,
InvalidAlgorithmParameterException, NoSuchPaddingException, NoSuchAlgorithmException,
InvalidKeySpecException, InvalidKeyException, TimeoutException, EffectiveModelContextBuilderException {

NoSuchAlgorithmException, InvalidKeySpecException, TimeoutException,
EffectiveModelContextBuilderException {
lightyController = new LightyControllerBuilder()
.from(ControllerConfigUtils.getConfiguration(Files.newInputStream(CONFIGURATION_PATH)))
.build();
Expand Down Expand Up @@ -501,7 +497,8 @@ private static SecurityChoice getInsecureSecurityChoice() {
}

private static AAAEncryptionServiceImpl createEncryptionService() throws NoSuchPaddingException,
NoSuchAlgorithmException, InvalidKeySpecException, InvalidAlgorithmParameterException, InvalidKeyException {
NoSuchAlgorithmException, InvalidKeySpecException, InvalidAlgorithmParameterException,
InvalidKeyException {
final AaaEncryptServiceConfig encrySrvConfig = getDefaultAaaEncryptServiceConfig();
final byte[] encryptionKeySalt = Base64.getDecoder().decode(encrySrvConfig.getEncryptSalt());
final SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(encrySrvConfig.getEncryptMethod());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at https://www.eclipse.org/legal/epl-v10.html
*/

package io.lighty.modules.gnmi.test.gnmi;

import static org.junit.jupiter.api.Assertions.assertEquals;
Expand Down Expand Up @@ -38,13 +37,11 @@
import org.slf4j.LoggerFactory;

public class SimulatorCrudTest {

private static final Logger LOG = LoggerFactory.getLogger(SimulatorCrudTest.class);

private static final int TARGET_PORT = 10161;
private static final String TARGET_HOST = "127.0.0.1";
private static final String INITIAL_DATA_PATH = "src/test/resources/json/initData";
private static final String TEST_SCHEMA_PATH = "src/test/resources/additional/models";
private static final String SIMULATOR_CONFIG = "/json/simulator_config.json";
private static final String SERVER_KEY = "src/test/resources/certs/server-pkcs8.key";
private static final String SERVER_CERT = "src/test/resources/certs/server.crt";
Expand All @@ -61,7 +58,6 @@ public class SimulatorCrudTest {

@BeforeEach
public void setUp() throws Exception {

GnmiSimulatorConfiguration simulatorConfiguration = GnmiSimulatorConfUtils
.loadGnmiSimulatorConfiguration(this.getClass().getResourceAsStream(SIMULATOR_CONFIG));
simulatorConfiguration.setTargetAddress(TARGET_HOST);
Expand Down

0 comments on commit b204d73

Please sign in to comment.