Spaces to Tabs

This commit is contained in:
Rob Winch
2016-02-22 22:12:47 -06:00
parent e338e70972
commit fad66c5cd2
7 changed files with 182 additions and 182 deletions

View File

@@ -1,11 +1,11 @@
buildscript {
repositories {
jcenter()
}
repositories {
jcenter()
}
dependencies {
classpath 'org.kordamp.gradle:livereload-gradle-plugin:0.2.1'
}
dependencies {
classpath 'org.kordamp.gradle:livereload-gradle-plugin:0.2.1'
}
}
apply plugin: 'org.kordamp.gradle.livereload'

View File

@@ -5,7 +5,7 @@
* 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
* 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,
@@ -21,80 +21,80 @@ import spock.lang.*
* https://github.com/kensiprell/geb-multibrowser
*/
abstract class MultiBrowserGebSpec extends Specification {
String gebConfEnv = null
String gebConfScript = null
String gebConfEnv = null
String gebConfScript = null
// Map of geb browsers which can be referenced by name in the spec
// THese currently share the same config. This is not a problem for
// my uses, but I can see potential for wanting to configure different
// browsers separately
@Shared _browsers = createBrowserMap()
def currentBrowser
// Map of geb browsers which can be referenced by name in the spec
// THese currently share the same config. This is not a problem for
// my uses, but I can see potential for wanting to configure different
// browsers separately
@Shared _browsers = createBrowserMap()
def currentBrowser
def createBrowserMap() {
[:].withDefault { new Browser(createConf()) }
}
def createBrowserMap() {
[:].withDefault { new Browser(createConf()) }
}
Configuration createConf() {
// Use the standard configured geb driver, but turn off cacheing so
// we can run multiple
def conf = new ConfigurationLoader(gebConfEnv).getConf(gebConfScript)
conf.cacheDriver = false
return conf
}
Configuration createConf() {
// Use the standard configured geb driver, but turn off cacheing so
// we can run multiple
def conf = new ConfigurationLoader(gebConfEnv).getConf(gebConfScript)
conf.cacheDriver = false
return conf
}
def withBrowserSession(browser, Closure c) {
currentBrowser = browser
def returnedValue = c.call()
currentBrowser = null
returnedValue
}
def withBrowserSession(browser, Closure c) {
currentBrowser = browser
def returnedValue = c.call()
currentBrowser = null
returnedValue
}
void resetBrowsers() {
_browsers.each { k, browser ->
if (browser.config?.autoClearCookies) {
browser.clearCookiesQuietly()
}
browser.quit()
}
_browsers = createBrowserMap()
}
void resetBrowsers() {
_browsers.each { k, browser ->
if (browser.config?.autoClearCookies) {
browser.clearCookiesQuietly()
}
browser.quit()
}
_browsers = createBrowserMap()
}
def propertyMissing(String name) {
if(currentBrowser) {
return currentBrowser."$name"
} else {
return _browsers[name]
}
}
def propertyMissing(String name) {
if(currentBrowser) {
return currentBrowser."$name"
} else {
return _browsers[name]
}
}
def methodMissing(String name, args) {
if(currentBrowser) {
return currentBrowser."$name"(*args)
} else {
def browser = _browsers[name]
if(args) {
return browser."${args[0]}"(*(args[1..-1]))
} else {
return browser
}
}
}
def methodMissing(String name, args) {
if(currentBrowser) {
return currentBrowser."$name"(*args)
} else {
def browser = _browsers[name]
if(args) {
return browser."${args[0]}"(*(args[1..-1]))
} else {
return browser
}
}
}
def propertyMissing(String name, value) {
if(!currentBrowser) throw new IllegalArgumentException("No context for setting property $name")
currentBrowser."$name" = value
}
def propertyMissing(String name, value) {
if(!currentBrowser) throw new IllegalArgumentException("No context for setting property $name")
currentBrowser."$name" = value
}
private isSpecStepwise() {
this.class.getAnnotation(Stepwise) != null
}
private isSpecStepwise() {
this.class.getAnnotation(Stepwise) != null
}
def cleanup() {
if (!isSpecStepwise()) resetBrowsers()
}
def cleanup() {
if (!isSpecStepwise()) resetBrowsers()
}
def cleanupSpec() {
if (isSpecStepwise()) resetBrowsers()
}
def cleanupSpec() {
if (isSpecStepwise()) resetBrowsers()
}
}

