Skip to content

Commit c12ba10

Browse files
authored
fix a comment (#810)
1. fix poster comment 2. run through google-java-format, (wasn’t totally happy)
1 parent d7559e0 commit c12ba10

File tree

4 files changed

+50
-55
lines changed

4 files changed

+50
-55
lines changed

appengine-java8/analytics/src/main/java/com/example/appengine/analytics/AnalyticsServlet.java

+18-18
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,50 @@
11
/**
22
* Copyright 2015 Google Inc.
33
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
4+
* <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5+
* except in compliance with the License. You may obtain a copy of the License at
76
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
7+
* <p>http://www.apache.org/licenses/LICENSE-2.0
98
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
9+
* <p>Unless required by applicable law or agreed to in writing, software distributed under the
10+
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11+
* express or implied. See the License for the specific language governing permissions and
1412
* limitations under the License.
1513
*/
16-
1714
package com.example.appengine.analytics;
1815

1916
import com.google.appengine.api.urlfetch.URLFetchService;
2017
import com.google.appengine.api.urlfetch.URLFetchServiceFactory;
21-
22-
import org.apache.http.client.utils.URIBuilder;
23-
2418
import java.io.IOException;
2519
import java.net.URI;
2620
import java.net.URISyntaxException;
2721
import java.net.URL;
28-
2922
import javax.servlet.ServletException;
3023
import javax.servlet.annotation.WebServlet;
3124
import javax.servlet.http.HttpServlet;
3225
import javax.servlet.http.HttpServletRequest;
3326
import javax.servlet.http.HttpServletResponse;
27+
import org.apache.http.client.utils.URIBuilder;
3428

3529
// [START example]
3630
@SuppressWarnings("serial")
3731
// With @WebServlet annotation the webapp/WEB-INF/web.xml is no longer required.
38-
@WebServlet(name = "analytics", description = "Analytics: Send Analytics Event to Google Analytics",
39-
urlPatterns = "/analytics")
32+
@WebServlet(
33+
name = "analytics",
34+
description = "Analytics: Send Analytics Event to Google Analytics",
35+
urlPatterns = "/analytics"
36+
)
4037
public class AnalyticsServlet extends HttpServlet {
4138

4239
@Override
43-
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException,
44-
ServletException {
40+
public void doGet(HttpServletRequest req, HttpServletResponse resp)
41+
throws IOException, ServletException {
4542
String trackingId = System.getenv("GA_TRACKING_ID");
4643
URIBuilder builder = new URIBuilder();
47-
builder.setScheme("http").setHost("www.google-analytics.com").setPath("/collect")
44+
builder
45+
.setScheme("http")
46+
.setHost("www.google-analytics.com")
47+
.setPath("/collect")
4848
.addParameter("v", "1") // API Version.
4949
.addParameter("tid", trackingId) // Tracking ID / Property ID.
5050
// Anonymous Client Identifier. Ideally, this should be a UUID that

appengine-java8/users/src/main/java/com/example/appengine/users/UsersServlet.java

+16-15
Original file line numberDiff line numberDiff line change
@@ -18,38 +18,39 @@
1818

1919
import com.google.appengine.api.users.UserService;
2020
import com.google.appengine.api.users.UserServiceFactory;
21-
2221
import java.io.IOException;
23-
2422
import javax.servlet.annotation.WebServlet;
2523
import javax.servlet.http.HttpServlet;
2624
import javax.servlet.http.HttpServletRequest;
2725
import javax.servlet.http.HttpServletResponse;
2826

2927
// With @WebServlet annotation the webapp/WEB-INF/web.xml is no longer required.
30-
@WebServlet(name = "UserAPI", description = "UserAPI: Login / Logout with UserService",
31-
urlPatterns = "/userapi")
28+
@WebServlet(
29+
name = "UserAPI",
30+
description = "UserAPI: Login / Logout with UserService",
31+
urlPatterns = "/userapi"
32+
)
3233
public class UsersServlet extends HttpServlet {
3334
@Override
34-
public void doGet(HttpServletRequest req, HttpServletResponse resp)
35-
throws IOException {
35+
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
3636
UserService userService = UserServiceFactory.getUserService();
3737

3838
String thisUrl = req.getRequestURI();
3939

4040
resp.setContentType("text/html");
4141
if (req.getUserPrincipal() != null) {
42-
resp.getWriter().println("<p>Hello, "
43-
+ req.getUserPrincipal().getName()
44-
+ "! You can <a href=\""
45-
+ userService.createLogoutURL(thisUrl)
46-
+ "\">sign out</a>.</p>");
42+
resp.getWriter()
43+
.println(
44+
"<p>Hello, "
45+
+ req.getUserPrincipal().getName()
46+
+ "! You can <a href=\""
47+
+ userService.createLogoutURL(thisUrl)
48+
+ "\">sign out</a>.</p>");
4749
} else {
48-
resp.getWriter().println("<p>Please <a href=\""
49-
+ userService.createLoginURL(thisUrl)
50-
+ "\">sign in</a>.</p>");
50+
resp.getWriter()
51+
.println(
52+
"<p>Please <a href=\"" + userService.createLoginURL(thisUrl) + "\">sign in</a>.</p>");
5153
}
5254
}
5355
}
5456
// [END users_API_example]
55-

appengine-java8/users/src/test/java/com/example/appengine/users/UsersServletTest.java

+15-21
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@
2020
import static org.mockito.Mockito.when;
2121

2222
import com.google.appengine.tools.development.testing.LocalServiceTestHelper;
23-
23+
import java.io.PrintWriter;
24+
import java.io.StringWriter;
25+
import javax.management.remote.JMXPrincipal;
26+
import javax.servlet.http.HttpServletRequest;
27+
import javax.servlet.http.HttpServletResponse;
2428
import org.junit.After;
2529
import org.junit.Before;
2630
import org.junit.Test;
@@ -29,20 +33,11 @@
2933
import org.mockito.Mock;
3034
import org.mockito.MockitoAnnotations;
3135

32-
import java.io.PrintWriter;
33-
import java.io.StringWriter;
34-
35-
import javax.management.remote.JMXPrincipal;
36-
import javax.servlet.http.HttpServletRequest;
37-
import javax.servlet.http.HttpServletResponse;
38-
39-
/**
40-
* Unit tests for {@link UsersServlet}.
41-
*/
36+
/** Unit tests for {@link UsersServlet}. */
4237
@RunWith(JUnit4.class)
4338
public class UsersServletTest {
44-
private static final String FAKE_URL = "fakey.fake.fak";
45-
private static final String FAKE_NAME = "Fake";
39+
private static final String FAKE_URL = "fakey.fake.fak";
40+
private static final String FAKE_NAME = "Fake";
4641
// Set up a helper so that the ApiProxy returns a valid environment for local testing.
4742
private final LocalServiceTestHelper helper = new LocalServiceTestHelper();
4843

@@ -65,7 +60,7 @@ public void setUp() throws Exception {
6560
// If the user is logged in, use this request
6661
when(mockRequestLoggedIn.getRequestURI()).thenReturn(FAKE_URL);
6762
// Most of the classes that implement Principal have been
68-
// deprecated. JMXPrincipal seems like a safe choice.
63+
// deprecated. JMXPrincipal seems like a safe choice.
6964
when(mockRequestLoggedIn.getUserPrincipal()).thenReturn(new JMXPrincipal(FAKE_NAME));
7065

7166
// Set up a fake HTTP response.
@@ -75,35 +70,34 @@ public void setUp() throws Exception {
7570
servletUnderTest = new UsersServlet();
7671
}
7772

78-
@After public void tearDown() {
73+
@After
74+
public void tearDown() {
7975
helper.tearDown();
8076
}
8177

8278
@Test
8379
public void doGet_userNotLoggedIn_writesResponse() throws Exception {
8480
servletUnderTest.doGet(mockRequestNotLoggedIn, mockResponse);
8581

86-
// If a user isn't logged in, we expect a prompt
82+
// If a user isn't logged in, we expect a prompt
8783
// to login to be returned.
8884
assertThat(responseWriter.toString())
8985
.named("UsersServlet response")
9086
.contains("<p>Please <a href=");
9187
assertThat(responseWriter.toString())
9288
.named("UsersServlet response")
93-
.contains("sign in</a>.</p>");
89+
.contains("sign in</a>.</p>");
9490
}
9591

9692
@Test
9793
public void doGet_userLoggedIn_writesResponse() throws Exception {
9894
servletUnderTest.doGet(mockRequestLoggedIn, mockResponse);
9995

100-
// If a user is logged in, we expect a prompt
96+
// If a user is logged in, we expect a prompt
10197
// to logout to be returned.
10298
assertThat(responseWriter.toString())
10399
.named("UsersServlet response")
104100
.contains("<p>Hello, " + FAKE_NAME + "!");
105-
assertThat(responseWriter.toString())
106-
.named("UsersServlet response")
107-
.contains("sign out");
101+
assertThat(responseWriter.toString()).named("UsersServlet response").contains("sign out");
108102
}
109103
}

flexible/postgres/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
<user>root</user>
3838
<password>myPassword</password>
3939
<database>sqldemo</database>
40-
<!-- [START_EXCLUDE] -->
40+
<!-- [START_EXCLUDE silent] -->
4141
<maven.compiler.target>1.8</maven.compiler.target>
4242
<maven.compiler.source>1.8</maven.compiler.source>
4343

0 commit comments

Comments
 (0)