Understanding the embedded EJBC content

I spent some time trying to understand Embeddable Enterprise Bean Applications and still need some clarification. Suppose I need Junitto test an application EJB.

So, I have an idea what should happen, please help me figure out the correct answer:

  • Junitis the entry point and deploys the application EJBto the server? So EJB and Jboss are โ€œembeddedโ€ in the tests.
  • Junit and 'EJBs' are two separate JVM processes, and they somehow exchange jndi names or something (I don't use remote EJB).
  • The real server (JBoss) has never been used, but EJBContaineris just a layout.
  • Something else.

Edited by:

I found an example :

Could you comment on this code:

@Test
public void test() throws Exception {
          String jbossHomeDir = "E:\\dev_station\\java_station\\Serveurs\\jboss-as-7.1.1.Final";
          System.setProperty("jboss.home.dir", jbossHomeDir);
          StandaloneServer server = EmbeddedServerFactory.create(new File(
                              jbossHomeDir), System.getProperties(), System.getenv(),
                              "org.jboss.logmanager");
          server.start();
          server.deploy(new File("target/classes"));
          Context namingContext = server.getContext();
} 
+4
source share
1 answer

The Java EE 6 tutorial (this first link in the question) says that

The nested container, the bean enterprise components, and the client all run on the same virtual machine using the same class path.

That is, the JUnit test ("client"), the built-in container (implemented by JBoss Wildfly, Glassfish, etc.) and the Java EE application components (EJB, etc.) all work in the same JVM instance (the same process) .

Nothing is mocking. Container services (transactions, injections, etc.) are provided using a real Java EE server implementation.

, , , - 1.

+2

Source: https://habr.com/ru/post/1655629/


All Articles