#Builds the callback receiver container and starts it in interactive mode
-docker build --build-arg NEXUS_PROXY_REPO=nexus3.onap.org:10001/ -t callback-receiver .
+docker build -t callback-receiver .
docker run --rm -it -p 8090:8090 -p 8091:8091 --name cr callback-receiver
#Builds the mrstub container and starts it in interactive mode
-docker build --build-arg NEXUS_PROXY_REPO=nexus3.onap.org:10001/ -t mrstub .
+docker build -t mrstub .
docker run --rm --name=dmaap-mr -it -p 3904:3904 -p 3905:3905 -v "$PWD/cert:/usr/src/app/cert" mrstub
NAME="producer-stub-test"
IMAGE_NAME="producer-stub-test-image"
-docker build --build-arg NEXUS_PROXY_REPO=nexus3.onap.org:10001/ -t $IMAGE_NAME .
+docker build -t $IMAGE_NAME .
docker run --rm -it -p 8992:8092 -p 8993:8093 --name $NAME $IMAGE_NAME
--- /dev/null
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### IntelliJ IDEA ###
+.idea/modules.xml
+.idea/jarRepositories.xml
+.idea/compiler.xml
+.idea/libraries/
+*.iws
+*.iml
+*.ipr
+
+### Eclipse ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/
+
+### Mac OS ###
+.DS_Store
\ No newline at end of file
--- /dev/null
+#==================================================================================
+# Copyright (C) 2023: OpenInfra Foundation Europe
+#
+# 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.
+#
+# This source code is part of the near-RT RIC (RAN Intelligent Controller)
+# platform project (RICP).
+#==================================================================================
+
+
+# Use Maven image with OpenJDK 17 for the build stage
+FROM maven:3.8.5-openjdk-17 AS maven_build
+
+# Copy Maven project files
+COPY pom.xml /tmp/
+COPY src /tmp/src/
+
+# Set working directory
+WORKDIR /tmp/
+
+# Build the Maven project
+RUN mvn package
+
+# Use a separate image with OpenJDK 17 for the runtime stage
+FROM openjdk:17-jdk-slim
+
+# Expose port 8080
+EXPOSE 8080
+
+# Set the working directory
+WORKDIR /app
+
+# Copy the JAR file from the maven_build stage to the runtime stage
+COPY --from=maven_build /tmp/target/hello-world-0.1.0.jar /app/hello-world-0.1.0.jar
+
+# Command to run the application
+CMD ["java", "-jar", "hello-world-0.1.0.jar"]
--- /dev/null
+# Hello World Service Stub\r
+\r
+This repository contains a Spring Boot application serving a Hello World endpoint. The application can be built and \r
+run using the provided script - ``service-stub-build-start.sh``.\r
+\r
+## Prerequisites\r
+\r
+- Docker installed on your machine.\r
+\r
+## Building and Running the Application\r
+Run the script:\r
+\r
+```bash\r
+ ./service-stub-build-start.sh\r
+```\r
+\r
+The script will build a Docker image and run a container with the Hello World service. After the container starts, \r
+wait for a few seconds to ensure the Spring Boot application is fully initialized. Next, it will make an HTTP request to the \r
+Hello World endpoint and display the response:\r
+\r
+```bash\r
+ response=$(curl -s http://localhost:8080/helloworld/sme)\r
+ echo "Response from the Hello World endpoint:"\r
+ echo "$response"\r
+```\r
+\r
+To stop and remove the Docker container:\r
+\r
+```bash\r
+ docker stop service-stub-hello-world-test\r
+ docker rm service-stub-hello-world-test\r
+```\r
+\r
+## Additional Information\r
+\r
+- The Hello World endpoint is available at http://localhost:8080/helloworld/sme.\r
+\r
--- /dev/null
+#!/bin/bash
+
+# ============LICENSE_START===============================================
+# Copyright (C) 2023: OpenInfra Foundation Europe.
+# ========================================================================
+# 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.
+# ============LICENSE_END=================================================
+#
+
+# Build image from Dockerfile with/without custom image tag
+# Optionally push to external image repo
+
+print_usage() {
+ echo "Usage: build.sh no-push|<docker-hub-repo-name> [<image-tag>]"
+ exit 1
+}
+
+if [ $# -ne 1 ] && [ $# -ne 2 ]; then
+ print_usage
+fi
+
+IMAGE_NAME="nonrtric-hello-world"
+IMAGE_TAG="latest"
+REPO=""
+if [ $1 == "no-push" ]; then
+ echo "Only local image build"
+else
+ REPO=$1
+ echo "Attempt to push built image to: "$REPO
+fi
+
+shift
+while [ $# -ne 0 ]; do
+ if [ $1 == "--tag" ]; then
+ shift
+ if [ -z "$1" ]; then
+ print_usage
+ fi
+ IMAGE_TAG=$1
+ echo "Setting image tag to: "$IMAGE_TAG
+ shift
+ else
+ echo "Unknown parameter: $1"
+ print_usage
+ fi
+done
+
+IMAGE=$IMAGE_NAME:$IMAGE_TAG
+
+export DOCKER_DEFAULT_PLATFORM=linux/amd64
+CURRENT_PLATFORM=$(docker system info --format '{{.OSType}}/{{.Architecture}}')
+if [ $CURRENT_PLATFORM != $DOCKER_DEFAULT_PLATFORM ]; then
+ echo "Image may not work on the current platform: $CURRENT_PLATFORM, only platform $DOCKER_DEFAULT_PLATFORM supported"
+fi
+
+echo "Building image $IMAGE"
+docker build -t $IMAGE_NAME:$IMAGE_TAG .
+if [ $? -ne 0 ]; then
+ echo "BUILD FAILED"
+ exit 1
+fi
+echo "BUILD OK"
+
+if [ "$REPO" != "" ]; then
+ echo "Tagging image"
+ NEW_IMAGE=$REPO/$IMAGE_NAME:$IMAGE_TAG
+ docker tag $IMAGE $NEW_IMAGE
+ if [ $? -ne 0 ]; then
+ echo "RE-TAGGING FAILED"
+ exit 1
+ fi
+ echo "RE-TAG OK"
+
+ echo "Pushing image $NEW_IMAGE"
+ docker push $NEW_IMAGE
+ if [ $? -ne 0 ]; then
+ echo "PUSHED FAILED"
+ echo " Perhaps not logged into docker-hub repo $REPO?"
+ exit 1
+ fi
+ IMAGE=$NEW_IMAGE
+ echo "PUSH OK"
+fi
+
+echo "IMAGE OK: $IMAGE"
+echo "DONE"
--- /dev/null
+# -
+# ========================LICENSE_START=================================
+# O-RAN-SC
+# %%
+# Copyright (C) 2023: OpenInfra Foundation Europe.
+# %%
+# 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.
+# ========================LICENSE_END===================================
+#
+
+# The Jenkins job requires a tag to build the Docker image.
+# By default this file is in the docker build directory,
+# but the location can configured in the JJB template.
+---
+tag: 0.1.0
--- /dev/null
+# -
+# ========================LICENSE_START=================================
+# O-RAN-SC
+# %%
+# Copyright (C) 2023: OpenInfra Foundation Europe
+# %%
+# 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.
+# ========================LICENSE_END===================================
+#
+
+version: "3.0"
+
+services:
+ hello-world:
+ build:
+ context: ./
+ dockerfile: Dockerfile
+ ports:
+ - 8080:8080
\ No newline at end of file
--- /dev/null
+# Patterns to ignore when building packages.
+# This supports shell glob matching, relative path matching, and
+# negation (prefixed with !). Only one pattern per line.
+.DS_Store
+# Common VCS dirs
+.git/
+.gitignore
+.bzr/
+.bzrignore
+.hg/
+.hgignore
+.svn/
+# Common backup files
+*.swp
+*.bak
+*.tmp
+*.orig
+*~
+# Various IDEs
+.project
+.idea/
+*.tmproj
+.vscode/
--- /dev/null
+# -
+# ========================LICENSE_START=================================
+# O-RAN-SC
+# %%
+# Copyright (C) 2023: OpenInfra Foundation Europe
+# %%
+# 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.
+# ========================LICENSE_END===================================
+#
+
+apiVersion: v2
+name: hello-world-chart
+description: A Helm chart for NONRTRIC Hello World
+
+# A chart can be either an 'application' or a 'library' chart.
+#
+# Application charts are a collection of templates that can be packaged into versioned archives
+# to be deployed.
+#
+# Library charts provide useful utilities or functions for the chart developer. They're included as
+# a dependency of application charts to inject those utilities and functions into the rendering
+# pipeline. Library charts do not define any templates and therefore cannot be deployed.
+type: application
+
+# This is the chart version. This version number should be incremented each time you make changes
+# to the chart and its templates, including the app version.
+# Versions are expected to follow Semantic Versioning (https://semver.org/)
+version: 0.1.0
+
+# This is the version number of the application being deployed. This version number should be
+# incremented each time you make changes to the application. Versions are not expected to
+# follow Semantic Versioning. They should reflect the version the application is using.
+# It is recommended to use it with quotes.
+appVersion: "0.1.0"
--- /dev/null
+{{/*
+Expand the name of the chart.
+*/}}
+{{- define "hello-world-chart.name" -}}
+{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
+{{- end }}
+
+{{/*
+Create a default fully qualified app name.
+We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
+If release name contains chart name it will be used as a full name.
+*/}}
+{{- define "hello-world-chart.fullname" -}}
+{{- if .Values.fullnameOverride }}
+{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
+{{- else }}
+{{- $name := default .Chart.Name .Values.nameOverride }}
+{{- if contains $name .Release.Name }}
+{{- .Release.Name | trunc 63 | trimSuffix "-" }}
+{{- else }}
+{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
+{{- end }}
+{{- end }}
+{{- end }}
+
+{{/*
+Create chart name and version as used by the chart label.
+*/}}
+{{- define "hello-world-chart.chart" -}}
+{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
+{{- end }}
+
+{{/*
+Common labels
+*/}}
+{{- define "hello-world-chart.labels" -}}
+helm.sh/chart: {{ include "hello-world-chart.chart" . }}
+{{ include "hello-world-chart.selectorLabels" . }}
+{{- if .Chart.AppVersion }}
+app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
+{{- end }}
+app.kubernetes.io/managed-by: {{ .Release.Service }}
+{{- end }}
+
+{{/*
+Selector labels
+*/}}
+{{- define "hello-world-chart.selectorLabels" -}}
+app.kubernetes.io/name: {{ include "hello-world-chart.name" . }}
+app.kubernetes.io/instance: {{ .Release.Name }}
+{{- end }}
+
+{{/*
+Create the name of the service account to use
+*/}}
+{{- define "hello-world-chart.serviceAccountName" -}}
+{{- if .Values.serviceAccount.create }}
+{{- default (include "hello-world-chart.fullname" .) .Values.serviceAccount.name }}
+{{- else }}
+{{- default "default" .Values.serviceAccount.name }}
+{{- end }}
+{{- end }}
--- /dev/null
+# -
+# ========================LICENSE_START=================================
+# O-RAN-SC
+# %%
+# Copyright (C) 2023: OpenInfra Foundation Europe
+# %%
+# 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.
+# ========================LICENSE_END===================================
+#
+
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: {{ include "hello-world-chart.fullname" . }}
+ labels:
+ {{- include "hello-world-chart.labels" . | nindent 4 }}
+spec:
+ replicas: {{ .Values.replicaCount }}
+ selector:
+ matchLabels:
+ {{- include "hello-world-chart.selectorLabels" . | nindent 8 }}
+ template:
+ metadata:
+ labels:
+ {{- include "hello-world-chart.selectorLabels" . | nindent 12 }}
+ spec:
+ containers:
+ - name: {{ .Chart.Name }}
+ image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
+ ports:
+ - name: http
+ containerPort: {{ .Values.service.port }}
+
--- /dev/null
+# -
+# ========================LICENSE_START=================================
+# O-RAN-SC
+# %%
+# Copyright (C) 2023: OpenInfra Foundation Europe
+# %%
+# 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.
+# ========================LICENSE_END===================================
+#
+
+apiVersion: v1
+kind: Service
+metadata:
+ name: {{ include "hello-world-chart.fullname" . }}
+ labels:
+ {{- include "hello-world-chart.labels" . | nindent 4 }}
+spec:
+ type: {{ .Values.service.type }}
+ ports:
+ - port: {{ .Values.service.port }}
+ targetPort: http
+ protocol: TCP
+ name: http
+ nodePort: 30951
+ selector:
+ {{- include "hello-world-chart.selectorLabels" . | nindent 4 }}
+
--- /dev/null
+# -
+# ========================LICENSE_START=================================
+# O-RAN-SC
+# %%
+# Copyright (C) 2023: OpenInfra Foundation Europe
+# %%
+# 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.
+# ========================LICENSE_END===================================
+#
+
+apiVersion: v1
+kind: Pod
+metadata:
+ name: "{{ include "hello-world-chart.fullname" . }}-test-connection"
+ labels:
+ {{- include "hello-world-chart.labels" . | nindent 4 }}
+ annotations:
+ "helm.sh/hook": test
+spec:
+ containers:
+ - name: wget
+ image: busybox
+ command: ['wget']
+ args: ['{{ include "hello-world-chart.fullname" . }}:{{ .Values.service.port }}']
+ restartPolicy: Never
--- /dev/null
+# -
+# ========================LICENSE_START=================================
+# O-RAN-SC
+# %%
+# Copyright (C) 2023: OpenInfra Foundation Europe
+# %%
+# 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.
+# ========================LICENSE_END===================================
+#
+
+image:
+ repository: nonrtric-hello-world
+ tag: latest
+
+service:
+ name: hello-world
+ type: NodePort
+ port: 8080
+
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+* ========================LICENSE_START=================================
+* O-RAN-SC
+* %%
+* Copyright (C) 2023 OpenInfra Foundation Europe.
+* %%
+* 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.
+* ========================LICENSE_END===================================
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.o-ran-sc.nonrtric.plt</groupId>
+ <artifactId>hello-world</artifactId>
+ <version>0.1.0</version>
+
+ <properties>
+ <maven.compiler.source>17</maven.compiler.source>
+ <maven.compiler.target>17</maven.compiler.target>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <parent>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-parent</artifactId>
+ <version>3.1.0</version>
+ </parent>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-web</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
\ No newline at end of file
--- /dev/null
+#!/bin/bash
+
+# -
+# ========================LICENSE_START=================================
+# O-RAN-SC
+# %%
+# Copyright (C) 2023: OpenInfra Foundation Europe.
+# %%
+# 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.
+# ========================LICENSE_END===================================
+#
+
+NAME="service-stub-hello-world-test"
+IMAGE_NAME="nonrtric-hello-world"
+
+docker build -t $IMAGE_NAME:latest .
+
+docker run --rm -d -p 8080:8080 --name $NAME $IMAGE_NAME
+
+sleep 10
+
+echo "Make an HTTP request to the Hello World endpoint and display the response"
+response=$(curl -s http://localhost:8080/helloworld/sme)
+
+echo "Response from the /helloworld/sme endpoint: "
+echo "$response"
+
+response2=$(curl -s http://localhost:8080/helloworld)
+echo "Response from the /helloworld endpoint: "
+echo "$response2"
--- /dev/null
+/*-\r
+ * ========================LICENSE_START=================================\r
+ * O-RAN-SC\r
+ * %%\r
+ * Copyright (C) 2023 OpenInfra Foundation Europe.\r
+ * %%\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ========================LICENSE_END===================================\r
+ */\r
+\r
+package org.oran.helloworld;\r
+\r
+import org.springframework.boot.SpringApplication;\r
+import org.springframework.boot.autoconfigure.SpringBootApplication;\r
+\r
+@SpringBootApplication(scanBasePackages = "org.oran.helloworld")\r
+public class HelloWorldApplication {\r
+ public static void main(String[] args) {\r
+ SpringApplication.run(HelloWorldApplication.class, args);\r
+ }\r
+}\r
--- /dev/null
+/*-\r
+ * ========================LICENSE_START=================================\r
+ * O-RAN-SC\r
+ * %%\r
+ * Copyright (C) 2023 OpenInfra Foundation Europe.\r
+ * %%\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ========================LICENSE_END===================================\r
+ */\r
+\r
+package org.oran.helloworld.rest;\r
+\r
+import org.springframework.web.bind.annotation.RequestMapping;\r
+import org.springframework.web.bind.annotation.RestController;\r
+\r
+@RestController\r
+@RequestMapping("/helloworld")\r
+public class HelloWorldController {\r
+\r
+ @RequestMapping("")\r
+ public String helloWorld() {\r
+ return "Hello World from service stub\n";\r
+ }\r
+ @RequestMapping("/sme")\r
+ public String helloWorldSme() {\r
+ return "Hello World from SME\n";\r
+ }\r
+}\r
--- /dev/null
+/*-\r
+ * ========================LICENSE_START=================================\r
+ * O-RAN-SC\r
+ * %%\r
+ * Copyright (C) 2023 OpenInfra Foundation Europe.\r
+ * %%\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ========================LICENSE_END===================================\r
+ */\r
+\r
+package org.oran.helloworld.rest;\r
+\r
+import org.junit.jupiter.api.Test;\r
+import org.springframework.beans.factory.annotation.Autowired;\r
+import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;\r
+import org.springframework.boot.test.mock.mockito.MockBean;\r
+import org.springframework.test.web.servlet.MockMvc;\r
+\r
+import static org.mockito.Mockito.when;\r
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;\r
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;\r
+\r
+@WebMvcTest(HelloWorldController.class)\r
+public class HelloWorldControllerTest {\r
+\r
+ @Autowired\r
+ private MockMvc mockMvc;\r
+\r
+ @MockBean\r
+ private HelloWorldController helloWorldController;\r
+\r
+ @Test\r
+ public void testHelloWorldEndpoint() throws Exception {\r
+ when(helloWorldController.helloWorld()).thenReturn("Hello World from service stub\n");\r
+\r
+ mockMvc.perform(get("/helloworld"))\r
+ .andExpect(status().isOk())\r
+ .andExpect(content().string("Hello World from service stub\n"));\r
+ }\r
+\r
+ @Test\r
+ public void testHelloWorldSmeEndpoint() throws Exception {\r
+ when(helloWorldController.helloWorldSme()).thenReturn("Hello World from SME\n");\r
+\r
+ mockMvc.perform(get("/helloworld/sme"))\r
+ .andExpect(status().isOk())\r
+ .andExpect(content().string("Hello World from SME\n"));\r
+ }\r
+}\r