use of org.apache.tapestry5.http.Link in project tapestry-5 by apache.
the class LinkImplTest method retrieve_parameter_values.
@Test
public void retrieve_parameter_values() {
Response response = mockResponse();
replay();
Link link = new LinkImpl("/foo/bar", false, null, response, null, null);
link.addParameter("fred", "flintstone");
assertEquals(link.getParameterValue("fred"), "flintstone");
verify();
}
use of org.apache.tapestry5.http.Link in project tapestry-5 by apache.
the class LinkImplTest method to_string_same_as_to_uri.
@Test
public void to_string_same_as_to_uri() {
Response response = mockResponse();
String url = "/bar/" + RAW_PATH;
train_encodeURL(response, url, ENCODED);
replay();
Link link = new LinkImpl(url, false, LinkSecurity.INSECURE, response, null, null);
assertEquals(link.toString(), ENCODED);
assertEquals(link.getBasePath(), url);
verify();
}
use of org.apache.tapestry5.http.Link in project tapestry-5 by apache.
the class LinkImplTest method force_insecure_URI_from_secure_link.
@Test
public void force_insecure_URI_from_secure_link() {
Response response = mockResponse();
BaseURLSource baseURLSource = mockBaseURLSource();
train_getBaseURL(baseURLSource, false, INSECURE_BASE_URL);
train_encodeURL(response, INSECURE_BASE_URL + BASE_PATH, ENCODED);
replay();
Link link = new LinkImpl(BASE_PATH, false, LinkSecurity.SECURE, response, null, baseURLSource);
assertEquals(link.toAbsoluteURI(false), ENCODED);
verify();
}
use of org.apache.tapestry5.http.Link in project tapestry-5 by apache.
the class ExceptionUtils method findCause.
/**
* Locates a particular type of exception, working its way down via any property that returns some type of Exception.
* This is more expensive, but more accurate, than {@link #findCause(Throwable, Class)} as it works with older exceptions
* that do not properly implement the (relatively new) {@linkplain Throwable#getCause() cause property}.
*
* @param t the outermost exception
* @param type the type of exception to search for
* @param access used to access properties
* @return the first exception of the given type, if found, or null
*/
public static <T extends Throwable> T findCause(Throwable t, Class<T> type, PropertyAccess access) {
Throwable current = t;
while (current != null) {
if (type.isInstance(current)) {
return type.cast(current);
}
Throwable next = null;
ClassPropertyAdapter adapter = access.getAdapter(current);
for (String name : adapter.getPropertyNames()) {
Object value = adapter.getPropertyAdapter(name).get(current);
if (value != null && value != current && value instanceof Throwable) {
next = (Throwable) value;
break;
}
}
current = next;
}
return null;
}
use of org.apache.tapestry5.http.Link in project tapestry-5 by apache.
the class ZoneRefresh method addJavaScript.
@AfterRender
void addJavaScript() {
Link link = resources.createEventLink("zoneRefresh", context);
javaScriptSupport.require("t5/core/zone-refresh").with(zone.getClientId(), period, link.toString());
}
Aggregations