Merge pull request #5337 from eugenp/BAEL-9051
BAEL-9051: Fixed failing unit tests
This commit is contained in:
commit
b46c2ddb3d
persistence-modules
spring-data-cassandra/src/test/java/org/baeldung
spring-data-gemfire/src/test/java/org/baeldung
spring-data-neo4j/src/test/java/org/baeldung
spring-data-redis/src/test/java/org/baeldung
spring-boot-angular-ecommerce/src/test/java/org/baeldung
spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration
spring-cloud-data-flow/batch-job/src/test/java/org/baeldung
spring-data-jpa/src/test/java/org/baeldung
spring-mvc-xml/src/main/java/com/baeldung/spring
spring-security-mvc-login/src/test/java/org/baeldung
spring-security-rest-basic-auth/src/test/java/org/baeldung
|
@ -1,16 +1,67 @@
|
||||||
package org.baeldung;
|
package org.baeldung;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import org.apache.cassandra.exceptions.ConfigurationException;
|
||||||
|
import org.apache.thrift.transport.TTransportException;
|
||||||
import org.baeldung.spring.data.cassandra.config.CassandraConfig;
|
import org.baeldung.spring.data.cassandra.config.CassandraConfig;
|
||||||
|
import org.baeldung.spring.data.cassandra.model.Book;
|
||||||
|
import org.cassandraunit.utils.EmbeddedCassandraServerHelper;
|
||||||
|
import org.junit.After;
|
||||||
|
import org.junit.AfterClass;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.cassandra.core.cql.CqlIdentifier;
|
||||||
|
import org.springframework.data.cassandra.core.CassandraAdminOperations;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
|
|
||||||
|
import com.datastax.driver.core.Cluster;
|
||||||
|
import com.datastax.driver.core.Session;
|
||||||
|
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
@ContextConfiguration(classes = CassandraConfig.class)
|
@ContextConfiguration(classes = CassandraConfig.class)
|
||||||
public class SpringContextIntegrationTest {
|
public class SpringContextIntegrationTest {
|
||||||
|
|
||||||
@Test
|
public static final String KEYSPACE_CREATION_QUERY = "CREATE KEYSPACE IF NOT EXISTS testKeySpace " + "WITH replication = { 'class': 'SimpleStrategy', 'replication_factor': '3' };";
|
||||||
|
|
||||||
|
public static final String KEYSPACE_ACTIVATE_QUERY = "USE testKeySpace;";
|
||||||
|
|
||||||
|
public static final String DATA_TABLE_NAME = "book";
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CassandraAdminOperations adminTemplate;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void startCassandraEmbedded() throws InterruptedException, TTransportException, ConfigurationException, IOException {
|
||||||
|
EmbeddedCassandraServerHelper.startEmbeddedCassandra();
|
||||||
|
final Cluster cluster = Cluster.builder().addContactPoints("127.0.0.1").withPort(9142).build();
|
||||||
|
final Session session = cluster.connect();
|
||||||
|
session.execute(KEYSPACE_CREATION_QUERY);
|
||||||
|
session.execute(KEYSPACE_ACTIVATE_QUERY);
|
||||||
|
Thread.sleep(5000);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void createTable() throws InterruptedException, TTransportException, ConfigurationException, IOException {
|
||||||
|
adminTemplate.createTable(true, CqlIdentifier.cqlId(DATA_TABLE_NAME), Book.class, new HashMap<String, Object>());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
|
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void dropTable() {
|
||||||
|
adminTemplate.dropTable(CqlIdentifier.cqlId(DATA_TABLE_NAME));
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterClass
|
||||||
|
public static void stopCassandraEmbedded() {
|
||||||
|
EmbeddedCassandraServerHelper.cleanEmbeddedCassandra();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
package org.baeldung;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
|
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
||||||
|
|
||||||
|
import com.baeldung.spring.data.gemfire.function.GemfireConfiguration;
|
||||||
|
|
||||||
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
|
@ContextConfiguration(classes=GemfireConfiguration.class, loader=AnnotationConfigContextLoader.class)
|
||||||
|
public class SpringContextIntegrationTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package org.baeldung;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.test.context.ActiveProfiles;
|
||||||
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
|
|
||||||
|
import com.baeldung.spring.data.neo4j.config.MovieDatabaseNeo4jTestConfiguration;
|
||||||
|
|
||||||
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
|
@ContextConfiguration(classes = MovieDatabaseNeo4jTestConfiguration.class)
|
||||||
|
@ActiveProfiles(profiles = "test")
|
||||||
|
public class SpringContextIntegrationTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package org.baeldung;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
|
|
||||||
|
import com.baeldung.spring.data.redis.config.RedisConfig;
|
||||||
|
|
||||||
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
|
@ContextConfiguration(classes = RedisConfig.class)
|
||||||
|
public class SpringContextIntegrationTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,10 +5,10 @@ import org.junit.runner.RunWith;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
import com.baeldung.ecommerce.EcommerceApplicationIntegrationTest;
|
import com.baeldung.ecommerce.EcommerceApplication;
|
||||||
|
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@SpringBootTest(classes = EcommerceApplicationIntegrationTest.class)
|
@SpringBootTest(classes = EcommerceApplication.class)
|
||||||
public class SpringContextIntegrationTest {
|
public class SpringContextIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -1,10 +1,27 @@
|
||||||
package com.baeldung.autoconfiguration;
|
package com.baeldung.autoconfiguration;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import javax.persistence.EntityManagerFactory;
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
|
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
|
||||||
import org.springframework.boot.autoconfigure.condition.*;
|
import org.springframework.boot.autoconfigure.condition.ConditionMessage;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionMessage.Style;
|
import org.springframework.boot.autoconfigure.condition.ConditionMessage.Style;
|
||||||
import org.springframework.context.annotation.*;
|
import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnResource;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.ConditionContext;
|
||||||
|
import org.springframework.context.annotation.Conditional;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.PropertySource;
|
||||||
import org.springframework.core.Ordered;
|
import org.springframework.core.Ordered;
|
||||||
import org.springframework.core.env.Environment;
|
import org.springframework.core.env.Environment;
|
||||||
import org.springframework.core.type.AnnotatedTypeMetadata;
|
import org.springframework.core.type.AnnotatedTypeMetadata;
|
||||||
|
@ -14,11 +31,6 @@ import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
|
||||||
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
|
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
|
||||||
import org.springframework.util.ClassUtils;
|
import org.springframework.util.ClassUtils;
|
||||||
|
|
||||||
import javax.persistence.EntityManagerFactory;
|
|
||||||
import javax.sql.DataSource;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@ConditionalOnClass(DataSource.class)
|
@ConditionalOnClass(DataSource.class)
|
||||||
@AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE)
|
@AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE)
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
package org.baeldung;
|
package org.baeldung;
|
||||||
|
|
||||||
import org.baeldung.spring.cloud.BatchJobApplication;
|
import org.baeldung.spring.cloud.JobConfiguration;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@SpringBootTest(classes = BatchJobApplication.class)
|
@SpringBootTest
|
||||||
|
@ContextConfiguration(classes = JobConfiguration.class)
|
||||||
public class SpringContextIntegrationTest {
|
public class SpringContextIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -2,12 +2,17 @@ package org.baeldung;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
import com.baeldung.Application;
|
import com.baeldung.Application;
|
||||||
|
import com.baeldung.config.PersistenceConfiguration;
|
||||||
|
import com.baeldung.config.PersistenceProductConfiguration;
|
||||||
|
import com.baeldung.config.PersistenceUserConfiguration;
|
||||||
|
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
|
@DataJpaTest(excludeAutoConfiguration = {PersistenceConfiguration.class, PersistenceUserConfiguration.class, PersistenceProductConfiguration.class})
|
||||||
@SpringBootTest(classes = Application.class)
|
@SpringBootTest(classes = Application.class)
|
||||||
public class SpringContextIntegrationTest {
|
public class SpringContextIntegrationTest {
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
package com.baeldung.spring;
|
package com.baeldung.spring;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.ImportResource;
|
import org.springframework.context.annotation.ImportResource;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
@ImportResource("classpath:webMvcConfig.xml")
|
@ImportResource("classpath:webMvcConfig.xml")
|
||||||
@Configuration
|
@Configuration
|
||||||
|
@ComponentScan
|
||||||
public class ClientWebConfig implements WebMvcConfigurer {
|
public class ClientWebConfig implements WebMvcConfigurer {
|
||||||
|
|
||||||
public ClientWebConfig() {
|
public ClientWebConfig() {
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
package org.baeldung;
|
package org.baeldung;
|
||||||
|
|
||||||
import org.baeldung.spring.ChannelSecSecurityConfig;
|
|
||||||
import org.baeldung.spring.MvcConfig;
|
|
||||||
import org.baeldung.spring.RedirectionSecurityConfig;
|
|
||||||
import org.baeldung.spring.SecSecurityConfig;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
|
@ -11,12 +7,10 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
import org.springframework.test.context.web.WebAppConfiguration;
|
import org.springframework.test.context.web.WebAppConfiguration;
|
||||||
|
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
@ContextConfiguration(classes = { MvcConfig.class, ChannelSecSecurityConfig.class, RedirectionSecurityConfig.class,
|
@ContextConfiguration({ "/RedirectionWebSecurityConfig.xml", "/mvc-servlet.xml" })
|
||||||
SecSecurityConfig.class })
|
|
||||||
@WebAppConfiguration
|
@WebAppConfiguration
|
||||||
public class SpringContextIntegrationTest {
|
public class SpringContextIntegrationTest {
|
||||||
|
@Test
|
||||||
@Test
|
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
|
||||||
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,12 @@
|
||||||
package org.baeldung;
|
package org.baeldung;
|
||||||
|
|
||||||
import org.baeldung.client.spring.ClientConfig;
|
|
||||||
import org.baeldung.spring.SecSecurityConfig;
|
|
||||||
import org.baeldung.spring.WebConfig;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
|
||||||
import org.springframework.test.context.web.WebAppConfiguration;
|
|
||||||
|
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
@ContextConfiguration(classes = { ClientConfig.class, SecSecurityConfig.class,
|
@ContextConfiguration({ "/WebSecurityConfig.xml" })
|
||||||
WebConfig.class }, loader = AnnotationConfigContextLoader.class)
|
|
||||||
public class SpringContextIntegrationTest {
|
public class SpringContextIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue