Use Gradle test fixture support for spring-beans and spring-context
See gh-23550
This commit is contained in:
@@ -0,0 +1,244 @@
|
||||
/*
|
||||
* Copyright 2002-2019 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.mock.jndi;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.naming.Binding;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
import javax.naming.NameClassPair;
|
||||
import javax.naming.NameNotFoundException;
|
||||
import javax.naming.NamingEnumeration;
|
||||
import javax.naming.NamingException;
|
||||
import javax.naming.spi.InitialContextFactory;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
|
||||
/**
|
||||
* Tests for {@link SimpleNamingContextBuilder} and {@link SimpleNamingContext}.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @author Chris Beams
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
class SimpleNamingContextTests {
|
||||
|
||||
@Test
|
||||
void namingContextBuilder() throws NamingException {
|
||||
SimpleNamingContextBuilder builder = new SimpleNamingContextBuilder();
|
||||
InitialContextFactory factory = builder.createInitialContextFactory(null);
|
||||
|
||||
DataSource ds = new StubDataSource();
|
||||
builder.bind("java:comp/env/jdbc/myds", ds);
|
||||
Object obj = new Object();
|
||||
builder.bind("myobject", obj);
|
||||
|
||||
Context context1 = factory.getInitialContext(null);
|
||||
assertThat(context1.lookup("java:comp/env/jdbc/myds") == ds).as("Correct DataSource registered").isTrue();
|
||||
assertThat(context1.lookup("myobject") == obj).as("Correct Object registered").isTrue();
|
||||
|
||||
Hashtable<String, String> env2 = new Hashtable<>();
|
||||
env2.put("key1", "value1");
|
||||
Context context2 = factory.getInitialContext(env2);
|
||||
assertThat(context2.lookup("java:comp/env/jdbc/myds") == ds).as("Correct DataSource registered").isTrue();
|
||||
assertThat(context2.lookup("myobject") == obj).as("Correct Object registered").isTrue();
|
||||
assertThat(context2.getEnvironment() != env2).as("Correct environment").isTrue();
|
||||
assertThat("value1".equals(context2.getEnvironment().get("key1"))).as("Correct key1").isTrue();
|
||||
|
||||
Integer i = new Integer(0);
|
||||
context1.rebind("myinteger", i);
|
||||
String s = "";
|
||||
context2.bind("mystring", s);
|
||||
|
||||
Context context3 = (Context) context2.lookup("");
|
||||
context3.rename("java:comp/env/jdbc/myds", "jdbc/myds");
|
||||
context3.unbind("myobject");
|
||||
|
||||
assertThat(context3.getEnvironment() != context2.getEnvironment()).as("Correct environment").isTrue();
|
||||
context3.addToEnvironment("key2", "value2");
|
||||
assertThat("value2".equals(context3.getEnvironment().get("key2"))).as("key2 added").isTrue();
|
||||
context3.removeFromEnvironment("key1");
|
||||
assertThat(context3.getEnvironment().get("key1") == null).as("key1 removed").isTrue();
|
||||
|
||||
assertThat(context1.lookup("jdbc/myds") == ds).as("Correct DataSource registered").isTrue();
|
||||
assertThatExceptionOfType(NameNotFoundException.class).isThrownBy(() ->
|
||||
context1.lookup("myobject"));
|
||||
assertThat(context1.lookup("myinteger") == i).as("Correct Integer registered").isTrue();
|
||||
assertThat(context1.lookup("mystring") == s).as("Correct String registered").isTrue();
|
||||
|
||||
assertThat(context2.lookup("jdbc/myds") == ds).as("Correct DataSource registered").isTrue();
|
||||
assertThatExceptionOfType(NameNotFoundException.class).isThrownBy(() ->
|
||||
context2.lookup("myobject"));
|
||||
assertThat(context2.lookup("myinteger") == i).as("Correct Integer registered").isTrue();
|
||||
assertThat(context2.lookup("mystring") == s).as("Correct String registered").isTrue();
|
||||
|
||||
assertThat(context3.lookup("jdbc/myds") == ds).as("Correct DataSource registered").isTrue();
|
||||
assertThatExceptionOfType(NameNotFoundException.class).isThrownBy(() ->
|
||||
context3.lookup("myobject"));
|
||||
assertThat(context3.lookup("myinteger") == i).as("Correct Integer registered").isTrue();
|
||||
assertThat(context3.lookup("mystring") == s).as("Correct String registered").isTrue();
|
||||
|
||||
Map<String, Binding> bindingMap = new HashMap<>();
|
||||
NamingEnumeration<?> bindingEnum = context3.listBindings("");
|
||||
while (bindingEnum.hasMoreElements()) {
|
||||
Binding binding = (Binding) bindingEnum.nextElement();
|
||||
bindingMap.put(binding.getName(), binding);
|
||||
}
|
||||
boolean condition = bindingMap.get("jdbc").getObject() instanceof Context;
|
||||
assertThat(condition).as("Correct jdbc subcontext").isTrue();
|
||||
assertThat(SimpleNamingContext.class.getName().equals(bindingMap.get("jdbc").getClassName())).as("Correct jdbc subcontext").isTrue();
|
||||
|
||||
Context jdbcContext = (Context) context3.lookup("jdbc");
|
||||
jdbcContext.bind("mydsX", ds);
|
||||
Map<String, Binding> subBindingMap = new HashMap<>();
|
||||
NamingEnumeration<?> subBindingEnum = jdbcContext.listBindings("");
|
||||
while (subBindingEnum.hasMoreElements()) {
|
||||
Binding binding = (Binding) subBindingEnum.nextElement();
|
||||
subBindingMap.put(binding.getName(), binding);
|
||||
}
|
||||
|
||||
assertThat(ds.equals(subBindingMap.get("myds").getObject())).as("Correct DataSource registered").isTrue();
|
||||
assertThat(StubDataSource.class.getName().equals(subBindingMap.get("myds").getClassName())).as("Correct DataSource registered").isTrue();
|
||||
assertThat(ds.equals(subBindingMap.get("mydsX").getObject())).as("Correct DataSource registered").isTrue();
|
||||
assertThat(StubDataSource.class.getName().equals(subBindingMap.get("mydsX").getClassName())).as("Correct DataSource registered").isTrue();
|
||||
assertThat(i.equals(bindingMap.get("myinteger").getObject())).as("Correct Integer registered").isTrue();
|
||||
assertThat(Integer.class.getName().equals(bindingMap.get("myinteger").getClassName())).as("Correct Integer registered").isTrue();
|
||||
assertThat(s.equals(bindingMap.get("mystring").getObject())).as("Correct String registered").isTrue();
|
||||
assertThat(String.class.getName().equals(bindingMap.get("mystring").getClassName())).as("Correct String registered").isTrue();
|
||||
|
||||
context1.createSubcontext("jdbc").bind("sub/subds", ds);
|
||||
|
||||
Map<String, String> pairMap = new HashMap<>();
|
||||
NamingEnumeration<?> pairEnum = context2.list("jdbc");
|
||||
while (pairEnum.hasMore()) {
|
||||
NameClassPair pair = (NameClassPair) pairEnum.next();
|
||||
pairMap.put(pair.getName(), pair.getClassName());
|
||||
}
|
||||
assertThat(SimpleNamingContext.class.getName().equals(pairMap.get("sub"))).as("Correct sub subcontext").isTrue();
|
||||
|
||||
Context subContext = (Context) context2.lookup("jdbc/sub");
|
||||
Map<String, String> subPairMap = new HashMap<>();
|
||||
NamingEnumeration<?> subPairEnum = subContext.list("");
|
||||
while (subPairEnum.hasMoreElements()) {
|
||||
NameClassPair pair = (NameClassPair) subPairEnum.next();
|
||||
subPairMap.put(pair.getName(), pair.getClassName());
|
||||
}
|
||||
|
||||
assertThat(StubDataSource.class.getName().equals(subPairMap.get("subds"))).as("Correct DataSource registered").isTrue();
|
||||
assertThat(StubDataSource.class.getName().equals(pairMap.get("myds"))).as("Correct DataSource registered").isTrue();
|
||||
assertThat(StubDataSource.class.getName().equals(pairMap.get("mydsX"))).as("Correct DataSource registered").isTrue();
|
||||
|
||||
pairMap.clear();
|
||||
pairEnum = context1.list("jdbc/");
|
||||
while (pairEnum.hasMore()) {
|
||||
NameClassPair pair = (NameClassPair) pairEnum.next();
|
||||
pairMap.put(pair.getName(), pair.getClassName());
|
||||
}
|
||||
assertThat(StubDataSource.class.getName().equals(pairMap.get("myds"))).as("Correct DataSource registered").isTrue();
|
||||
assertThat(StubDataSource.class.getName().equals(pairMap.get("mydsX"))).as("Correct DataSource registered").isTrue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Demonstrates how emptyActivatedContextBuilder() method can be
|
||||
* used repeatedly, and how it affects creating a new InitialContext()
|
||||
*/
|
||||
@Test
|
||||
void createInitialContext() throws Exception {
|
||||
SimpleNamingContextBuilder builder = SimpleNamingContextBuilder.emptyActivatedContextBuilder();
|
||||
String name = "foo";
|
||||
Object o = new Object();
|
||||
builder.bind(name, o);
|
||||
// Check it affects JNDI
|
||||
Context ctx = new InitialContext();
|
||||
assertThat(ctx.lookup(name) == o).isTrue();
|
||||
// Check it returns mutable contexts
|
||||
ctx.unbind(name);
|
||||
InitialContext badCtx1 = new InitialContext();
|
||||
assertThatExceptionOfType(NamingException.class).isThrownBy(() ->
|
||||
badCtx1.lookup(name));
|
||||
|
||||
// Check the same call will work again, but the context is empty
|
||||
builder = SimpleNamingContextBuilder.emptyActivatedContextBuilder();
|
||||
InitialContext badCtx2 = new InitialContext();
|
||||
assertThatExceptionOfType(NamingException.class).isThrownBy(() ->
|
||||
badCtx2.lookup(name));
|
||||
Object o2 = new Object();
|
||||
builder.bind(name, o2);
|
||||
assertThat(o2).isEqualTo(badCtx2.lookup(name));
|
||||
}
|
||||
|
||||
|
||||
static class StubDataSource implements DataSource {
|
||||
|
||||
@Override
|
||||
public Connection getConnection() throws SQLException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Connection getConnection(String username, String password) throws SQLException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrintWriter getLogWriter() throws SQLException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLoginTimeout() throws SQLException {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLogWriter(PrintWriter arg0) throws SQLException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLoginTimeout(int arg0) throws SQLException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWrapperFor(Class<?> arg0) throws SQLException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T unwrap(Class<T> arg0) throws SQLException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Logger getParentLogger() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,10 +19,10 @@ package org.springframework.test.context.configuration;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.test.fixtures.beans.Pet;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.ContextLoader;
|
||||
import org.springframework.test.context.junit4.PropertiesBasedSpringJUnit4ClassRunnerAppCtxTests;
|
||||
import org.springframework.tests.sample.beans.Pet;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
@@ -19,11 +19,11 @@ package org.springframework.test.context.configuration;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.test.fixtures.beans.Pet;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.ContextLoader;
|
||||
import org.springframework.test.context.junit4.PropertiesBasedSpringJUnit4ClassRunnerAppCtxTests;
|
||||
import org.springframework.test.context.support.GenericPropertiesContextLoader;
|
||||
import org.springframework.tests.sample.beans.Pet;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
@@ -20,11 +20,11 @@ import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.test.fixtures.beans.Employee;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import org.springframework.tests.sample.beans.Employee;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
@@ -20,8 +20,8 @@ import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.test.fixtures.beans.Employee;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import org.springframework.tests.sample.beans.Employee;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
@@ -16,10 +16,10 @@
|
||||
|
||||
package org.springframework.test.context.configuration.interfaces;
|
||||
|
||||
import org.springframework.beans.test.fixtures.beans.Employee;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.configuration.interfaces.ContextConfigurationTestInterface.Config;
|
||||
import org.springframework.tests.sample.beans.Employee;
|
||||
|
||||
/**
|
||||
* @author Sam Brannen
|
||||
|
||||
@@ -19,9 +19,9 @@ package org.springframework.test.context.groovy;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.test.fixtures.beans.Employee;
|
||||
import org.springframework.beans.test.fixtures.beans.Pet;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
import org.springframework.tests.sample.beans.Employee;
|
||||
import org.springframework.tests.sample.beans.Pet;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
@@ -18,10 +18,10 @@ package org.springframework.test.context.groovy;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.test.fixtures.beans.Employee;
|
||||
import org.springframework.beans.test.fixtures.beans.Pet;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.GenericGroovyApplicationContext;
|
||||
import org.springframework.tests.sample.beans.Employee;
|
||||
import org.springframework.tests.sample.beans.Pet;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
@@ -24,11 +24,11 @@ import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.beans.factory.BeanNameAware;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.test.fixtures.beans.Employee;
|
||||
import org.springframework.beans.test.fixtures.beans.Pet;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import org.springframework.tests.sample.beans.Employee;
|
||||
import org.springframework.tests.sample.beans.Pet;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
@@ -20,10 +20,10 @@ import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.test.fixtures.beans.Employee;
|
||||
import org.springframework.beans.test.fixtures.beans.Pet;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
import org.springframework.tests.sample.beans.Employee;
|
||||
import org.springframework.tests.sample.beans.Pet;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
@@ -25,11 +25,11 @@ import org.junit.Test;
|
||||
import org.springframework.beans.factory.BeanNameAware;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.test.fixtures.beans.Employee;
|
||||
import org.springframework.beans.test.fixtures.beans.Pet;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.transaction.AfterTransaction;
|
||||
import org.springframework.test.context.transaction.BeforeTransaction;
|
||||
import org.springframework.tests.sample.beans.Employee;
|
||||
import org.springframework.tests.sample.beans.Pet;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
||||
@@ -20,12 +20,12 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.test.fixtures.beans.Pet;
|
||||
import org.springframework.test.context.BootstrapWith;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.ContextLoader;
|
||||
import org.springframework.test.context.support.DefaultTestContextBootstrapper;
|
||||
import org.springframework.test.context.support.GenericPropertiesContextLoader;
|
||||
import org.springframework.tests.sample.beans.Pet;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
@@ -28,13 +28,13 @@ import org.junit.runners.Parameterized.Parameter;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.test.fixtures.beans.Employee;
|
||||
import org.springframework.beans.test.fixtures.beans.Pet;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.TestContextManager;
|
||||
import org.springframework.test.context.TestExecutionListeners;
|
||||
import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
|
||||
import org.springframework.tests.sample.beans.Employee;
|
||||
import org.springframework.tests.sample.beans.Pet;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
@@ -22,10 +22,10 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.test.fixtures.beans.Pet;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.support.GenericPropertiesContextLoader;
|
||||
import org.springframework.tests.sample.beans.Pet;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
@@ -28,14 +28,14 @@ import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.beans.test.fixtures.beans.Employee;
|
||||
import org.springframework.beans.test.fixtures.beans.Pet;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.TestExecutionListeners;
|
||||
import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
|
||||
import org.springframework.test.context.support.GenericXmlContextLoader;
|
||||
import org.springframework.tests.sample.beans.Employee;
|
||||
import org.springframework.tests.sample.beans.Pet;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
@@ -18,10 +18,10 @@ package org.springframework.test.context.junit4.annotation;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.test.fixtures.beans.Employee;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.tests.sample.beans.Employee;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
@@ -20,12 +20,12 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.test.fixtures.beans.Employee;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
||||
import org.springframework.tests.sample.beans.Employee;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
@@ -19,10 +19,10 @@ package org.springframework.test.context.junit4.annotation;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.test.fixtures.beans.Pet;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.tests.sample.beans.Pet;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
@@ -18,11 +18,11 @@ package org.springframework.test.context.junit4.annotation;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.test.fixtures.beans.Employee;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.support.DelegatingSmartContextLoader;
|
||||
import org.springframework.tests.sample.beans.Employee;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
@@ -20,12 +20,12 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.test.fixtures.beans.Employee;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.support.DelegatingSmartContextLoader;
|
||||
import org.springframework.tests.sample.beans.Employee;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
@@ -19,11 +19,11 @@ package org.springframework.test.context.junit4.annotation;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.test.fixtures.beans.Pet;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.support.DelegatingSmartContextLoader;
|
||||
import org.springframework.tests.sample.beans.Pet;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
@@ -20,10 +20,10 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.test.fixtures.beans.Employee;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.support.DelegatingSmartContextLoader;
|
||||
import org.springframework.tests.sample.beans.Employee;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
@@ -20,10 +20,10 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.test.fixtures.beans.Pet;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.support.DelegatingSmartContextLoader;
|
||||
import org.springframework.tests.sample.beans.Pet;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
@@ -20,10 +20,10 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.test.fixtures.beans.Employee;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
||||
import org.springframework.tests.sample.beans.Employee;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
@@ -20,10 +20,10 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.test.fixtures.beans.Pet;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
||||
import org.springframework.tests.sample.beans.Pet;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
@@ -16,10 +16,10 @@
|
||||
|
||||
package org.springframework.test.context.junit4.annotation;
|
||||
|
||||
import org.springframework.beans.test.fixtures.beans.Employee;
|
||||
import org.springframework.beans.test.fixtures.beans.Pet;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.tests.sample.beans.Employee;
|
||||
import org.springframework.tests.sample.beans.Pet;
|
||||
|
||||
/**
|
||||
* ApplicationContext configuration class for various integration tests.
|
||||
|
||||
@@ -20,10 +20,10 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.test.fixtures.beans.Employee;
|
||||
import org.springframework.beans.test.fixtures.beans.Pet;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit4.annotation.PojoAndStringConfig;
|
||||
import org.springframework.tests.sample.beans.Employee;
|
||||
import org.springframework.tests.sample.beans.Pet;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
@@ -20,11 +20,11 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.test.fixtures.beans.Employee;
|
||||
import org.springframework.beans.test.fixtures.beans.Pet;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
||||
import org.springframework.tests.sample.beans.Employee;
|
||||
import org.springframework.tests.sample.beans.Pet;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
|
||||
package org.springframework.test.context.junit4.profile.annotation;
|
||||
|
||||
import org.springframework.beans.test.fixtures.beans.Pet;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.tests.sample.beans.Pet;
|
||||
|
||||
/**
|
||||
* @author Sam Brannen
|
||||
|
||||
@@ -16,10 +16,10 @@
|
||||
|
||||
package org.springframework.test.context.junit4.profile.annotation;
|
||||
|
||||
import org.springframework.beans.test.fixtures.beans.Employee;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
import org.springframework.tests.sample.beans.Employee;
|
||||
|
||||
/**
|
||||
* @author Sam Brannen
|
||||
|
||||
@@ -20,10 +20,10 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.test.fixtures.beans.Employee;
|
||||
import org.springframework.beans.test.fixtures.beans.Pet;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.tests.sample.beans.Employee;
|
||||
import org.springframework.tests.sample.beans.Pet;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
@@ -16,10 +16,10 @@
|
||||
|
||||
package org.springframework.test.context.junit4.profile.importresource;
|
||||
|
||||
import org.springframework.beans.test.fixtures.beans.Pet;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.ImportResource;
|
||||
import org.springframework.tests.sample.beans.Pet;
|
||||
|
||||
/**
|
||||
* @author Juergen Hoeller
|
||||
|
||||
@@ -20,10 +20,10 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.test.fixtures.beans.Employee;
|
||||
import org.springframework.beans.test.fixtures.beans.Pet;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.tests.sample.beans.Employee;
|
||||
import org.springframework.tests.sample.beans.Pet;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
@@ -29,10 +29,10 @@ import org.junit.runners.Parameterized.Parameter;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.test.fixtures.beans.Employee;
|
||||
import org.springframework.beans.test.fixtures.beans.Pet;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.tests.sample.beans.Employee;
|
||||
import org.springframework.tests.sample.beans.Pet;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
@@ -20,9 +20,9 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.test.fixtures.beans.Employee;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.tests.sample.beans.Employee;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@ package org.springframework.test.context.junit4.spr3896;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.test.fixtures.beans.Pet;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.tests.sample.beans.Pet;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
@@ -20,9 +20,9 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.test.fixtures.beans.Employee;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.tests.sample.beans.Employee;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@ package org.springframework.test.context.junit4.spr3896;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.test.fixtures.beans.Pet;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.tests.sample.beans.Pet;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.test.fixtures.beans.Employee;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
@@ -31,7 +32,6 @@ import org.springframework.test.annotation.DirtiesContext.ClassMode;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.transaction.AfterTransaction;
|
||||
import org.springframework.test.context.transaction.BeforeTransaction;
|
||||
import org.springframework.tests.sample.beans.Employee;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -20,12 +20,12 @@ import javax.sql.DataSource;
|
||||
|
||||
import org.junit.Before;
|
||||
|
||||
import org.springframework.beans.test.fixtures.beans.Employee;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.tests.sample.beans.Employee;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -20,6 +20,7 @@ import javax.sql.DataSource;
|
||||
|
||||
import org.junit.Before;
|
||||
|
||||
import org.springframework.beans.test.fixtures.beans.Employee;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
@@ -28,7 +29,6 @@ import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.transaction.AfterTransaction;
|
||||
import org.springframework.test.context.transaction.TransactionalTestExecutionListener;
|
||||
import org.springframework.tests.sample.beans.Employee;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -19,11 +19,11 @@ package org.springframework.test.context.testng;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.test.fixtures.beans.Employee;
|
||||
import org.springframework.beans.test.fixtures.beans.Pet;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.tests.sample.beans.Employee;
|
||||
import org.springframework.tests.sample.beans.Pet;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
|
||||
@@ -25,6 +25,8 @@ import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.test.fixtures.beans.Employee;
|
||||
import org.springframework.beans.test.fixtures.beans.Pet;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||
@@ -32,8 +34,6 @@ import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.transaction.AfterTransaction;
|
||||
import org.springframework.test.context.transaction.BeforeTransaction;
|
||||
import org.springframework.tests.sample.beans.Employee;
|
||||
import org.springframework.tests.sample.beans.Pet;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -27,11 +27,11 @@ import org.testng.annotations.Test;
|
||||
import org.springframework.beans.factory.BeanNameAware;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.test.fixtures.beans.Employee;
|
||||
import org.springframework.beans.test.fixtures.beans.Pet;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.transaction.AfterTransaction;
|
||||
import org.springframework.test.context.transaction.BeforeTransaction;
|
||||
import org.springframework.tests.sample.beans.Employee;
|
||||
import org.springframework.tests.sample.beans.Pet;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
||||
@@ -19,10 +19,10 @@ package org.springframework.test.context.web;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.test.fixtures.beans.TestBean;
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
import org.springframework.mock.web.MockHttpSession;
|
||||
import org.springframework.test.context.junit.jupiter.web.SpringJUnitWebConfig;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
Reference in New Issue
Block a user