View File

@@ -40,7 +40,7 @@ task runGemFireServer(dependsOn: availablePort) << {
String classpath = sourceSets.main.runtimeClasspath.collect { it }.join(File.pathSeparator)
String[] commandLine = ['java', '-server', '-ea',
"-Dspring.session.data.gemfire.port=$port",
"-Dspring.session.data.gemfire.port=$port",
"-Dsample.httpsession.gemfire.log-level="
+ System.getProperty('sample.httpsession.gemfire.log-level', 'warning'),
'-classpath', classpath, 'sample.ServerConfig']

View File

@@ -5,7 +5,7 @@
* 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
* 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,
@@ -68,7 +68,7 @@ public class ServerConfig {
@Bean
CacheServerFactoryBean gemfireCacheServer(Cache gemfireCache, // <4>
@Value("${spring.session.data.gemfire.port:"+SERVER_PORT+"}") int port) {
@Value("${spring.session.data.gemfire.port:"+SERVER_PORT+"}") int port) {
CacheServerFactoryBean cacheServerFactory = new CacheServerFactoryBean();

View File

@@ -5,7 +5,7 @@
* 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
* 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,
@@ -31,55 +31,55 @@ import javax.servlet.http.HttpServletResponse
@Stepwise
class RestTests extends Specification {
@Shared
RESTClient client = new RESTClient(System.properties.'geb.build.baseUrl')
@Shared
RESTClient client = new RESTClient(System.properties.'geb.build.baseUrl')
@Shared
String session
@Shared
String session
def 'Unauthenticated user sent to log in page'() {
when: 'unauthenticated user request protected page'
def resp = client.get path: '/', headers: ['Accept':'application/json']
then: 'sent to the log in page'
def e = thrown(HttpResponseException)
e.response.status == HttpServletResponse.SC_UNAUTHORIZED
}
def 'Unauthenticated user sent to log in page'() {
when: 'unauthenticated user request protected page'
def resp = client.get path: '/', headers: ['Accept':'application/json']
then: 'sent to the log in page'
def e = thrown(HttpResponseException)
e.response.status == HttpServletResponse.SC_UNAUTHORIZED
}
def 'Authenticate with Basic Works'() {
when: 'Authenticate with Basic'
def username, response
client.get(path: '/', headers: ['Authorization': 'Basic ' + 'user:password'.bytes.encodeBase64() ]) { resp, json ->
response = resp
username = json.username
session = resp.headers.'x-auth-token'
}
then: 'Access the User information and obtain session via x-auth-token header'
response.status == HttpServletResponse.SC_OK
username == 'user'
session
}
def 'Authenticate with Basic Works'() {
when: 'Authenticate with Basic'
def username, response
client.get(path: '/', headers: ['Authorization': 'Basic ' + 'user:password'.bytes.encodeBase64() ]) { resp, json ->
response = resp
username = json.username
session = resp.headers.'x-auth-token'
}
then: 'Access the User information and obtain session via x-auth-token header'
response.status == HttpServletResponse.SC_OK
username == 'user'
session
}
def 'Authenticate with x-auth-token works'() {
when: 'Authenticate with x-auth-token'
def username, response
client.get(path: '/', headers: ['x-auth-token': session ]) { resp, json ->
response = resp
username = json.username
}
then: 'Access the User information'
response.status == HttpServletResponse.SC_OK
username == 'user'
}
def 'Authenticate with x-auth-token works'() {
when: 'Authenticate with x-auth-token'
def username, response
client.get(path: '/', headers: ['x-auth-token': session ]) { resp, json ->
response = resp
username = json.username
}
then: 'Access the User information'
response.status == HttpServletResponse.SC_OK
username == 'user'
}
def 'Logout'() {
when: 'invalide session'
def response
client.get(path: '/logout', headers: ['x-auth-token': session ]) { resp, json ->
response = resp
session = resp.headers.'x-auth-token'
}
then: 'The session is deleted and an empty x-auth-token is returned'
response.status == HttpServletResponse.SC_NO_CONTENT
session == ''
}
def 'Logout'() {
when: 'invalide session'
def response
client.get(path: '/logout', headers: ['x-auth-token': session ]) { resp, json ->
response = resp
session = resp.headers.'x-auth-token'
}
then: 'The session is deleted and an empty x-auth-token is returned'
response.status == HttpServletResponse.SC_NO_CONTENT
session == ''
}
}

View File

@@ -5,17 +5,17 @@ apply plugin: 'spring-io'
description = "Aggregator for Spring Session and Spring Data GemFire"
dependencies {
compile project(':spring-session')
compile("org.springframework.data:spring-data-gemfire:$springDataGemFireVersion") {
exclude group: "org.slf4j", module: 'slf4j-api'
exclude group: "org.slf4j", module: 'jcl-over-slf4j'
}
compile project(':spring-session')
compile("org.springframework.data:spring-data-gemfire:$springDataGemFireVersion") {
exclude group: "org.slf4j", module: 'slf4j-api'
exclude group: "org.slf4j", module: 'jcl-over-slf4j'
}
}
dependencyManagement {
springIoTestRuntime {
imports {
mavenBom "io.spring.platform:platform-bom:${springIoVersion}"
}
}
springIoTestRuntime {
imports {
mavenBom "io.spring.platform:platform-bom:${springIoVersion}"
}
}
}

View File

@@ -98,70 +98,70 @@ public class HazelcastHttpSessionConfiguration extends SpringHttpSessionConfigur
public void setSessionMapName(String sessionMapName) {
this.sessionMapName = sessionMapName;
}
static class ExpiringSessionMap implements Map<String, ExpiringSession> {
private IMap<String,ExpiringSession> delegate;
private IMap<String,ExpiringSession> delegate;
ExpiringSessionMap(IMap<String,ExpiringSession> delegate) {
this.delegate = delegate;
}
public ExpiringSession put(String key, ExpiringSession value) {
if(value == null) {
return delegate.put(key, value);
}
return delegate.put(key, value, value.getMaxInactiveIntervalInSeconds(), TimeUnit.SECONDS);
}
ExpiringSessionMap(IMap<String,ExpiringSession> delegate) {
this.delegate = delegate;
}
public ExpiringSession put(String key, ExpiringSession value) {
if(value == null) {
return delegate.put(key, value);
}
return delegate.put(key, value, value.getMaxInactiveIntervalInSeconds(), TimeUnit.SECONDS);
}
public int size() {
return delegate.size();
}
public int size() {
return delegate.size();
}
public boolean isEmpty() {
return delegate.isEmpty();
}
public boolean isEmpty() {
return delegate.isEmpty();
}
public boolean containsKey(Object key) {
return delegate.containsKey(key);
}
public boolean containsKey(Object key) {
return delegate.containsKey(key);
}
public boolean containsValue(Object value) {
return delegate.containsValue(value);
}
public boolean containsValue(Object value) {
return delegate.containsValue(value);
}
public ExpiringSession get(Object key) {
return delegate.get(key);
}
public ExpiringSession get(Object key) {
return delegate.get(key);
}
public ExpiringSession remove(Object key) {
return delegate.remove(key);
}
public ExpiringSession remove(Object key) {
return delegate.remove(key);
}
public void putAll(Map<? extends String, ? extends ExpiringSession> m) {
delegate.putAll(m);
}
public void putAll(Map<? extends String, ? extends ExpiringSession> m) {
delegate.putAll(m);
}
public void clear() {
delegate.clear();
}
public void clear() {
delegate.clear();
}
public Set<String> keySet() {
return delegate.keySet();
}
public Set<String> keySet() {
return delegate.keySet();
}
public Collection<ExpiringSession> values() {
return delegate.values();
}
public Collection<ExpiringSession> values() {
return delegate.values();
}
public Set<java.util.Map.Entry<String, ExpiringSession>> entrySet() {
return delegate.entrySet();
}
public Set<java.util.Map.Entry<String, ExpiringSession>> entrySet() {
return delegate.entrySet();
}
public boolean equals(Object o) {
return delegate.equals(o);
}
public boolean equals(Object o) {
return delegate.equals(o);
}
public int hashCode() {
return delegate.hashCode();
}
public int hashCode() {
return delegate.hashCode();
}
}
}