Java Code Examples for com.google.apphosting.api.ApiProxy#Environment
The following examples show how to use
com.google.apphosting.api.ApiProxy#Environment .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AppIdentityServiceTest.java From appengine-tck with Apache License 2.0 | 6 votes |
@Test public void testGetDefaultGcsBucketName() { ApiProxy.Environment env = ApiProxy.getCurrentEnvironment(); String expectedBucketName; Property property = property("testGetDefaultGcsBucketName"); if (property.exists()) { expectedBucketName = property.getPropertyValue(); } else { expectedBucketName = (String) env.getAttributes().get("com.google.appengine.runtime.default_version_hostname"); } try { String bucketName = appIdentity.getDefaultGcsBucketName(); Assert.assertEquals(expectedBucketName, bucketName); } catch (AppIdentityServiceFailureException aisfe) { //TODO: This means that there is no default bucket setup for this project. Have a better way to verify this. } }
Example 2
Source File: TestSocketServlet.java From appengine-java-vm-runtime with Apache License 2.0 | 5 votes |
@Override public Future<byte[]> makeAsyncCall( ApiProxy.Environment environment, String packageName, String methodName, byte[] request, ApiProxy.ApiConfig apiConfig) { if ("remote_socket".equals(packageName)) { final byte[] response = makeResponse(methodName, request); return new Future<byte[]>() { @Override public boolean cancel(boolean mayInterruptIfRunning) { return false; } @Override public boolean isCancelled() { return false; } @Override public boolean isDone() { return true; } @Override public byte[] get() throws InterruptedException, ExecutionException { return response; } @Override public byte[] get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { return response; } }; } throw new UnsupportedOperationException(); }
Example 3
Source File: LoadOnStartupServlet.java From appengine-java-vm-runtime with Apache License 2.0 | 5 votes |
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { resp.setContentType("text/plain"); ApiProxy.Environment requestEnv = ApiProxy.getCurrentEnvironment(); for (String key : requestEnv.getAttributes().keySet()) { if (!INIT_ENV.getAttributes().containsKey(key) && !REQUEST_ONLY_ATTRIBUTES.contains(key)) { resp.getWriter().println("Init environment attributes do not contain " + key); } } }
Example 4
Source File: TestInetAddressServlet.java From appengine-java-vm-runtime with Apache License 2.0 | 5 votes |
@Override public Future<byte[]> makeAsyncCall( ApiProxy.Environment environment, String packageName, String methodName, byte[] request, ApiProxy.ApiConfig apiConfig) { if ("remote_socket".equals(packageName) && "Resolve".equals(methodName)) { return new Future<byte[]>() { @Override public boolean cancel(boolean mayInterruptIfRunning) { return false; } @Override public boolean isCancelled() { return false; } @Override public boolean isDone() { return true; } @Override public byte[] get() throws InterruptedException, ExecutionException { return RESOLVER_RESPONSE; } @Override public byte[] get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { return RESOLVER_RESPONSE; } }; } throw new UnsupportedOperationException(); }
Example 5
Source File: AppIdentityBasicTest.java From appengine-tck with Apache License 2.0 | 5 votes |
@Test public void testGetVersionedHostname() { String expectedHostname = getExpectedAppHostname("testGetVersionedHostname"); ApiProxy.Environment env = ApiProxy.getCurrentEnvironment(); String hostname = (String) env.getAttributes().get("com.google.appengine.runtime.default_version_hostname"); String errMsg = "The versioned hostname should end with " + expectedHostname + ", but was " + hostname; Assert.assertTrue(errMsg, hostname.endsWith(expectedHostname)); }
Example 6
Source File: IdentityServlet.java From java-docs-samples with Apache License 2.0 | 5 votes |
@Override public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { resp.setContentType("text/plain"); ApiProxy.Environment env = ApiProxy.getCurrentEnvironment(); resp.getWriter().print("default_version_hostname: "); resp.getWriter() .println(env.getAttributes().get("com.google.appengine.runtime.default_version_hostname")); }
Example 7
Source File: TestSocketServlet.java From appengine-java-vm-runtime with Apache License 2.0 | 5 votes |
@Override public byte[] makeSyncCall( ApiProxy.Environment environment, String packageName, String methodName, byte[] request) { if (!"remote_socket".equals(packageName)) { throw new UnsupportedOperationException(); } return makeResponse(methodName, request); }
Example 8
Source File: SessionManagerTest.java From appengine-java-vm-runtime with Apache License 2.0 | 5 votes |
public Future<byte[]> makeAsyncCall( ApiProxy.Environment environment, String packageName, String methodName, byte[] request, ApiProxy.ApiConfig apiConfig) { if (packageName.equals("datastore_v3") && timeoutCount > 0) { timeoutCount--; throw new DatastoreTimeoutException("Timeout"); } return delegate.makeAsyncCall(environment, packageName, methodName, request, apiConfig); }
Example 9
Source File: AppIdentityBasicTest.java From appengine-tck with Apache License 2.0 | 5 votes |
@Test public void testRequestId() { ApiProxy.Environment env = ApiProxy.getCurrentEnvironment(); String requestId = (String) env.getAttributes().get("com.google.appengine.runtime.request_log_id"); String errMsg = "The request id should not be null"; Assert.assertNotNull(errMsg, requestId); }
Example 10
Source File: TestDatagramSocketServlet.java From appengine-java-vm-runtime with Apache License 2.0 | 5 votes |
@Override public byte[] makeSyncCall( ApiProxy.Environment environment, String packageName, String methodName, byte[] request) { if (!"remote_socket".equals(packageName)) { throw new UnsupportedOperationException(); } return makeResponse(methodName, request); }
Example 11
Source File: Config.java From teammates with GNU General Public License v2.0 | 5 votes |
/** * Returns the GAE's internal request ID of a request. This is not related to HttpServletRequest. * * @see <a href="https://cloud.google.com/appengine/docs/standard/java/how-requests-are-handled">https://cloud.google.com/appengine/docs/standard/java/how-requests-are-handled</a> */ public static String getRequestId() { ApiProxy.Environment serverEnvironment = ApiProxy.getCurrentEnvironment(); if (serverEnvironment == null) { // This will be the case in dev server return "dummyrequestid"; } return String.valueOf(ApiProxy.getCurrentEnvironment().getAttributes() .get("com.google.appengine.runtime.request_log_id")); }
Example 12
Source File: Config.java From teammates with GNU General Public License v2.0 | 5 votes |
private static String readAppUrl() { ApiProxy.Environment serverEnvironment = ApiProxy.getCurrentEnvironment(); if (serverEnvironment == null) { return null; } String hostname = (String) serverEnvironment.getAttributes() .get("com.google.appengine.runtime.default_version_hostname"); if (hostname == null) { return null; } return (isDevServer() ? "http://" : "https://") + hostname; }
Example 13
Source File: ChatSocketServer.java From appengine-websocketchat-java with Apache License 2.0 | 4 votes |
protected ApiProxy.Environment getBackgroundEnvironment() { return backgroundEnvironment; }
Example 14
Source File: TestSocketServlet.java From appengine-java-vm-runtime with Apache License 2.0 | 4 votes |
@Override public void log(ApiProxy.Environment environment, ApiProxy.LogRecord record) {}
Example 15
Source File: TestSocketServlet.java From appengine-java-vm-runtime with Apache License 2.0 | 4 votes |
@Override public void flushLogs(ApiProxy.Environment environment) {}
Example 16
Source File: TestSocketServlet.java From appengine-java-vm-runtime with Apache License 2.0 | 4 votes |
@Override public List<Thread> getRequestThreads(ApiProxy.Environment environment) { return null; }
Example 17
Source File: TestInetAddressServlet.java From appengine-java-vm-runtime with Apache License 2.0 | 4 votes |
@Override public void log(ApiProxy.Environment environment, ApiProxy.LogRecord record) {}
Example 18
Source File: VmEnvironmentFactory.java From appengine-java-vm-runtime with Apache License 2.0 | 4 votes |
@Override public ApiProxy.Environment newEnvironment() { defaultEnvironment.setThreadLocalAttributes(); return defaultEnvironment; }
Example 19
Source File: TestInetAddressServlet.java From appengine-java-vm-runtime with Apache License 2.0 | 4 votes |
@Override public List<Thread> getRequestThreads(ApiProxy.Environment environment) { return null; }
Example 20
Source File: SessionManagerTest.java From appengine-java-vm-runtime with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") public void log(ApiProxy.Environment environment, LogRecord record) { delegate.log(environment, record); }