15
15
*/
16
16
package org .springframework .sbm .jee .ejb .api ;
17
17
18
- import org .springframework .sbm .engine .context .ProjectContext ;
19
- import org .springframework .sbm .jee .ejb .filter .EjbJarXmlResourceFilter ;
20
- import org .springframework .sbm .jee .ejb .resource .JeeEjbJarXmlProjectResourceRegistrar ;
21
- import org .springframework .sbm .project .resource .TestProjectContext ;
22
18
import org .assertj .core .api .Assertions ;
23
19
import org .junit .jupiter .api .Disabled ;
24
20
import org .junit .jupiter .api .Test ;
25
21
import org .openrewrite .xml .XmlParser ;
26
22
import org .openrewrite .xml .tree .Xml ;
23
+ import org .springframework .sbm .engine .context .ProjectContext ;
24
+ import org .springframework .sbm .jee .ejb .filter .EjbJarXmlResourceFilter ;
25
+ import org .springframework .sbm .jee .ejb .resource .JeeEjbJarXmlProjectResourceRegistrar ;
26
+ import org .springframework .sbm .project .resource .TestProjectContext ;
27
27
28
28
import javax .xml .bind .JAXBException ;
29
29
import java .lang .String ;
@@ -39,6 +39,51 @@ class EjbJarXmlTest {
39
39
public static final String EJB_TYPE = "Stateless" ;
40
40
private static final String EJB_NAME = "noInterfaceView" ;
41
41
42
+
43
+ @ Test
44
+ void unmarshal_21_ejb_jarXml () {
45
+ String ejbJarXmlContent =
46
+ "<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n " +
47
+ "<ejb-jar id=\" ejb-jar_1\" xmlns=\" http://xmlns.jcp.org/xml/ns/javaee\" \n " +
48
+ " xmlns:xsi=\" http://www.w3.org/2001/XMLSchema-instance\" \n " +
49
+ " xsi:schemaLocation=\" http://java.sun.com/xml/ns/j2ee\n " +
50
+ " http://xmlns.jcp.org/xml/ns/javaee/ejb-jar_2_1.xsd\" version=\" 2.1\" >\n " +
51
+ " <description>Example of a session bean</description>\n " +
52
+ " <display-name>MyTimeBeanEJBName</display-name>\n " +
53
+ " <enterprise-beans>\n " +
54
+ " <session id=\" Session_MyTime\" >\n " +
55
+ " <description>An EJB named MyTimeBean</description>\n " +
56
+ " <display-name>MyTimeBeanName</display-name>\n " +
57
+ " <ejb-name>MyTimeBean</ejb-name>\n " +
58
+ " <local-home>mytimepak.MyTimeLocalHome</local-home>\n " +
59
+ " <local>mytimepak.MyTimeLocal</local>\n " +
60
+ " <ejb-class>mytimepak.MyTimeBean</ejb-class>\n " +
61
+ " <session-type>Stateless</session-type>\n " +
62
+ " <transaction-type>Container</transaction-type>\n " +
63
+ " </session>\n " +
64
+ " </enterprise-beans>\n " +
65
+ "</ejb-jar>" ;
66
+
67
+ ProjectContext projectContext = TestProjectContext .buildProjectContext ()
68
+ .addRegistrar (new JeeEjbJarXmlProjectResourceRegistrar ())
69
+ .addProjectResource ("src/main/resources/ejb-jar.xml" , ejbJarXmlContent )
70
+ .build ();
71
+
72
+ Optional <EjbJarXml > ejbJarXmlOptional = projectContext .search (new EjbJarXmlResourceFilter ());
73
+ EjbJarType ejbJarXml = ejbJarXmlOptional .get ().getEjbJarXml ();
74
+ assertThat (ejbJarXml .getEnterpriseBeans ().getSessionOrEntityOrMessageDriven ()).hasSize (1 );
75
+ assertThat (ejbJarXml .getEnterpriseBeans ().getSessionOrEntityOrMessageDriven ().get (0 )).isInstanceOf (SessionBeanType .class );
76
+ SessionBeanType sb = (SessionBeanType ) ejbJarXml .getEnterpriseBeans ().getSessionOrEntityOrMessageDriven ().get (0 );
77
+ assertThat (sb .getDescription ().get (0 ).getValue ()).isEqualTo ("An EJB named MyTimeBean" );
78
+ assertThat (sb .getDisplayName ().get (0 ).getValue ()).isEqualTo ("MyTimeBeanName" );
79
+ assertThat (sb .getEjbName ().getValue ()).isEqualTo ("MyTimeBean" );
80
+ assertThat (sb .getLocalHome ().getValue ()).isEqualTo ("mytimepak.MyTimeLocalHome" );
81
+ assertThat (sb .getLocal ().getValue ()).isEqualTo ("mytimepak.MyTimeLocal" );
82
+ assertThat (sb .getEjbClass ().getValue ()).isEqualTo ("mytimepak.MyTimeBean" );
83
+ assertThat (sb .getSessionType ().getValue ()).isEqualTo ("Stateless" );
84
+ assertThat (sb .getTransactionType ().getValue ()).isEqualTo ("Container" );
85
+ }
86
+
42
87
@ Test
43
88
void unmarshal_jcp_3_2_schema () throws JAXBException {
44
89
0 commit comments