BAEL-8874 Merge ejb projects
-Merged ejb and spring-ejb modules into spring-ejb
This commit is contained in:
+11
@@ -0,0 +1,11 @@
|
||||
package com.baeldung.ejb.tutorial;
|
||||
|
||||
import javax.ejb.Remote;
|
||||
|
||||
@Remote
|
||||
public interface HelloStatefulWorld {
|
||||
|
||||
int howManyTimes();
|
||||
String getHelloWorld();
|
||||
|
||||
}
|
||||
+19
@@ -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!";
|
||||
}
|
||||
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package com.baeldung.ejb.tutorial;
|
||||
|
||||
import javax.ejb.Remote;
|
||||
|
||||
@Remote
|
||||
public interface HelloStatelessWorld {
|
||||
|
||||
String getHelloWorld();
|
||||
|
||||
}
|
||||
+12
@@ -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,8 @@
|
||||
package com.baeldung.ejb.tutorial;
|
||||
|
||||
import javax.ejb.Remote;
|
||||
|
||||
@Remote
|
||||
public interface HelloWorld {
|
||||
String getHelloWorld();
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package com.baeldung.ejb.tutorial;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.ejb.SessionContext;
|
||||
import javax.ejb.Stateless;
|
||||
|
||||
@Stateless(name = "HelloWorld")
|
||||
public class HelloWorldBean implements HelloWorld {
|
||||
|
||||
@Resource
|
||||
private SessionContext context;
|
||||
|
||||
@Override
|
||||
public String getHelloWorld() {
|
||||
return "Welcome to EJB Tutorial!";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package com.baeldung.ejb.wildfly;
|
||||
|
||||
import javax.ejb.Stateless;
|
||||
|
||||
@Stateless
|
||||
public class TextProcessorBean implements TextProcessorRemote {
|
||||
public String processText(String text) {
|
||||
return text.toUpperCase();
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package com.baeldung.ejb.wildfly;
|
||||
|
||||
import javax.ejb.Remote;
|
||||
|
||||
@Remote
|
||||
public interface TextProcessorRemote {
|
||||
|
||||
String processText(String text);
|
||||
}
|
||||
@@ -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>spring-ejb-remote</module-name>
|
||||
</ejb-jar>
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
|
||||
</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="INFO">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
</configuration>
|
||||
+32
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
+24
@@ -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!");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user