[BAEL-1218] Guide to Spring EJB Integration (#3266)

* Evaluation article about types of bean injection in spring

* BAEL-1319 Quick Guide on Data.sql and Schema.sql Files in Spring

* Revert "Evaluation article about types of bean injection in spring"

This reverts commit eb071171673e0b8fa2b7ecffdad86f596e5fb114.

* BAEL-1218: adding spring-ejb and configuring ejb start and deploy

* BAEL-1218: adding spring

* BAEL-1218: wrapping all together

* BAEL-1218: new spring-ejb module

* BAEL-1218: tests and improvements

* BAEL-1218: removing moved files from old article

* BAEL-1218: code review requested changes

* BAEL-1218: test methods nomenclature correction

* BAEL-1418: removing tabs

* BAEL-1218: removing tabs

* BAEL-1218: correcting boot parent module path
This commit is contained in:
Allan Vital
2018-01-07 21:59:53 -02:00
committed by KevinGilmore
parent 09cbc1c6ee
commit cf32e14a9b
15 changed files with 463 additions and 0 deletions
@@ -0,0 +1,11 @@
package com.baeldung.ejb.tutorial;
import javax.ejb.Remote;
@Remote
public interface HelloStatefulWorld {
int howManyTimes();
String getHelloWorld();
}
@@ -0,0 +1,19 @@
package com.baeldung.ejb.tutorial;
import javax.ejb.Stateful;
@Stateful(name = "HelloStatefulWorld")
public class HelloStatefulWorldBean implements HelloStatefulWorld {
private int howManyTimes = 0;
public int howManyTimes() {
return howManyTimes;
}
public String getHelloWorld() {
howManyTimes++;
return "Hello Stateful World!";
}
}
@@ -0,0 +1,10 @@
package com.baeldung.ejb.tutorial;
import javax.ejb.Remote;
@Remote
public interface HelloStatelessWorld {
String getHelloWorld();
}
@@ -0,0 +1,12 @@
package com.baeldung.ejb.tutorial;
import javax.ejb.Stateless;
@Stateless(name = "HelloStatelessWorld")
public class HelloStatelessWorldBean implements HelloStatelessWorld {
public String getHelloWorld() {
return "Hello Stateless World!";
}
}
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/ejb-jar_3_2.xsd"
version="3.2">
<module-name>ejb-remote-for-spring</module-name>
</ejb-jar>
@@ -0,0 +1,32 @@
package com.baeldung.ejb.tutorial;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.Before;
import org.junit.Test;
public class HelloStatefulWorldTestUnitTest {
private HelloStatefulWorldBean statefulBean;
@Before
public void setup() {
statefulBean = new HelloStatefulWorldBean();
}
@Test
public void whenGetHelloWorld_thenHelloStatefulWorldIsReturned() {
String helloWorld = statefulBean.getHelloWorld();
assertThat(helloWorld).isEqualTo("Hello Stateful World!");
}
@Test
public void whenGetHelloWorldIsCalledTwice_thenCounterIs2() {
statefulBean.getHelloWorld();
statefulBean.getHelloWorld();
assertThat(statefulBean.howManyTimes()).isEqualTo(2);
}
}
@@ -0,0 +1,24 @@
package com.baeldung.ejb.tutorial;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.Before;
import org.junit.Test;
public class HelloStatelessWorldTestUnitTest {
private HelloStatelessWorldBean statelessBean;
@Before
public void setup() {
statelessBean = new HelloStatelessWorldBean();
}
@Test
public void whenGetHelloWorld_thenHelloStatelessWorldIsReturned() {
String helloWorld = statelessBean.getHelloWorld();
assertThat(helloWorld).isEqualTo("Hello Stateless World!");
}
}