From c12ba1013f2368571465da34f07d8b1d50361a9b Mon Sep 17 00:00:00 2001 From: Les Vogel Date: Tue, 15 Aug 2017 16:56:13 -0700 Subject: [PATCH] fix a comment (#810) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. fix poster comment 2. run through google-java-format, (wasn’t totally happy) --- .../appengine/analytics/AnalyticsServlet.java | 36 +++++++++---------- .../example/appengine/users/UsersServlet.java | 31 ++++++++-------- .../appengine/users/UsersServletTest.java | 36 ++++++++----------- flexible/postgres/pom.xml | 2 +- 4 files changed, 50 insertions(+), 55 deletions(-) diff --git a/appengine-java8/analytics/src/main/java/com/example/appengine/analytics/AnalyticsServlet.java b/appengine-java8/analytics/src/main/java/com/example/appengine/analytics/AnalyticsServlet.java index a8085a2b611..d4153212ffc 100644 --- a/appengine-java8/analytics/src/main/java/com/example/appengine/analytics/AnalyticsServlet.java +++ b/appengine-java8/analytics/src/main/java/com/example/appengine/analytics/AnalyticsServlet.java @@ -1,50 +1,50 @@ /** * Copyright 2015 Google Inc. * - * 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 + *

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 + *

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 + *

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 com.example.appengine.analytics; import com.google.appengine.api.urlfetch.URLFetchService; import com.google.appengine.api.urlfetch.URLFetchServiceFactory; - -import org.apache.http.client.utils.URIBuilder; - import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; - import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.apache.http.client.utils.URIBuilder; // [START example] @SuppressWarnings("serial") // With @WebServlet annotation the webapp/WEB-INF/web.xml is no longer required. -@WebServlet(name = "analytics", description = "Analytics: Send Analytics Event to Google Analytics", - urlPatterns = "/analytics") +@WebServlet( + name = "analytics", + description = "Analytics: Send Analytics Event to Google Analytics", + urlPatterns = "/analytics" +) public class AnalyticsServlet extends HttpServlet { @Override - public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException, - ServletException { + public void doGet(HttpServletRequest req, HttpServletResponse resp) + throws IOException, ServletException { String trackingId = System.getenv("GA_TRACKING_ID"); URIBuilder builder = new URIBuilder(); - builder.setScheme("http").setHost("www.google-analytics.com").setPath("/collect") + builder + .setScheme("http") + .setHost("www.google-analytics.com") + .setPath("/collect") .addParameter("v", "1") // API Version. .addParameter("tid", trackingId) // Tracking ID / Property ID. // Anonymous Client Identifier. Ideally, this should be a UUID that diff --git a/appengine-java8/users/src/main/java/com/example/appengine/users/UsersServlet.java b/appengine-java8/users/src/main/java/com/example/appengine/users/UsersServlet.java index 2752793c520..a4b7e298d93 100644 --- a/appengine-java8/users/src/main/java/com/example/appengine/users/UsersServlet.java +++ b/appengine-java8/users/src/main/java/com/example/appengine/users/UsersServlet.java @@ -18,38 +18,39 @@ import com.google.appengine.api.users.UserService; import com.google.appengine.api.users.UserServiceFactory; - import java.io.IOException; - import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; // With @WebServlet annotation the webapp/WEB-INF/web.xml is no longer required. -@WebServlet(name = "UserAPI", description = "UserAPI: Login / Logout with UserService", - urlPatterns = "/userapi") +@WebServlet( + name = "UserAPI", + description = "UserAPI: Login / Logout with UserService", + urlPatterns = "/userapi" +) public class UsersServlet extends HttpServlet { @Override - public void doGet(HttpServletRequest req, HttpServletResponse resp) - throws IOException { + public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { UserService userService = UserServiceFactory.getUserService(); String thisUrl = req.getRequestURI(); resp.setContentType("text/html"); if (req.getUserPrincipal() != null) { - resp.getWriter().println("

Hello, " - + req.getUserPrincipal().getName() - + "! You can sign out.

"); + resp.getWriter() + .println( + "

Hello, " + + req.getUserPrincipal().getName() + + "! You can sign out.

"); } else { - resp.getWriter().println("

Please sign in.

"); + resp.getWriter() + .println( + "

Please sign in.

"); } } } // [END users_API_example] - diff --git a/appengine-java8/users/src/test/java/com/example/appengine/users/UsersServletTest.java b/appengine-java8/users/src/test/java/com/example/appengine/users/UsersServletTest.java index ffc0a74785a..5c2c7a7df31 100644 --- a/appengine-java8/users/src/test/java/com/example/appengine/users/UsersServletTest.java +++ b/appengine-java8/users/src/test/java/com/example/appengine/users/UsersServletTest.java @@ -20,7 +20,11 @@ import static org.mockito.Mockito.when; import com.google.appengine.tools.development.testing.LocalServiceTestHelper; - +import java.io.PrintWriter; +import java.io.StringWriter; +import javax.management.remote.JMXPrincipal; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -29,20 +33,11 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import java.io.PrintWriter; -import java.io.StringWriter; - -import javax.management.remote.JMXPrincipal; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** - * Unit tests for {@link UsersServlet}. - */ +/** Unit tests for {@link UsersServlet}. */ @RunWith(JUnit4.class) public class UsersServletTest { - private static final String FAKE_URL = "fakey.fake.fak"; - private static final String FAKE_NAME = "Fake"; + private static final String FAKE_URL = "fakey.fake.fak"; + private static final String FAKE_NAME = "Fake"; // Set up a helper so that the ApiProxy returns a valid environment for local testing. private final LocalServiceTestHelper helper = new LocalServiceTestHelper(); @@ -65,7 +60,7 @@ public void setUp() throws Exception { // If the user is logged in, use this request when(mockRequestLoggedIn.getRequestURI()).thenReturn(FAKE_URL); // Most of the classes that implement Principal have been - // deprecated. JMXPrincipal seems like a safe choice. + // deprecated. JMXPrincipal seems like a safe choice. when(mockRequestLoggedIn.getUserPrincipal()).thenReturn(new JMXPrincipal(FAKE_NAME)); // Set up a fake HTTP response. @@ -75,7 +70,8 @@ public void setUp() throws Exception { servletUnderTest = new UsersServlet(); } - @After public void tearDown() { + @After + public void tearDown() { helper.tearDown(); } @@ -83,27 +79,25 @@ public void setUp() throws Exception { public void doGet_userNotLoggedIn_writesResponse() throws Exception { servletUnderTest.doGet(mockRequestNotLoggedIn, mockResponse); - // If a user isn't logged in, we expect a prompt + // If a user isn't logged in, we expect a prompt // to login to be returned. assertThat(responseWriter.toString()) .named("UsersServlet response") .contains("

Please .

"); + .contains("sign in.

"); } @Test public void doGet_userLoggedIn_writesResponse() throws Exception { servletUnderTest.doGet(mockRequestLoggedIn, mockResponse); - // If a user is logged in, we expect a prompt + // If a user is logged in, we expect a prompt // to logout to be returned. assertThat(responseWriter.toString()) .named("UsersServlet response") .contains("

Hello, " + FAKE_NAME + "!"); - assertThat(responseWriter.toString()) - .named("UsersServlet response") - .contains("sign out"); + assertThat(responseWriter.toString()).named("UsersServlet response").contains("sign out"); } } diff --git a/flexible/postgres/pom.xml b/flexible/postgres/pom.xml index 8ab2b6b78ac..cac3699752b 100644 --- a/flexible/postgres/pom.xml +++ b/flexible/postgres/pom.xml @@ -37,7 +37,7 @@ root myPassword sqldemo - + 1.8 1.8