diff --git a/spring-remoting/remoting-hessian-burlap/client/pom.xml b/spring-remoting/remoting-hessian-burlap/client/pom.xml index 11250e63d2..1ae9b10019 100644 --- a/spring-remoting/remoting-hessian-burlap/client/pom.xml +++ b/spring-remoting/remoting-hessian-burlap/client/pom.xml @@ -31,5 +31,29 @@ hessian 4.0.38 + + + + ${project.groupId} + remoting-hessian-burlap-server + ${project.version} + test + + + javax.servlet + javax.servlet-api + test + + + org.springframework.boot + spring-boot-starter-test + test + + + org.springframework.boot + spring-boot-starter-tomcat + test + + \ No newline at end of file diff --git a/spring-remoting/remoting-hessian-burlap/client/src/test/java/com/baeldung/client/CabBookingServiceTest.java b/spring-remoting/remoting-hessian-burlap/client/src/test/java/com/baeldung/client/CabBookingServiceTest.java new file mode 100644 index 0000000000..20746bbf09 --- /dev/null +++ b/spring-remoting/remoting-hessian-burlap/client/src/test/java/com/baeldung/client/CabBookingServiceTest.java @@ -0,0 +1,73 @@ +package com.baeldung.client; + +import com.baeldung.api.Booking; +import com.baeldung.api.BookingException; +import com.baeldung.api.CabBookingService; +import com.baeldung.server.Server; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.runner.RunWith; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +import static java.lang.Thread.sleep; + +@SpringBootTest(classes = {BurlapClient.class, HessianClient.class}) +@RunWith(SpringRunner.class) +public class CabBookingServiceTest { + + static Logger log = LoggerFactory.getLogger(CabBookingServiceTest.class); + @Autowired @Qualifier("burlapInvoker") CabBookingService burlapClient; + @Autowired @Qualifier("hessianInvoker") CabBookingService hessianClient; + static Thread serverThread; + + @BeforeClass + public static void startServer() throws InterruptedException { + serverThread = serverThread(); + log.info("Starting server."); + serverThread.start(); + sleep(4000); + } + + @org.junit.Test + public void bookACabWithBurlapClient() throws InterruptedException { + bookACab(this.burlapClient); + } + + @org.junit.Test + public void bookACabWithHessianClient() throws InterruptedException { + bookACab(this.hessianClient); + } + + private void bookACab(CabBookingService burlapClient) { + Booking booking; + try { + booking = burlapClient.bookRide("Duomo place"); + log.info("Booking success: {}", booking); + } catch (BookingException e) { + log.info("Booking failed: {}", e.getMessage()); + } + } + + @AfterClass + public static void stopServer() throws InterruptedException { + serverThread.interrupt(); + serverThread.join(); + log.info("Server terminated."); + } + + static Thread serverThread() { + Thread serverThread = new Thread(()-> { + log.info("Starting Burlap and Hessian server"); + Server.main(new String[]{}); + log.info("Burlap and Hessian server terminated"); + }); + serverThread.setDaemon(true); + return serverThread; + } + +} diff --git a/spring-remoting/remoting-hessian-burlap/client/src/test/resources/application.properties b/spring-remoting/remoting-hessian-burlap/client/src/test/resources/application.properties new file mode 100644 index 0000000000..13577dc391 --- /dev/null +++ b/spring-remoting/remoting-hessian-burlap/client/src/test/resources/application.properties @@ -0,0 +1 @@ +application.properties=9999 \ No newline at end of file diff --git a/spring-remoting/remoting-hessian-burlap/server/pom.xml b/spring-remoting/remoting-hessian-burlap/server/pom.xml index c97092b247..f1fed73ed8 100644 --- a/spring-remoting/remoting-hessian-burlap/server/pom.xml +++ b/spring-remoting/remoting-hessian-burlap/server/pom.xml @@ -15,7 +15,7 @@ com.baeldung spring-remoting-http-server - 1.0-SNAPSHOT + ${project.version} org.springframework.boot