Issue gh-434
This commit is contained in:
Rob Winch
2016-09-12 15:12:13 -05:00
parent 0e1d81f509
commit 1f7193f32d
10 changed files with 232 additions and 118 deletions

View File

@@ -1,15 +1,14 @@
package samples
import geb.spock.GebSpec
import geb.spock.*
import sample.Application
import samples.pages.*
import spock.lang.Stepwise
import org.springframework.boot.test.IntegrationTest
import org.springframework.boot.test.SpringApplicationContextLoader
import org.springframework.test.context.ContextConfiguration
import org.springframework.test.context.web.WebAppConfiguration
import sample.Application
import samples.pages.HomePage
import samples.pages.LoginPage
import samples.pages.SetAttributePage
import spock.lang.Stepwise
/**
* @author jitendra on 15/3/16.
@@ -20,36 +19,36 @@ import spock.lang.Stepwise
@IntegrationTest
class HttpRedisJsonTest extends GebSpec {
def 'login page test'() {
when:
to LoginPage
then:
at LoginPage
}
def'login page test'() {
when:
to LoginPage
then:
at LoginPage
}
def "Unauthenticated user sent to login page"() {
when:
via HomePage
then:
at LoginPage
}
def"Unauthenticated user sent to login page"() {
when:
via HomePage
then:
at LoginPage
}
def "Successful Login test"() {
when:
login()
then:
at HomePage
driver.manage().cookies.find {it.name == "SESSION"}
!driver.manage().cookies.find {it.name == "JSESSIONID"}
}
def"Successful Login test"() {
when:
login()
then:
at HomePage
driver.manage().cookies.find {it.name == "SESSION"}
!driver.manage().cookies.find {it.name == "JSESSIONID"}
}
def "Set and get attributes in session"() {
when:
setAttribute("Demo Key", "Demo Value")
def"Set and get attributes in session"() {
when:
setAttribute("Demo Key", "Demo Value")
then:
at SetAttributePage
tdKey()*.text().contains("Demo Key")
tdKey()*.text().contains("Demo Value")
}
then:
at SetAttributePage
tdKey()*.text().contains("Demo Key")
tdKey()*.text().contains("Demo Value")
}
}

View File

@@ -6,13 +6,15 @@ import geb.Page
* @author jitendra on 15/3/16.
*/
class HomePage extends Page {
static url = "/"
static url="/"
static at = {
static at=
{
driver.title == "Spring Session Sample - Home"
}
static content = {
static content=
{
form { $('form') }
submit { $('button[type=submit]') }
setAttribute(required: false) { key = 'project', value = 'SessionRedisJson' ->

View File

@@ -6,14 +6,16 @@ import geb.Page
* @author jitendra on 15/3/16.
*/
class LoginPage extends Page {
static url = "/login"
static url="/login"
static at = {
static at=
{
assert title == "Spring Session Sample - Login"
return true
}
static content = {
static content=
{
form { $('form') }
submit { $('button[type=submit]') }
login(required: false) { user = 'user', pass = 'password' ->

View File

@@ -6,13 +6,15 @@ import geb.Page
* @author jitendra on 15/3/16.
*/
class SetAttributePage extends Page {
static url = "/setValue"
static url="/setValue"
static at = {
static at=
{
title == "Spring Session Sample - Home"
}
static content = {
static content=
{
tdKey { $('td') }
}
}

View File

@@ -1,16 +1,31 @@
/*
* Copyright 2014-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package samples;
import org.junit.Test;
import org.junit.runner.RunWith;
import sample.Application;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import sample.Application;
import static org.springframework.util.Assert.notNull;
import static org.junit.Assert.*;
import static org.assertj.core.api.Assertions.assertThat;
/**
* @author jitendra on 8/3/16.
@@ -19,13 +34,14 @@ import static org.junit.Assert.*;
@SpringApplicationConfiguration(Application.class)
public class RedisSerializerTest {
@Autowired
RedisTemplate sessionRedisTemplate;
@Autowired
RedisTemplate<Object, Object> sessionRedisTemplate;
@Test
public void testRedisTemplate() {
notNull(sessionRedisTemplate);
notNull(sessionRedisTemplate.getDefaultSerializer());
assertTrue(sessionRedisTemplate.getDefaultSerializer() instanceof GenericJackson2JsonRedisSerializer);
}
@Test
public void testRedisTemplate() {
assertThat(this.sessionRedisTemplate).isNotNull();
assertThat(this.sessionRedisTemplate.getDefaultSerializer()).isNotNull();
assertThat(this.sessionRedisTemplate.getDefaultSerializer())
.isInstanceOf(GenericJackson2JsonRedisSerializer.class);
}
}