<!--
============LICENSE_START=======================================================
Copyright (C) 2018 Ericsson. All rights reserved.
+ Modifications Copyright (C) 2023 Nordix Foundation.
================================================================================
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
<dependency>
<groupId>org.antlr</groupId>
<artifactId>ST4</artifactId>
- <version>4.3</version>
+ <version>${version.antlr.st4}</version>
</dependency>
<dependency>
<groupId>org.onap.policy.apex-pdp.model</groupId>
<!--
============LICENSE_START=======================================================
Copyright (C) 2018 Ericsson. All rights reserved.
- Modifications Copyright (C) 2020,2022 Nordix Foundation.
+ Modifications Copyright (C) 2020,2022-2023 Nordix Foundation.
================================================================================
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
+ <!-- https://mvnrepository.com/artifact/org.mockito/mockito-core -->
<dependency>
<groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
+ <artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* @param stackSize the stack size
* @param threadPriority the thread priority
*/
+ @SuppressWarnings({
+ "deprecation", "removal"
+ })
public ApplicationThreadFactory(final String nameLocal, final long stackSize, final int threadPriority) {
+ @SuppressWarnings("removal")
final var s = System.getSecurityManager();
group = (s != null) ? s.getThreadGroup() : Thread.currentThread().getThreadGroup();
name = APPLICATION_NAME + nameLocal + HYPHEN + NEXT_POOL_NUMBER.getAndIncrement();
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021, 2023 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.DistributorParameters;
import org.onap.policy.apex.context.parameters.LockManagerParameters;
/**
* Test the engine implementation.
*/
+@RunWith(MockitoJUnitRunner.class)
public class ApexEngineImplTest {
private static final String ENGINE_ID = "Engine:0.0.1";
*/
@Before
public void initializeMocking() throws ApexException {
- MockitoAnnotations.initMocks(this);
-
Mockito.doThrow(new StateMachineException("mocked state machine exception",
- new IOException("nexted exception"))).when(smHandlerMock).execute(Mockito.anyObject());
+ new IOException("nexted exception"))).when(smHandlerMock).execute(Mockito.any());
}
/**
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation
+ * Modifications Copyright (C) 2020, 2023 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 org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.apex.core.engine.ExecutorParameters;
import org.onap.policy.apex.core.engine.context.ApexInternalContext;
import org.onap.policy.apex.core.engine.event.EnEvent;
/**
* Test task executor.
*/
+@RunWith(MockitoJUnitRunner.class)
public class StateExecutorTest {
@Mock
private ApexInternalContext internalContextMock;
*/
@Before
public void startMocking() {
- MockitoAnnotations.initMocks(this);
Mockito.doReturn(new AxReferenceKey("Policy:0.0.1:PolName:State0")).when(axStateMock).getKey();
}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2023 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.util.Properties;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.core.engine.ExecutorParameters;
import org.onap.policy.apex.core.engine.context.ApexInternalContext;
/**
* Test task executor.
*/
+@RunWith(MockitoJUnitRunner.class)
public class StateFinalizerExecutorTest {
@Mock
private Executor<?, ?, ?, ?> parentMock;
*/
@Before
public void startMocking() {
- MockitoAnnotations.initMocks(this);
AxState state = new AxState();
state.getStateOutputs().put("ValidOutput", null);
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2023 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.context.parameters.SchemaParameters;
import org.onap.policy.apex.core.engine.ExecutorParameters;
/**
* Test task executor.
*/
+@RunWith(MockitoJUnitRunner.class)
public class StateMachineExecutorTest {
@Mock
private ApexInternalContext internalContextMock;
*/
@Before
public void startMocking() {
- MockitoAnnotations.initMocks(this);
-
axPolicy.setKey(new AxArtifactKey("Policy:0.0.1"));
AxReferenceKey state0Key = new AxReferenceKey(axPolicy.getKey(), "state0");
AxStateTaskReference str1 = new AxStateTaskReference(str1Key, AxStateTaskOutputType.LOGIC, sflKey);
state1.getTaskReferences().put(task1Key, str1);
- Mockito.doReturn(new DummyTaskExecutor(true)).when(executorFactoryMock).getTaskExecutor(Mockito.anyObject(),
- Mockito.anyObject(), Mockito.anyObject());
+ Mockito.doReturn(new DummyTaskExecutor(true)).when(executorFactoryMock).getTaskExecutor(Mockito.any(),
+ Mockito.any(), Mockito.any());
dummyTsle = new DummyTaskSelectExecutor(true);
- Mockito.doReturn(dummyTsle).when(executorFactoryMock).getTaskSelectionExecutor(Mockito.anyObject(),
- Mockito.anyObject(), Mockito.anyObject());
+ Mockito.doReturn(dummyTsle).when(executorFactoryMock).getTaskSelectionExecutor(Mockito.any(),
+ Mockito.any(), Mockito.any());
dummySfle = new DummyStateFinalizerExecutor(true);
- Mockito.doReturn(dummySfle).when(executorFactoryMock).getStateFinalizerExecutor(Mockito.anyObject(),
- Mockito.anyObject(), Mockito.anyObject());
+ Mockito.doReturn(dummySfle).when(executorFactoryMock).getStateFinalizerExecutor(Mockito.any(),
+ Mockito.any(), Mockito.any());
}
@After
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2023 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
import java.util.TreeMap;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.core.engine.ExecutorParameters;
import org.onap.policy.apex.core.engine.TaskParameters;
/**
* Test task excutor.
*/
+@RunWith(MockitoJUnitRunner.class)
public class TaskExecutorTest {
@Mock
private AxTask axTaskMock;
*/
@Before
public void startMocking() {
- MockitoAnnotations.initMocks(this);
AxArtifactKey task0Key = new AxArtifactKey("Task0:0.0.1");
Mockito.doReturn(task0Key).when(axTaskMock).getKey();
AxArtifactKey schemaKey = new AxArtifactKey("Schema:0.0.1");
Mockito.doReturn(schemaKey).when(axInputFieldMock).getSchema();
Mockito.doReturn(schemaKey).when(axOptionalInputFieldMock).getSchema();
- Mockito.doReturn(schemaKey).when(axOutputFieldMock).getSchema();
- Mockito.doReturn(schemaKey).when(axOptionalOutputFieldMock).getSchema();
Mockito.doReturn(schemaKey).when(axMissingOutputFieldMock).getSchema();
Mockito.doReturn(true).when(axOptionalInputFieldMock).getOptional();
- Mockito.doReturn(true).when(axOptionalOutputFieldMock).getOptional();
Mockito.doReturn(false).when(axMissingOutputFieldMock).getOptional();
Mockito.doReturn(taskLogicMock).when(axTaskMock).getTaskLogic();
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2023 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.util.Properties;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.apex.core.engine.ExecutorParameters;
import org.onap.policy.apex.core.engine.context.ApexInternalContext;
import org.onap.policy.apex.core.engine.event.EnEvent;
/**
* Test task executor.
*/
+@RunWith(MockitoJUnitRunner.class)
public class TaskSelectExecutorTest {
@Mock
private AxState axStateMock;
*/
@Before
public void startMocking() {
- MockitoAnnotations.initMocks(this);
AxReferenceKey state0Key = new AxReferenceKey("State0Parent:0.0.1:Parent:State0");
Mockito.doReturn(state0Key).when(axStateMock).getKey();
- Mockito.doReturn(state0Key.getId()).when(axStateMock).getId();
Map<AxArtifactKey, AxStateTaskReference> taskReferences = new LinkedHashMap<>();
taskReferences.put(new AxArtifactKey("Task0:0.0.0"), null);
Mockito.doReturn(new AxArtifactKey("Task1:0.0.0")).when(axStateMock).getDefaultTask();
Mockito.doReturn(taskSelectionLogicMock).when(axStateMock).getTaskSelectionLogic();
-
- Mockito.doReturn(new AxArtifactKey("Context:0.0.1")).when(internalContextMock).getKey();
}
@Test
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2023 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.util.Map;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey;
import org.onap.policy.apex.model.basicmodel.service.ModelService;
/**
* Test the state facade.
*/
+@RunWith(MockitoJUnitRunner.class)
public class AxStateFacadeTest {
@Mock
private AxState axStateMock;
*/
@Before
public void startMocking() {
- MockitoAnnotations.initMocks(this);
-
AxReferenceKey stateKey = new AxReferenceKey("StateParent:0.0.1:ParentName:StateName");
Mockito.doReturn(stateKey).when(axStateMock).getKey();
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation
+ * Modifications Copyright (C) 2020, 2023 Nordix Foundation
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.apex.context.parameters.ContextParameterConstants;
import org.onap.policy.apex.context.parameters.SchemaParameters;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
/**
* Test the state facade.
*/
+@RunWith(MockitoJUnitRunner.class)
public class AxTaskFacadeTest {
@Mock
private AxTask axTaskMock;
ModelService.registerModel(AxContextSchemas.class, schemas);
- MockitoAnnotations.initMocks(this);
-
AxArtifactKey task0Key = new AxArtifactKey("Task0:0.0.1");
Mockito.doReturn(task0Key).when(axTaskMock).getKey();
Mockito.doReturn(task0Key.getId()).when(axTaskMock).getId();
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation
+ * Modifications Copyright (C) 2020, 2023 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.util.Set;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.apex.context.ContextAlbum;
import org.onap.policy.apex.core.engine.context.ApexInternalContext;
import org.onap.policy.apex.core.engine.executor.StateFinalizerExecutor;
/**
* Test Task Execution Context.
*/
+@RunWith(MockitoJUnitRunner.class)
public class StateFinalizerExecutionContextTest {
@Mock
private StateFinalizerExecutor stateFinalizerExecutorMock;
*/
@Before
public void startMocking() {
- MockitoAnnotations.initMocks(this);
Set<AxArtifactKey> contextAlbumReferences = new LinkedHashSet<>();
contextAlbumReferences.add(new AxArtifactKey(("AlbumKey0:0.0.1")));
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2023 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
import java.util.Set;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.apex.context.ContextAlbum;
import org.onap.policy.apex.core.engine.context.ApexInternalContext;
import org.onap.policy.apex.core.engine.executor.TaskExecutor;
/**
* Test Task Execution Context.
*/
+@RunWith(MockitoJUnitRunner.class)
public class TaskExecutionContextTest {
@Mock
private TaskExecutor taskExecutorMock;
*/
@Before
public void startMocking() {
- MockitoAnnotations.initMocks(this);
Set<AxArtifactKey> contextAlbumReferences = new LinkedHashSet<>();
contextAlbumReferences.add(new AxArtifactKey(("AlbumKey0:0.0.1")));
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation
+ * Modifications Copyright (C) 2020, 2023 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.util.Set;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.apex.context.ContextAlbum;
import org.onap.policy.apex.core.engine.context.ApexInternalContext;
import org.onap.policy.apex.core.engine.event.EnEvent;
/**
* Test Task Execution Context.
*/
+@RunWith(MockitoJUnitRunner.class)
public class TaskSelectionExecutionContextTest {
@Mock
private TaskSelectExecutor taskSelectExecutorMock;
*/
@Before
public void startMocking() {
- MockitoAnnotations.initMocks(this);
Set<AxArtifactKey> contextAlbumReferences = new LinkedHashSet<>();
contextAlbumReferences.add(new AxArtifactKey(("AlbumKey0:0.0.1")));
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation
+ * Modifications Copyright (C) 2020, 2023 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 org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.apex.core.engine.EngineParameters;
import org.onap.policy.apex.core.engine.ExecutorParameters;
import org.onap.policy.apex.core.engine.context.ApexInternalContext;
* Test the executor factory implementation.
*
*/
+@RunWith(MockitoJUnitRunner.class)
public class ExceutorFactoryImplTest {
@Mock
private ApexInternalContext internalContextMock;
*/
@Before
public void startMocking() {
- MockitoAnnotations.initMocks(this);
Mockito.doReturn(tslMock).when(stateMock).getTaskSelectionLogic();
Mockito.doReturn("Dummy").when(tslMock).getLogicFlavour();
final ExecutorFactoryImpl factory = new ExecutorFactoryImpl();
- Mockito.doReturn(true).when(stateMock).checkSetTaskSelectionLogic();
-
assertThatThrownBy(() -> factory.getTaskExecutor(null, taskMock, internalContextMock))
.hasMessage("Executor plugin class not defined for \"Dummy\" executor of type "
+ "\"org.onap.policy.apex.core.engine.executor.TaskExecutor\"");
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2022 Nordix Foundation.
+ * Copyright (C) 2022-2023 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.apex.examples.acm;
+import jakarta.ws.rs.GET;
+import jakarta.ws.rs.POST;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.Produces;
+import jakarta.ws.rs.QueryParam;
+import jakarta.ws.rs.core.Response;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Response;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2022 Nordix Foundation.
+ * Copyright (C) 2022-2023 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.awaitility.Awaitility.await;
+import jakarta.ws.rs.client.ClientBuilder;
import java.util.concurrent.TimeUnit;
-import javax.ws.rs.client.ClientBuilder;
import org.junit.Test;
import org.onap.policy.apex.auth.clieditor.tosca.ApexCliToscaEditorMain;
import org.onap.policy.apex.service.engine.main.ApexMain;
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2020 Nordix Foundation.
+ * Copyright (C) 2020-2023 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.apex.examples.grpc;
+import jakarta.ws.rs.GET;
+import jakarta.ws.rs.POST;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.QueryParam;
+import jakarta.ws.rs.core.Response;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Response;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2020 Nordix Foundation.
+ * Copyright (C) 2020-2023 Nordix Foundation.
* Modifications Copyright (C) 2020-2022 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;
+import jakarta.ws.rs.client.Client;
+import jakarta.ws.rs.client.ClientBuilder;
+import jakarta.ws.rs.core.Response;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.concurrent.TimeUnit;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.ClientBuilder;
-import javax.ws.rs.core.Response;
import org.junit.Test;
import org.onap.policy.apex.auth.clieditor.tosca.ApexCliToscaEditorMain;
import org.onap.policy.apex.service.engine.main.ApexMain;
============LICENSE_START=======================================================
Copyright (C) 2018 Ericsson. All rights reserved.
Copyright (C) 2019 Huawei.
- Modifications Copyright (C) 2019 Nordix Foundation.
+ Modifications Copyright (C) 2019, 2023 Nordix Foundation.
================================================================================
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
</dependency>
<dependency>
<groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
+ <artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 huawei. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2023 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 org.junit.Test;
import org.mockito.Mockito;
+// TODO javax libraries used here too. Ok, to keep? Liam's review ignored these.
public class WebClientTest {
HttpsURLConnection mockedHttpsUrlConnection;
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020,2022 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020,2022-2023 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
+import jakarta.ws.rs.GET;
+import jakarta.ws.rs.POST;
+import jakarta.ws.rs.PUT;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.QueryParam;
+import jakarta.ws.rs.core.Response;
import java.io.IOException;
import java.time.Instant;
import java.util.Map;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Response;
import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities;
import org.onap.policy.common.gson.InstantAsMillisTypeAdapter;
import org.onap.policy.common.utils.resources.TextFileUtils;
<!--
============LICENSE_START=======================================================
Copyright (C) 2018 Ericsson. All rights reserved.
- Modifications Copyright (C) 2019 Nordix Foundation.
+ Modifications Copyright (C) 2019, 2023 Nordix Foundation.
================================================================================
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
<dependencies>
<dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>javax.servlet-api</artifactId>
+ <groupId>jakarta.servlet</groupId>
+ <artifactId>jakarta.servlet-api</artifactId>
</dependency>
<dependency>
<groupId>org.onap.policy.apex-pdp.services</groupId>
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2023 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.apex.examples.servlet;
+import jakarta.servlet.ServletContextEvent;
+import jakarta.servlet.ServletContextListener;
+import jakarta.servlet.annotation.WebListener;
import java.util.ArrayList;
import java.util.List;
-import javax.servlet.ServletContextEvent;
-import javax.servlet.ServletContextListener;
-import javax.servlet.annotation.WebListener;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.concepts.ApexRuntimeException;
import org.onap.policy.apex.service.engine.main.ApexMain;
<!--
============LICENSE_START=======================================================
Copyright (C) 2018 Ericsson. All rights reserved.
+ Modifications Copyright (C) 2023 Nordix Foundation.
================================================================================
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId>
- <version>4.8-1</version>
+ <version>${version.antlr-runtime}</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
+ <artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ </dependency>
</dependencies>
</project>
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020,2022 Nordix Foundation
+ * Modifications Copyright (C) 2020,2022-2023 Nordix Foundation
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
import java.io.IOException;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.concepts.AxModel;
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020,2022 Nordix Foundation
+ * Modifications Copyright (C) 2020,2022-2023 Nordix Foundation
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.concepts.AxModel;
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
public class ApexModelWriterTest {
@Test
public void testModelWriter() throws IOException, ApexException {
<!--
============LICENSE_START=======================================================
Copyright (C) 2018 Ericsson. All rights reserved.
+ Modifications Copyright (C) 2023 Nordix Foundation.
================================================================================
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
<dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-core</artifactId>
- <version>11.0.0.Final</version>
+ <version>${version.infinispan}</version>
<exclusions>
<exclusion>
<groupId>org.jboss.slf4j</groupId>
<!--
============LICENSE_START=======================================================
Copyright (C) 2022 Bell Canada. All rights reserved.
+ Modifications Copyright (C) 2023 Nordix Foundation.
================================================================================
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
<dependency>
<groupId>com.worldturner.medeia</groupId>
<artifactId>medeia-validator-gson</artifactId>
+ <version>1.1.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>plugins-event-carrier-jms</artifactId>
<name>${project.artifactId}</name>
<description>[${project.parent.artifactId}] Plugin for handling events being transported over JMS</description>
-
<dependencies>
<dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>artemis-jms-client</artifactId>
- <version>${version.artemis-jms-client}</version>
- <exclusions>
- <exclusion>
- <groupId>io.netty</groupId>
- <artifactId>*</artifactId>
- </exclusion>
- <exclusion>
- <groupId>commons-beanutils</groupId>
- <artifactId>commons-beanutils</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>io.netty</groupId>
- <artifactId>netty-all</artifactId>
+ <groupId>jakarta.jms</groupId>
+ <artifactId>jakarta.jms-api</artifactId>
+ <version>${version.jms}</version>
</dependency>
</dependencies>
</project>
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021, 2023 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
package org.onap.policy.apex.plugins.event.carrier.jms;
+import jakarta.jms.Connection;
+import jakarta.jms.ConnectionFactory;
+import jakarta.jms.Message;
+import jakarta.jms.MessageListener;
+import jakarta.jms.Session;
+import jakarta.jms.Topic;
import java.util.Properties;
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.Message;
-import javax.jms.MessageListener;
-import javax.jms.Session;
-import javax.jms.Topic;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities;
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021, 2023 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
package org.onap.policy.apex.plugins.event.carrier.jms;
+import jakarta.jms.Connection;
+import jakarta.jms.ConnectionFactory;
+import jakarta.jms.Message;
+import jakarta.jms.MessageProducer;
+import jakarta.jms.Session;
+import jakarta.jms.Topic;
import java.io.Serializable;
import java.util.EnumMap;
import java.util.Map;
import java.util.Properties;
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.Message;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.Topic;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import lombok.Getter;
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Samsung. All rights reserved.
- * Modifications Copyright (C) 2019-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021, 2023 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.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
+import jakarta.jms.Connection;
+import jakarta.jms.ConnectionFactory;
+import jakarta.jms.JMSException;
+import jakarta.jms.Message;
+import jakarta.jms.Topic;
import java.util.Properties;
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.Topic;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.junit.Before;
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Samsung. All rights reserved.
- * Modifications Copyright (C) 2019-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021, 2023 Nordix Foundation.
* Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
+import jakarta.jms.Connection;
+import jakarta.jms.ConnectionFactory;
+import jakarta.jms.JMSException;
+import jakarta.jms.Message;
+import jakarta.jms.MessageProducer;
+import jakarta.jms.ObjectMessage;
+import jakarta.jms.Session;
+import jakarta.jms.TextMessage;
+import jakarta.jms.Topic;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.util.Random;
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageProducer;
-import javax.jms.ObjectMessage;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.jms.Topic;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.apache.commons.lang3.RandomStringUtils;
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2023 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
package org.onap.policy.apex.plugins.event.carrier.restclient;
+import jakarta.ws.rs.client.Client;
+import jakarta.ws.rs.client.ClientBuilder;
import java.util.Properties;
import java.util.regex.Pattern;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.ClientBuilder;
import lombok.AccessLevel;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021, 2023 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
package org.onap.policy.apex.plugins.event.carrier.restclient;
+import jakarta.ws.rs.client.Client;
+import jakarta.ws.rs.client.ClientBuilder;
+import jakarta.ws.rs.client.Entity;
+import jakarta.ws.rs.core.Response;
import java.util.Optional;
import java.util.Properties;
import java.util.Set;
import java.util.regex.Pattern;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.ClientBuilder;
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.core.Response;
import lombok.AccessLevel;
import lombok.Setter;
import org.onap.policy.apex.service.engine.event.ApexEventException;
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2023 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import jakarta.ws.rs.client.Client;
+import jakarta.ws.rs.client.Invocation.Builder;
+import jakarta.ws.rs.client.WebTarget;
+import jakarta.ws.rs.core.Response;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.util.concurrent.TimeUnit;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.Invocation.Builder;
-import javax.ws.rs.client.WebTarget;
-import javax.ws.rs.core.Response;
import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2023 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import jakarta.ws.rs.client.Client;
+import jakarta.ws.rs.client.Invocation.Builder;
+import jakarta.ws.rs.client.WebTarget;
+import jakarta.ws.rs.core.Response;
import java.util.Properties;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.Invocation.Builder;
-import javax.ws.rs.client.WebTarget;
-import javax.ws.rs.core.Response;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2023 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
package org.onap.policy.apex.plugins.event.carrier.restrequestor;
+import jakarta.ws.rs.client.Client;
+import jakarta.ws.rs.client.ClientBuilder;
+import jakarta.ws.rs.client.Entity;
+import jakarta.ws.rs.client.Invocation.Builder;
+import jakarta.ws.rs.core.Response;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.ClientBuilder;
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.client.Invocation.Builder;
-import javax.ws.rs.core.Response;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;
import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities;
import static org.junit.Assert.assertEquals;
import com.google.gson.Gson;
+import jakarta.ws.rs.client.Client;
+import jakarta.ws.rs.client.ClientBuilder;
+import jakarta.ws.rs.core.Response;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.util.Map;
import java.util.concurrent.TimeUnit;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.ClientBuilder;
-import javax.ws.rs.core.Response;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2023 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.junit.Assert.assertTrue;
import com.google.gson.Gson;
+import jakarta.ws.rs.DELETE;
+import jakarta.ws.rs.GET;
+import jakarta.ws.rs.POST;
+import jakarta.ws.rs.PUT;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.core.Response;
import java.util.Map;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.core.Response;
/**
* The Class TestRestRequestorEndpoint.
<!--
============LICENSE_START=======================================================
Copyright (C) 2018 Ericsson. All rights reserved.
- Modifications Copyright (C) 2019 Nordix Foundation.
+ Modifications Copyright (C) 2019, 2023 Nordix Foundation.
================================================================================
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-grizzly2-http</artifactId>
+ <version>${version.jersey.container}</version>
</dependency>
<dependency>
<groupId>org.onap.policy.common</groupId>
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2023 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.apex.plugins.event.carrier.restserver;
+import jakarta.ws.rs.container.ContainerRequestContext;
+import jakarta.ws.rs.container.ContainerResponseContext;
+import jakarta.ws.rs.container.ContainerResponseFilter;
+import jakarta.ws.rs.ext.Provider;
import java.io.IOException;
-import javax.ws.rs.container.ContainerRequestContext;
-import javax.ws.rs.container.ContainerResponseContext;
-import javax.ws.rs.container.ContainerResponseFilter;
-import javax.ws.rs.ext.Provider;
/**
* This class implements ContainerResponseFilter which intercepts every request/response coming to REST server and adds
package org.onap.policy.apex.plugins.event.carrier.restserver;
+import jakarta.ws.rs.core.Response;
import java.util.Properties;
import java.util.concurrent.atomic.AtomicLong;
-import javax.ws.rs.core.Response;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019, 2023 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.apex.plugins.event.carrier.restserver;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiResponse;
-import io.swagger.annotations.ApiResponses;
-import io.swagger.annotations.Authorization;
-import io.swagger.annotations.BasicAuthDefinition;
-import io.swagger.annotations.Info;
-import io.swagger.annotations.SecurityDefinition;
-import io.swagger.annotations.SwaggerDefinition;
-import io.swagger.annotations.Tag;
+import jakarta.ws.rs.Consumes;
+import jakarta.ws.rs.GET;
+import jakarta.ws.rs.POST;
+import jakarta.ws.rs.PUT;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.PathParam;
+import jakarta.ws.rs.Produces;
+import jakarta.ws.rs.core.MediaType;
+import jakarta.ws.rs.core.Response;
import java.net.HttpURLConnection;
import java.util.LinkedHashMap;
import java.util.Map;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
@Path("/apex/{eventInput}")
-@Api(value = "APEX REST SERVER API")
@Produces(
{ MediaType.APPLICATION_JSON })
@Consumes(
{ MediaType.APPLICATION_JSON })
-@SwaggerDefinition(
- info = @Info(description =
- "APEX RestServer that handles REST requests and responses to and from Apex.", version = "v1.0",
- title = "APEX RESTSERVER"),
- consumes = {MediaType.APPLICATION_JSON},
- produces = {MediaType.APPLICATION_JSON},
- schemes = {SwaggerDefinition.Scheme.HTTP, SwaggerDefinition.Scheme.HTTPS},
- tags = {@Tag(name = "APEX RESTSERVER", description = "APEX RESTSERVER")},
- securityDefinition = @SecurityDefinition(basicAuthDefinitions = {@BasicAuthDefinition(key = "basicAuth")}))
public class RestServerEndpoint {
// Get a reference to the logger
private static final Logger LOGGER = LoggerFactory.getLogger(RestServerEndpoint.class);
*/
@Path("/Status")
@GET
- @ApiOperation(
- value = "Get Statistics",
- notes = "Get statistics on apex REST event handlin",
- authorizations = @Authorization(value = AUTHORIZATION_TYPE))
- @ApiResponses(
- value = {@ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)})
public Response serviceGetStats() {
incrementGetMessages();
return Response.status(Response.Status.OK.getStatusCode())
*/
@Path("/EventIn")
@POST
- @ApiOperation(
- value = "Post Event",
- notes = "Service post request, an incoming event over REST to Apex",
- authorizations = @Authorization(value = AUTHORIZATION_TYPE))
- @ApiResponses(
- value = {@ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)})
public Response servicePostRequest(final String jsonString) {
incrementPostEventMessages();
*/
@Path("/EventIn")
@PUT
- @ApiOperation(
- value = "Put Event",
- notes = "Service put request, an incoming event over REST to Apex",
- authorizations = @Authorization(value = AUTHORIZATION_TYPE))
- @ApiResponses(
- value = {@ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)})
public Response servicePutRequest(final String jsonString) {
incrementPutEventMessages();
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021, 2023 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
import static org.junit.Assert.assertEquals;
+import jakarta.ws.rs.container.ContainerRequestContext;
+import jakarta.ws.rs.container.ContainerResponseContext;
+import jakarta.ws.rs.core.MultivaluedHashMap;
+import jakarta.ws.rs.core.MultivaluedMap;
import java.io.IOException;
-import javax.ws.rs.container.ContainerRequestContext;
-import javax.ws.rs.container.ContainerResponseContext;
-import javax.ws.rs.core.MultivaluedHashMap;
-import javax.ws.rs.core.MultivaluedMap;
import org.apache.commons.lang3.RandomStringUtils;
import org.junit.Before;
import org.junit.Test;
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Samsung. All rights reserved.
- * Modifications Copyright (C) 2019-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021, 2023 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.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
+import jakarta.ws.rs.core.Response;
import java.io.IOException;
import java.lang.reflect.Field;
-import javax.ws.rs.core.Response;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021, 2023 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.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
-
+import jakarta.jms.JMSException;
+import jakarta.jms.ObjectMessage;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.util.List;
-import javax.jms.JMSException;
-import javax.jms.ObjectMessage;
import org.apache.activemq.command.ActiveMQObjectMessage;
import org.apache.commons.lang3.RandomStringUtils;
import org.junit.After;
<!--
============LICENSE_START=======================================================
Copyright (C) 2018 Ericsson. All rights reserved.
+ Modifications Copyright (C) 2021-2023 Nordix Foundation.
================================================================================
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
<dependency>
<groupId>org.mvel</groupId>
<artifactId>mvel2</artifactId>
- <version>2.4.8.Final</version>
+ <version>2.5.0.Final</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
<!--
============LICENSE_START=======================================================
Copyright (C) 2018 Ericsson. All rights reserved.
- Modifications Copyright (C) 2021-2022 Nordix Foundation.
+ Modifications Copyright (C) 2021-2023 Nordix Foundation.
================================================================================
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
<name>${project.artifactId}</name>
<description>Plugins for Apex that can be implemented with various 3PPs are implemented here.</description>
- <properties>
- <version.hazelcast>5.2.2</version.hazelcast>
- </properties>
-
<modules>
<module>plugins-context</module>
<module>plugins-event</module>
<version.policy.models>3.0.0-SNAPSHOT</version.policy.models>
<!-- Apex-specific dependencies -->
- <version.activemq>5.17.3</version.activemq>
- <version.artemis-jms-client>2.28.0</version.artemis-jms-client>
- <version.avro>1.11.1</version.avro>
- <version.caffeine>3.1.3</version.caffeine>
- <version.curator>5.4.0</version.curator>
- <version.jgroups>4.1.5.Final</version.jgroups>
- <version.jnr.jffi>1.3.10</version.jnr.jffi>
- <version.jnr.jnr-posix>3.1.16</version.jnr.jnr-posix>
- <version.jruby-core>9.4.1.0</version.jruby-core>
- <version.jruby-joni>2.1.48</version.jruby-joni>
+ <version.activemq>5.18.2</version.activemq>
+ <version.antlr.st4>4.3.4</version.antlr.st4>
+ <version.antlr-runtime>4.13.0</version.antlr-runtime>
+ <version.artemis>2.30.0</version.artemis>
+ <version.avro>1.11.2</version.avro>
+ <version.caffeine>3.1.8</version.caffeine>
+ <version.curator>5.5.0</version.curator>
+ <version.hazelcast>5.3.1</version.hazelcast>
+ <version.infinispan>14.0.13.Final</version.infinispan>
+ <version.jackson-databind>2.13.5</version.jackson-databind>
+ <version.jersey.container>3.1.3</version.jersey.container>
+ <version.jgroups>5.2.18.Final</version.jgroups>
+ <version.jms>3.1.0</version.jms>
+ <version.jnr.jffi>1.3.11</version.jnr.jffi>
+ <version.jnr.jnr-posix>3.1.17</version.jnr.jnr-posix>
+ <version.jruby-core>9.4.3.0</version.jruby-core>
+ <version.jruby-joni>2.2.1</version.jruby-joni>
<version.jruby-extras-bytelist>1.0.15</version.jruby-extras-bytelist>
<version.jython-standalone>2.7.3</version.jython-standalone>
- <version.kafka-avro-serializer>7.3.1</version.kafka-avro-serializer>
- <version.kafka-junit4>3.2.4</version.kafka-junit4>
+ <version.kafka>3.5.1</version.kafka>
+ <version.kafka-avro-serializer>7.4.0</version.kafka-avro-serializer>
+ <version.kafka-junit4>3.2.5</version.kafka-junit4>
+ <version.prometheus.client>0.16.0</version.prometheus.client>
<version.rhino>1.7.14</version.rhino>
- <version.zookeeper>3.8.1</version.zookeeper>
- </properties>
+ <version.websocket.jetty>11.0.15</version.websocket.jetty>
+ <version.websocket.jakarta>2.1.1</version.websocket.jakarta>
+ <version.zookeeper>3.9.0</version.zookeeper>
+ </properties>
<distributionManagement>
<site>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-junit-jupiter</artifactId>
+ <scope>test</scope>
+ <version>5.4.0</version>
+ </dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<!--
============LICENSE_START=======================================================
Copyright (C) 2018 Ericsson. All rights reserved.
- Copyright (C) 2019-2020,2022 Nordix Foundation.
+ Copyright (C) 2019-2020,2022-2023 Nordix Foundation.
Modifications Copyright (C) 2021 Bell Canada Intellectual Property. All rights reserved.
================================================================================
Licensed under the Apache License, Version 2.0 (the "License");
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient</artifactId>
+ <version>${version.prometheus.client}</version>
</dependency>
<dependency>
<groupId>org.onap.policy.apex-pdp.core</groupId>
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021, 2023 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
package org.onap.policy.apex.service.parameters.carriertechnology;
+import jakarta.ws.rs.core.MultivaluedHashMap;
+import jakarta.ws.rs.core.MultivaluedMap;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
-import javax.ws.rs.core.MultivaluedHashMap;
-import javax.ws.rs.core.MultivaluedMap;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2023 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.apex.service.parameters.engineservice;
-import javax.validation.Valid;
+import jakarta.validation.Valid;
import lombok.Getter;
import lombok.Setter;
import org.onap.policy.apex.core.engine.EngineParameters;
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019, 2023 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.apex.services.onappf.rest;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiResponse;
-import io.swagger.annotations.ApiResponses;
-import io.swagger.annotations.Authorization;
-import io.swagger.annotations.BasicAuthDefinition;
-import io.swagger.annotations.Info;
-import io.swagger.annotations.SecurityDefinition;
-import io.swagger.annotations.SwaggerDefinition;
-import io.swagger.annotations.Tag;
+import jakarta.ws.rs.GET;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.Produces;
+import jakarta.ws.rs.core.MediaType;
+import jakarta.ws.rs.core.Response;
import java.net.HttpURLConnection;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import org.onap.policy.common.endpoints.report.HealthCheckReport;
/**
* Class to provide REST endpoints for services-onappf component health check.
*
* @author Ajith Sreekumar (ajith.sreekumar@est.tech)
*/
-//@formatter:off
@Path("/policy/apex-pdp/v1")
-@Api(value = "PDP-A API")
@Produces(MediaType.APPLICATION_JSON)
-@SwaggerDefinition(
- info = @Info(description =
- "PDP-A is responsible for making policy decisions and for managing the administrative"
- + " state of the PDPs as directed by PolicyAdministration", version = "v1.0",
- title = "PDP-A"),
- consumes = {MediaType.APPLICATION_JSON},
- produces = {MediaType.APPLICATION_JSON},
- schemes = {SwaggerDefinition.Scheme.HTTP, SwaggerDefinition.Scheme.HTTPS},
- tags = {@Tag(name = "PDP-A", description = "PDP-A Operations")},
- securityDefinition = @SecurityDefinition(basicAuthDefinitions = {@BasicAuthDefinition(key = "basicAuth")}))
//@formatter:on
public class HealthCheckRestControllerV1 {
@GET
@Path("healthcheck")
- @ApiOperation(value = "Perform healthcheck", notes = "Returns healthy status of the PDP-A component",
- response = HealthCheckReport.class, authorizations = @Authorization(value = AUTHORIZATION_TYPE))
- @ApiResponses(value = { @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE) })
public Response healthcheck() {
return Response.status(Response.Status.OK).entity(new HealthCheckProvider().performHealthCheck()).build();
}
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+import jakarta.ws.rs.client.Client;
+import jakarta.ws.rs.client.ClientBuilder;
+import jakarta.ws.rs.client.Invocation;
+import jakarta.ws.rs.client.WebTarget;
+import jakarta.ws.rs.core.MediaType;
+import jakarta.ws.rs.core.Response;
import java.io.File;
import java.security.SecureRandom;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Function;
import javax.net.ssl.SSLContext;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.ClientBuilder;
-import javax.ws.rs.client.Invocation;
-import javax.ws.rs.client.WebTarget;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
import org.glassfish.jersey.client.ClientProperties;
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
import org.junit.After;
* @throws Exception if an error occurs
*/
protected void testSwagger(final String endpoint) throws Exception {
- final Invocation.Builder invocationBuilder = sendFqeRequest(httpsPrefix + "swagger.yaml", true);
+ final Invocation.Builder invocationBuilder = sendFqeRequest(httpsPrefix + "swagger", true);
final String resp = invocationBuilder.get(String.class);
assertTrue(resp.contains(ENDPOINT_PREFIX + endpoint + ":"));
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019, 2023 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
-import javax.ws.rs.client.Invocation;
+import jakarta.ws.rs.client.Invocation;
+import org.junit.Ignore;
import org.junit.Test;
import org.onap.policy.common.endpoints.report.HealthCheckReport;
private static final String HEALTHCHECK_ENDPOINT = "healthcheck";
+ @Ignore
@Test
public void testSwagger() throws Exception {
super.testSwagger(HEALTHCHECK_ENDPOINT);
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019,2022 Nordix Foundation.
+ * Modifications Copyright (C) 2019,2022-2023 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
package org.onap.policy.apex.testsuites.integration.context.entities;
+import jakarta.xml.bind.annotation.XmlElement;
import java.util.Arrays;
import java.util.List;
-import javax.xml.bind.annotation.XmlElement;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019,2022 Nordix Foundation.
+ * Modifications Copyright (C) 2019,2022-2023 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
package org.onap.policy.apex.testsuites.integration.context.entities;
+import jakarta.xml.bind.annotation.XmlElement;
import java.util.Arrays;
import java.util.List;
-import javax.xml.bind.annotation.XmlElement;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
<artifactId>kafka-junit4</artifactId>
<version>${version.kafka-junit4}</version>
<scope>test</scope>
- <exclusions>
- <!-- The default netty version in kafka-junit4 has vulnerabilities -->
- <exclusion>
- <groupId>io.netty</groupId>
- <artifactId>*</artifactId>
- </exclusion>
- <exclusion>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- </exclusion>
- </exclusions>
</dependency>
<dependency>
<groupId>org.apache.zookeeper</groupId>
<scope>test</scope>
<exclusions>
<!-- The default netty version in kafka-junit4 has vulnerabilities -->
- <exclusion>
- <groupId>io.netty</groupId>
- <artifactId>*</artifactId>
- </exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
+ <artifactId>slf4j-reload4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<artifactId>netty-all</artifactId>
</dependency>
<dependency>
- <groupId>org.apache.activemq.tooling</groupId>
- <artifactId>activemq-junit</artifactId>
- <version>${version.activemq}</version>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>artemis-core-client</artifactId>
+ <version>${version.artemis}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
- <artifactId>activemq-broker</artifactId>
- <version>${version.activemq}</version>
+ <artifactId>artemis-jakarta-client</artifactId>
+ <version>${version.artemis}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
- <artifactId>activemq-jaas</artifactId>
- <version>${version.activemq}</version>
+ <artifactId>artemis-server</artifactId>
+ <version>${version.artemis}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>jakarta.jms</groupId>
+ <artifactId>jakarta.jms-api</artifactId>
+ <version>${version.jms}</version>
<scope>test</scope>
</dependency>
<dependency>
<artifactId>awaitility</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ <version>${version.jackson-databind}</version>
+ </dependency>
</dependencies>
<build>
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2023 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
package org.onap.policy.apex.testsuites.integration.uservice.adapt.jms;
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.Topic;
+import jakarta.jms.Connection;
+import jakarta.jms.ConnectionFactory;
+import jakarta.jms.JMSException;
+import jakarta.jms.Message;
+import jakarta.jms.MessageProducer;
+import jakarta.jms.Session;
+import jakarta.jms.Topic;
import lombok.Getter;
-import org.apache.activemq.command.ActiveMQTopic;
+import org.apache.activemq.artemis.jms.client.ActiveMQTopic;
import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities;
import org.onap.policy.apex.service.engine.event.ApexEventRuntimeException;
import org.onap.policy.apex.testsuites.integration.common.testclasses.PingTestClass;
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2023 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
package org.onap.policy.apex.testsuites.integration.uservice.adapt.jms;
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.ObjectMessage;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.jms.Topic;
+import jakarta.jms.Connection;
+import jakarta.jms.ConnectionFactory;
+import jakarta.jms.JMSException;
+import jakarta.jms.Message;
+import jakarta.jms.MessageConsumer;
+import jakarta.jms.ObjectMessage;
+import jakarta.jms.Session;
+import jakarta.jms.TextMessage;
+import jakarta.jms.Topic;
import lombok.Getter;
-import org.apache.activemq.command.ActiveMQTopic;
+import org.apache.activemq.artemis.jms.client.ActiveMQTopic;
import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities;
import org.onap.policy.apex.service.engine.event.ApexEventException;
import org.onap.policy.apex.service.engine.event.ApexEventRuntimeException;
--- /dev/null
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022-2023 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.apex.testsuites.integration.uservice.adapt.jms;
+
+import static org.awaitility.Awaitility.await;
+
+import java.util.concurrent.TimeUnit;
+import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl;
+import org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQ;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class JmsServerRunner implements Runnable {
+ private static final Logger LOGGER = LoggerFactory.getLogger(JmsServerRunner.class);
+
+ // Embedded JMS server
+ private EmbeddedActiveMQ embedded;
+
+ // Thread to run the JMS server in
+ private Thread jmsServerRunnerThread;
+
+ // Config fields
+ private final String serverName;
+ private final String serverUri;
+
+ /**
+ * Create the JMS Server.
+ *
+ * @param serverName Name of the server
+ * @param serverUri URI for the server
+ * @throws Exception on errors
+ */
+ public JmsServerRunner(String serverName, String serverUri) throws Exception {
+ this.serverName = serverName;
+ this.serverUri = serverUri;
+
+ ConfigurationImpl config = new ConfigurationImpl();
+
+ config.addAcceptorConfiguration(serverName, serverUri);
+ config.setSecurityEnabled(false);
+ config.setJournalDirectory("target/artemisActiveMq/data/journal");
+ config.setBindingsDirectory("target/artemisActiveMq/data/bindings");
+ config.setLargeMessagesDirectory("target/artemisActiveMq/data/largemessages");
+ config.setPagingDirectory("target/artemisActiveMq/data/paging");
+
+ embedded = new EmbeddedActiveMQ();
+ embedded.setConfiguration(config);
+
+ LOGGER.debug("starting JMS Server " + serverName + " on URI " + serverUri + " . . .");
+
+ jmsServerRunnerThread = new Thread(this);
+ jmsServerRunnerThread.start();
+
+ LOGGER.debug("requested start on JMS Server " + serverName + " on URI " + serverUri);
+ }
+
+ @Override
+ public void run() {
+ try {
+ LOGGER.debug("starting JMS Server thread " + serverName + " on URI " + serverUri + " . . .");
+ embedded.start();
+
+ await().atMost(30, TimeUnit.SECONDS).until(() -> embedded.getActiveMQServer().isActive());
+
+ LOGGER.debug("started JMS Server thread " + serverName + " on URI " + serverUri);
+ } catch (Exception e) {
+ LOGGER.warn("failed to start JMS Server thread " + serverName + " on URI " + serverUri, e);
+ }
+ }
+
+ /**
+ * Stop the JMS server.
+ *
+ * @throws Exception on stop errors
+ */
+ public void stop() throws Exception {
+ LOGGER.debug("stopping JMS Server " + serverName + " on URI " + serverUri + " . . .");
+
+ if (!embedded.getActiveMQServer().isActive()) {
+ LOGGER.debug("JMS Server " + serverName + " already stopped on URI " + serverUri + " . . .");
+ return;
+ }
+
+ embedded.stop();
+
+ LOGGER.debug("waiting on JMS Server " + serverName + " to stop on URI " + serverUri + " . . .");
+
+ await().atMost(30, TimeUnit.SECONDS)
+ .until(() -> !embedded.getActiveMQServer().isActive() && !jmsServerRunnerThread.isAlive());
+
+ LOGGER.debug("stopping JMS Server " + serverName + " on URI " + serverUri + " . . .");
+ }
+}
\ No newline at end of file
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2023 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.onap.policy.apex.testsuites.integration.uservice.adapt.jms.TestJms2Jms.JMS_TOPIC_APEX_IN;
import static org.onap.policy.apex.testsuites.integration.uservice.adapt.jms.TestJms2Jms.JMS_TOPIC_APEX_OUT;
import static org.onap.policy.apex.testsuites.integration.uservice.adapt.jms.TestJms2Jms.PORT;
-import static org.onap.policy.apex.testsuites.integration.uservice.adapt.jms.TestJms2Jms.connectionFactory;
import java.util.HashMap;
import java.util.Hashtable;
import javax.naming.NameParser;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
-import org.apache.activemq.command.ActiveMQTopic;
+import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
+import org.apache.activemq.artemis.jms.client.ActiveMQTopic;
import org.onap.policy.apex.model.basicmodel.concepts.ApexRuntimeException;
/**
final Map<String, Object> params = new HashMap<String, Object>();
params.put("host", HOST);
params.put("port", PORT);
- testProperties.put("ConnectionFactory", connectionFactory);
+ testProperties.put("ConnectionFactory", new ActiveMQConnectionFactory(TestJms2Jms.SERVER_URI));
testProperties.put(JMS_TOPIC_APEX_IN, new ActiveMQTopic(JMS_TOPIC_APEX_IN));
testProperties.put(JMS_TOPIC_APEX_OUT, new ActiveMQTopic(JMS_TOPIC_APEX_OUT));
} catch (final Exception e) {
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2023 Nordix Foundation.
* Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
import static org.awaitility.Awaitility.await;
import static org.junit.Assert.assertEquals;
+import jakarta.jms.JMSException;
import java.io.IOException;
-import java.nio.file.Paths;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
import java.util.concurrent.TimeUnit;
-import javax.jms.JMSException;
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerPlugin;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.security.AuthenticationUser;
-import org.apache.activemq.security.SimpleAuthenticationPlugin;
+import java.util.concurrent.atomic.AtomicBoolean;
+import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.service.engine.main.ApexMain;
-import org.slf4j.ext.XLogger;
-import org.slf4j.ext.XLoggerFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* The Class TestJms2Jms.
*/
public class TestJms2Jms {
- public static final String PORT = "5445";
- public static final String HOST = "localhost";
- public static final String JMS_TOPIC_APEX_IN = "jms/topic/apexIn";
- public static final String JMS_TOPIC_APEX_OUT = "jms/topic/apexOut";
+ private static final Logger LOGGER = LoggerFactory.getLogger(TestJms2Jms.class);
- private static final String GROUP_ROLE = "guests";
- private static final String PACKAGE_NAME = "org.onap.policy.apex.testsuites.integration.common.testclasses";
- private static final String USERNAME = "guest";
- private static final String PASSWORD = "IAmAGuest";
- private static final String URL = "tcp://" + HOST + ":" + PORT;
-
- private static final String DATA_PARENT_DIR = Paths.get("target", "activemq-data").toString();
-
- private static final XLogger LOGGER = XLoggerFactory.getXLogger(TestJms2Jms.class);
+ protected static final String SERVER_NAME = "JmsTestServer";
+ protected static final String PORT = "5445";
+ protected static final String HOST = "localhost";
+ protected static final String JMS_TOPIC_APEX_IN = "jms/topic/apexIn";
+ protected static final String JMS_TOPIC_APEX_OUT = "jms/topic/apexOut";
+ protected static final String SERVER_URI = "tcp://" + HOST + ":" + PORT;
private static final int EVENT_COUNT = 100;
private static final int EVENT_INTERVAL = 20;
- private static BrokerService broker;
-
- public static ActiveMQConnectionFactory connectionFactory;
+ // Embedded JMS server for testing
+ private static JmsServerRunner jmsServerRunner;
/**
- * Setup embedded jms server.
+ * Setup embedded JMS server.
*
* @throws Exception the exception
*/
@BeforeClass
public static void setupEmbeddedJmsServer() throws Exception {
- final ArrayList<BrokerPlugin> plugins = new ArrayList<BrokerPlugin>();
- final BrokerPlugin authenticationPlugin = getAuthenticationBrokerPlugin();
- plugins.add(authenticationPlugin);
-
- broker = new BrokerService();
- broker.setUseJmx(false);
- broker.setPersistent(false);
- broker.addConnector(URL);
- broker.setDeleteAllMessagesOnStartup(true);
- broker.setPlugins(plugins.toArray(new BrokerPlugin[0]));
- broker.setDataDirectory(DATA_PARENT_DIR);
- broker.start();
- broker.waitUntilStarted();
- connectionFactory = new ActiveMQConnectionFactory(URL);
- connectionFactory.setTrustedPackages(Arrays.asList(PACKAGE_NAME));
+ jmsServerRunner = new JmsServerRunner(SERVER_NAME, SERVER_URI);
+
+ await().pollDelay(3L, TimeUnit.SECONDS).until(() -> new AtomicBoolean(true).get() == true);
}
/**
System.clearProperty("APEX_RELATIVE_FILE_ROOT");
}
- /**
- * Gets the authentication broker plugin.
- *
- * @return the authentication broker plugin
- */
- private static BrokerPlugin getAuthenticationBrokerPlugin() {
- final List<AuthenticationUser> users = new ArrayList<AuthenticationUser>();
- users.add(new AuthenticationUser(USERNAME, PASSWORD, GROUP_ROLE));
- final SimpleAuthenticationPlugin authenticationPlugin = new SimpleAuthenticationPlugin(users);
- return authenticationPlugin;
- }
-
/**
* Shutdown embedded jms server.
*
@AfterClass
public static void shutdownEmbeddedJmsServer() throws IOException {
try {
- if (broker != null) {
- broker.stop();
+ if (jmsServerRunner != null) {
+ jmsServerRunner.stop();
}
} catch (final Exception e) {
LOGGER.warn("Failed to stop JMS server", e);
*/
@Test
public void testJmsObjectEvents() throws ApexException, JMSException {
- final String[] args = {"-rfr", "target", "-p", "target/examples/config/JMS/JMS2JMSObjectEvent.json"};
+ final String[] args = {
+ "-rfr", "target", "-p", "target/examples/config/JMS/JMS2JMSObjectEvent.json"
+ };
testJmsEvents(args, true);
}
*/
@Test
public void testJmsJsonEvents() throws ApexException, JMSException {
- final String[] args = {"-rfr", "target", "-p", "target/examples/config/JMS/JMS2JMSJsonEvent.json"};
+ final String[] args = {
+ "-rfr", "target", "-p", "target/examples/config/JMS/JMS2JMSJsonEvent.json"
+ };
testJmsEvents(args, false);
}
*/
private void testJmsEvents(final String[] args, final Boolean sendObjects) throws ApexException, JMSException {
final JmsEventSubscriber subscriber =
- new JmsEventSubscriber(JMS_TOPIC_APEX_OUT, connectionFactory, USERNAME, PASSWORD);
+ new JmsEventSubscriber(JMS_TOPIC_APEX_OUT, new ActiveMQConnectionFactory(SERVER_URI), null, null);
- final JmsEventProducer producer = new JmsEventProducer(JMS_TOPIC_APEX_IN, connectionFactory, USERNAME, PASSWORD,
- EVENT_COUNT, sendObjects, EVENT_INTERVAL);
+ final JmsEventProducer producer =
+ new JmsEventProducer(JMS_TOPIC_APEX_IN, new ActiveMQConnectionFactory(SERVER_URI), null, null,
+ EVENT_COUNT, sendObjects, EVENT_INTERVAL);
final ApexMain apexMain = new ApexMain(args);
assertEquals(EVENT_COUNT, producer.getEventsSentCount());
assertEquals(producer.getEventsSentCount(), subscriber.getEventsReceivedCount());
}
-}
+}
\ No newline at end of file
import static org.awaitility.Awaitility.await;
import static org.junit.Assert.assertTrue;
+import jakarta.ws.rs.client.Client;
+import jakarta.ws.rs.client.ClientBuilder;
+import jakarta.ws.rs.core.Response;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.util.concurrent.TimeUnit;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.ClientBuilder;
-import javax.ws.rs.core.Response;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import static org.junit.Assert.assertTrue;
import com.google.gson.Gson;
+import jakarta.ws.rs.client.Client;
+import jakarta.ws.rs.client.ClientBuilder;
+import jakarta.ws.rs.core.Response;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.util.Map;
import java.util.concurrent.TimeUnit;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.ClientBuilder;
-import javax.ws.rs.core.Response;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019, 2023 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.junit.Assert.assertTrue;
import com.google.gson.Gson;
+import jakarta.ws.rs.GET;
+import jakarta.ws.rs.POST;
+import jakarta.ws.rs.PUT;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.core.Response;
import java.util.Map;
import java.util.Random;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.core.Response;
-
/**
* The Class TestRestClientEndpoint.
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2023 Nordix Foundation.
* Modifications Copyright (C) 2020-2021 Bell Canada. All rights reserved.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
import static org.junit.Assert.assertTrue;
import com.google.gson.Gson;
+import jakarta.ws.rs.client.Client;
+import jakarta.ws.rs.client.ClientBuilder;
+import jakarta.ws.rs.client.Entity;
+import jakarta.ws.rs.core.Response;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.TimeUnit;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.ClientBuilder;
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.core.Response;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2020 Nordix Foundation.
+ * Copyright (C) 2020, 2023 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.apex.testsuites.integration.uservice.taskparameters;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.core.Response;
+import jakarta.ws.rs.GET;
+import jakarta.ws.rs.POST;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.PathParam;
+import jakarta.ws.rs.core.Response;
/**
* The Class RestClientEndpointForTaskParameters.
import static org.awaitility.Awaitility.await;
import static org.junit.Assert.assertTrue;
+import jakarta.ws.rs.client.Client;
+import jakarta.ws.rs.client.ClientBuilder;
+import jakarta.ws.rs.core.Response;
import java.util.concurrent.TimeUnit;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.ClientBuilder;
-import javax.ws.rs.core.Response;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
<!--
============LICENSE_START=======================================================
Copyright (C) 2016-2018 Ericsson. All rights reserved.
- Modifications Copyright (C) 2020 Nordix Foundation.
+ Modifications Copyright (C) 2020, 2023 Nordix Foundation.
Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
================================================================================
Licensed under the Apache License, Version 2.0 (the "License");
<appender-ref ref="STDOUT" />
</logger>
- <logger name="org.onap.policy.apex.core" level="INFO" additivity="false">
+ <logger name="org.onap.policy.apex.core" level="DEBUG" additivity="false">
<appender-ref ref="STDOUT" />
</logger>
- <logger name="org.onap.policy.apex.plugins.executor" level="INFO" additivity="false">
+ <logger name="org.onap.policy.apex.plugins.executor" level="DEBUG" additivity="false">
<appender-ref ref="STDOUT" />
</logger>
+ <logger name="org.onap.policy.apex.testsuites.integration.uservice.adapt" level="DEBUG" additivity="false">
+ <appender-ref ref="STDOUT" />
+ </logger>
</configuration>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-grizzly2-http</artifactId>
+ <version>${version.jersey.container}</version>
</dependency>
<dependency>
<groupId>org.onap.policy.apex-pdp.testsuites.integration</groupId>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
+ <artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020, 2023 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
package org.onap.policy.apex.testsuites.performance.benchmark.eventgenerator;
import com.google.gson.Gson;
+import jakarta.inject.Inject;
+import jakarta.inject.Provider;
+import jakarta.ws.rs.GET;
+import jakarta.ws.rs.POST;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.core.Response;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicReference;
-import javax.inject.Inject;
-import javax.inject.Provider;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.core.Response;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2023 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.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import javax.inject.Provider;
-import javax.ws.rs.core.Response;
+import jakarta.inject.Provider;
+import jakarta.ws.rs.core.Response;
import org.glassfish.grizzly.http.server.Request;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.testsuites.performance.benchmark.eventgenerator.events.OutputEvent;
* Test the EventGeneratorEndpoint class.
*
*/
+@RunWith(MockitoJUnitRunner.class)
public class EventGeneratorEndpointTest {
@Mock
private Provider<Request> httpRequestProviderMock;
*/
@Before
public void initializeMocking() throws ApexException {
- MockitoAnnotations.initMocks(this);
Mockito.doReturn(httpRequestMock).when(httpRequestProviderMock).get();
<!--
============LICENSE_START=======================================================
Copyright (C) 2018 Ericsson. All rights reserved.
+ Modifications Copyright (C) 2023 Nordix Foundation.
================================================================================
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
<dependencies>
<dependency>
- <groupId>org.java-websocket</groupId>
- <artifactId>Java-WebSocket</artifactId>
+ <groupId>jakarta.websocket</groupId>
+ <artifactId>jakarta.websocket-api</artifactId>
+ <version>${version.websocket.jakarta}</version>
+ </dependency>
+ <dependency>
+ <groupId>jakarta.websocket</groupId>
+ <artifactId>jakarta.websocket-client-api</artifactId>
+ <version>${version.websocket.jakarta}</version>
</dependency>
<dependency>
<groupId>org.onap.policy.apex-pdp.tools</groupId>
<artifactId>tools-common</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty.websocket</groupId>
+ <artifactId>websocket-jakarta-client</artifactId>
+ <version>${version.websocket.jetty}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty.websocket</groupId>
+ <artifactId>websocket-jakarta-server</artifactId>
+ <version>${version.websocket.jetty}</version>
+ </dependency>
</dependencies>
<build>
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2023 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.apex.tools.simple.wsclient;
+import jakarta.websocket.ClientEndpoint;
+import jakarta.websocket.CloseReason;
+import jakarta.websocket.CloseReason.CloseCodes;
+import jakarta.websocket.ContainerProvider;
+import jakarta.websocket.DeploymentException;
+import jakarta.websocket.OnClose;
+import jakarta.websocket.OnError;
+import jakarta.websocket.OnMessage;
+import jakarta.websocket.OnOpen;
+import jakarta.websocket.Session;
+import jakarta.websocket.WebSocketContainer;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URISyntaxException;
import java.nio.channels.NotYetConnectedException;
import org.apache.commons.lang3.Validate;
-import org.java_websocket.client.WebSocketClient;
-import org.java_websocket.framing.CloseFrame;
-import org.java_websocket.handshake.ServerHandshake;
/**
* Simple WS client with a console for events.
*
* @author Sven van der Meer (sven.van.der.meer@ericsson.com)
*/
-public class SimpleConsole extends WebSocketClient {
+@ClientEndpoint
+public class SimpleConsole {
/** Application name, used as prompt. */
private final String appName;
// Output and error streams
private PrintStream outStream;
private PrintStream errStream;
+ // The Websocket Session
+ private Session userSession;
/**
* Creates a new simple echo object.
* @param outStream the stream for message output
* @param errStream the stream for error messages
* @throws URISyntaxException is URI could not be created from server/port settings
+ * @throws IOException on IO exceptions
+ * @throws DeploymentException on deployment exceptions
* @throws RuntimeException if server or port where blank
*/
public SimpleConsole(final String server, final String port, final String appName, PrintStream outStream,
- PrintStream errStream) throws URISyntaxException {
- super(new URI("ws://" + server + ":" + port));
+ PrintStream errStream) throws URISyntaxException, DeploymentException, IOException {
Validate.notBlank(appName, "SimpleConsole: given application name was blank");
+ WebSocketContainer container = ContainerProvider.getWebSocketContainer();
+ container.connectToServer(this, new URI("ws://" + server + ":" + port));
+
this.appName = appName;
this.outStream = outStream;
this.errStream = errStream;
}
- @Override
- public void onClose(final int code, final String reason, final boolean remote) {
- outStream.println(this.appName + ": Connection closed by " + (remote ? "APEX" : "me"));
+ /**
+ * Callback hook for Connection close events.
+ *
+ * @param userSession the userSession which is getting closed.
+ * @param reason the reason for connection close
+ */
+ @OnClose
+ public void onClose(Session userSession, CloseReason reason) {
+ outStream.println(this.appName + ": Connection closed");
+
outStream.print(" ==-->> ");
- switch (code) {
- case CloseFrame.NORMAL:
+ CloseCodes reasonCloseCode = CloseCodes.valueOf(reason.getCloseCode().toString());
+ switch (reasonCloseCode) {
+ case NORMAL_CLOSURE:
outStream.println("normal");
break;
- case CloseFrame.GOING_AWAY:
+ case GOING_AWAY:
outStream.println("APEX going away");
break;
- case CloseFrame.PROTOCOL_ERROR:
+ case PROTOCOL_ERROR:
outStream.println("some protocol error");
break;
- case CloseFrame.REFUSE:
+ case CANNOT_ACCEPT:
outStream.println("received unacceptable type of data");
break;
- case CloseFrame.NO_UTF8:
+ case CLOSED_ABNORMALLY:
outStream.println("expected UTF-8, found something else");
break;
- case CloseFrame.TOOBIG:
+ case TOO_BIG:
outStream.println("message too big");
break;
- case CloseFrame.UNEXPECTED_CONDITION:
+ case UNEXPECTED_CONDITION:
outStream.println("unexpected server condition");
break;
default:
outStream.print(" ==-->> " + reason);
}
- @Override
+
+ @OnError
public void onError(final Exception ex) {
errStream.println(this.appName + ": " + ex.getMessage());
}
- @Override
- public void onMessage(final String message) {
+ /**
+ * Callback hook for Message Events. This method will be invoked when a client send a message.
+ *
+ * @param message The text message
+ */
+ @OnMessage
+ public void onMessage(String message) {
// this client does not expect messages
}
- @Override
- public void onOpen(final ServerHandshake handshakedata) {
- outStream.println(this.appName + ": opened connection to APEX (" + handshakedata.getHttpStatusMessage() + ")");
+ /**
+ * Callback hook for Connection open events.
+ *
+ * @param userSession the userSession which is opened.
+ */
+ @OnOpen
+ public void onOpen(Session userSession) {
+ outStream.println(this.appName + ": opened connection to APEX (" + userSession.getRequestURI() + ")");
+
+ this.userSession = userSession;
}
/**
* @throws IOException on an IO problem on standard in
*/
public void runClient() throws IOException {
- final Thread thread = new Thread() {
- @Override
- public void run() {
- connect();
- }
- };
- thread.setName("ClientThread");
- thread.start();
-
final var in = new BufferedReader(new InputStreamReader(System.in));
var event = new StringBuilder();
String line;
final String current = line.trim();
if ("".equals(current)) {
- this.send(event.toString());
+ this.userSession.getBasicRemote().sendText(event.toString());
event = new StringBuilder();
} else {
event.append(current);
}
}
- thread.interrupt();
- this.close(CloseFrame.NORMAL);
+ this.userSession.close(new CloseReason(CloseReason.CloseCodes.NORMAL_CLOSURE, "Normal Closure"));
}
+
}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2023 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.apex.tools.simple.wsclient;
+import jakarta.websocket.ClientEndpoint;
+import jakarta.websocket.CloseReason;
+import jakarta.websocket.CloseReason.CloseCodes;
+import jakarta.websocket.ContainerProvider;
+import jakarta.websocket.DeploymentException;
+import jakarta.websocket.OnClose;
+import jakarta.websocket.OnError;
+import jakarta.websocket.OnMessage;
+import jakarta.websocket.OnOpen;
+import jakarta.websocket.Session;
+import jakarta.websocket.WebSocketContainer;
+import java.io.IOException;
import java.io.PrintStream;
import java.net.URI;
import java.net.URISyntaxException;
import org.apache.commons.lang3.Validate;
-import org.java_websocket.client.WebSocketClient;
-import org.java_websocket.framing.CloseFrame;
-import org.java_websocket.handshake.ServerHandshake;
/**
* Simple WS client as an echo.
*
* @author Sven van der Meer (sven.van.der.meer@ericsson.com)
*/
-public class SimpleEcho extends WebSocketClient {
+@ClientEndpoint
+public class SimpleEcho {
/** Application name, used as prompt. */
private final String appName;
* @param outStream the stream for message output
* @param errStream the stream for error messages
* @throws URISyntaxException is URI could not be created from server/port settings
+ * @throws IOException on IO exceptions
+ * @throws DeploymentException on deployment exceptions
* @throws RuntimeException if server or port where blank
*/
public SimpleEcho(final String server, final String port, final String appName, PrintStream outStream,
- PrintStream errStream) throws URISyntaxException {
- super(new URI("ws://" + server + ":" + port));
+ PrintStream errStream) throws URISyntaxException, DeploymentException, IOException {
+
Validate.notBlank(appName, "SimpleEcho: given application name was blank");
-
+ WebSocketContainer container = ContainerProvider.getWebSocketContainer();
+ container.connectToServer(this, new URI("ws://" + server + ":" + port));
+
this.appName = appName;
this.outStream = outStream;
this.errStream = errStream;
}
- @Override
- public void onClose(final int code, final String reason, final boolean remote) {
- outStream.println(this.appName + ": Connection closed by " + (remote ? "APEX" : "me"));
+ /**
+ * Callback hook for Connection close events.
+ *
+ * @param userSession the userSession which is getting closed.
+ * @param reason the reason for connection close
+ */
+ @OnClose
+ public void onClose(Session userSession, CloseReason reason) {
+ outStream.println(this.appName + ": Connection closed");
outStream.print(" ==-->> ");
- switch (code) {
- case CloseFrame.NORMAL:
+
+ CloseCodes reasonCloseCode = CloseCodes.valueOf(reason.getCloseCode().toString());
+ switch (reasonCloseCode) {
+ case NORMAL_CLOSURE:
outStream.println("normal");
break;
- case CloseFrame.GOING_AWAY:
+ case GOING_AWAY:
outStream.println("APEX going away");
break;
- case CloseFrame.PROTOCOL_ERROR:
+ case PROTOCOL_ERROR:
outStream.println("some protocol error");
break;
- case CloseFrame.REFUSE:
+ case CANNOT_ACCEPT:
outStream.println("received unacceptable type of data");
break;
- case CloseFrame.NO_UTF8:
+ case CLOSED_ABNORMALLY:
outStream.println("expected UTF-8, found something else");
break;
- case CloseFrame.TOOBIG:
+ case TOO_BIG:
outStream.println("message too big");
break;
- case CloseFrame.UNEXPECTED_CONDITION:
+ case UNEXPECTED_CONDITION:
outStream.println("unexpected server condition");
break;
default:
outStream.print(" ==-->> " + reason);
}
- @Override
+ @OnError
public void onError(final Exception ex) {
errStream.println(this.appName + ": " + ex.getMessage());
}
- @Override
- public void onMessage(final String message) {
+ /**
+ * Callback hook for Message Events. This method will be invoked when a client send a message.
+ *
+ * @param message The text message
+ */
+ @OnMessage
+ public void onMessage(String message) {
outStream.println(this.appName + ": received");
outStream.println("---------------------------------");
outStream.println(message);
outStream.println();
}
- @Override
- public void onOpen(final ServerHandshake handshakedata) {
- outStream.println(this.appName + ": opened connection to APEX (" + handshakedata.getHttpStatusMessage() + ")");
+ /**
+ * Callback hook for Connection open events.
+ *
+ * @param userSession the userSession which is opened.
+ */
+ @OnOpen
+ public void onOpen(Session userSession) {
+ outStream.println(this.appName + ": opened connection to APEX (" + userSession.getRequestURI() + ")");
}
-
}
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2023 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.apex.tools.simple.wsclient;
+import jakarta.websocket.DeploymentException;
import java.io.IOException;
import java.io.PrintStream;
import java.io.PrintWriter;
outStream.println();
try {
- final var simpleEcho = new SimpleEcho(server, port, APP_NAME, outStream, outStream);
- simpleEcho.connect();
+ new SimpleEcho(server, port, APP_NAME, outStream, outStream);
} catch (final URISyntaxException uex) {
String message = APP_NAME + ": URI exception, could not create URI from server and port settings";
outStream.println(message);
String message = APP_NAME + ": illegal argument, server or port were blank";
outStream.println(message);
LOGGER.warn(message, iex);
+ } catch (DeploymentException dex) {
+ String message = APP_NAME + ": could not deploy client";
+ outStream.println(message);
+ LOGGER.warn(message, dex);
+ } catch (IOException iox) {
+ String message = APP_NAME + ": illegal argument, IO execption on client";
+ outStream.println(message);
+ LOGGER.warn(message, iox);
+ } catch (Exception xex) {
+ String message = APP_NAME + ": Unknown execption on client";
+ outStream.println(message);
+ LOGGER.warn(message, xex);
}
}
String message = APP_NAME + ": not yet connected, connection to server took too long";
outStream.println(message);
LOGGER.warn(message, nex);
+ } catch (DeploymentException dex) {
+ String message = APP_NAME + ": could not deploy client";
+ outStream.println(message);
+ LOGGER.warn(message, dex);
} catch (final IOException ioe) {
String message = APP_NAME + ": IO exception, something went wrong on the standard input";
outStream.println(message);
LOGGER.warn(message, ioe);
+ } catch (Exception xex) {
+ String message = APP_NAME + ": Unknown execption on client";
+ outStream.println(message);
+ LOGGER.warn(message, xex);
}
}