Skip to content

Commit

Permalink
BAEL-2886- post incremented counter variable
Browse files Browse the repository at this point in the history
  • Loading branch information
pkoli committed Jun 1, 2019
1 parent d143f54 commit dc73b7a
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 52 deletions.

This file was deleted.

2 changes: 2 additions & 0 deletions spring-session/spring-session-mongodb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
<version>${spring-boot-starter-data-mongodb.version}</version>
</dependency>

<dependency>
Expand All @@ -43,6 +44,7 @@

<properties>
<spring-session-data-mongodb.version>2.1.3.RELEASE</spring-session-data-mongodb.version>
<spring-boot-starter-data-mongodb.version>2.1.5.RELEASE</spring-boot-starter-data-mongodb.version>
</properties>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.baeldung.springsessionmongodb.controller;

import javax.servlet.http.HttpSession;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

@RestController
public class SpringSessionMongoDBController {

Expand All @@ -17,7 +17,7 @@ public ResponseEntity<Integer> count(HttpSession session) {
if (counter == null) {
counter = 1;
} else {
counter += 1;
counter++;
}

session.setAttribute("count", counter);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.baeldung.springsessionmongodb;

import java.util.Base64;

import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -14,6 +12,8 @@
import org.springframework.session.data.mongo.MongoOperationsSessionRepository;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.Base64;


@RunWith(SpringRunner.class)
@SpringBootTest(classes = SpringSessionMongoDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
Expand All @@ -26,8 +26,8 @@ public class SpringSessionMongoDBIntegrationTest {

@Test
public void givenEndpointIsCalledTwiceAndResponseIsReturned_whenMongoDBIsQueriedForCount_thenCountMustBeSame() {
HttpEntity<String> response = restTemplate.
exchange("http://localhost:" + 8080, HttpMethod.GET, null, String.class);
HttpEntity<String> response = restTemplate
.exchange("http://localhost:" + 8080, HttpMethod.GET, null, String.class);
HttpHeaders headers = response.getHeaders();
String set_cookie = headers.getFirst(HttpHeaders.SET_COOKIE);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package org.baeldung;

import com.baeldung.springsessionmongodb.SpringSessionMongoDBApplication;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import com.baeldung.springsessionmongodb.SpringSessionMongoDBApplication;

@RunWith(SpringRunner.class)
@SpringBootTest(classes = SpringSessionMongoDBApplication.class)
public class SpringContextIntegrationTest {
Expand Down

0 comments on commit dc73b7a

Please sign in to comment.