Restore outdated local/remote-slsb attributes for declaration compatibility
Legacy EJB attributes are ignored since 6.0 due to being bound to a plain JndiObjectFactoryBean - but can still be declared now, e.g. when validating against the common versions of spring-jee.xsd out there. Closes gh-31627
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,9 +16,12 @@
|
||||
|
||||
package org.springframework.ejb.config;
|
||||
|
||||
import javax.naming.NoInitialContextException;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.beans.factory.config.RuntimeBeanReference;
|
||||
@@ -29,6 +32,7 @@ import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.jndi.JndiObjectFactoryBean;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
|
||||
/**
|
||||
* @author Rob Harrop
|
||||
@@ -93,6 +97,10 @@ public class JeeNamespaceHandlerTests {
|
||||
BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("simpleLocalEjb");
|
||||
assertThat(beanDefinition.getBeanClassName()).isEqualTo(JndiObjectFactoryBean.class.getName());
|
||||
assertPropertyValue(beanDefinition, "jndiName", "ejb/MyLocalBean");
|
||||
|
||||
assertThatExceptionOfType(BeanCreationException.class)
|
||||
.isThrownBy(() -> this.beanFactory.getBean("simpleLocalEjb"))
|
||||
.withCauseInstanceOf(NoInitialContextException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -100,6 +108,32 @@ public class JeeNamespaceHandlerTests {
|
||||
BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("simpleRemoteEjb");
|
||||
assertThat(beanDefinition.getBeanClassName()).isEqualTo(JndiObjectFactoryBean.class.getName());
|
||||
assertPropertyValue(beanDefinition, "jndiName", "ejb/MyRemoteBean");
|
||||
|
||||
assertThatExceptionOfType(BeanCreationException.class)
|
||||
.isThrownBy(() -> this.beanFactory.getBean("simpleRemoteEjb"))
|
||||
.withCauseInstanceOf(NoInitialContextException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testComplexLocalSlsb() {
|
||||
BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("complexLocalEjb");
|
||||
assertThat(beanDefinition.getBeanClassName()).isEqualTo(JndiObjectFactoryBean.class.getName());
|
||||
assertPropertyValue(beanDefinition, "jndiName", "ejb/MyLocalBean");
|
||||
|
||||
assertThatExceptionOfType(BeanCreationException.class)
|
||||
.isThrownBy(() -> this.beanFactory.getBean("complexLocalEjb"))
|
||||
.withCauseInstanceOf(NoInitialContextException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testComplexRemoteSlsb() {
|
||||
BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("complexRemoteEjb");
|
||||
assertThat(beanDefinition.getBeanClassName()).isEqualTo(JndiObjectFactoryBean.class.getName());
|
||||
assertPropertyValue(beanDefinition, "jndiName", "ejb/MyRemoteBean");
|
||||
|
||||
assertThatExceptionOfType(BeanCreationException.class)
|
||||
.isThrownBy(() -> this.beanFactory.getBean("complexRemoteEjb"))
|
||||
.withCauseInstanceOf(NoInitialContextException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -40,14 +40,41 @@
|
||||
</util:properties>
|
||||
|
||||
<!-- Local EJB Tests -->
|
||||
<jee:local-slsb id="simpleLocalEjb" jndi-name="ejb/MyLocalBean"/>
|
||||
<jee:local-slsb id="simpleLocalEjb" jndi-name="ejb/MyLocalBean"
|
||||
business-interface="org.springframework.beans.testfixture.beans.ITestBean"/>
|
||||
|
||||
<jee:local-slsb id="complexLocalEjb"
|
||||
jndi-name="ejb/MyLocalBean"
|
||||
business-interface="org.springframework.beans.testfixture.beans.ITestBean"
|
||||
cache-home="true"
|
||||
lookup-home-on-startup="true"
|
||||
resource-ref="true">
|
||||
<jee:environment>foo=bar</jee:environment>
|
||||
</jee:local-slsb>
|
||||
|
||||
<!-- Remote EJB Tests -->
|
||||
<jee:remote-slsb id="simpleRemoteEjb" jndi-name="ejb/MyRemoteBean"/>
|
||||
<jee:remote-slsb id="simpleRemoteEjb" jndi-name="ejb/MyRemoteBean"
|
||||
business-interface="org.springframework.beans.testfixture.beans.ITestBean"/>
|
||||
|
||||
<!-- Lazy beans Tests-->
|
||||
<jee:remote-slsb id="complexRemoteEjb"
|
||||
jndi-name="ejb/MyRemoteBean"
|
||||
business-interface="org.springframework.beans.testfixture.beans.ITestBean"
|
||||
cache-home="true"
|
||||
lookup-home-on-startup="true"
|
||||
resource-ref="true"
|
||||
home-interface="org.springframework.beans.testfixture.beans.ITestBean"
|
||||
refresh-home-on-connect-failure="true"
|
||||
cache-session-bean="true">
|
||||
<jee:environment>foo=bar</jee:environment>
|
||||
</jee:remote-slsb>
|
||||
|
||||
<!-- Lazy Lookup Tests-->
|
||||
<jee:jndi-lookup id="lazyDataSource" jndi-name="jdbc/MyDataSource" lazy-init="true"/>
|
||||
<jee:local-slsb id="lazyLocalBean" jndi-name="ejb/MyLocalBean" lazy-init="true"/>
|
||||
<jee:remote-slsb id="lazyRemoteBean" jndi-name="ejb/MyRemoteBean" lazy-init="true"/>
|
||||
|
||||
<jee:local-slsb id="lazyLocalBean" jndi-name="ejb/MyLocalBean"
|
||||
business-interface="org.springframework.beans.testfixture.beans.ITestBean" lazy-init="true"/>
|
||||
|
||||
<jee:remote-slsb id="lazyRemoteBean" jndi-name="ejb/MyRemoteBean"
|
||||
business-interface="org.springframework.beans.testfixture.beans.ITestBean" lazy-init="true"/>
|
||||
|
||||
</beans>
|
||||
|
||||
Reference in New Issue
Block a user