Commit e69296d7 authored by Phillip Webb's avatar Phillip Webb

Fix checkstyle violations in samples

parent 48534770
...@@ -5,8 +5,7 @@ ...@@ -5,8 +5,7 @@
<suppressions> <suppressions>
<suppress files="SpringApplicationTests\.java" checks="FinalClass" /> <suppress files="SpringApplicationTests\.java" checks="FinalClass" />
<suppress files=".+Configuration\.java" checks="HideUtilityClassConstructor" /> <suppress files=".+Configuration\.java" checks="HideUtilityClassConstructor" />
<suppress files="LaunchScriptTestApplication\.java" checks="HideUtilityClassConstructor" /> <suppress files=".+Application\.java" checks="HideUtilityClassConstructor" />
<suppress files="DevToolsTestApplication\.java" checks="HideUtilityClassConstructor" />
<suppress files="SignalUtils\.java" checks="IllegalImport" /> <suppress files="SignalUtils\.java" checks="IllegalImport" />
<suppress files="[\\/]src[\\/]test[\\/]java[\\/]cli[\\/]command[\\/]" checks="ImportControl" /> <suppress files="[\\/]src[\\/]test[\\/]java[\\/]cli[\\/]command[\\/]" checks="ImportControl" />
<suppress files="[\\/]src[\\/]main[\\/]java[\\/]sample[\\/]" checks="ImportControl" /> <suppress files="[\\/]src[\\/]main[\\/]java[\\/]sample[\\/]" checks="ImportControl" />
...@@ -23,4 +22,8 @@ ...@@ -23,4 +22,8 @@
<suppress files="LogLevel\.java" checks="JavadocVariable" /> <suppress files="LogLevel\.java" checks="JavadocVariable" />
<suppress files="HelpMojo\.java" checks=".*"/> <suppress files="HelpMojo\.java" checks=".*"/>
<suppress files="[\\/]org.springframework.boot.configurationprocessor.json[\\/].*\.java$" checks=".*"/> <suppress files="[\\/]org.springframework.boot.configurationprocessor.json[\\/].*\.java$" checks=".*"/>
<suppress files="TripType\.java" checks="JavadocVariable" />
<suppress files="Rating\.java" checks="JavadocVariable" />
<suppress files="Direction\.java" checks="JavadocVariable" />
<suppress files="JooqExamples\.java" checks="AvoidStaticImport"/>
</suppressions> </suppressions>
endpoints.shutdown.enabled=true endpoints.shutdown.enabled=true
management.security.enabled=false
management.security.enabled=false
\ No newline at end of file
health.diskspace.enabled=false health.diskspace.enabled=false
\ No newline at end of file
endpoints.cors.allowed-origins=http://localhost:8080 endpoints.cors.allowed-origins=http://localhost:8080
endpoints.cors.allowed-methods=GET endpoints.cors.allowed-methods=GET
\ No newline at end of file
server.error.path: /oops server.error.path: /oops
management.context-path: /admin management.context-path: /admin
endpoints.health.sensitive: false endpoints.health.sensitive: false
\ No newline at end of file
...@@ -16,17 +16,18 @@ ...@@ -16,17 +16,18 @@
package sample.ant; package sample.ant;
import static org.assertj.core.api.Assertions.assertThat;
import java.io.File; import java.io.File;
import java.io.FileFilter; import java.io.FileFilter;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.junit.Test; import org.junit.Test;
import org.springframework.boot.loader.tools.JavaExecutable; import org.springframework.boot.loader.tools.JavaExecutable;
import org.springframework.util.FileCopyUtils; import org.springframework.util.FileCopyUtils;
import static org.assertj.core.api.Assertions.assertThat;
/** /**
* Integration Tests for {@code SampleAntApplication}. * Integration Tests for {@code SampleAntApplication}.
* *
......
/* /*
* Copyright 2012-2016 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -59,6 +59,10 @@ public class SampleAtmosphereApplication { ...@@ -59,6 +59,10 @@ public class SampleAtmosphereApplication {
return registration; return registration;
} }
public static void main(String[] args) throws Exception {
SpringApplication.run(SampleAtmosphereApplication.class, args);
}
@Configuration @Configuration
static class MvcConfiguration extends WebMvcConfigurerAdapter { static class MvcConfiguration extends WebMvcConfigurerAdapter {
...@@ -79,8 +83,4 @@ public class SampleAtmosphereApplication { ...@@ -79,8 +83,4 @@ public class SampleAtmosphereApplication {
} }
public static void main(String[] args) throws Exception {
SpringApplication.run(SampleAtmosphereApplication.class, args);
}
} }
/* /*
* Copyright 2012-2016 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -53,7 +53,7 @@ class SampleClient { ...@@ -53,7 +53,7 @@ class SampleClient {
private final Random random; private final Random random;
public SampleClient(CountryRepository countryService) { SampleClient(CountryRepository countryService) {
this.countryService = countryService; this.countryService = countryService;
this.random = new Random(); this.random = new Random();
} }
......
/* /*
* Copyright 2012-2016 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -24,7 +24,9 @@ import org.springframework.boot.loader.tools.Layouts; ...@@ -24,7 +24,9 @@ import org.springframework.boot.loader.tools.Layouts;
import org.springframework.boot.loader.tools.LoaderClassesWriter; import org.springframework.boot.loader.tools.LoaderClassesWriter;
/** /**
* @author pwebb * An example layout.
*
* @author Phillip Webb
*/ */
public class SampleLayout extends Layouts.Jar implements CustomLoaderLayout { public class SampleLayout extends Layouts.Jar implements CustomLoaderLayout {
......
/* /*
* Copyright 2012-2013 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -24,9 +24,9 @@ import org.springframework.data.repository.CrudRepository; ...@@ -24,9 +24,9 @@ import org.springframework.data.repository.CrudRepository;
public interface CustomerRepository extends CrudRepository<Customer, String> { public interface CustomerRepository extends CrudRepository<Customer, String> {
@Query("Select * from customer where firstname=?0") @Query("Select * from customer where firstname=?0")
public Customer findByFirstName(String firstName); Customer findByFirstName(String firstName);
@Query("Select * from customer where lastname=?0") @Query("Select * from customer where lastname=?0")
public List<Customer> findByLastName(String lastName); List<Customer> findByLastName(String lastName);
} }
/* /*
* Copyright 2012-2013 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -22,8 +22,8 @@ import org.springframework.data.elasticsearch.repository.ElasticsearchRepository ...@@ -22,8 +22,8 @@ import org.springframework.data.elasticsearch.repository.ElasticsearchRepository
public interface CustomerRepository extends ElasticsearchRepository<Customer, String> { public interface CustomerRepository extends ElasticsearchRepository<Customer, String> {
public Customer findByFirstName(String firstName); Customer findByFirstName(String firstName);
public List<Customer> findByLastName(String lastName); List<Customer> findByLastName(String lastName);
} }
...@@ -34,8 +34,7 @@ class CityServiceImpl implements CityService { ...@@ -34,8 +34,7 @@ class CityServiceImpl implements CityService {
private final HotelRepository hotelRepository; private final HotelRepository hotelRepository;
public CityServiceImpl(CityRepository cityRepository, CityServiceImpl(CityRepository cityRepository, HotelRepository hotelRepository) {
HotelRepository hotelRepository) {
this.cityRepository = cityRepository; this.cityRepository = cityRepository;
this.hotelRepository = hotelRepository; this.hotelRepository = hotelRepository;
} }
......
...@@ -41,8 +41,7 @@ class HotelServiceImpl implements HotelService { ...@@ -41,8 +41,7 @@ class HotelServiceImpl implements HotelService {
private final ReviewRepository reviewRepository; private final ReviewRepository reviewRepository;
public HotelServiceImpl(HotelRepository hotelRepository, HotelServiceImpl(HotelRepository hotelRepository, ReviewRepository reviewRepository) {
ReviewRepository reviewRepository) {
this.hotelRepository = hotelRepository; this.hotelRepository = hotelRepository;
this.reviewRepository = reviewRepository; this.reviewRepository = reviewRepository;
} }
...@@ -82,7 +81,7 @@ class HotelServiceImpl implements HotelService { ...@@ -82,7 +81,7 @@ class HotelServiceImpl implements HotelService {
private final Map<Rating, Long> ratingCount; private final Map<Rating, Long> ratingCount;
public ReviewsSummaryImpl(List<RatingCount> ratingCounts) { ReviewsSummaryImpl(List<RatingCount> ratingCounts) {
this.ratingCount = new HashMap<Rating, Long>(); this.ratingCount = new HashMap<Rating, Long>();
for (RatingCount ratingCount : ratingCounts) { for (RatingCount ratingCount : ratingCounts) {
this.ratingCount.put(ratingCount.getRating(), ratingCount.getCount()); this.ratingCount.put(ratingCount.getRating(), ratingCount.getCount());
...@@ -92,7 +91,7 @@ class HotelServiceImpl implements HotelService { ...@@ -92,7 +91,7 @@ class HotelServiceImpl implements HotelService {
@Override @Override
public long getNumberOfReviewsWithRating(Rating rating) { public long getNumberOfReviewsWithRating(Rating rating) {
Long count = this.ratingCount.get(rating); Long count = this.ratingCount.get(rating);
return count == null ? 0 : count; return (count != null ? count : 0);
} }
} }
......
spring.datasource.name=scratchdb spring.datasource.name=scratchdb
spring.jmx.default-domain=jpa.sample spring.jmx.default-domain=jpa.sample
\ No newline at end of file
...@@ -37,8 +37,8 @@ public class Customer { ...@@ -37,8 +37,8 @@ public class Customer {
@Override @Override
public String toString() { public String toString() {
return String.format("Customer[id=%s, firstName='%s', lastName='%s']", id, return String.format("Customer[id=%s, firstName='%s', lastName='%s']", this.id,
firstName, lastName); this.firstName, this.lastName);
} }
} }
...@@ -39,8 +39,8 @@ public class Customer { ...@@ -39,8 +39,8 @@ public class Customer {
@Override @Override
public String toString() { public String toString() {
return String.format("Customer[id=%s, firstName='%s', lastName='%s']", id, return String.format("Customer[id=%s, firstName='%s', lastName='%s']", this.id,
firstName, lastName); this.firstName, this.lastName);
} }
} }
/* /*
* Copyright 2012-2016 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -22,8 +22,8 @@ import org.springframework.data.neo4j.repository.GraphRepository; ...@@ -22,8 +22,8 @@ import org.springframework.data.neo4j.repository.GraphRepository;
public interface CustomerRepository extends GraphRepository<Customer> { public interface CustomerRepository extends GraphRepository<Customer> {
public Customer findByFirstName(String firstName); Customer findByFirstName(String firstName);
public List<Customer> findByLastName(String lastName); List<Customer> findByLastName(String lastName);
} }
/* /*
* Copyright 2012-2016 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -23,7 +23,7 @@ import org.junit.Test; ...@@ -23,7 +23,7 @@ import org.junit.Test;
import org.springframework.boot.test.rule.OutputCapture; import org.springframework.boot.test.rule.OutputCapture;
import static org.junit.Assert.assertTrue; import static org.assertj.core.api.Assertions.assertThat;
/** /**
* Tests for {@link SampleNeo4jApplication}. * Tests for {@link SampleNeo4jApplication}.
...@@ -46,8 +46,7 @@ public class SampleNeo4jApplicationTests { ...@@ -46,8 +46,7 @@ public class SampleNeo4jApplicationTests {
} }
} }
String output = this.outputCapture.toString(); String output = this.outputCapture.toString();
assertTrue("Wrong output: " + output, assertThat(output).contains("firstName='Alice', lastName='Smith'");
output.contains("firstName='Alice', lastName='Smith'"));
} }
private boolean neo4jServerRunning(Throwable ex) { private boolean neo4jServerRunning(Throwable ex) {
......
spring.data.rest.base-path=/api spring.data.rest.base-path=/api
\ No newline at end of file
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -16,8 +16,14 @@ ...@@ -16,8 +16,14 @@
package sample.devtools; package sample.devtools;
public class Message { public final class Message {
/**
* Sample message.
*/
public static String MESSAGE = "Message"; public static String MESSAGE = "Message";
private Message() {
}
} }
management.security.enabled=false management.security.enabled=false
spring.jpa.hibernate.ddl-auto=validate spring.jpa.hibernate.ddl-auto=validate
spring.h2.console.enabled=true
spring.h2.console.enabled=true
\ No newline at end of file
...@@ -34,8 +34,7 @@ class CityServiceImpl implements CityService { ...@@ -34,8 +34,7 @@ class CityServiceImpl implements CityService {
private final HotelRepository hotelRepository; private final HotelRepository hotelRepository;
public CityServiceImpl(CityRepository cityRepository, CityServiceImpl(CityRepository cityRepository, HotelRepository hotelRepository) {
HotelRepository hotelRepository) {
this.cityRepository = cityRepository; this.cityRepository = cityRepository;
this.hotelRepository = hotelRepository; this.hotelRepository = hotelRepository;
} }
......
...@@ -41,8 +41,7 @@ class HotelServiceImpl implements HotelService { ...@@ -41,8 +41,7 @@ class HotelServiceImpl implements HotelService {
private final ReviewRepository reviewRepository; private final ReviewRepository reviewRepository;
public HotelServiceImpl(HotelRepository hotelRepository, HotelServiceImpl(HotelRepository hotelRepository, ReviewRepository reviewRepository) {
ReviewRepository reviewRepository) {
this.hotelRepository = hotelRepository; this.hotelRepository = hotelRepository;
this.reviewRepository = reviewRepository; this.reviewRepository = reviewRepository;
} }
...@@ -82,7 +81,7 @@ class HotelServiceImpl implements HotelService { ...@@ -82,7 +81,7 @@ class HotelServiceImpl implements HotelService {
private final Map<Rating, Long> ratingCount; private final Map<Rating, Long> ratingCount;
public ReviewsSummaryImpl(List<RatingCount> ratingCounts) { ReviewsSummaryImpl(List<RatingCount> ratingCounts) {
this.ratingCount = new HashMap<Rating, Long>(); this.ratingCount = new HashMap<Rating, Long>();
for (RatingCount ratingCount : ratingCounts) { for (RatingCount ratingCount : ratingCounts) {
this.ratingCount.put(ratingCount.getRating(), ratingCount.getCount()); this.ratingCount.put(ratingCount.getRating(), ratingCount.getCount());
...@@ -92,7 +91,7 @@ class HotelServiceImpl implements HotelService { ...@@ -92,7 +91,7 @@ class HotelServiceImpl implements HotelService {
@Override @Override
public long getNumberOfReviewsWithRating(Rating rating) { public long getNumberOfReviewsWithRating(Rating rating) {
Long count = this.ratingCount.get(rating); Long count = this.ratingCount.get(rating);
return count == null ? 0 : count; return (count != null ? count : 0);
} }
} }
......
spring.datasource.name=scratchdb spring.datasource.name=scratchdb
spring.jmx.default-domain=jpa.sample spring.jmx.default-domain=jpa.sample
\ No newline at end of file
...@@ -34,8 +34,7 @@ class CityServiceImpl implements CityService { ...@@ -34,8 +34,7 @@ class CityServiceImpl implements CityService {
private final HotelRepository hotelRepository; private final HotelRepository hotelRepository;
public CityServiceImpl(CityRepository cityRepository, CityServiceImpl(CityRepository cityRepository, HotelRepository hotelRepository) {
HotelRepository hotelRepository) {
this.cityRepository = cityRepository; this.cityRepository = cityRepository;
this.hotelRepository = hotelRepository; this.hotelRepository = hotelRepository;
} }
......
...@@ -41,8 +41,7 @@ class HotelServiceImpl implements HotelService { ...@@ -41,8 +41,7 @@ class HotelServiceImpl implements HotelService {
private final ReviewRepository reviewRepository; private final ReviewRepository reviewRepository;
public HotelServiceImpl(HotelRepository hotelRepository, HotelServiceImpl(HotelRepository hotelRepository, ReviewRepository reviewRepository) {
ReviewRepository reviewRepository) {
this.hotelRepository = hotelRepository; this.hotelRepository = hotelRepository;
this.reviewRepository = reviewRepository; this.reviewRepository = reviewRepository;
} }
...@@ -82,7 +81,7 @@ class HotelServiceImpl implements HotelService { ...@@ -82,7 +81,7 @@ class HotelServiceImpl implements HotelService {
private final Map<Rating, Long> ratingCount; private final Map<Rating, Long> ratingCount;
public ReviewsSummaryImpl(List<RatingCount> ratingCounts) { ReviewsSummaryImpl(List<RatingCount> ratingCounts) {
this.ratingCount = new HashMap<Rating, Long>(); this.ratingCount = new HashMap<Rating, Long>();
for (RatingCount ratingCount : ratingCounts) { for (RatingCount ratingCount : ratingCounts) {
this.ratingCount.put(ratingCount.getRating(), ratingCount.getCount()); this.ratingCount.put(ratingCount.getRating(), ratingCount.getCount());
...@@ -92,7 +91,7 @@ class HotelServiceImpl implements HotelService { ...@@ -92,7 +91,7 @@ class HotelServiceImpl implements HotelService {
@Override @Override
public long getNumberOfReviewsWithRating(Rating rating) { public long getNumberOfReviewsWithRating(Rating rating) {
Long count = this.ratingCount.get(rating); Long count = this.ratingCount.get(rating);
return count == null ? 0 : count; return (count != null ? count : 0);
} }
} }
......
spring.datasource.name=scratchdb spring.datasource.name=scratchdb
spring.jmx.default-domain=jpa.sample spring.jmx.default-domain=jpa.sample
\ No newline at end of file
# management.context-path=/admin # management.context-path=/admin
management.security.enabled=false management.security.enabled=false
spring.http.converters.preferred-json-mapper=gson
spring.http.converters.preferred-json-mapper=gson
\ No newline at end of file
management.context-path=/admin management.context-path=/admin
endpoints.docs.curies.enabled=true endpoints.docs.curies.enabled=true
\ No newline at end of file
management.security.enabled=false management.security.enabled=false
management.context-path=/admin
management.context-path=/admin
\ No newline at end of file
# management.context-path=/admin # management.context-path=/admin
management.security.enabled=false management.security.enabled=false
endpoints.docs.curies.enabled=true
endpoints.docs.curies.enabled=true
\ No newline at end of file
server.port = 8443 server.port = 8443
server.ssl.key-store = classpath:sample.jks server.ssl.key-store = classpath:sample.jks
server.ssl.key-store-password = secret server.ssl.key-store-password = secret
server.ssl.key-password = password server.ssl.key-password = password
\ No newline at end of file
server.port = 8443 server.port = 8443
server.ssl.key-store = classpath:sample.jks server.ssl.key-store = classpath:sample.jks
server.ssl.key-store-password = secret server.ssl.key-store-password = secret
server.ssl.key-password = password server.ssl.key-password = password
\ No newline at end of file
logging.level.com.atomikos=WARN logging.level.com.atomikos=WARN
spring.artemis.embedded.queues=accounts spring.artemis.embedded.queues=accounts
\ No newline at end of file
spring.artemis.embedded.queues=accounts spring.artemis.embedded.queues=accounts
\ No newline at end of file
spring.artemis.embedded.queues=accounts spring.artemis.embedded.queues=accounts
logging.level.com.arjuna=INFO logging.level.com.arjuna=INFO
\ No newline at end of file
management.security.enabled=false management.security.enabled=false
service.name=Phil service.name=Phil
metrics.names.tags.process=${spring.application.name:application}:${random.value:0000} metrics.names.tags.process=${spring.application.name:application}:${random.value:0000}
\ No newline at end of file
...@@ -6,4 +6,4 @@ spring.metrics.export.redis.key=keys.metrics.sample ...@@ -6,4 +6,4 @@ spring.metrics.export.redis.key=keys.metrics.sample
spring.metrics.export.aggregate.prefix=${random.value:0000}.${spring.application.name:application} spring.metrics.export.aggregate.prefix=${random.value:0000}.${spring.application.name:application}
spring.metrics.export.aggregate.key-pattern=d spring.metrics.export.aggregate.key-pattern=d
spring.jmx.default-domain=org.springframework.boot spring.jmx.default-domain=org.springframework.boot
spring.data.redis.repositories.enabled=false spring.data.redis.repositories.enabled=false
\ No newline at end of file
/* /*
* Copyright 2012-2016 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -36,6 +36,11 @@ import org.springframework.integration.file.FileWritingMessageHandler; ...@@ -36,6 +36,11 @@ import org.springframework.integration.file.FileWritingMessageHandler;
@EnableConfigurationProperties(ServiceProperties.class) @EnableConfigurationProperties(ServiceProperties.class)
public class SampleParentContextApplication { public class SampleParentContextApplication {
public static void main(String[] args) throws Exception {
new SpringApplicationBuilder(Parent.class)
.child(SampleParentContextApplication.class).run(args);
}
@EnableAutoConfiguration @EnableAutoConfiguration
protected static class Parent { protected static class Parent {
...@@ -83,9 +88,4 @@ public class SampleParentContextApplication { ...@@ -83,9 +88,4 @@ public class SampleParentContextApplication {
} }
public static void main(String[] args) throws Exception {
new SpringApplicationBuilder(Parent.class)
.child(SampleParentContextApplication.class).run(args);
}
} }
/* /*
* Copyright 2012-2013 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -16,9 +16,6 @@ ...@@ -16,9 +16,6 @@
package sample.profile.service; package sample.profile.service;
/**
* @author Dave Syer
*/
public interface MessageService { public interface MessageService {
String getMessage(); String getMessage();
......
sample.host=192.168.0.1 sample.host=192.168.0.1
sample.port=7070 sample.port=7070
\ No newline at end of file
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -44,7 +44,7 @@ public class SampleSecureOAuth2ActuatorApplication { ...@@ -44,7 +44,7 @@ public class SampleSecureOAuth2ActuatorApplication {
private String value; private String value;
public Message(String value) { Message(String value) {
this.value = value; this.value = value;
} }
......
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -27,6 +27,7 @@ import org.springframework.security.core.context.SecurityContextHolder; ...@@ -27,6 +27,7 @@ import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.web.FilterChainProxy; import org.springframework.security.web.FilterChainProxy;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.util.Base64Utils; import org.springframework.util.Base64Utils;
import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.WebApplicationContext;
...@@ -35,7 +36,6 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder ...@@ -35,7 +36,6 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import static org.springframework.test.web.servlet.setup.MockMvcBuilders.webAppContextSetup;
/** /**
* Series of automated integration tests to verify proper behavior of auto-configured, * Series of automated integration tests to verify proper behavior of auto-configured,
...@@ -57,7 +57,8 @@ public class SampleSecureOAuth2ActuatorApplicationTests { ...@@ -57,7 +57,8 @@ public class SampleSecureOAuth2ActuatorApplicationTests {
@Before @Before
public void setUp() { public void setUp() {
this.mvc = webAppContextSetup(this.context).addFilters(this.filterChain).build(); this.mvc = MockMvcBuilders.webAppContextSetup(this.context)
.addFilters(this.filterChain).build();
SecurityContextHolder.clearContext(); SecurityContextHolder.clearContext();
} }
......
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -26,7 +26,7 @@ import javax.persistence.Id; ...@@ -26,7 +26,7 @@ import javax.persistence.Id;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
/** /**
* Domain object for tracking flights * Domain object for tracking flights.
* *
* @author Craig Walls * @author Craig Walls
* @author Greg Turnquist * @author Greg Turnquist
......
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -19,7 +19,7 @@ package sample.secure.oauth2.resource; ...@@ -19,7 +19,7 @@ package sample.secure.oauth2.resource;
import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.CrudRepository;
/** /**
* Spring Data interface with secured methods * Spring Data interface with secured methods.
* *
* @author Craig Walls * @author Craig Walls
* @author Greg Turnquist * @author Greg Turnquist
......
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -28,16 +28,16 @@ import org.springframework.security.core.context.SecurityContextHolder; ...@@ -28,16 +28,16 @@ import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.web.FilterChainProxy; import org.springframework.security.web.FilterChainProxy;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.WebApplicationContext;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import static org.springframework.test.web.servlet.setup.MockMvcBuilders.webAppContextSetup;
/** /**
* Series of automated integration tests to verify proper behavior of auto-configured, * Series of automated integration tests to verify proper behavior of auto-configured,
* OAuth2-secured system * OAuth2-secured system.
* *
* @author Greg Turnquist * @author Greg Turnquist
* @author Dave Syer * @author Dave Syer
...@@ -56,7 +56,8 @@ public class SampleSecureOAuth2ResourceApplicationTests { ...@@ -56,7 +56,8 @@ public class SampleSecureOAuth2ResourceApplicationTests {
@Before @Before
public void setUp() { public void setUp() {
this.mvc = webAppContextSetup(this.context).addFilters(this.filterChain).build(); this.mvc = MockMvcBuilders.webAppContextSetup(this.context)
.addFilters(this.filterChain).build();
SecurityContextHolder.clearContext(); SecurityContextHolder.clearContext();
} }
......
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -26,7 +26,7 @@ import javax.persistence.Id; ...@@ -26,7 +26,7 @@ import javax.persistence.Id;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
/** /**
* Domain object for tracking flights * Domain object for tracking flights.
* *
* @author Craig Walls * @author Craig Walls
* @author Greg Turnquist * @author Greg Turnquist
......
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -20,7 +20,7 @@ import org.springframework.data.repository.CrudRepository; ...@@ -20,7 +20,7 @@ import org.springframework.data.repository.CrudRepository;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
/** /**
* Spring Data interface with secured methods * Spring Data interface with secured methods.
* *
* @author Craig Walls * @author Craig Walls
* @author Greg Turnquist * @author Greg Turnquist
......
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -34,6 +34,7 @@ import org.springframework.security.web.FilterChainProxy; ...@@ -34,6 +34,7 @@ import org.springframework.security.web.FilterChainProxy;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.MvcResult; import org.springframework.test.web.servlet.MvcResult;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.WebApplicationContext;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
...@@ -42,7 +43,6 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder ...@@ -42,7 +43,6 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import static org.springframework.test.web.servlet.setup.MockMvcBuilders.webAppContextSetup;
/** /**
* Series of automated integration tests to verify proper behavior of auto-configured, * Series of automated integration tests to verify proper behavior of auto-configured,
...@@ -66,7 +66,8 @@ public class SampleSecureOAuth2ApplicationTests { ...@@ -66,7 +66,8 @@ public class SampleSecureOAuth2ApplicationTests {
@Before @Before
public void setUp() { public void setUp() {
this.mvc = webAppContextSetup(this.context).addFilters(this.filterChain).build(); this.mvc = MockMvcBuilders.webAppContextSetup(this.context)
.addFilters(this.filterChain).build();
SecurityContextHolder.clearContext(); SecurityContextHolder.clearContext();
} }
......
/* /*
* Copyright 2012-2014 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -20,10 +20,6 @@ import org.springframework.security.access.annotation.Secured; ...@@ -20,10 +20,6 @@ import org.springframework.security.access.annotation.Secured;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
/**
* @author Dave Syer
*
*/
@Service @Service
public class SampleService { public class SampleService {
......
security.user.password=password security.user.password=password
\ No newline at end of file
...@@ -25,7 +25,7 @@ import sample.test.domain.VehicleIdentificationNumber; ...@@ -25,7 +25,7 @@ import sample.test.domain.VehicleIdentificationNumber;
*/ */
public class VehicleIdentificationNumberNotFoundException extends RuntimeException { public class VehicleIdentificationNumberNotFoundException extends RuntimeException {
private VehicleIdentificationNumber vehicleIdentificationNumber; private final VehicleIdentificationNumber vehicleIdentificationNumber;
public VehicleIdentificationNumberNotFoundException(VehicleIdentificationNumber vin) { public VehicleIdentificationNumberNotFoundException(VehicleIdentificationNumber vin) {
this(vin, null); this(vin, null);
......
/* /*
* Copyright 2012-2016 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -22,7 +22,7 @@ import org.springframework.web.bind.annotation.ResponseStatus; ...@@ -22,7 +22,7 @@ import org.springframework.web.bind.annotation.ResponseStatus;
@ResponseStatus(HttpStatus.NOT_FOUND) @ResponseStatus(HttpStatus.NOT_FOUND)
public class UserNameNotFoundException extends RuntimeException { public class UserNameNotFoundException extends RuntimeException {
private String username; private final String username;
public UserNameNotFoundException(String username) { public UserNameNotFoundException(String username) {
this.username = username; this.username = username;
......
spring.mvc.view.prefix: /WEB-INF/jsp/ spring.mvc.view.prefix: /WEB-INF/jsp/
spring.mvc.view.suffix: .jsp spring.mvc.view.suffix: .jsp
application.message: Hello Phil application.message: Hello Phil
\ No newline at end of file
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -26,7 +26,7 @@ import org.springframework.context.annotation.Bean; ...@@ -26,7 +26,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.util.SocketUtils; import org.springframework.util.SocketUtils;
/** /**
* Sample Application to show Tomcat running two connectors * Sample Application to show Tomcat running two connectors.
* *
* @author Brock Mills * @author Brock Mills
* @author Andy Wilkinson * @author Andy Wilkinson
......
...@@ -127,7 +127,7 @@ public class SampleTomcatTwoConnectorsApplicationTests { ...@@ -127,7 +127,7 @@ public class SampleTomcatTwoConnectorsApplicationTests {
private final HostnameVerifier verifier; private final HostnameVerifier verifier;
public MySimpleClientHttpRequestFactory(final HostnameVerifier verifier) { MySimpleClientHttpRequestFactory(final HostnameVerifier verifier) {
this.verifier = verifier; this.verifier = verifier;
} }
......
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -55,6 +55,13 @@ public class NonAutoConfigurationSampleTomcatApplicationTests { ...@@ -55,6 +55,13 @@ public class NonAutoConfigurationSampleTomcatApplicationTests {
@Autowired @Autowired
private TestRestTemplate restTemplate; private TestRestTemplate restTemplate;
@Test
public void testHome() throws Exception {
ResponseEntity<String> entity = this.restTemplate.getForEntity("/", String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody()).isEqualTo("Hello World");
}
@Configuration @Configuration
@Import({ EmbeddedServletContainerAutoConfiguration.class, @Import({ EmbeddedServletContainerAutoConfiguration.class,
DispatcherServletAutoConfiguration.class, DispatcherServletAutoConfiguration.class,
...@@ -71,11 +78,4 @@ public class NonAutoConfigurationSampleTomcatApplicationTests { ...@@ -71,11 +78,4 @@ public class NonAutoConfigurationSampleTomcatApplicationTests {
} }
@Test
public void testHome() throws Exception {
ResponseEntity<String> entity = this.restTemplate.getForEntity("/", String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody()).isEqualTo("Hello World");
}
} }
spring.mvc.view.prefix: /WEB-INF/jsp/ spring.mvc.view.prefix: /WEB-INF/jsp/
spring.mvc.view.suffix: .jsp spring.mvc.view.suffix: .jsp
application.message: Hello Phil application.message: Hello Phil
\ No newline at end of file
server.port = 8443 server.port = 8443
server.ssl.key-store = classpath:sample.jks server.ssl.key-store = classpath:sample.jks
server.ssl.key-store-password = secret server.ssl.key-store-password = secret
server.ssl.key-password = password server.ssl.key-password = password
\ No newline at end of file
...@@ -2,4 +2,4 @@ server.undertow.accesslog.enabled=true ...@@ -2,4 +2,4 @@ server.undertow.accesslog.enabled=true
server.undertow.accesslog.dir=target/logs server.undertow.accesslog.dir=target/logs
server.undertow.accesslog.pattern=combined server.undertow.accesslog.pattern=combined
server.compression.enabled=true server.compression.enabled=true
server.compression.min-response-size=1 server.compression.min-response-size=1
\ No newline at end of file
/* /*
* Copyright 2012-2016 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -21,11 +21,8 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; ...@@ -21,11 +21,8 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.support.SpringBootServletInitializer; import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.annotation.PropertySource; import org.springframework.context.annotation.PropertySource;
/**
* Sample WAR application
*/
@SpringBootApplication @SpringBootApplication
@PropertySource(value = { "WEB-INF/custom.properties" }) @PropertySource("WEB-INF/custom.properties")
public class SampleWarApplication extends SpringBootServletInitializer { public class SampleWarApplication extends SpringBootServletInitializer {
public static void main(String[] args) { public static void main(String[] args) {
......
application.message: Hello, Andy application.message: Hello, Andy
\ No newline at end of file
# Allow templates to be reloaded at dev time # Allow templates to be reloaded at dev time
spring.groovy.template.cache: false spring.groovy.template.cache: false
logging.level.org.springframework.web: INFO logging.level.org.springframework.web: INFO
\ No newline at end of file
/* /*
* Copyright 2012-2016 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -84,14 +84,10 @@ public class MessageControllerWebTests { ...@@ -84,14 +84,10 @@ public class MessageControllerWebTests {
private final String regex; private final String regex;
public RegexMatcher(String regex) { RegexMatcher(String regex) {
this.regex = regex; this.regex = regex;
} }
public static org.hamcrest.Matcher<java.lang.String> matches(String regex) {
return new RegexMatcher(regex);
}
@Override @Override
public boolean matchesSafely(String item) { public boolean matchesSafely(String item) {
return Pattern.compile(this.regex).matcher(item).find(); return Pattern.compile(this.regex).matcher(item).find();
...@@ -108,6 +104,10 @@ public class MessageControllerWebTests { ...@@ -108,6 +104,10 @@ public class MessageControllerWebTests {
.appendText(this.regex); .appendText(this.regex);
} }
public static org.hamcrest.Matcher<java.lang.String> matches(String regex) {
return new RegexMatcher(regex);
}
} }
} }
spring.mvc.view.prefix: /WEB-INF/jsp/ spring.mvc.view.prefix: /WEB-INF/jsp/
spring.mvc.view.suffix: .jsp spring.mvc.view.suffix: .jsp
application.message: Hello Phil application.message: Hello Phil
\ No newline at end of file
/* /*
* Copyright 2012-2016 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -41,6 +41,16 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter ...@@ -41,6 +41,16 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
@EnableGlobalMethodSecurity(securedEnabled = true) @EnableGlobalMethodSecurity(securedEnabled = true)
public class SampleMethodSecurityApplication extends WebMvcConfigurerAdapter { public class SampleMethodSecurityApplication extends WebMvcConfigurerAdapter {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/login").setViewName("login");
registry.addViewController("/access").setViewName("access");
}
public static void main(String[] args) throws Exception {
new SpringApplicationBuilder(SampleMethodSecurityApplication.class).run(args);
}
@Controller @Controller
protected static class HomeController { protected static class HomeController {
...@@ -55,16 +65,6 @@ public class SampleMethodSecurityApplication extends WebMvcConfigurerAdapter { ...@@ -55,16 +65,6 @@ public class SampleMethodSecurityApplication extends WebMvcConfigurerAdapter {
} }
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/login").setViewName("login");
registry.addViewController("/access").setViewName("access");
}
public static void main(String[] args) throws Exception {
new SpringApplicationBuilder(SampleMethodSecurityApplication.class).run(args);
}
@Order(Ordered.HIGHEST_PRECEDENCE) @Order(Ordered.HIGHEST_PRECEDENCE)
@Configuration @Configuration
protected static class AuthenticationSecurity protected static class AuthenticationSecurity
......
spring.thymeleaf.cache: false spring.thymeleaf.cache: false
logging.level.org.springframework.security: INFO logging.level.org.springframework.security: INFO
\ No newline at end of file
application.message: Hello, Andy application.message: Hello, Andy
\ No newline at end of file
spring.thymeleaf.cache: false spring.thymeleaf.cache: false
security.basic.enabled: false security.basic.enabled: false
logging.level.org.springframework.security: INFO logging.level.org.springframework.security: INFO
\ No newline at end of file
debug: true debug: true
spring.thymeleaf.cache: false spring.thymeleaf.cache: false
security.basic.enabled: false security.basic.enabled: false
logging.level.org.springframework.security: INFO logging.level.org.springframework.security: INFO
\ No newline at end of file
...@@ -3,4 +3,4 @@ security.basic.enabled: false ...@@ -3,4 +3,4 @@ security.basic.enabled: false
# demo only: # demo only:
security.user.password: password security.user.password: password
logging.level.org.springframework.security: INFO logging.level.org.springframework.security: INFO
logging.level.org.springframework.boot.actuate.audit.listener.AuditListener: DEBUG logging.level.org.springframework.boot.actuate.audit.listener.AuditListener: DEBUG
\ No newline at end of file
/* /*
* Copyright 2012-2016 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -20,9 +20,6 @@ import java.util.concurrent.ConcurrentHashMap; ...@@ -20,9 +20,6 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
/**
* @author Dave Syer
*/
public class InMemoryMessageRepository implements MessageRepository { public class InMemoryMessageRepository implements MessageRepository {
private static AtomicLong counter = new AtomicLong(); private static AtomicLong counter = new AtomicLong();
......
...@@ -20,9 +20,6 @@ import java.util.Calendar; ...@@ -20,9 +20,6 @@ import java.util.Calendar;
import org.hibernate.validator.constraints.NotEmpty; import org.hibernate.validator.constraints.NotEmpty;
/**
* @author Rob Winch
*/
public class Message { public class Message {
private Long id; private Long id;
......
/* /*
* Copyright 2012-2016 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -16,9 +16,6 @@ ...@@ -16,9 +16,6 @@
package sample.web.thymeleaf3; package sample.web.thymeleaf3;
/**
* @author Rob Winch
*/
public interface MessageRepository { public interface MessageRepository {
Iterable<Message> findAll(); Iterable<Message> findAll();
......
/* /*
* Copyright 2012-2016 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -31,10 +31,6 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -31,10 +31,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.support.RedirectAttributes; import org.springframework.web.servlet.mvc.support.RedirectAttributes;
/**
* @author Rob Winch
* @author Doo-Hwan Kwak
*/
@Controller @Controller
@RequestMapping("/") @RequestMapping("/")
public class MessageController { public class MessageController {
...@@ -77,14 +73,14 @@ public class MessageController { ...@@ -77,14 +73,14 @@ public class MessageController {
throw new RuntimeException("Expected exception in controller"); throw new RuntimeException("Expected exception in controller");
} }
@GetMapping(value = "delete/{id}") @GetMapping("delete/{id}")
public ModelAndView delete(@PathVariable("id") Long id) { public ModelAndView delete(@PathVariable("id") Long id) {
this.messageRepository.deleteMessage(id); this.messageRepository.deleteMessage(id);
Iterable<Message> messages = this.messageRepository.findAll(); Iterable<Message> messages = this.messageRepository.findAll();
return new ModelAndView("messages/list", "messages", messages); return new ModelAndView("messages/list", "messages", messages);
} }
@GetMapping(value = "modify/{id}") @GetMapping("modify/{id}")
public ModelAndView modifyForm(@PathVariable("id") Message message) { public ModelAndView modifyForm(@PathVariable("id") Message message) {
return new ModelAndView("messages/form", "message", message); return new ModelAndView("messages/form", "message", message);
} }
......
...@@ -84,14 +84,10 @@ public class MessageControllerWebTests { ...@@ -84,14 +84,10 @@ public class MessageControllerWebTests {
private final String regex; private final String regex;
public RegexMatcher(String regex) { RegexMatcher(String regex) {
this.regex = regex; this.regex = regex;
} }
public static org.hamcrest.Matcher<java.lang.String> matches(String regex) {
return new RegexMatcher(regex);
}
@Override @Override
public boolean matchesSafely(String item) { public boolean matchesSafely(String item) {
return Pattern.compile(this.regex).matcher(item).find(); return Pattern.compile(this.regex).matcher(item).find();
...@@ -108,6 +104,10 @@ public class MessageControllerWebTests { ...@@ -108,6 +104,10 @@ public class MessageControllerWebTests {
.appendText(this.regex); .appendText(this.regex);
} }
public static org.hamcrest.Matcher<java.lang.String> matches(String regex) {
return new RegexMatcher(regex);
}
} }
} }
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -20,9 +20,6 @@ import java.util.concurrent.ConcurrentHashMap; ...@@ -20,9 +20,6 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
/**
* @author Dave Syer
*/
public class InMemoryMessageRepository implements MessageRepository { public class InMemoryMessageRepository implements MessageRepository {
private static AtomicLong counter = new AtomicLong(); private static AtomicLong counter = new AtomicLong();
......
/* /*
* Copyright 2012-2018 the original author or authors. * Copyright 2012-2018 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 * Licensed under the Apache License, Version 2.0 (the "License");
* the License. You may obtain a copy of the License at * 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 * Unless required by applicable law or agreed to in writing, software
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * distributed under the License is distributed on an "AS IS" BASIS,
* specific language governing permissions and limitations under the License. * 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 sample.web.ui; package sample.web.ui;
...@@ -17,9 +20,6 @@ import java.util.Calendar; ...@@ -17,9 +20,6 @@ import java.util.Calendar;
import org.hibernate.validator.constraints.NotEmpty; import org.hibernate.validator.constraints.NotEmpty;
/**
* @author Rob Winch
*/
public class Message { public class Message {
private Long id; private Long id;
......
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2018 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 * Licensed under the Apache License, Version 2.0 (the "License");
* the License. You may obtain a copy of the License at * 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 * Unless required by applicable law or agreed to in writing, software
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * distributed under the License is distributed on an "AS IS" BASIS,
* specific language governing permissions and limitations under the License. * 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 sample.web.ui; package sample.web.ui;
/**
* @author Rob Winch
*/
public interface MessageRepository { public interface MessageRepository {
Iterable<Message> findAll(); Iterable<Message> findAll();
......
/* /*
* Copyright 2012-2016 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -31,10 +31,6 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -31,10 +31,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.support.RedirectAttributes; import org.springframework.web.servlet.mvc.support.RedirectAttributes;
/**
* @author Rob Winch
* @author Doo-Hwan Kwak
*/
@Controller @Controller
@RequestMapping("/") @RequestMapping("/")
public class MessageController { public class MessageController {
...@@ -77,14 +73,14 @@ public class MessageController { ...@@ -77,14 +73,14 @@ public class MessageController {
throw new RuntimeException("Expected exception in controller"); throw new RuntimeException("Expected exception in controller");
} }
@GetMapping(value = "delete/{id}") @GetMapping("delete/{id}")
public ModelAndView delete(@PathVariable("id") Long id) { public ModelAndView delete(@PathVariable("id") Long id) {
this.messageRepository.deleteMessage(id); this.messageRepository.deleteMessage(id);
Iterable<Message> messages = this.messageRepository.findAll(); Iterable<Message> messages = this.messageRepository.findAll();
return new ModelAndView("messages/list", "messages", messages); return new ModelAndView("messages/list", "messages", messages);
} }
@GetMapping(value = "modify/{id}") @GetMapping("modify/{id}")
public ModelAndView modifyForm(@PathVariable("id") Message message) { public ModelAndView modifyForm(@PathVariable("id") Message message) {
return new ModelAndView("messages/form", "message", message); return new ModelAndView("messages/form", "message", message);
} }
......
# Allow Thymeleaf templates to be reloaded at dev time # Allow Thymeleaf templates to be reloaded at dev time
spring.thymeleaf.cache: false spring.thymeleaf.cache: false
server.tomcat.access_log_enabled: true server.tomcat.access_log_enabled: true
server.tomcat.basedir: target/tomcat server.tomcat.basedir: target/tomcat
\ No newline at end of file
...@@ -84,14 +84,10 @@ public class MessageControllerWebTests { ...@@ -84,14 +84,10 @@ public class MessageControllerWebTests {
private final String regex; private final String regex;
public RegexMatcher(String regex) { RegexMatcher(String regex) {
this.regex = regex; this.regex = regex;
} }
public static org.hamcrest.Matcher<java.lang.String> matches(String regex) {
return new RegexMatcher(regex);
}
@Override @Override
public boolean matchesSafely(String item) { public boolean matchesSafely(String item) {
return Pattern.compile(this.regex).matcher(item).find(); return Pattern.compile(this.regex).matcher(item).find();
...@@ -108,6 +104,10 @@ public class MessageControllerWebTests { ...@@ -108,6 +104,10 @@ public class MessageControllerWebTests {
.appendText(this.regex); .appendText(this.regex);
} }
public static org.hamcrest.Matcher<java.lang.String> matches(String regex) {
return new RegexMatcher(regex);
}
} }
} }
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -21,7 +21,7 @@ public class DefaultEchoService implements EchoService { ...@@ -21,7 +21,7 @@ public class DefaultEchoService implements EchoService {
private final String echoFormat; private final String echoFormat;
public DefaultEchoService(String echoFormat) { public DefaultEchoService(String echoFormat) {
this.echoFormat = (echoFormat != null) ? echoFormat : "%s"; this.echoFormat = (echoFormat != null ? echoFormat : "%s");
} }
@Override @Override
......
/* /*
* Licensed to the Apache Software Foundation (ASF) under one or more * Copyright 2012-2018 the original author or authors.
* contributor license agreements. See the NOTICE file distributed with *
* this work for additional information regarding copyright ownership. * Licensed under the Apache License, Version 2.0 (the "License");
* The ASF licenses this file to You under the Apache License, Version 2.0 * you may not use this file except in compliance with the License.
* (the "License"); you may not use this file except in compliance with * You may obtain a copy of the License at
* 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
* *
......
/* /*
* Licensed to the Apache Software Foundation (ASF) under one or more * Copyright 2012-2018 the original author or authors.
* contributor license agreements. See the NOTICE file distributed with *
* this work for additional information regarding copyright ownership. * Licensed under the Apache License, Version 2.0 (the "License");
* The ASF licenses this file to You under the Apache License, Version 2.0 * you may not use this file except in compliance with the License.
* (the "License"); you may not use this file except in compliance with * You may obtain a copy of the License at
* 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
* *
...@@ -19,16 +18,16 @@ package samples.websocket.jetty.snake; ...@@ -19,16 +18,16 @@ package samples.websocket.jetty.snake;
public class Location { public class Location {
/**
* The X location.
*/
public int x; public int x;
/**
* The Y location.
*/
public int y; public int y;
public static final int GRID_SIZE = 10;
public static final int PLAYFIELD_HEIGHT = 480;
public static final int PLAYFIELD_WIDTH = 640;
public Location(int x, int y) { public Location(int x, int y) {
this.x = x; this.x = x;
this.y = y; this.y = y;
...@@ -37,13 +36,13 @@ public class Location { ...@@ -37,13 +36,13 @@ public class Location {
public Location getAdjacentLocation(Direction direction) { public Location getAdjacentLocation(Direction direction) {
switch (direction) { switch (direction) {
case NORTH: case NORTH:
return new Location(this.x, this.y - Location.GRID_SIZE); return new Location(this.x, this.y - SnakeUtils.GRID_SIZE);
case SOUTH: case SOUTH:
return new Location(this.x, this.y + Location.GRID_SIZE); return new Location(this.x, this.y + SnakeUtils.GRID_SIZE);
case EAST: case EAST:
return new Location(this.x + Location.GRID_SIZE, this.y); return new Location(this.x + SnakeUtils.GRID_SIZE, this.y);
case WEST: case WEST:
return new Location(this.x - Location.GRID_SIZE, this.y); return new Location(this.x - SnakeUtils.GRID_SIZE, this.y);
case NONE: case NONE:
// fall through // fall through
default: default:
...@@ -59,16 +58,13 @@ public class Location { ...@@ -59,16 +58,13 @@ public class Location {
if (o == null || getClass() != o.getClass()) { if (o == null || getClass() != o.getClass()) {
return false; return false;
} }
Location location = (Location) o; Location location = (Location) o;
if (this.x != location.x) { if (this.x != location.x) {
return false; return false;
} }
if (this.y != location.y) { if (this.y != location.y) {
return false; return false;
} }
return true; return true;
} }
......
/* /*
* Licensed to the Apache Software Foundation (ASF) under one or more * Copyright 2012-2018 the original author or authors.
* contributor license agreements. See the NOTICE file distributed with *
* this work for additional information regarding copyright ownership. * Licensed under the Apache License, Version 2.0 (the "License");
* The ASF licenses this file to You under the Apache License, Version 2.0 * you may not use this file except in compliance with the License.
* (the "License"); you may not use this file except in compliance with * You may obtain a copy of the License at
* 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
* *
......
/* /*
* Licensed to the Apache Software Foundation (ASF) under one or more * Copyright 2012-2018 the original author or authors.
* contributor license agreements. See the NOTICE file distributed with *
* this work for additional information regarding copyright ownership. * Licensed under the Apache License, Version 2.0 (the "License");
* The ASF licenses this file to You under the Apache License, Version 2.0 * you may not use this file except in compliance with the License.
* (the "License"); you may not use this file except in compliance with * You may obtain a copy of the License at
* 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
* *
...@@ -31,7 +30,7 @@ import org.slf4j.LoggerFactory; ...@@ -31,7 +30,7 @@ import org.slf4j.LoggerFactory;
/** /**
* Sets up the timer for the multi-player snake game WebSocket example. * Sets up the timer for the multi-player snake game WebSocket example.
*/ */
public class SnakeTimer { public final class SnakeTimer {
private static final long TICK_DELAY = 100; private static final long TICK_DELAY = 100;
...@@ -43,6 +42,9 @@ public class SnakeTimer { ...@@ -43,6 +42,9 @@ public class SnakeTimer {
private static Timer gameTimer = null; private static Timer gameTimer = null;
private SnakeTimer() {
}
public static void addSnake(Snake snake) { public static void addSnake(Snake snake) {
synchronized (MONITOR) { synchronized (MONITOR) {
if (snakes.isEmpty()) { if (snakes.isEmpty()) {
......
/* /*
* Licensed to the Apache Software Foundation (ASF) under one or more * Copyright 2012-2018 the original author or authors.
* contributor license agreements. See the NOTICE file distributed with *
* this work for additional information regarding copyright ownership. * Licensed under the Apache License, Version 2.0 (the "License");
* The ASF licenses this file to You under the Apache License, Version 2.0 * you may not use this file except in compliance with the License.
* (the "License"); you may not use this file except in compliance with * You may obtain a copy of the License at
* 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
* *
...@@ -20,16 +19,28 @@ package samples.websocket.jetty.snake; ...@@ -20,16 +19,28 @@ package samples.websocket.jetty.snake;
import java.awt.Color; import java.awt.Color;
import java.util.Random; import java.util.Random;
public class SnakeUtils { public final class SnakeUtils {
/**
* The width of the playfield.
*/
public static final int PLAYFIELD_WIDTH = 640; public static final int PLAYFIELD_WIDTH = 640;
/**
* The height of the playfield.
*/
public static final int PLAYFIELD_HEIGHT = 480; public static final int PLAYFIELD_HEIGHT = 480;
/**
* The grid size.
*/
public static final int GRID_SIZE = 10; public static final int GRID_SIZE = 10;
private static final Random random = new Random(); private static final Random random = new Random();
private SnakeUtils() {
}
public static String getRandomHexColor() { public static String getRandomHexColor() {
float hue = random.nextFloat(); float hue = random.nextFloat();
// sat between 0.1 and 0.3 // sat between 0.1 and 0.3
......
/* /*
* Licensed to the Apache Software Foundation (ASF) under one or more * Copyright 2012-2018 the original author or authors.
* contributor license agreements. See the NOTICE file distributed with *
* this work for additional information regarding copyright ownership. * Licensed under the Apache License, Version 2.0 (the "License");
* The ASF licenses this file to You under the Apache License, Version 2.0 * you may not use this file except in compliance with the License.
* (the "License"); you may not use this file except in compliance with * You may obtain a copy of the License at
* 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
* *
...@@ -29,12 +28,6 @@ import org.springframework.web.socket.handler.TextWebSocketHandler; ...@@ -29,12 +28,6 @@ import org.springframework.web.socket.handler.TextWebSocketHandler;
public class SnakeWebSocketHandler extends TextWebSocketHandler { public class SnakeWebSocketHandler extends TextWebSocketHandler {
public static final int PLAYFIELD_WIDTH = 640;
public static final int PLAYFIELD_HEIGHT = 480;
public static final int GRID_SIZE = 10;
private static final AtomicInteger snakeIds = new AtomicInteger(0); private static final AtomicInteger snakeIds = new AtomicInteger(0);
private static final Random random = new Random(); private static final Random random = new Random();
...@@ -54,15 +47,15 @@ public class SnakeWebSocketHandler extends TextWebSocketHandler { ...@@ -54,15 +47,15 @@ public class SnakeWebSocketHandler extends TextWebSocketHandler {
} }
public static Location getRandomLocation() { public static Location getRandomLocation() {
int x = roundByGridSize(random.nextInt(PLAYFIELD_WIDTH)); int x = roundByGridSize(random.nextInt(SnakeUtils.PLAYFIELD_WIDTH));
int y = roundByGridSize(random.nextInt(PLAYFIELD_HEIGHT)); int y = roundByGridSize(random.nextInt(SnakeUtils.PLAYFIELD_HEIGHT));
return new Location(x, y); return new Location(x, y);
} }
private static int roundByGridSize(int value) { private static int roundByGridSize(int value) {
value = value + (GRID_SIZE / 2); value = value + (SnakeUtils.GRID_SIZE / 2);
value = value / GRID_SIZE; value = value / SnakeUtils.GRID_SIZE;
value = value * GRID_SIZE; value = value * SnakeUtils.GRID_SIZE;
return value; return value;
} }
......
/* /*
* Copyright 2012-2016 the original author or authors. * Copyright 2012-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -21,7 +21,7 @@ public class DefaultEchoService implements EchoService { ...@@ -21,7 +21,7 @@ public class DefaultEchoService implements EchoService {
private final String echoFormat; private final String echoFormat;
public DefaultEchoService(String echoFormat) { public DefaultEchoService(String echoFormat) {
this.echoFormat = (echoFormat != null) ? echoFormat : "%s"; this.echoFormat = (echoFormat != null ? echoFormat : "%s");
} }
@Override @Override
......
/* /*
* Licensed to the Apache Software Foundation (ASF) under one or more * Copyright 2012-2018 the original author or authors.
* contributor license agreements. See the NOTICE file distributed with *
* this work for additional information regarding copyright ownership. * Licensed under the Apache License, Version 2.0 (the "License");
* The ASF licenses this file to You under the Apache License, Version 2.0 * you may not use this file except in compliance with the License.
* (the "License"); you may not use this file except in compliance with * You may obtain a copy of the License at
* 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
* *
......
/* /*
* Licensed to the Apache Software Foundation (ASF) under one or more * Copyright 2012-2018 the original author or authors.
* contributor license agreements. See the NOTICE file distributed with *
* this work for additional information regarding copyright ownership. * Licensed under the Apache License, Version 2.0 (the "License");
* The ASF licenses this file to You under the Apache License, Version 2.0 * you may not use this file except in compliance with the License.
* (the "License"); you may not use this file except in compliance with * You may obtain a copy of the License at
* 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
* *
...@@ -19,16 +18,16 @@ package samples.websocket.jetty93.snake; ...@@ -19,16 +18,16 @@ package samples.websocket.jetty93.snake;
public class Location { public class Location {
/**
* The X location.
*/
public int x; public int x;
/**
* The Y location.
*/
public int y; public int y;
public static final int GRID_SIZE = 10;
public static final int PLAYFIELD_HEIGHT = 480;
public static final int PLAYFIELD_WIDTH = 640;
public Location(int x, int y) { public Location(int x, int y) {
this.x = x; this.x = x;
this.y = y; this.y = y;
...@@ -37,13 +36,13 @@ public class Location { ...@@ -37,13 +36,13 @@ public class Location {
public Location getAdjacentLocation(Direction direction) { public Location getAdjacentLocation(Direction direction) {
switch (direction) { switch (direction) {
case NORTH: case NORTH:
return new Location(this.x, this.y - Location.GRID_SIZE); return new Location(this.x, this.y - SnakeUtils.GRID_SIZE);
case SOUTH: case SOUTH:
return new Location(this.x, this.y + Location.GRID_SIZE); return new Location(this.x, this.y + SnakeUtils.GRID_SIZE);
case EAST: case EAST:
return new Location(this.x + Location.GRID_SIZE, this.y); return new Location(this.x + SnakeUtils.GRID_SIZE, this.y);
case WEST: case WEST:
return new Location(this.x - Location.GRID_SIZE, this.y); return new Location(this.x - SnakeUtils.GRID_SIZE, this.y);
case NONE: case NONE:
// fall through // fall through
default: default:
...@@ -59,16 +58,13 @@ public class Location { ...@@ -59,16 +58,13 @@ public class Location {
if (o == null || getClass() != o.getClass()) { if (o == null || getClass() != o.getClass()) {
return false; return false;
} }
Location location = (Location) o; Location location = (Location) o;
if (this.x != location.x) { if (this.x != location.x) {
return false; return false;
} }
if (this.y != location.y) { if (this.y != location.y) {
return false; return false;
} }
return true; return true;
} }
......
/* /*
* Licensed to the Apache Software Foundation (ASF) under one or more * Copyright 2012-2018 the original author or authors.
* contributor license agreements. See the NOTICE file distributed with *
* this work for additional information regarding copyright ownership. * Licensed under the Apache License, Version 2.0 (the "License");
* The ASF licenses this file to You under the Apache License, Version 2.0 * you may not use this file except in compliance with the License.
* (the "License"); you may not use this file except in compliance with * You may obtain a copy of the License at
* 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
* *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment