16
16
package org .springframework .data .jpa .repository .support ;
17
17
18
18
import static org .assertj .core .api .Assertions .*;
19
- import static org .mockito .Mockito .*;
20
19
21
- import java .util .Arrays ;
22
- import java .util .HashSet ;
23
-
24
- import javax .naming .NamingException ;
25
20
import jakarta .persistence .EntityManager ;
26
21
import jakarta .persistence .EntityManagerFactory ;
27
- import javax .sql .DataSource ;
22
+
23
+ import java .util .Arrays ;
24
+ import java .util .HashSet ;
28
25
29
26
import org .junit .jupiter .api .BeforeAll ;
30
27
import org .junit .jupiter .api .BeforeEach ;
31
28
import org .junit .jupiter .api .Test ;
32
-
33
29
import org .springframework .beans .factory .annotation .Autowired ;
34
30
import org .springframework .context .ConfigurableApplicationContext ;
35
31
import org .springframework .context .annotation .AnnotationConfigApplicationContext ;
36
32
import org .springframework .context .annotation .Bean ;
37
33
import org .springframework .context .annotation .ComponentScan ;
38
34
import org .springframework .context .annotation .ComponentScan .Filter ;
39
35
import org .springframework .context .annotation .FilterType ;
40
- import org .springframework .context .support .ClassPathXmlApplicationContext ;
41
36
import org .springframework .data .jpa .domain .sample .Category ;
42
37
import org .springframework .data .jpa .domain .sample .User ;
43
38
import org .springframework .data .jpa .infrastructure .HibernateTestUtils ;
44
39
import org .springframework .data .jpa .repository .JpaContext ;
45
40
import org .springframework .data .jpa .repository .config .EnableJpaRepositories ;
46
41
import org .springframework .jdbc .datasource .embedded .EmbeddedDatabaseBuilder ;
47
42
import org .springframework .jdbc .datasource .embedded .EmbeddedDatabaseType ;
48
- import org .springframework .jndi .JndiObjectFactoryBean ;
49
- import org .springframework .mock .jndi .ExpectedLookupTemplate ;
50
- import org .springframework .mock .jndi .SimpleNamingContextBuilder ;
51
43
import org .springframework .orm .jpa .LocalContainerEntityManagerFactoryBean ;
52
44
import org .springframework .stereotype .Component ;
53
45
@@ -132,21 +124,6 @@ void bootstrapsDefaultJpaContextInSpringContainer() {
132
124
context .close ();
133
125
}
134
126
135
- @ Test // DATAJPA-813
136
- void bootstrapsDefaultJpaContextInSpringContainerWithEntityManagerFromJndi () throws Exception {
137
-
138
- SimpleNamingContextBuilder builder = SimpleNamingContextBuilder .emptyActivatedContextBuilder ();
139
- builder .bind ("some/EMF" , createEntityManagerFactory ("spring-data-jpa" ));
140
- builder .bind ("some/other/Component" , new Object ());
141
-
142
- ConfigurableApplicationContext context = new ClassPathXmlApplicationContext ("config/jpa-context-with-jndi.xml" );
143
- ApplicationComponent component = context .getBean (ApplicationComponent .class );
144
-
145
- assertThat (component .context ).isNotNull ();
146
-
147
- context .close ();
148
- }
149
-
150
127
@ EnableJpaRepositories
151
128
@ ComponentScan (includeFilters = @ Filter (type = FilterType .ASSIGNABLE_TYPE , value = ApplicationComponent .class ),
152
129
useDefaultFilters = false )
@@ -157,19 +134,6 @@ public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
157
134
return createEntityManagerFactoryBean ("spring-data-jpa" );
158
135
}
159
136
160
- // A non-EntityManagerFactory JNDI object to make sure the detection doesn't include it
161
- // see DATAJPA-956
162
- @ Bean
163
- public JndiObjectFactoryBean jndiObject () throws NamingException {
164
-
165
- JndiObjectFactoryBean bean = new JndiObjectFactoryBean ();
166
-
167
- bean .setJndiName ("some/DataSource" );
168
- bean .setJndiTemplate (new ExpectedLookupTemplate ("some/DataSource" , mock (DataSource .class )));
169
- bean .setExpectedType (DataSource .class );
170
-
171
- return bean ;
172
- }
173
137
}
174
138
175
139
@ Component
0 commit comments