LIGHT

  • News
  • Docs
  • Community
  • Reddit
  • GitHub

Build and Test

By now, we have walked through each sub-modules. Let’s build and test the services we have built.

Build

Here are the commands to build the project and run the test cases.

cd ~/networknt/light-example-4j/tram/light-tram-todolist/multi-module
mvn clean install

Start

There are two different ways to start servers. Start them as a standalone servers with java -jar or start them with docker-compose all together.

If you are still in development and want to test the code or debug individual service start server with java -jar or within IDE would make more sense.

As our view service is depending on ElasticSearch, let’s first start it in a docker-compose.

docker-compose -f docker-compose-elasticsearch.yml up

Two things should be verified before running the service:

  1. since we are using Elasticsearch for view persistence, please increase the docker memory space to 4gb for the docker. The problem seems to be only on Mac Book Pro and Linux is fine.

    – please refer issue: https://github.com/10up/wp-local-docker/issues/6

  2. current default Elasticsearch host setting is for Mac, if you running the service for Linux, change it to the network IP like “192.168.1.120” or the IP address running Elasticsearch

    • com.networknt.tram.todolist.view.TodoViewService:
      • com.networknt.tram.todolist.view.TodoViewServiceImpl:
        • java.lang.String: 10.200.10.1

For more information about DOCKER_HOST_IP, please refer to eventuate getting started

For me to run the application on Linux, I have to change the above IP from 10.200.10.1 to 192.168.1.120 in service.yml file under tram-todo-view/src/main/resources/config

Let’s start the command service first

cd ~/networknt/light-example-4j/tram/light-tram-todolist/multi-module/tram-todo-command
java -jar target/tram-todo-command-service-1.0.0.jar

Next let’s start view service.

cd ~/networknt/light-example-4j/tram/light-tram-todolist/multi-module/tram-todo-view
java -jar target/tram-todo-view-service-1.0.0.jar

Test

It is very easy to test with curl command as both sides are implemented as restful services.

To create a new TODO item,

curl -X POST   http://localhost:8081/v1/todos   -H 'Cache-Control: no-cache'   -H 'Content-Type: application/json'   -d '{"title":"canada","completed":false,"order":0}'

And you might have a response like this.

{"id":"00000160d83cd066-8eb59f5f03eb0000","title":"canada","completed":false,"executionOrder":0}

Now let’s access the query or view side.

curl -X GET   'http://localhost:8082/v1/todoviews?searchValue=canada'   -H 'Cache-Control: no-cache'   -H 'Content-Type: application/json'

And the response will be something like this.

[{"id":"00000160d83cd066-8eb59f5f03eb0000","title":"canada","completed":false,"executionOrder":0},{"id":"00000160d8408c1f-8eb59f5f03eb0000","title":"canada","completed":false,"executionOrder":0}]

In the next step, we are going to use Docker for all services.

  • About Light
    • Overview
    • Testimonials
    • What is Light
    • Features
    • Principles
    • Benefits
    • Roadmap
    • Community
    • Articles
    • Videos
    • License
    • Why Light Platform
  • Getting Started
    • Get Started Overview
    • Environment
    • Light Codegen Tool
    • Light Rest 4j
    • Light Tram 4j
    • Light Graphql 4j
    • Light Hybrid 4j
    • Light Eventuate 4j
    • Light Oauth2
    • Light Portal Service
    • Light Proxy Server
    • Light Router Server
    • Light Config Server
    • Light Saga 4j
    • Light Session 4j
    • Webserver
    • Websocket
    • Spring Boot Servlet
  • Architecture
    • Architecture Overview
    • API Category
    • API Gateway
    • Architecture Patterns
    • CQRS
    • Eco System
    • Event Sourcing
    • Fail Fast vs Fail Slow
    • Integration Patterns
    • JavaEE declining
    • Key Distribution
    • Microservices Architecture
    • Microservices Monitoring
    • Microservices Security
    • Microservices Traceability
    • Modular Monolith
    • Platform Ecosystem
    • Plugin Architecture
    • Scalability and Performance
    • Serverless
    • Service Collaboration
    • Service Mesh
    • SOA
    • Spring is bloated
    • Stages of API Adoption
    • Transaction Management
    • Microservices Cross-cutting Concerns Options
    • Service Mesh Plus
    • Service Discovery
  • Design
    • Design Overview
    • Design First vs Code First
    • Desgin Pattern
    • Service Evolution
    • Consumer Contract and Consumer Driven Contract
    • Handling Partial Failure
    • Idempotency
    • Server Life Cycle
    • Environment Segregation
    • Database
    • Decomposition Patterns
    • Http2
    • Test Driven
    • Multi-Tenancy
    • Why check token expiration
    • WebServices to Microservices
  • Cross-Cutting Concerns
    • Concerns Overview
  • API Styles
    • Light-4j for absolute performance
    • Style Overview
    • Distributed session on IMDG
    • Hybrid Serverless Modularized Monolithic
    • Kafka - Event Sourcing and CQRS
    • REST - Representational state transfer
    • Web Server with Light
    • Websocket with Light
    • Spring Boot Integration
    • Single Page Application
    • GraphQL - A query language for your API
    • Light IBM MQ
    • Light AWS Lambda
    • Chaos Monkey
  • Infrastructure Services
    • Service Overview
    • Light Proxy
    • Light Mesh
    • Light Router
    • Light Portal
    • Messaging Infrastructure
    • Centralized Logging
    • COVID-19
    • Light OAuth2
    • Metrics and Alerts
    • Config Server
    • Tokenization
    • Light Controller
  • Tool Chain
    • Tool Chain Overview
  • Utility Library
  • Service Consumer
    • Service Consumer
  • Development
    • Development Overview
  • Deployment
    • Deployment Overview
    • Frontend Backend
    • Linux Service
    • Windows Service
    • Install Eventuate on Windows
    • Secure API
    • Client vs light-router
    • Memory Limit
    • Deploy to Kubernetes
  • Benchmark
    • Benchmark Overview
  • Tutorial
    • Tutorial Overview
  • Troubleshooting
    • Troubleshoot
  • FAQ
    • FAQ Overview
  • Milestones
  • Contribute
    • Contribute to Light
    • Development
    • Documentation
    • Example
    • Tutorial
“Build and Test” was last updated: July 5, 2021: fixes #275 checked and corrected grammar/spelling for majority of pages (#276) (b3bbb7b)
Improve this page
  • News
  • Docs
  • Community
  • Reddit
  • GitHub
  • About Light
  • Getting Started
  • Architecture
  • Design
  • Cross-Cutting Concerns
  • API Styles
  • Infrastructure Services
  • Tool Chain
  • Utility Library
  • Service Consumer
  • Development
  • Deployment
  • Benchmark
  • Tutorial
  • Troubleshooting
  • FAQ
  • Milestones
  • Contribute