| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 5a16c30 commit bd53b6c
132 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,19 @@ | |||
| 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 | + | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,6 +11,7 @@ | |||
| 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,9 +31,9 @@ | |||
| 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 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,18 +17,19 @@ | |||
| 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] | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,7 +19,6 @@ | |||
| 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,17 +34,20 @@ | |||
| 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 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,21 +19,20 @@ | |||
| 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 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,17 +18,20 @@ | |||
| 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() { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,7 +20,10 @@ | |||
| 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,12 +32,6 @@ | |||
| 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 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,7 +20,10 @@ | |||
| 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,12 +32,6 @@ | |||
| 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()) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,6 +16,7 @@ | |||
| 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,12 +29,11 @@ | |||
| 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] | |
| Back | FazBrowse Home | New Git URL |
0 commit comments