GeezerVison is showing github.com — First pass of many formatting fixes (#820) · nnegrey/java-docs-samples@bd53b6c
File treeExpand file treeCollapse file tree Open diff view settings analytics/src/main/java/com/example/appengine/analytics main/java/com/example/appengine/appidentity test/java/com/example/appengine/appidentity
main/java/com/example/bigtable test/java/com/example/bigtable
cloudsql/src/main/java/com/example/appengine/cloudsql datastore-indexes-exploding/src main/java/com/example/appengine test/java/com/example/appengine
datastore-indexes-perfect/src main/java/com/example/appengine test/java/com/example/appengine
main/java/com/example/appengine test/java/com/example/appengine
test/java/com/example/appengine
endpoints-v2-backend/src/main/java/com/example/echo firebase-event-proxy/src/main/java/com/example/GaeFirebaseEventProxy main/java/com/example/appengine/firetactoe test/java/com/example/appengine/firetactoe
gaeinfo/src/main/java/com/example/appengine/standard guestbook-cloud-datastore/src main/java/com/example/guestbook test/java/com/example/guestbook
main/java/com/example/guestbook test/java/com/example/guestbook
logs/src/main/java/com/example/appengine/logs mailgun/src/main/java/com/example/appengine/mailgun mailjet/src/main/java/com/example/appengine/mailjet main/java/com/example/appengine test/java/com/example/appengine
oauth2/src/main/java/com/example/appengine remote-client/src/main/java/com/example/appengine/remote main/java/com/example/appengine/requests test/java/com/example/appengine/requests
main/java/com/example/appengine/search test/java/com/example/appengine/search
sendgrid/src/main/java/com/example/appengine/sendgrid spanner/src/main/java/com/example/appengine/spanner taskqueues-deferred/src/main/java/com/google/cloud/taskqueue/samples taskqueues-pull/src/main/java/com/example/taskqueue main/java/com/example/appengine/taskqueue/push test/java/com/example/appengine/taskqueue/push
twilio/src/main/java/com/example/appengine/twilio urlfetch/src/main/java/com/example/appengine main/java/com/example/appengine/users test/java/com/example/appengine/users
flexible/analytics/src/main/java/com/example/analytics
Some content is hiddenLarge Commits have some content hidden by default. Use the searchbox below for content that may be hidden. Dismiss bannerExpand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboard +19Lines changed: 19 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +[*] | | 2 | +charset=utf-8 | | 3 | +end_of_line=lf | | 4 | +insert_final_newline=false | | 5 | +indent_style=space | | 6 | +indent_size=2 | | 7 | + | | 8 | +[{*.gson,*.gradle,*.groovy,*.gant,*.gdsl,*.gy}] | | 9 | +indent_style=space | | 10 | +indent_size=4 | | 11 | + | | 12 | +[{*.xjsp,*.tag,*.jsf,*.jsp,*.jspf,*.tagf}] | | 13 | +indent_style=space | | 14 | +indent_size=4 | | 15 | + | | 16 | +[{*.yml,*.yaml}] | | 17 | +indent_style=space | | 18 | +indent_size=2 | | 19 | + |
Collapse file Copy file name to clipboardExpand all lines: appengine-java8/analytics/src/main/java/com/example/appengine/analytics/AnalyticsServlet.java +4-3Lines changed: 4 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 11 | 11 | * express or implied. See the License for the specific language governing permissions and | 12 | 12 | * limitations under the License. | 13 | 13 | */ | | 14 | + | 14 | 15 | package com.example.appengine.analytics; | 15 | 16 |
| 16 | 17 | import com.google.appengine.api.urlfetch.URLFetchService; | | 30 | 31 | @SuppressWarnings("serial") | 31 | 32 | // With @WebServlet annotation the webapp/WEB-INF/web.xml is no longer required. | 32 | 33 | @WebServlet( | 33 | | - name = "analytics", | 34 | | - description = "Analytics: Send Analytics Event to Google Analytics", | 35 | | - urlPatterns = "/analytics" | | 34 | + name = "analytics", | | 35 | + description = "Analytics: Send Analytics Event to Google Analytics", | | 36 | + urlPatterns = "/analytics" | 36 | 37 | ) | 37 | 38 | public class AnalyticsServlet extends HttpServlet { | 38 | 39 |
| |
Collapse file Copy file name to clipboardExpand all lines: appengine-java8/appidentity/src/main/java/com/example/appengine/appidentity/IdentityServlet.java +5-4Lines changed: 5 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 17 | 17 | package com.example.appengine.appidentity; | 18 | 18 |
| 19 | 19 | import com.google.apphosting.api.ApiProxy; | 20 | | - | 21 | 20 | import java.io.IOException; | 22 | | - | 23 | 21 | import javax.servlet.annotation.WebServlet; | 24 | 22 | import javax.servlet.http.HttpServlet; | 25 | 23 | import javax.servlet.http.HttpServletRequest; | 26 | 24 | import javax.servlet.http.HttpServletResponse; | 27 | 25 |
| 28 | 26 | @SuppressWarnings("serial") | 29 | 27 | // With @WebServlet annotation the webapp/WEB-INF/web.xml is no longer required. | 30 | | -@WebServlet(name = "appidentity", description = "AppIdentity: Get the Host Name", | 31 | | - urlPatterns = "/appidentity/identity") | | 28 | +@WebServlet( | | 29 | + name = "appidentity", | | 30 | + description = "AppIdentity: Get the Host Name", | | 31 | + urlPatterns = "/appidentity/identity" | | 32 | +) | 32 | 33 | public class IdentityServlet extends HttpServlet { | 33 | 34 |
| 34 | 35 | // [START versioned_hostnames] | |
Collapse file Copy file name to clipboardExpand all lines: appengine-java8/appidentity/src/main/java/com/example/appengine/appidentity/SignForAppServlet.java +7-8Lines changed: 7 additions & 8 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 19 | 19 | import com.google.appengine.api.appidentity.AppIdentityService; | 20 | 20 | import com.google.appengine.api.appidentity.AppIdentityServiceFactory; | 21 | 21 | import com.google.appengine.api.appidentity.PublicCertificate; | 22 | | - | 23 | 22 | import java.io.ByteArrayInputStream; | 24 | 23 | import java.io.IOException; | 25 | 24 | import java.io.InputStream; | | 35 | 34 | import java.util.Arrays; | 36 | 35 | import java.util.Calendar; | 37 | 36 | import java.util.Collection; | 38 | | - | 39 | 37 | import javax.servlet.annotation.WebServlet; | 40 | 38 | import javax.servlet.http.HttpServlet; | 41 | 39 | import javax.servlet.http.HttpServletRequest; | 42 | 40 | import javax.servlet.http.HttpServletResponse; | 43 | 41 |
| 44 | 42 | @SuppressWarnings("serial") | 45 | 43 | // With @WebServlet annotation the webapp/WEB-INF/web.xml is no longer required. | 46 | | -@WebServlet(name = "signforapp", description = "AppIdentity: Sign 'abcdefg'", | 47 | | - urlPatterns = "/appidentity/sign") | | 44 | +@WebServlet( | | 45 | + name = "signforapp", | | 46 | + description = "AppIdentity: Sign 'abcdefg'", | | 47 | + urlPatterns = "/appidentity/sign" | | 48 | +) | 48 | 49 | public class SignForAppServlet extends HttpServlet { | | 50 | + | 49 | 51 | private final AppIdentityService appIdentity; | 50 | 52 |
| 51 | 53 | public SignForAppServlet() { | @@ -98,10 +100,7 @@ private String simulateIdentityAssertion() | 98 | 100 |
| 99 | 101 | return String.format( | 100 | 102 | "isValid=%b for message: %s\n\tsignature: %s\n\tpublic cert: %s", | 101 | | - isValid, | 102 | | - message, | 103 | | - Arrays.toString(blobSignature), | 104 | | - Arrays.toString(publicCert)); | | 103 | + isValid, message, Arrays.toString(blobSignature), Arrays.toString(publicCert)); | 105 | 104 | } | 106 | 105 | // [END asserting_identity_to_other_services] | 107 | 106 |
| |
Collapse file Copy file name to clipboardExpand all lines: appengine-java8/appidentity/src/main/java/com/example/appengine/appidentity/UrlShortener.java +7-9Lines changed: 7 additions & 9 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 19 | 19 | import com.google.appengine.api.appidentity.AppIdentityService; | 20 | 20 | import com.google.appengine.api.appidentity.AppIdentityServiceFactory; | 21 | 21 | import com.google.common.io.CharStreams; | 22 | | - | 23 | | -import org.json.JSONObject; | 24 | | -import org.json.JSONTokener; | 25 | | - | 26 | 22 | import java.io.InputStream; | 27 | 23 | import java.io.InputStreamReader; | 28 | 24 | import java.io.OutputStreamWriter; | 29 | 25 | import java.net.HttpURLConnection; | 30 | 26 | import java.net.URL; | 31 | 27 | import java.nio.charset.StandardCharsets; | 32 | 28 | import java.util.ArrayList; | | 29 | +import org.json.JSONObject; | | 30 | +import org.json.JSONTokener; | 33 | 31 |
| 34 | 32 | @SuppressWarnings("serial") | 35 | 33 | class UrlShortener { | 36 | 34 | // [START asserting_identity_to_Google_APIs] | | 35 | + | 37 | 36 | /** | 38 | 37 | * Returns a shortened URL by calling the Google URL Shortener API. | 39 | 38 | * | @@ -68,11 +67,10 @@ public String createShortUrl(String longUrl) throws Exception { | 68 | 67 | } else { | 69 | 68 | try (InputStream s = connection.getErrorStream(); | 70 | 69 | InputStreamReader r = new InputStreamReader(s, StandardCharsets.UTF_8)) { | 71 | | - throw new RuntimeException(String.format( | 72 | | - "got error (%d) response %s from %s", | 73 | | - connection.getResponseCode(), | 74 | | - CharStreams.toString(r), | 75 | | - connection.toString())); | | 70 | + throw new RuntimeException( | | 71 | + String.format( | | 72 | + "got error (%d) response %s from %s", | | 73 | + connection.getResponseCode(), CharStreams.toString(r), connection.toString())); | 76 | 74 | } | 77 | 75 | } | 78 | 76 | } | |
Collapse file Copy file name to clipboardExpand all lines: appengine-java8/appidentity/src/main/java/com/example/appengine/appidentity/UrlShortenerServlet.java +6-3Lines changed: 6 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 18 | 18 |
| 19 | 19 | import java.io.IOException; | 20 | 20 | import java.io.PrintWriter; | 21 | | - | 22 | 21 | import javax.servlet.annotation.WebServlet; | 23 | 22 | import javax.servlet.http.HttpServlet; | 24 | 23 | import javax.servlet.http.HttpServletRequest; | 25 | 24 | import javax.servlet.http.HttpServletResponse; | 26 | 25 |
| 27 | 26 | @SuppressWarnings("serial") | 28 | 27 | // With @WebServlet annotation the webapp/WEB-INF/web.xml is no longer required. | 29 | | -@WebServlet(name = "UrlShortener", description = "AppIdentity: Url Shortener", | 30 | | - urlPatterns = "/appidentity/shorten") | | 28 | +@WebServlet( | | 29 | + name = "UrlShortener", | | 30 | + description = "AppIdentity: Url Shortener", | | 31 | + urlPatterns = "/appidentity/shorten" | | 32 | +) | 31 | 33 | public class UrlShortenerServlet extends HttpServlet { | | 34 | + | 32 | 35 | private final UrlShortener shortener; | 33 | 36 |
| 34 | 37 | public UrlShortenerServlet() { | |
Collapse file Copy file name to clipboardExpand all lines: appengine-java8/appidentity/src/test/java/com/example/appengine/appidentity/IdentityServletTest.java +10-10Lines changed: 10 additions & 10 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 20 | 20 | import static org.mockito.Mockito.when; | 21 | 21 |
| 22 | 22 | import com.google.appengine.tools.development.testing.LocalServiceTestHelper; | 23 | | - | | 23 | +import java.io.PrintWriter; | | 24 | +import java.io.StringWriter; | | 25 | +import javax.servlet.http.HttpServletRequest; | | 26 | +import javax.servlet.http.HttpServletResponse; | 24 | 27 | import org.junit.After; | 25 | 28 | import org.junit.Before; | 26 | 29 | import org.junit.Test; | | 29 | 32 | import org.mockito.Mock; | 30 | 33 | import org.mockito.MockitoAnnotations; | 31 | 34 |
| 32 | | -import java.io.PrintWriter; | 33 | | -import java.io.StringWriter; | 34 | | - | 35 | | -import javax.servlet.http.HttpServletRequest; | 36 | | -import javax.servlet.http.HttpServletResponse; | 37 | | - | 38 | 35 | /** | 39 | 36 | * Unit tests for {@link IdentityServlet}. | 40 | 37 | */ | @@ -44,8 +41,10 @@ public class IdentityServletTest { | 44 | 41 | // Set up a helper so that the ApiProxy returns a valid environment for local testing. | 45 | 42 | private final LocalServiceTestHelper helper = new LocalServiceTestHelper(); | 46 | 43 |
| 47 | | - @Mock private HttpServletRequest mockRequest; | 48 | | - @Mock private HttpServletResponse mockResponse; | | 44 | + @Mock | | 45 | + private HttpServletRequest mockRequest; | | 46 | + @Mock | | 47 | + private HttpServletResponse mockResponse; | 49 | 48 | private StringWriter responseWriter; | 50 | 49 | private IdentityServlet servletUnderTest; | 51 | 50 |
| @@ -61,7 +60,8 @@ public void setUp() throws Exception { | 61 | 60 | servletUnderTest = new IdentityServlet(); | 62 | 61 | } | 63 | 62 |
| 64 | | - @After public void tearDown() { | | 63 | + @After | | 64 | + public void tearDown() { | 65 | 65 | helper.tearDown(); | 66 | 66 | } | 67 | 67 |
| |
Collapse file Copy file name to clipboardExpand all lines: appengine-java8/appidentity/src/test/java/com/example/appengine/appidentity/SignForAppServletTest.java +14-12Lines changed: 14 additions & 12 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 20 | 20 | import static org.mockito.Mockito.when; | 21 | 21 |
| 22 | 22 | import com.google.appengine.tools.development.testing.LocalServiceTestHelper; | 23 | | - | | 23 | +import java.io.PrintWriter; | | 24 | +import java.io.StringWriter; | | 25 | +import javax.servlet.http.HttpServletRequest; | | 26 | +import javax.servlet.http.HttpServletResponse; | 24 | 27 | import org.junit.After; | 25 | 28 | import org.junit.Before; | 26 | 29 | import org.junit.Test; | | 29 | 32 | import org.mockito.Mock; | 30 | 33 | import org.mockito.MockitoAnnotations; | 31 | 34 |
| 32 | | -import java.io.PrintWriter; | 33 | | -import java.io.StringWriter; | 34 | | - | 35 | | -import javax.servlet.http.HttpServletRequest; | 36 | | -import javax.servlet.http.HttpServletResponse; | 37 | | - | 38 | 35 | /** | 39 | 36 | * Unit tests for {@link SignForAppServlet}. | 40 | 37 | */ | @@ -43,12 +40,15 @@ public class SignForAppServletTest { | 43 | 40 |
| 44 | 41 | private final LocalServiceTestHelper helper = new LocalServiceTestHelper(); | 45 | 42 |
| 46 | | - @Mock private HttpServletRequest mockRequest; | 47 | | - @Mock private HttpServletResponse mockResponse; | | 43 | + @Mock | | 44 | + private HttpServletRequest mockRequest; | | 45 | + @Mock | | 46 | + private HttpServletResponse mockResponse; | 48 | 47 | private StringWriter responseWriter; | 49 | 48 | private SignForAppServlet servletUnderTest; | 50 | 49 |
| 51 | | - @Before public void setUp() throws Exception { | | 50 | + @Before | | 51 | + public void setUp() throws Exception { | 52 | 52 | MockitoAnnotations.initMocks(this); | 53 | 53 | helper.setUp(); | 54 | 54 |
| @@ -59,11 +59,13 @@ public class SignForAppServletTest { | 59 | 59 | servletUnderTest = new SignForAppServlet(); | 60 | 60 | } | 61 | 61 |
| 62 | | - @After public void tearDown() { | | 62 | + @After | | 63 | + public void tearDown() { | 63 | 64 | helper.tearDown(); | 64 | 65 | } | 65 | 66 |
| 66 | | - @Test public void doGet_defaultEnvironment_successfullyVerifiesSignature() throws Exception { | | 67 | + @Test | | 68 | + public void doGet_defaultEnvironment_successfullyVerifiesSignature() throws Exception { | 67 | 69 | servletUnderTest.doGet(mockRequest, mockResponse); | 68 | 70 |
| 69 | 71 | assertThat(responseWriter.toString()) | |
Collapse file Copy file name to clipboardExpand all lines: appengine-java8/bigtable/src/main/java/com/example/bigtable/BigtableHelloWorld.java +14-13Lines changed: 14 additions & 13 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 16 | 16 |
| 17 | 17 | package com.example.bigtable; | 18 | 18 |
| | 19 | +import java.io.IOException; | 19 | 20 | import org.apache.hadoop.hbase.HColumnDescriptor; | 20 | 21 | import org.apache.hadoop.hbase.HTableDescriptor; | 21 | 22 | import org.apache.hadoop.hbase.TableName; | | 28 | 29 | import org.apache.hadoop.hbase.client.Scan; | 29 | 30 | import org.apache.hadoop.hbase.client.Table; | 30 | 31 | import org.apache.hadoop.hbase.util.Bytes; | 31 | | - | 32 | | -import java.io.IOException; | 33 | 32 | // [START example] | | 33 | + | 34 | 34 | /** | 35 | | - * A minimal application that connects to Cloud Bigtable using the native HBase API | 36 | | - * and performs some basic operations. | | 35 | + * A minimal application that connects to Cloud Bigtable using the native HBase API and performs | | 36 | + * some basic operations. | 37 | 37 | */ | 38 | 38 | public class BigtableHelloWorld { | 39 | 39 |
| @@ -43,13 +43,18 @@ public class BigtableHelloWorld { | 43 | 43 | private static final byte[] COLUMN_NAME = Bytes.toBytes("greeting"); | 44 | 44 |
| 45 | 45 | // Write some friendly greetings to Cloud Bigtable | 46 | | - private static final String[] GREETINGS = | 47 | | - { "Hello World!", "Hello Cloud Bigtable!", "Hello HBase!" }; | 48 | | - | | 46 | + private static final String[] GREETINGS = { | | 47 | + "Hello World!", "Hello Cloud Bigtable!", "Hello HBase!" | | 48 | + }; | 49 | 49 |
| | 50 | + /** | | 51 | + * Create a table -- first time only. | | 52 | + * @param connection to Bigtable | | 53 | + * @return the status | | 54 | + */ | 50 | 55 | public static String create(Connection connection) { | 51 | 56 | try { | 52 | | - // The admin API lets us create, manage and delete tables | | 57 | + // The admin API lets us create, manage and delete tables | 53 | 58 | Admin admin = connection.getAdmin(); | 54 | 59 | // [END connecting_to_bigtable] | 55 | 60 |
| @@ -66,9 +71,7 @@ public static String create(Connection connection) { | 66 | 71 | return "Create table " + Bytes.toString(TABLE_NAME); | 67 | 72 | } | 68 | 73 |
| 69 | | - /** | 70 | | - * Connects to Cloud Bigtable, runs some basic operations and prints the results. | 71 | | - */ | | 74 | + /** Connects to Cloud Bigtable, runs some basic operations and prints the results. */ | 72 | 75 | public static String doHelloWorld() { | 73 | 76 |
| 74 | 77 | StringBuilder result = new StringBuilder(); | @@ -141,7 +144,5 @@ public static String doHelloWorld() { | 141 | 144 |
| 142 | 145 | return result.toString(); | 143 | 146 | } | 144 | | - | 145 | | - | 146 | 147 | } | 147 | 148 | // [END example] |
|