<scope>compile</scope>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
+ <artifactId>mockito-junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<artifactId>spring-test</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest-core</artifactId>
+ <version>2.2</version>
+ <scope>compile</scope>
+ </dependency>
</dependencies>
</project>
package org.onap.policy.common.utils.gson;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
* Common Utils-Test
* =============================================================================
* Copyright (C) 2018, 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.common.utils.test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.lang.reflect.Constructor;
* Common Utils-Test
* =============================================================================
* Copyright (C) 2018, 2020-2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.common.utils.test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
* ONAP
* ================================================================================
* Copyright (C) 2018-2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.common.utils.time;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.fail;
import java.util.Iterator;
import java.util.LinkedList;
* ONAP
* ================================================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.io.StringReader;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class GsonSerializerTest {
+class GsonSerializerTest {
@Test
- public void testReadJsonReader() {
+ void testReadJsonReader() {
JsonReader rdr = new JsonReader(new StringReader("10"));
GsonSerializer<Object> ser = new GsonSerializer<Object>() {
* ONAP
* ================================================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.common.utils.gson;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-public class GsonTestUtilsBuilderTest {
+class GsonTestUtilsBuilderTest {
private GsonTestUtils utils;
- @Before
+ @BeforeEach
public void setUp() {
utils = new MyBuilder().build();
}
@Test
- public void testBuilderAddMock() {
+ void testBuilderAddMock() {
PreMock pre = mock(PreMock.class);
when(pre.getId()).thenReturn(2000);
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-public class GsonTestUtilsTest {
+class GsonTestUtilsTest {
private static final String HELLO = "hello";
private GsonTestUtils utils;
- @Before
+ @BeforeEach
public void setUp() {
utils = new GsonTestUtils();
}
@Test
- public void testGetGson() {
+ void testGetGson() {
assertNotNull(utils.getGson());
}
@Test
- public void testGsonRoundTrip() {
+ void testGsonRoundTrip() {
Data data = new Data();
data.setId(500);
}
@Test
- public void testCompareGsonObjectClass_testCompareGsonObjectFile() {
+ void testCompareGsonObjectClass_testCompareGsonObjectFile() {
Data data = new Data();
data.setId(500);
data.setText(HELLO);
}
@Test
- public void testCompareGsonObjectString() {
+ void testCompareGsonObjectString() {
Data data = new Data();
data.setId(600);
data.setText(HELLO);
}
@Test
- public void testCompareGsonObjectJsonElement() {
+ void testCompareGsonObjectJsonElement() {
Data data = new Data();
data.setId(650);
data.setText(HELLO);
}
@Test
- public void testApplyScripts() {
+ void testApplyScripts() {
Data data = new Data();
data.setId(700);
data.setText(HELLO);
}
@Test
- public void testReorderJsonObject() {
+ void testReorderJsonObject() {
// insert properties in a non-alphabetical order
JsonObject inner = new JsonObject();
inner.addProperty("objBint", 100);
}
@Test
- public void testReorderJsonArray() {
+ void testReorderJsonArray() {
// insert properties in a non-alphabetical order
JsonObject inner = new JsonObject();
inner.add("objCNull", JsonNull.INSTANCE);
}
@Test
- public void testReorderJsonElement() {
+ void testReorderJsonElement() {
// null element
JsonElement jsonEl = null;
assertNull(utils.reorder(jsonEl));
* ONAP Policy Engine - Common Modules
* ================================================================================
* Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved.
- * Modificaitons Copyright (C) 2023 Nordix Foundation.
+ * Modificaitons Copyright (C) 2023-2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.common.utils.io;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.utils.io.Serializer.Factory;
import org.springframework.test.util.ReflectionTestUtils;
-public class SerializerTest {
+class SerializerTest {
private static final String FACTORY = "factory";
/**
*/
private static Factory saveFactory;
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() {
saveFactory = (Factory) ReflectionTestUtils.getField(Serializer.class, FACTORY);
}
- @AfterClass
+ @AfterAll
public static void tearDownAfterClass() {
ReflectionTestUtils.setField(Serializer.class, FACTORY, saveFactory);
}
- @Before
+ @BeforeEach
public void setUp() {
setFactory(saveFactory);
}
@Test
- public void testFactory() {
+ void testFactory() {
assertNotNull(saveFactory);
}
@Test
- public void testSerialize() throws Exception {
+ void testSerialize() throws Exception {
MyObject obj1 = new MyObject(3);
byte[] data = Serializer.serialize(obj1);
assertTrue(data.length > 0);
assertEquals(obj1.value, obj2.value);
}
- @Test(expected = java.io.NotSerializableException.class)
- public void testSerialize_Ex() throws Exception {
- Serializer.serialize(new NotSerializable());
+ @Test
+ void testSerialize_Ex() {
+ assertThatThrownBy(() -> Serializer.serialize(new NotSerializable()))
+ .isInstanceOf(java.io.NotSerializableException.class);
}
@Test
- public void testSerialize_ArrayCloseEx() {
+ void testSerialize_ArrayCloseEx() {
IOException ex = new IOException("testSerialize_ArrayCloseEx");
/*
}
@Test
- public void testSerialize_ObjectWriteEx() {
+ void testSerialize_ObjectWriteEx() {
IOException ex = new IOException("testSerialize_ObjectWriteEx");
/*
}
@Test
- public void testSerialize_ObjectCloseEx() throws Exception {
+ void testSerialize_ObjectCloseEx() throws Exception {
IOException ex = new IOException("testSerialize_ObjectCloseEx");
ObjectOutputStream oos = mock(ObjectOutputStream.class);
doThrow(ex).when(oos).close();
}
@Test
- public void testSerialize_BothCloseEx() throws Exception {
+ void testSerialize_BothCloseEx() throws Exception {
IOException ex = new IOException("testSerialize_BothCloseEx");
IOException ex2 = new IOException("testSerialize_BothCloseEx_2");
ObjectOutputStream oos = mock(ObjectOutputStream.class);
}
@Test
- public void testDeserialize() throws Exception {
+ void testDeserialize() throws Exception {
MyObject obj1 = new MyObject(3);
MyObject obj2 = Serializer.roundTrip(obj1);
assertEquals(obj1.value, obj2.value);
}
@Test
- public void testDeserialize_ArrayCloseEx() throws Exception {
+ void testDeserialize_ArrayCloseEx() {
IOException ex = new IOException("testSerialize_ObjectWriteEx");
/*
}
@Test
- public void testDeserialize_ObjectReadEx() throws Exception {
+ void testDeserialize_ObjectReadEx() {
IOException ex = new IOException("testDeserialize_ObjectReadEx");
/*
}
@Test
- public void testDeserialize_ObjectRead_ClassEx() throws Exception {
+ void testDeserialize_ObjectRead_ClassEx() throws Exception {
MyObject obj1 = new MyObject(200);
// must use binary character set
}
@Test
- public void testDeserialize_ObjectCloseEx() throws Exception {
+ void testDeserialize_ObjectCloseEx() {
IOException ex = new IOException("testDeserialize_ObjectCloseEx");
/*
}
@Test
- public void testDeserialize_BothCloseEx() throws Exception {
+ void testDeserialize_BothCloseEx() {
IOException ex = new IOException("testDeserialize_BothCloseEx");
IOException ex2 = new IOException("testDeserialize_BothCloseEx_2");
}
@Test
- public void testRoundTrip() throws Exception {
+ void testRoundTrip() throws Exception {
MyObject obj1 = new MyObject(3);
MyObject obj2 = Serializer.roundTrip(obj1);
assertEquals(obj1.value, obj2.value);
}
- @Test(expected = java.io.NotSerializableException.class)
- public void testRoundTrip_Ex() throws Exception {
- Serializer.roundTrip(new NotSerializable());
+ @Test
+ void testRoundTrip_Ex() {
+ assertThatThrownBy(() -> Serializer.roundTrip(new NotSerializable()))
+ .isInstanceOf(java.io.NotSerializableException.class);
}
/**
* ONAP
* ================================================================================
* Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
public class SelfSignedKeyStoreTest {
private static final String USER_DIR_PROP = "user.dir";
/**
* Saves the user.dir property and initializes static fields.
*/
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() {
saveUserDir = System.getProperty(USER_DIR_PROP);
defaultName = saveUserDir + "/" + SelfSignedKeyStore.RELATIVE_PATH;
defaultKeystore = new File(defaultName);
}
- @Before
+ @BeforeEach
public void setUp() {
System.setProperty(USER_DIR_PROP, saveUserDir);
delete(defaultKeystore);
* Tests the constructor, when the SAN file is not found.
*/
@Test
- public void testSelfSignedKeyStoreStringNoSanFile() throws Exception {
+ public void testSelfSignedKeyStoreStringNoSanFile() {
assertThatThrownBy(() -> new SelfSignedKeyStore() {
@Override
protected String getKeystoreSanName() {
* Tests the constructor, when write fails.
*/
@Test
- public void testSelfSignedKeyStoreStringWriteFailure() throws Exception {
+ public void testSelfSignedKeyStoreStringWriteFailure() {
assertThatThrownBy(() -> new SelfSignedKeyStore("target/unknown/path/to/keystore"))
.isInstanceOf(IOException.class);
}
* Common Utils-Test
* ================================================================================
* Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.common.utils.test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class ConstructionErrorTest extends ErrorsTester {
+class ConstructionErrorTest extends ErrorsTester {
@Test
- public void test() {
+ void test() {
assertEquals(4, testAllError(ConstructionError.class));
}
* Common Utils-Test
* ================================================================================
* Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.common.utils.test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class ErrorsTesterTest {
+class ErrorsTesterTest {
@Test
- public void test() {
+ void test() {
assertEquals(2, new ErrorsTester().testAllError(SimpleError.class));
assertEquals(5, new ErrorsTester().testAllError(StaticError.class));
}
* Common Utils-Test
* ================================================================================
* Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.common.utils.test;
-import static org.junit.Assert.assertEquals;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class ExceptionsTesterTest {
+class ExceptionsTesterTest {
@Test
- public void test() {
+ void test() {
assertEquals(2, new ExceptionsTester().test(SimpleException.class));
assertEquals(8, new ExceptionsTester().test(StaticException.class));
}
- @Test(expected = AssertionError.class)
- public void testNoConstructorsException() {
- new ExceptionsTester().test(NoConstructorsException.class);
+ @Test
+ void testNoConstructorsException() {
+ ExceptionsTester tester = new ExceptionsTester();
+ assertThatThrownBy(() -> tester.test(NoConstructorsException.class))
+ .isInstanceOf(AssertionError.class);
}
/**
* Common Utils-Test
* ================================================================================
* Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.common.utils.test;
-import static org.junit.Assert.assertEquals;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class ThrowablesTesterTest {
+class ThrowablesTesterTest {
@Test
- public void test() {
+ void test() {
assertEquals(2, new ThrowablesTester().testAllThrowable(SimpleThrowable.class));
assertEquals(5, new ThrowablesTester().testAllThrowable(StaticThrowable.class));
}
@Test
- public void testNoConstructorsThrowable() {
+ void testNoConstructorsThrowable() {
// this will not throw an error, but it should return 0, as there are
// no matching constructors
assertEquals(0, new ThrowablesTester().testAllThrowable(NoConstructorsThrowable.class));
}
- @Test(expected = AssertionError.class)
- public void testIgnoreMessageThrowable() {
- new ThrowablesTester().testAllThrowable(IgnoreMessageThrowable.class);
+ @Test
+ void testIgnoreMessageThrowable() {
+ ThrowablesTester tester = new ThrowablesTester();
+ assertThatThrownBy(() -> tester.testAllThrowable(IgnoreMessageThrowable.class))
+ .isInstanceOf(AssertionError.class);
}
- @Test(expected = AssertionError.class)
- public void testIgnoreCauseThrowable() {
- new ThrowablesTester().testAllThrowable(IgnoreCauseThrowable.class);
+ @Test
+ void testIgnoreCauseThrowable() {
+ ThrowablesTester tester = new ThrowablesTester();
+ assertThatThrownBy(() -> tester.testAllThrowable(IgnoreCauseThrowable.class))
+ .isInstanceOf(AssertionError.class);
}
- @Test(expected = AssertionError.class)
- public void testAlwaysSuppressThrowable() {
- new ThrowablesTester().testAllThrowable(AlwaysSuppressThrowable.class);
+ @Test
+ void testAlwaysSuppressThrowable() {
+ ThrowablesTester tester = new ThrowablesTester();
+ assertThatThrownBy(() -> tester.testAllThrowable(AlwaysSuppressThrowable.class))
+ .isInstanceOf(AssertionError.class);
}
- @Test(expected = AssertionError.class)
- public void testNeverSuppressThrowable() {
- new ThrowablesTester().testAllThrowable(NeverSuppressThrowable.class);
+ @Test
+ void testNeverSuppressThrowable() {
+ ThrowablesTester tester = new ThrowablesTester();
+ assertThatThrownBy(() -> tester.testAllThrowable(NeverSuppressThrowable.class))
+ .isInstanceOf(AssertionError.class);
}
- @Test(expected = AssertionError.class)
- public void testAlwaysWritableThrowable() {
- new ThrowablesTester().testAllThrowable(AlwaysWritableThrowable.class);
+ @Test
+ void testAlwaysWritableThrowable() {
+ ThrowablesTester tester = new ThrowablesTester();
+ assertThatThrownBy(() -> tester.testAllThrowable(AlwaysWritableThrowable.class))
+ .isInstanceOf(AssertionError.class);
}
- @Test(expected = AssertionError.class)
- public void testNeverWritableThrowable() {
- new ThrowablesTester().testAllThrowable(NeverWritableThrowable.class);
+ @Test
+ void testNeverWritableThrowable() {
+ ThrowablesTester tester = new ThrowablesTester();
+ assertThatThrownBy(() -> tester.testAllThrowable(NeverWritableThrowable.class))
+ .isInstanceOf(AssertionError.class);
}
- @Test(expected = ConstructionError.class)
- public void testThrowInstantiationException() {
- new ThrowablesTester().testAllThrowable(ThrowInstantiationThrowable.class);
+ @Test
+ void testThrowInstantiationException() {
+ ThrowablesTester tester = new ThrowablesTester();
+ assertThatThrownBy(() -> tester.testAllThrowable(ThrowInstantiationThrowable.class))
+ .isInstanceOf(AssertionError.class);
}
/**
* Common Utils-Test
* ================================================================================
* Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.common.utils.test.log.logback;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.slf4j.LoggerFactory;
-public class ExtractAppenderTest {
+class ExtractAppenderTest {
private static final String ABC_DIGIT = "abc[0-9]";
private static final String ABC_DIGIT1 = "abc[1-9]";
private static final String DEF_DIGIT = "def[0-9]";
private List<Thread> threads;
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() {
logger = (Logger) LoggerFactory.getLogger(ExtractAppenderTest.class);
logger.setLevel(Level.INFO);
}
- @Before
+ @BeforeEach
public void setUp() {
threads = new LinkedList<>();
}
/**
* Tear down all appenders and threads.
*/
- @After
+ @AfterEach
public void tearDown() throws Exception {
logger.detachAndStopAllAppenders();
}
@Test
- public void testExtractAppender() {
+ void testExtractAppender() {
AtomicInteger count = new AtomicInteger(0);
ExtractAppender appender = new ExtractAppender() {
}
@Test
- public void testExtractAppenderStringArray() {
+ void testExtractAppenderStringArray() {
AtomicInteger count = new AtomicInteger(0);
ExtractAppender appender = new ExtractAppender(ABC_DIGIT, DEF_DIGIT) {
}
@Test
- public void testExtractAppenderQueueStringArray() {
+ void testExtractAppenderQueueStringArray() {
// no. of matches allowed in the list
int nallowed = 3;
}
@Test
- public void testAppendILoggingEvent_NoPatterns() {
+ void testAppendILoggingEvent_NoPatterns() {
ExtractAppender appender = makeAppender();
logger.info(HELLO);
}
@Test
- public void testAppendILoggingEvent_Formatted() {
+ void testAppendILoggingEvent_Formatted() {
ExtractAppender appender = makeAppender();
logger.info("hello {} world{}", "there", "!");
}
@Test
- public void testAppendILoggingEvent_MatchFirstPattern() {
+ void testAppendILoggingEvent_MatchFirstPattern() {
ExtractAppender appender = makeAppender(ABC_DIGIT, DEF_DIGIT);
logger.info("hello abc1");
}
@Test
- public void testAppendILoggingEvent_MatchLastPattern() {
+ void testAppendILoggingEvent_MatchLastPattern() {
ExtractAppender appender = makeAppender(ABC_DIGIT, DEF_DIGIT);
logger.info("hello def1");
}
@Test
- public void testAppendILoggingEvent_Group1() {
+ void testAppendILoggingEvent_Group1() {
ExtractAppender appender = makeAppender("hello (abc)|(xyz)", DEF_DIGIT);
logger.info("hello abc, world!");
}
@Test
- public void testAppendILoggingEvent_Group3() {
+ void testAppendILoggingEvent_Group3() {
ExtractAppender appender = makeAppender("hello (abc)|(pdq)|(xyz)", DEF_DIGIT);
logger.info("say hello xyz, world!");
}
@Test
- public void testAppendILoggingEvent_NoGroup() {
+ void testAppendILoggingEvent_NoGroup() {
ExtractAppender appender = makeAppender(HELLO_ABC);
logger.info("say hello abc, world!");
}
@Test
- public void testGetExtracted() {
+ void testGetExtracted() {
ExtractAppender appender = makeAppender(ABC_DIGIT1);
logger.info(HELLO_ABC1_WORLD);
}
@Test
- public void testClearExtractions() {
+ void testClearExtractions() {
final ExtractAppender appender = makeAppender(ABC_DIGIT1);
logger.info(HELLO_ABC1_WORLD);
}
@Test
- public void testSetPattern() {
+ void testSetPattern() {
final ExtractAppender appender = makeAppender(ABC_DIGIT1);
logger.info(HELLO_ABC1_WORLD);
* Launches threads doing everything in parallel to ensure nothing crashes.
*/
@Test
- public void test_MultiThreaded() throws Exception {
+ void test_MultiThreaded() throws Exception {
// when to stop
long tend = System.currentTimeMillis() + 250;
* ONAP
* ================================================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.common.utils.time;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-public class PeriodicItemTest {
+class PeriodicItemTest {
private static final long DELAY_MS = 100L;
private static final long PERIOD_MS = 200L;
private static final Object ASSOCIATE = new Object();
/**
* Sets up objects, including {@link #item}.
*/
- @Before
+ @BeforeEach
public void setUp() {
currentTime = new TestTime();
count = 0;
}
@Test
- public void testBumpNextTime() {
+ void testBumpNextTime() {
assertTrue(item.bumpNextTime());
assertEquals(currentTime.getMillis() + PERIOD_MS, item.getNextMs());
}
@Test
- public void testToString() {
+ void testToString() {
assertNotNull(item.toString());
}
@Test
- public void testPeriodicItem() {
+ void testPeriodicItem() {
assertSame(ASSOCIATE, item.getAssociate());
assertNotNull(item.getAction());
assertEquals(currentTime.getMillis() + DELAY_MS, item.getNextMs());
* ONAP
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.common.utils.time;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-public class PseudoExecutorTest {
+class PseudoExecutorTest {
private int invoked;
private PseudoExecutor executor;
- @Before
+ @BeforeEach
public void setUp() {
invoked = 0;
executor = new PseudoExecutor();
}
@Test
- public void test() {
+ void test() {
assertEquals(0, executor.getQueueLength());
assertEquals(0, executor.getTasks().size());
assertTrue(executor.runAll(0));
* ONAP
* ================================================================================
* Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.common.utils.time;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-public class PseudoScheduledExecutorServiceTest {
+class PseudoScheduledExecutorServiceTest {
private static final long DELAY_MS = 100L;
private static final long PERIOD_MS = 200L;
private static final List<Callable<Object>> EMPTY_CALLABLES = Collections.emptyList();
/**
* Sets up objects, including {@link #svc}.
*/
- @Before
+ @BeforeEach
public void setUp() {
ran = 0;
called = 0;
}
@Test
- public void testShutdown() {
+ void testShutdown() {
// submit some tasks
svc.submit(new MyRun());
svc.schedule(new MyRun(), 1L, TimeUnit.SECONDS);
}
@Test
- public void testShutdownNow() {
+ void testShutdownNow() {
// submit some tasks
svc.submit(new MyRun());
svc.schedule(new MyRun(), 1L, TimeUnit.SECONDS);
}
@Test
- public void testIsShutdown_testIsTerminated() {
+ void testIsShutdown_testIsTerminated() {
assertFalse(svc.isShutdown());
assertFalse(svc.isTerminated());
}
@Test
- public void testAwaitTermination() throws InterruptedException {
+ void testAwaitTermination() throws InterruptedException {
assertFalse(svc.awaitTermination(1L, TimeUnit.SECONDS));
svc.shutdown();
}
@Test
- public void testSubmitCallableOfT() throws Exception {
+ void testSubmitCallableOfT() throws Exception {
Future<Integer> future = svc.submit(new MyCallable());
currentTime.runOneTask(0);
}
@Test
- public void testSubmitRunnableT() throws Exception {
+ void testSubmitRunnableT() throws Exception {
Future<Integer> future = svc.submit(new MyRun(), 2);
currentTime.runOneTask(0);
}
@Test
- public void testSubmitRunnable() throws Exception {
+ void testSubmitRunnable() throws Exception {
assertNotNull(svc.submit(new MyRun()));
currentTime.runOneTask(0);
}
@Test
- public void testInvokeAllCollectionOfQextendsCallableOfT() {
+ void testInvokeAllCollectionOfQextendsCallableOfT() {
assertThatThrownBy(() -> svc.invokeAll(EMPTY_CALLABLES))
.isInstanceOf(UnsupportedOperationException.class);
}
@Test
- public void testInvokeAllCollectionOfQextendsCallableOfTLongTimeUnit() {
+ void testInvokeAllCollectionOfQextendsCallableOfTLongTimeUnit() {
assertThatThrownBy(() -> svc.invokeAll(EMPTY_CALLABLES, 1, TimeUnit.MILLISECONDS))
.isInstanceOf(UnsupportedOperationException.class);
}
@Test
- public void testInvokeAnyCollectionOfQextendsCallableOfT() {
+ void testInvokeAnyCollectionOfQextendsCallableOfT() {
assertThatThrownBy(() -> svc.invokeAny(EMPTY_CALLABLES))
.isInstanceOf(UnsupportedOperationException.class);
}
@Test
- public void testInvokeAnyCollectionOfQextendsCallableOfTLongTimeUnit() {
+ void testInvokeAnyCollectionOfQextendsCallableOfTLongTimeUnit() {
assertThatThrownBy(() -> svc.invokeAny(EMPTY_CALLABLES, 1, TimeUnit.MILLISECONDS))
.isInstanceOf(UnsupportedOperationException.class);
}
@Test
- public void testExecute() throws InterruptedException {
+ void testExecute() throws InterruptedException {
svc.execute(new MyRun());
currentTime.runOneTask(0);
}
@Test
- public void testScheduleRunnableLongTimeUnit() throws InterruptedException {
+ void testScheduleRunnableLongTimeUnit() throws InterruptedException {
assertNotNull(svc.schedule(new MyRun(), DELAY_MS, TimeUnit.MILLISECONDS));
assertEquals(DELAY_MS, oneTaskElapsedTime());
}
@Test
- public void testScheduleCallableOfVLongTimeUnit() throws Exception {
+ void testScheduleCallableOfVLongTimeUnit() throws Exception {
ScheduledFuture<Integer> future = svc.schedule(new MyCallable(), DELAY_MS, TimeUnit.MILLISECONDS);
assertEquals(DELAY_MS, oneTaskElapsedTime());
}
@Test
- public void testScheduleAtFixedRate() throws InterruptedException {
+ void testScheduleAtFixedRate() throws InterruptedException {
final ScheduledFuture<?> future =
svc.scheduleAtFixedRate(new MyRun(), DELAY_MS, PERIOD_MS, TimeUnit.MILLISECONDS);
}
@Test
- public void testScheduleWithFixedDelay() throws InterruptedException {
+ void testScheduleWithFixedDelay() throws InterruptedException {
final ScheduledFuture<?> future =
svc.scheduleWithFixedDelay(new MyRun(), DELAY_MS, PERIOD_MS, TimeUnit.MILLISECONDS);
* ONAP
* ================================================================================
* Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.common.utils.time;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.lenient;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.util.concurrent.Delayed;
import java.util.concurrent.TimeUnit;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
-@RunWith(MockitoJUnitRunner.class)
-public class PseudoScheduledFutureTest {
+@ExtendWith(MockitoExtension.class)
+class PseudoScheduledFutureTest {
private static final long DELAY_MS = 1000L;
private int count;
/**
* Sets up objects, including {@link #future}.
*/
- @Before
+ @BeforeEach
public void setUp() {
- when(work.getDelay()).thenReturn(DELAY_MS);
+ lenient().when(work.getDelay()).thenReturn(DELAY_MS);
count = 0;
future = new PseudoScheduledFuture<>(() -> ++count, true);
}
@Test
- public void testRun() {
+ void testRun() {
// verify with a periodic task - should execute twice
count = 0;
future.run();
}
@Test
- public void testPseudoScheduledFutureRunnableTBoolean() throws Exception {
+ void testPseudoScheduledFutureRunnableTBoolean() throws Exception {
final Integer result = 100;
future = new PseudoScheduledFuture<>(() -> ++count, result, true);
assertTrue(future.isPeriodic());
}
@Test
- public void testPseudoScheduledFutureCallableOfTBoolean() throws Exception {
+ void testPseudoScheduledFutureCallableOfTBoolean() throws Exception {
assertTrue(future.isPeriodic());
future.run();
future.run();
}
@Test
- public void testGetDelay() {
+ void testGetDelay() {
assertEquals(DELAY_MS, future.getDelay(TimeUnit.MILLISECONDS));
assertEquals(TimeUnit.MILLISECONDS.toSeconds(DELAY_MS), future.getDelay(TimeUnit.SECONDS));
}
@Test
- public void testCompareTo() {
+ void testCompareTo() {
Delayed delayed = mock(Delayed.class);
when(delayed.getDelay(TimeUnit.MILLISECONDS)).thenReturn(DELAY_MS + 1);
}
@Test
- public void testIsPeriodic() {
+ void testIsPeriodic() {
assertTrue(future.isPeriodic());
assertFalse(new PseudoScheduledFuture<>(() -> ++count, false).isPeriodic());
}
@Test
- public void testGetWorkItem() {
+ void testGetWorkItem() {
assertSame(work, future.getWorkItem());
}
@Test
- public void testSetWorkItem() {
+ void testSetWorkItem() {
work = mock(WorkItem.class);
future.setWorkItem(work);
assertSame(work, future.getWorkItem());
* ONAP
* ================================================================================
* Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.common.utils.time;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Date;
import java.util.TimerTask;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-public class PseudoTimerTest {
+class PseudoTimerTest {
private static final long DELAY_MS = 1000L;
private static final long PERIOD_MS = 2000L;
/**
* Sets up objects, including {@link #timer}.
*/
- @Before
+ @BeforeEach
public void setUp() {
count = 0;
currentTime = new TestTimeMulti();
}
@Test
- public void testCancel() {
+ void testCancel() {
// schedule two tasks
timer.scheduleAtFixedRate(new MyTask(), DELAY_MS, PERIOD_MS);
timer.schedule(new MyTask(), DELAY_MS);
}
@Test
- public void testPurge() {
+ void testPurge() {
assertEquals(0, timer.purge());
assertEquals(0, timer.purge());
}
@Test
- public void testScheduleTimerTaskLong() throws InterruptedException {
+ void testScheduleTimerTaskLong() throws InterruptedException {
timer.schedule(new MyTask(), DELAY_MS);
assertFalse(currentTime.isEmpty());
}
@Test
- public void testScheduleTimerTaskDate() {
+ void testScheduleTimerTaskDate() {
MyTask task = new MyTask();
Date curdate = new Date();
assertThatThrownBy(() -> timer.schedule(task, curdate)).isInstanceOf(UnsupportedOperationException.class);
}
@Test
- public void testScheduleTimerTaskLongLong() throws InterruptedException {
+ void testScheduleTimerTaskLongLong() throws InterruptedException {
timer.schedule(new MyTask(), DELAY_MS, PERIOD_MS);
assertFalse(currentTime.isEmpty());
}
@Test
- public void testScheduleTimerTaskDateLong() {
+ void testScheduleTimerTaskDateLong() {
MyTask task = new MyTask();
Date curdate = new Date();
assertThatThrownBy(() -> timer.schedule(task, curdate, 1L)).isInstanceOf(UnsupportedOperationException.class);
}
@Test
- public void testScheduleAtFixedRateTimerTaskLongLong() throws InterruptedException {
+ void testScheduleAtFixedRateTimerTaskLongLong() throws InterruptedException {
timer.scheduleAtFixedRate(new MyTask(), DELAY_MS, PERIOD_MS);
assertFalse(currentTime.isEmpty());
}
@Test
- public void testScheduleAtFixedRateTimerTaskDateLong() {
+ void testScheduleAtFixedRateTimerTaskDateLong() {
MyTask task = new MyTask();
Date curdate = new Date();
assertThatThrownBy(() -> timer.scheduleAtFixedRate(task, curdate, 1L))
* ONAP
* ================================================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.common.utils.time;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.concurrent.FutureTask;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-public class RunnableItemTest {
+class RunnableItemTest {
private static final long DELAY_MS = 100L;
private static final Object ASSOCIATE = new Object();
/**
* Sets up objects, including {@link #item}.
*/
- @Before
+ @BeforeEach
public void setUp() {
currentTime = new TestTime();
count = 0;
}
@Test
- public void testWasCancelled() {
+ void testWasCancelled() {
assertFalse(item.wasCancelled());
FutureTask<Object> future = new FutureTask<>(() -> count++);
}
@Test
- public void testIsAssociatedWith() {
+ void testIsAssociatedWith() {
assertFalse(item.isAssociatedWith(this));
assertTrue(item.isAssociatedWith(ASSOCIATE));
}
@Test
- public void testFire() {
+ void testFire() {
item.fire();
assertEquals(1, count);
}
@Test
- public void testRunnableItem_testGetAssociate_testGetAction() {
+ void testRunnableItem_testGetAssociate_testGetAction() {
assertSame(ASSOCIATE, item.getAssociate());
assertNotNull(item.getAction());
assertEquals(currentTime.getMillis() + DELAY_MS, item.getNextMs());
}
@Test
- public void testToString() {
+ void testToString() {
assertNotNull(item.toString());
}
}
* ONAP
* ================================================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.common.utils.time;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-public class SleepItemTest {
+class SleepItemTest {
private static final int SLEEP_MS = 250;
private static final long MAX_WAIT_MS = 5000L;
/**
* Sets up objects, including {@link #item}.
*/
- @Before
+ @BeforeEach
public void setUp() {
currentTime = new TestTime();
started = new CountDownLatch(1);
}
@Test
- public void testInterrupt() throws InterruptedException {
+ void testInterrupt() throws InterruptedException {
startThread();
item.interrupt();
}
@Test
- public void testFire_testAwait() throws InterruptedException {
+ void testFire_testAwait() throws InterruptedException {
startThread();
// verify that it hasn't finished yet
}
@Test
- public void testSleepItem() {
+ void testSleepItem() {
assertEquals(currentTime.getMillis() + SLEEP_MS, item.getNextMs());
}
@Test
- public void testToString() {
+ void testToString() {
assertNotNull(item.toString());
}
* ONAP
* ================================================================================
* Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.awaitility.Awaitility.await;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-public class TestTimeMultiTest {
+class TestTimeMultiTest {
private static final long SHORT_WAIT_MS = 100L;
private static final long DELAY_MS = 500L;
private static final long MAX_WAIT_MS = 5000L;
private TestTimeMulti multi;
- @Before
+ @BeforeEach
public void setUp() {
multi = new TestTimeMulti();
}
@Test
- public void testSleep() throws InterruptedException {
+ void testSleep() throws InterruptedException {
// negative sleep time
final long tbegin = multi.getMillis();
MyThread thread = new MyThread(-5);
}
@Test
- public void testTestTimeMulti() {
+ void testTestTimeMulti() {
assertTrue(multi.getMaxWaitMs() > 0);
}
@Test
- public void testTestTimeMultiLong() {
+ void testTestTimeMultiLong() {
assertEquals(200, new TestTimeMulti(200).getMaxWaitMs());
}
@Test
- public void testIsEmpty_testQueueLength() throws InterruptedException {
+ void testIsEmpty_testQueueLength() throws InterruptedException {
assertTrue(multi.isEmpty());
// queue up two items
}
@Test
- public void testDestroy() throws InterruptedException {
+ void testDestroy() throws InterruptedException {
// this won't interrupt
multi.enqueue(new WorkItem(multi, DELAY_MS));
}
@Test
- public void testRunOneTask() throws InterruptedException {
+ void testRunOneTask() throws InterruptedException {
// nothing in the queue yet
assertFalse(multi.runOneTask(0));
}
@Test
- public void testWaitFor() throws InterruptedException {
+ void testWaitFor() throws InterruptedException {
// queue up a couple of items
multi.enqueue(new WorkItem(multi, DELAY_MS));
multi.enqueue(new WorkItem(multi, DELAY_MS * 2));
}
@Test
- public void testWaitFor_EmptyQueue() throws InterruptedException {
+ void testWaitFor_EmptyQueue() throws InterruptedException {
multi = new TestTimeMulti(SHORT_WAIT_MS);
final long realBegin = System.currentTimeMillis();
}
@Test
- public void testWaitUntilCallable() throws InterruptedException {
+ void testWaitUntilCallable() throws InterruptedException {
multi.enqueue(new WorkItem(multi, DELAY_MS));
multi.enqueue(new WorkItem(multi, DELAY_MS * 2));
multi.enqueue(new WorkItem(multi, DELAY_MS * 3));
}
@Test
- public void testWaitUntilCallable_InterruptEx() throws InterruptedException {
+ void testWaitUntilCallable_InterruptEx() throws InterruptedException {
multi = new TestTimeMulti();
Callable<Boolean> callable = () -> {
}
@Test
- public void testWaitUntilCallable_ConditionThrowsEx() throws InterruptedException {
+ void testWaitUntilCallable_ConditionThrowsEx() throws InterruptedException {
multi = new TestTimeMulti();
Callable<Boolean> callable = () -> {
}
@Test
- public void testWaitUntilCallable_NeverSatisfied() throws InterruptedException {
+ void testWaitUntilCallable_NeverSatisfied() throws InterruptedException {
multi = new TestTimeMulti(SHORT_WAIT_MS);
final long realBegin = System.currentTimeMillis();
}
@Test
- public void testWaitUntilLongTimeUnitCallable() throws InterruptedException {
+ void testWaitUntilLongTimeUnitCallable() throws InterruptedException {
multi.enqueue(new WorkItem(multi, DELAY_MS));
multi.enqueue(new WorkItem(multi, DELAY_MS * 2));
multi.enqueue(new WorkItem(multi, DELAY_MS * 3));
}
@Test
- public void testWaitUntilLongTimeUnitCallable_PseudoTimeExpires() throws InterruptedException {
+ void testWaitUntilLongTimeUnitCallable_PseudoTimeExpires() throws InterruptedException {
multi.enqueue(new WorkItem(multi, DELAY_MS));
multi.enqueue(new WorkItem(multi, DELAY_MS * 2));
multi.enqueue(new WorkItem(multi, DELAY_MS * 3));
}
@Test
- public void testRunItem() throws InterruptedException {
+ void testRunItem() throws InterruptedException {
AtomicBoolean fired = new AtomicBoolean(false);
multi.enqueue(new MyWorkItem(fired));
}
@Test
- public void testRunItem_Rescheduled() throws InterruptedException {
+ void testRunItem_Rescheduled() throws InterruptedException {
AtomicBoolean fired = new AtomicBoolean(false);
multi.enqueue(new MyWorkItem(fired) {
}
@Test
- public void testRunItem_Canceled() throws InterruptedException {
+ void testRunItem_Canceled() throws InterruptedException {
AtomicBoolean fired = new AtomicBoolean(false);
multi.enqueue(new MyWorkItem(fired) {
}
@Test
- public void testEnqueue() throws InterruptedException {
+ void testEnqueue() throws InterruptedException {
CountDownLatch started = new CountDownLatch(1);
CountDownLatch finished = new CountDownLatch(1);
AtomicReference<InterruptedException> ex = new AtomicReference<>();
}
@Test
- public void testCancelItems() throws InterruptedException {
+ void testCancelItems() throws InterruptedException {
AtomicBoolean fired1 = new AtomicBoolean();
multi.enqueue(new MyWorkItem(fired1));
}
@Test
- public void testPurgeItems() throws InterruptedException {
+ void testPurgeItems() throws InterruptedException {
AtomicBoolean fired = new AtomicBoolean();
// queue up two that are canceled, one that is not
* Common Utils-Test
* ================================================================================
* Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.common.utils.time;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class TestTimeTest {
* ONAP
* ================================================================================
* Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
public class WorkItemTest {
private TestTime currentTime;
private WorkItem item;
- @Before
+ @BeforeEach
public void setUp() {
currentTime = new TestTime();
item = new WorkItem(currentTime, 0);