protected final void train_getBaseURL(BaseURLSource baseURLSource, boolean secure, String baseURL) { expect(baseURLSource.getBaseURL(secure)).andReturn(baseURL); }
Object onReloadRoot() throws MalformedURLException { reloadHelper.forceReload(); return new URL(baseURLSource.getBaseURL(request.isSecure())); }
builder.append(baseURLSource.getBaseURL(true)); break; case FORCE_INSECURE: builder.append(baseURLSource.getBaseURL(false)); break; default:
public String constructAssetPath(String virtualFolder, String path, StreamableResource resource) throws IOException { assert InternalUtils.isNonBlank(path); assert InternalUtils.isNonBlank(virtualFolder); StringBuilder builder = new StringBuilder(); if (fullyQualified) { builder.append(baseURLSource.getBaseURL(request.isSecure())); } builder.append(prefix); builder.append(virtualFolder); builder.append('/'); // The 'z' prefix indicates a compressed resource. if (resource.getCompression() == CompressionStatus.COMPRESSED) { builder.append('z'); } builder.append(resource.getChecksum()); builder.append('/'); builder.append(path); return pathConverter.convertAssetPath(builder.toString()); }
public void reportException(Throwable exception) { rootException = exception; rootURL = baseURLSource.getBaseURL(request.isSecure()); // Capture this now ... before the gears are shifted around to make ExceptionReport the active page. failurePage = (request.getAttribute(InternalConstants.ACTIVE_PAGE_LOADED) == null) ? null : requestGlobals.getActivePageName(); }
protected final void train_getBaseSource(BaseURLSource baseURLSource, Request request) { expect(request.isSecure()).andReturn(false); expect(baseURLSource.getBaseURL(false)).andReturn(""); }
@Test public void getBaseURLWithContributedNonStandardSecurePort() { replay(); BaseURLSource baseURLSource = new BaseURLSourceImpl(request, "localhost", 80, 8443); assertEquals(baseURLSource.getBaseURL(true), "https://localhost:8443"); verify(); }
@Test public void insecure_url_using_default_port() { replay(); BaseURLSource baseURLSource = new BaseURLSourceImpl(request, "localhost", 80, 443); assertEquals(baseURLSource.getBaseURL(false), "http://localhost"); verify(); }
@Test public void secure_url_using_default_port() { replay(); BaseURLSource baseURLSource = new BaseURLSourceImpl(request, "localhost", 80, 443); assertEquals(baseURLSource.getBaseURL(true), "https://localhost"); verify(); }
@Test public void hostname_from_environment_variable() { expect(request.getServerPort()).andReturn(80).once(); expect(request.isSecure()).andReturn(false); replay(); BaseURLSource baseURLSource = new BaseURLSourceImpl(request, "$HOSTNAME", 0, 0); assertEquals(baseURLSource.getBaseURL(false), "http://" + System.getenv("HOSTNAME")); verify(); }
@Test public void secure_url_without_configured_hostports() { expect(request.isSecure()).andReturn(false).once(); replay(); BaseURLSource baseURLSource = new BaseURLSourceImpl(request, "localhost", 0, 0); // In other words, in the absense of any other configuration, it assumes that you have SSL on port 443 // and there's no need for that in the URL, since that's what the browser is going to do. assertEquals(baseURLSource.getBaseURL(true), "https://localhost"); verify(); }
@Test public void contributed_hostname() { expect(request.getServerPort()).andReturn(80).once(); expect(request.isSecure()).andReturn(false); replay(); BaseURLSource baseURLSource = new BaseURLSourceImpl(request, "my.server.com", 0, 0); assertEquals(baseURLSource.getBaseURL(false), "http://my.server.com"); verify(); }
@Test public void server_name_from_request_object() { expect(request.getServerName()).andReturn("localhost").once(); expect(request.getServerPort()).andReturn(80).once(); expect(request.isSecure()).andReturn(false); replay(); BaseURLSource baseURLSource = new BaseURLSourceImpl(request, "", 0, 0); assertEquals(baseURLSource.getBaseURL(false), "http://localhost"); verify(); }