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.Test;
|
||||
|
||||
public class SolrJavaIntegrationTest {
|
||||
public class SolrJavaLiveTest {
|
||||
|
||||
private SolrJavaIntegration solrJavaIntegration;
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
<context:annotation-config />
|
||||
<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"
|
||||
>
|
||||
|
||||
<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">
|
||||
<property name="dataSource" ref="dataSource"/>
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
</dependencyManagement>
|
||||
|
||||
<properties>
|
||||
<spring-cloud.version>Camden.SR4</spring-cloud.version>
|
||||
<spring-cloud.version>Edgware.SR4</spring-cloud.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -2,7 +2,14 @@ package org.baeldung;
|
|||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mockito;
|
||||
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;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
|
@ -11,5 +18,25 @@ public class SpringCloudRestServerIntegrationTest {
|
|||
@Test
|
||||
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>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-modules</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>1.4.4.RELEASE</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
|
||||
<dependencyManagement>
|
||||
|
@ -55,6 +56,10 @@
|
|||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-jooq</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Testing -->
|
||||
<dependency>
|
||||
|
|
|
@ -12,14 +12,16 @@ import org.jooq.impl.DSL;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
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;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = Application.class)
|
||||
@Transactional("transactionManager")
|
||||
import com.baeldung.jooq.introduction.PersistenceContextIntegrationTest;
|
||||
|
||||
@ContextConfiguration(classes = PersistenceContextIntegrationTest.class)
|
||||
@Transactional(transactionManager = "transactionManager")
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class SpringBootIntegrationTest {
|
||||
|
||||
@Autowired
|
||||
|
|
|
@ -1,23 +1,19 @@
|
|||
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.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
|
||||
public class WebsocketSendToUserController {
|
||||
|
||||
@Autowired
|
||||
private SimpMessageSendingOperations messagingTemplate;
|
||||
|
||||
private Gson gson = new Gson();
|
||||
|
||||
@MessageMapping("/message")
|
||||
|
|
|
@ -14,10 +14,12 @@ public class GeoIpIntegrationTest {
|
|||
|
||||
@Test
|
||||
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();
|
||||
|
||||
InetAddress ipAddress = InetAddress.getByName("your-public-ip");
|
||||
InetAddress ipAddress = InetAddress.getByName("google.com");
|
||||
CityResponse response = dbReader.city(ipAddress);
|
||||
|
||||
String countryName = response.getCountry().getName();
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
*.class
|
||||
|
||||
#folders#
|
||||
/target
|
||||
/neoDb*
|
||||
/data
|
||||
/src/main/webapp/WEB-INF/classes
|
||||
*/META-INF/*
|
||||
|
||||
# Packaged files #
|
||||
*.jar
|
||||
*.war
|
||||
*.ear
|
Binary file not shown.
After Width: | Height: | Size: 54 MiB |
Loading…
Reference in New Issue