Fixed spring-mvc-java, spring-cloud-rest-discovery-server apache-solr… (#4661)
* Fixed spring-mvc-java, spring-cloud-rest-discovery-server apache-solrj integration tests * Fixed integration tests for spring-hibernate-3, spring-jooq module
This commit is contained in:
parent
f959cbe55a
commit
d9d8f169eb
@ -12,7 +12,7 @@ import org.apache.solr.common.SolrDocumentList;
|
|||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class SolrJavaIntegrationTest {
|
public class SolrJavaLiveTest {
|
||||||
|
|
||||||
private SolrJavaIntegration solrJavaIntegration;
|
private SolrJavaIntegration solrJavaIntegration;
|
||||||
|
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
<context:annotation-config />
|
<context:annotation-config />
|
||||||
<context:component-scan base-package="org.baeldung.persistence" />
|
<context:component-scan base-package="org.baeldung.persistence" />
|
||||||
<context:property-placeholder location="classpath:persistence-mysql.properties"/>
|
<context:property-placeholder location="classpath:persistence-h2.properties"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd"
|
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd"
|
||||||
>
|
>
|
||||||
|
|
||||||
<context:property-placeholder location="classpath:persistence-mysql.properties"/>
|
<context:property-placeholder location="classpath:persistence-h2.properties"/>
|
||||||
|
|
||||||
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
|
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
|
||||||
<property name="dataSource" ref="dataSource"/>
|
<property name="dataSource" ref="dataSource"/>
|
||||||
|
@ -52,7 +52,7 @@
|
|||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<spring-cloud.version>Camden.SR4</spring-cloud.version>
|
<spring-cloud.version>Edgware.SR4</spring-cloud.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -2,7 +2,14 @@ package org.baeldung;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.Mockito;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.data.redis.connection.RedisConnection;
|
||||||
|
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||||
|
import org.springframework.data.redis.serializer.RedisSerializer;
|
||||||
|
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@ -11,5 +18,25 @@ public class SpringCloudRestServerIntegrationTest {
|
|||||||
@Test
|
@Test
|
||||||
public void contextLoads() {
|
public void contextLoads() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EnableRedisHttpSession
|
||||||
|
@Configuration
|
||||||
|
static class Config {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public RedisSerializer<Object> defaultRedisSerializer() {
|
||||||
|
return Mockito.mock(RedisSerializer.class);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
@Bean
|
||||||
|
public RedisConnectionFactory connectionFactory() {
|
||||||
|
|
||||||
|
RedisConnectionFactory factory = Mockito.mock(RedisConnectionFactory.class);
|
||||||
|
RedisConnection connection = Mockito.mock(RedisConnection.class);
|
||||||
|
Mockito.when(factory.getConnection()).thenReturn(connection);
|
||||||
|
|
||||||
|
return factory;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -5,9 +5,10 @@
|
|||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>parent-modules</artifactId>
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
<version>1.4.4.RELEASE</version>
|
||||||
|
<relativePath/>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
@ -55,6 +56,10 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-jooq</artifactId>
|
<artifactId>spring-boot-starter-jooq</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- Testing -->
|
<!-- Testing -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -12,14 +12,16 @@ import org.jooq.impl.DSL;
|
|||||||
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.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
|
||||||
import org.springframework.dao.DataAccessException;
|
import org.springframework.dao.DataAccessException;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@RunWith(SpringRunner.class)
|
import com.baeldung.jooq.introduction.PersistenceContextIntegrationTest;
|
||||||
@SpringBootTest(classes = Application.class)
|
|
||||||
@Transactional("transactionManager")
|
@ContextConfiguration(classes = PersistenceContextIntegrationTest.class)
|
||||||
|
@Transactional(transactionManager = "transactionManager")
|
||||||
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
public class SpringBootIntegrationTest {
|
public class SpringBootIntegrationTest {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@ -1,23 +1,19 @@
|
|||||||
package com.baeldung.web.controller;
|
package com.baeldung.web.controller;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.messaging.handler.annotation.MessageExceptionHandler;
|
|
||||||
import org.springframework.messaging.handler.annotation.MessageMapping;
|
|
||||||
import org.springframework.messaging.handler.annotation.Payload;
|
|
||||||
import org.springframework.messaging.simp.SimpMessageSendingOperations;
|
|
||||||
import org.springframework.messaging.simp.annotation.SendToUser;
|
|
||||||
import org.springframework.stereotype.Controller;
|
|
||||||
|
|
||||||
import java.security.Principal;
|
import java.security.Principal;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.springframework.messaging.handler.annotation.MessageExceptionHandler;
|
||||||
|
import org.springframework.messaging.handler.annotation.MessageMapping;
|
||||||
|
import org.springframework.messaging.handler.annotation.Payload;
|
||||||
|
import org.springframework.messaging.simp.annotation.SendToUser;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class WebsocketSendToUserController {
|
public class WebsocketSendToUserController {
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SimpMessageSendingOperations messagingTemplate;
|
|
||||||
|
|
||||||
private Gson gson = new Gson();
|
private Gson gson = new Gson();
|
||||||
|
|
||||||
@MessageMapping("/message")
|
@MessageMapping("/message")
|
||||||
|
@ -14,10 +14,12 @@ public class GeoIpIntegrationTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenIP_whenFetchingCity_thenReturnsCityData() throws IOException, GeoIp2Exception {
|
public void givenIP_whenFetchingCity_thenReturnsCityData() throws IOException, GeoIp2Exception {
|
||||||
File database = new File("your-path-to-db-file");
|
|
||||||
|
ClassLoader classLoader = getClass().getClassLoader();
|
||||||
|
File database = new File(classLoader.getResource("GeoLite2-City.mmdb").getFile());
|
||||||
DatabaseReader dbReader = new DatabaseReader.Builder(database).build();
|
DatabaseReader dbReader = new DatabaseReader.Builder(database).build();
|
||||||
|
|
||||||
InetAddress ipAddress = InetAddress.getByName("your-public-ip");
|
InetAddress ipAddress = InetAddress.getByName("google.com");
|
||||||
CityResponse response = dbReader.city(ipAddress);
|
CityResponse response = dbReader.city(ipAddress);
|
||||||
|
|
||||||
String countryName = response.getCountry().getName();
|
String countryName = response.getCountry().getName();
|
||||||
|
13
spring-mvc-xml/src/test/resources/.gitignore
vendored
13
spring-mvc-xml/src/test/resources/.gitignore
vendored
@ -1,13 +0,0 @@
|
|||||||
*.class
|
|
||||||
|
|
||||||
#folders#
|
|
||||||
/target
|
|
||||||
/neoDb*
|
|
||||||
/data
|
|
||||||
/src/main/webapp/WEB-INF/classes
|
|
||||||
*/META-INF/*
|
|
||||||
|
|
||||||
# Packaged files #
|
|
||||||
*.jar
|
|
||||||
*.war
|
|
||||||
*.ear
|
|
BIN
spring-mvc-xml/src/test/resources/GeoLite2-City.mmdb
Normal file
BIN
spring-mvc-xml/src/test/resources/GeoLite2-City.mmdb
Normal file
Binary file not shown.
After Width: | Height: | Size: 54 MiB |
Loading…
x
Reference in New Issue
Block a user