Spring Stomp Server

Spring Stomp Server for ui e2e Websocket testing

Лицензия

Лицензия

Категории

Категории

Сеть
Группа

Группа

net.brabenetz.app
Идентификатор

Идентификатор

spring-stomp-server
Последняя версия

Последняя версия

1.0.1
Дата

Дата

Тип

Тип

jar
Описание

Описание

Spring Stomp Server
Spring Stomp Server for ui e2e Websocket testing
Ссылка на сайт

Ссылка на сайт

http://spring-stomp-server.brabenetz.net
Организация-разработчик

Организация-разработчик

Brabenetz Harald, Austria
Система контроля версий

Система контроля версий

https://github.com/brabenetz/spring-stomp-server

Скачать spring-stomp-server

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/net.brabenetz.app/spring-stomp-server/ -->
<dependency>
    <groupId>net.brabenetz.app</groupId>
    <artifactId>spring-stomp-server</artifactId>
    <version>1.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/net.brabenetz.app/spring-stomp-server/
implementation 'net.brabenetz.app:spring-stomp-server:1.0.1'
// https://jarcasting.com/artifacts/net.brabenetz.app/spring-stomp-server/
implementation ("net.brabenetz.app:spring-stomp-server:1.0.1")
'net.brabenetz.app:spring-stomp-server:jar:1.0.1'
<dependency org="net.brabenetz.app" name="spring-stomp-server" rev="1.0.1">
  <artifact name="spring-stomp-server" type="jar" />
</dependency>
@Grapes(
@Grab(group='net.brabenetz.app', module='spring-stomp-server', version='1.0.1')
)
libraryDependencies += "net.brabenetz.app" % "spring-stomp-server" % "1.0.1"
[net.brabenetz.app/spring-stomp-server "1.0.1"]

Зависимости

compile (1)

Идентификатор библиотеки Тип Версия
org.springframework.boot : spring-boot-starter-websocket jar 2.3.1.RELEASE

test (2)

Идентификатор библиотеки Тип Версия
org.springframework.boot : spring-boot-starter-test jar 2.3.1.RELEASE
org.springframework.boot : spring-boot-configuration-processor Необязательный jar 2.3.1.RELEASE

Модули Проекта

Данный проект не имеет модулей.

Build Status Coverage Status Coverity Maven site License: Apache 2.0 Maven Central Javadocs

Spring Stomp Server

Spring Stomp Server is only a Spring-Boot-Application with a very simple Websocket-Stomp Configurion as described by the Spring Boot Guide:
https://spring.io/guides/gs/messaging-stomp-websocket/

Basic Idea

For e2e tests with angular, a Mock-Websocket-Stomp server is needed to also automatically test the Websocket functionality.

The benefit to use Spring Stomp Server as mock websocket endpoint is:

  • Easy to use, even without java knowledge
  • Interoperability: works on linux, mac-os and windows the same way (only java 8 or higher is needed)
  • It is the most realistic way if your real enpoint is a spring-boot application

"Spring Stomp Server" should never be used on a Production System! It is only designed to be used as simple Mock-Server for automatic tests.

Integration into an angular application

the usage can be summerized into two steps:

  • download jar from the central Maven Repository
  • start the application with "java -jar"
  • custom config with System-Properties "-D..." AND/OR by YAML "spring-stomp-server.yaml"

download jar from the central Maven Repository

The best way is, to use maven for downloading the artifact:

package.json:

  "scripts": {
    ...
    "stomp-server:download": "mvn org.apache.maven.plugins:maven-dependency-plugin:3.0.0:copy -Dartifact=net.brabenetz.app:spring-stomp-server:1.0.0 -DoutputDirectory=./target -Dmdep.stripVersion=true",
    ...
  },

(Benefit for maven: maven has a local repository where the artifacts are cached. So download will only be done once for all your projects)

Alternative download with wget:

package.json:

  "scripts": {
    ...
    "stomp-server:download": "wget https://repo1.maven.org/maven2/net/brabenetz/app/spring-stomp-server/1.0.0/spring-stomp-server-1.0.0.jar -O ./target/spring-stomp-server.jar",
    ...
  },

TIP: This step can be add as post install script:

package.json:

  "scripts": {
    "postinstall": "npm run stomp-server:download",
    ...
    "stomp-server:download": "...",
    ...
  },

This will execute automatically after "npm install".

start the application with java -jar

package.json:

  "scripts": {
    ...
    "stomp-server": "java -jar ./target/spring-stomp-server.jar ",
    ...
  },

With that, the Websocket endpoint will be ws:/localhost:8182/websocket
And the Stomp Config will listen on all destinations with the prefixes "/topic", "/app", "/user".

For local development you can simply start the server in the background by "npm run stomp-server".

For e2e tests, you can do it with the npm package 'concurrently':

package.json:

  "scripts": {
    ...
    "e2e": "concurrently -s first -k --names \"STOMP-SERVER,ANGULAR-CLI\" --prefix \"[{name}]\" \"npm run stomp-server\" \"npm run e2e:ng\"",
    "e2e:ng": "ng e2e",
    ...
  },

custom configuration

The preferd way to apply a custom config is by System-Properties "-D..." AND/OR by YAML "spring-stomp-server.yaml".
(There are more ways, see: https://www.tutorialspoint.com/spring_boot/spring_boot_application_properties.htm )

If a property exists as SystemProperty AND in YAML, the SystemProperty wins.

A detailed description for the most relevant properties can be found in:
https://brabenetz.github.io/spring-stomp-server/archiv/latest/configuration.html

custom configuration with System-Properties

package.json:

  "scripts": {
    ...
    "stomp-server": "java -jar -Dserver.port=8182 -Dspring-stomp-server.destination-prefixes=/topic,/app,/user -Dspring-stomp-server.websocket-endpoints=/my-backend-app/websocket ./target/spring-stomp-server.jar ",
    ...
  },

With that, the Websocket endpoint will be ws:/localhost:8182/my-backend-app/websocket
And the Stomp Config will listen on all destinations with the prefixes "/topic", "/app", "/user".

custom configuration with spring-stomp-server.yaml

package.json:

  "scripts": {
    ...
    "stomp-server": "java -jar ./target/spring-stomp-server.jar ",
    ...
  },

spring-stomp-server.yaml: (in same folder as package.json)

server.port: 8182
spring-stomp-server:
  websocket-endpoints:
  - "/my-backend-app/websocket"
  destination-prefixes:
  - "/topic"
  - "/app"
  - "/user"

With that, the Websocket endpoint will be ws:/localhost:8182/my-backend-app/websocket
And the Stomp Config will listen on all destinations with the prefixes "/topic", "/app", "/user".

More Details

Версии библиотеки

Версия
1.0.1
1.0.0