File tree Expand file tree Collapse file tree
apache-solrj/src/test/java/com/baeldung/solrjava
persistence-modules/spring-hibernate-3/src/main/resources
spring-cloud/spring-cloud-rest/spring-cloud-rest-discovery-server
src/test/java/org/baeldung
src/test/java/com/baeldung/jooq/springboot
spring-mvc-java/src/main/java/com/baeldung/web/controller Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1212import org .junit .Before ;
1313import org .junit .Test ;
1414
15- public class SolrJavaIntegrationTest {
15+ public class SolrJavaLiveTest {
1616
1717 private SolrJavaIntegration solrJavaIntegration ;
1818
Original file line number Diff line number Diff line change 1717
1818 <context : annotation-config />
1919 <context : component-scan base-package =" org.baeldung.persistence" />
20- <context : property-placeholder location =" classpath:persistence-mysql .properties" />
20+ <context : property-placeholder location =" classpath:persistence-h2 .properties" />
2121
2222
2323
Original file line number Diff line number Diff line change 55 http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd"
66>
77
8- <context : property-placeholder location =" classpath:persistence-mysql .properties" />
8+ <context : property-placeholder location =" classpath:persistence-h2 .properties" />
99
1010 <bean id =" sessionFactory" class =" org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean" >
1111 <property name =" dataSource" ref =" dataSource" />
Original file line number Diff line number Diff line change 5252 </dependencyManagement >
5353
5454 <properties >
55- <spring-cloud .version>Camden .SR4</spring-cloud .version>
55+ <spring-cloud .version>Edgware .SR4</spring-cloud .version>
5656 </properties >
5757
5858</project >
Original file line number Diff line number Diff line change 22
33import org .junit .Test ;
44import org .junit .runner .RunWith ;
5+ import org .mockito .Mockito ;
56import org .springframework .boot .test .context .SpringBootTest ;
7+ import org .springframework .context .annotation .Bean ;
8+ import org .springframework .context .annotation .Configuration ;
9+ import org .springframework .data .redis .connection .RedisConnection ;
10+ import org .springframework .data .redis .connection .RedisConnectionFactory ;
11+ import org .springframework .data .redis .serializer .RedisSerializer ;
12+ import org .springframework .session .data .redis .config .annotation .web .http .EnableRedisHttpSession ;
613import org .springframework .test .context .junit4 .SpringRunner ;
714
815@ RunWith (SpringRunner .class )
@@ -11,5 +18,25 @@ public class SpringCloudRestServerIntegrationTest {
1118 @ Test
1219 public void contextLoads () {
1320 }
21+
22+ @ EnableRedisHttpSession
23+ @ Configuration
24+ static class Config {
25+
26+ @ Bean
27+ @ SuppressWarnings ("unchecked" )
28+ public RedisSerializer <Object > defaultRedisSerializer () {
29+ return Mockito .mock (RedisSerializer .class );
30+ }
1431
15- }
32+ @ Bean
33+ public RedisConnectionFactory connectionFactory () {
34+
35+ RedisConnectionFactory factory = Mockito .mock (RedisConnectionFactory .class );
36+ RedisConnection connection = Mockito .mock (RedisConnection .class );
37+ Mockito .when (factory .getConnection ()).thenReturn (connection );
38+
39+ return factory ;
40+ }
41+ }
42+ }
Original file line number Diff line number Diff line change 55 <version >0.0.1-SNAPSHOT</version >
66
77 <parent >
8- <groupId >com.baeldung</groupId >
9- <artifactId >parent-modules</artifactId >
10- <version >1.0.0-SNAPSHOT</version >
8+ <groupId >org.springframework.boot</groupId >
9+ <artifactId >spring-boot-starter-parent</artifactId >
10+ <version >1.4.4.RELEASE</version >
11+ <relativePath />
1112 </parent >
1213
1314 <dependencyManagement >
5556 <groupId >org.springframework.boot</groupId >
5657 <artifactId >spring-boot-starter-jooq</artifactId >
5758 </dependency >
59+ <dependency >
60+ <groupId >org.springframework.boot</groupId >
61+ <artifactId >spring-boot-starter-test</artifactId >
62+ </dependency >
5863
5964 <!-- Testing -->
6065 <dependency >
Original file line number Diff line number Diff line change 1212import org .junit .Test ;
1313import org .junit .runner .RunWith ;
1414import org .springframework .beans .factory .annotation .Autowired ;
15- import org .springframework .boot .test .context .SpringBootTest ;
1615import org .springframework .dao .DataAccessException ;
17- import org .springframework .test .context .junit4 .SpringRunner ;
16+ import org .springframework .test .context .ContextConfiguration ;
17+ import org .springframework .test .context .junit4 .SpringJUnit4ClassRunner ;
1818import org .springframework .transaction .annotation .Transactional ;
1919
20- @ RunWith (SpringRunner .class )
21- @ SpringBootTest (classes = Application .class )
22- @ Transactional ("transactionManager" )
20+ import com .baeldung .jooq .introduction .PersistenceContextIntegrationTest ;
21+
22+ @ ContextConfiguration (classes = PersistenceContextIntegrationTest .class )
23+ @ Transactional (transactionManager = "transactionManager" )
24+ @ RunWith (SpringJUnit4ClassRunner .class )
2325public class SpringBootIntegrationTest {
2426
2527 @ Autowired
Original file line number Diff line number Diff line change 11package com .baeldung .web .controller ;
22
3- import com .google .gson .Gson ;
4- import org .springframework .beans .factory .annotation .Autowired ;
3+ import java .security .Principal ;
4+ import java .util .Map ;
5+
56import org .springframework .messaging .handler .annotation .MessageExceptionHandler ;
67import org .springframework .messaging .handler .annotation .MessageMapping ;
78import org .springframework .messaging .handler .annotation .Payload ;
8- import org .springframework .messaging .simp .SimpMessageSendingOperations ;
99import org .springframework .messaging .simp .annotation .SendToUser ;
1010import org .springframework .stereotype .Controller ;
1111
12- import java .security .Principal ;
13- import java .util .Map ;
12+ import com .google .gson .Gson ;
1413
1514@ Controller
1615public class WebsocketSendToUserController {
1716
18- @ Autowired
19- private SimpMessageSendingOperations messagingTemplate ;
20-
2117 private Gson gson = new Gson ();
2218
2319 @ MessageMapping ("/message" )
Original file line number Diff line number Diff line change @@ -14,10 +14,12 @@ public class GeoIpIntegrationTest {
1414
1515 @ Test
1616 public void givenIP_whenFetchingCity_thenReturnsCityData () throws IOException , GeoIp2Exception {
17- File database = new File ("your-path-to-db-file" );
17+
18+ ClassLoader classLoader = getClass ().getClassLoader ();
19+ File database = new File (classLoader .getResource ("GeoLite2-City.mmdb" ).getFile ());
1820 DatabaseReader dbReader = new DatabaseReader .Builder (database ).build ();
1921
20- InetAddress ipAddress = InetAddress .getByName ("your-public-ip " );
22+ InetAddress ipAddress = InetAddress .getByName ("google.com " );
2123 CityResponse response = dbReader .city (ipAddress );
2224
2325 String countryName = response .getCountry ().getName ();
Load diff This file was deleted.
You can’t perform that action at this time.
0 commit comments