Skip to content

Instantly share code, notes, and snippets.

@brikis98
Created July 18, 2011 18:27
Show Gist options
  • Select an option

  • Save brikis98/1090246 to your computer and use it in GitHub Desktop.

Select an option

Save brikis98/1090246 to your computer and use it in GitHub Desktop.
Frontier component example
<!-- Sample Frontier JSP. Shows how to pull in the common "chrome", specify components (data) the JSP depends on and how to render this data. -->
<chrome:base/>
<component:set>
<component:decl id="lastModifiedComponent" class="com.linkedin.fronttest.component.LastModifiedComponent" />
</component:set>
<html>
<head>
<title>Last Modified Component</title>
</head>
<body id="fronttest-component-misc-last-modified-mode">
Last Modified header set to: <span id="last- modified">${lastModifiedComponent.derived.lastModified}</span>
</body>
</html>
/**
*
* Sample Frontier Component. These are reusable blocks of functionality that can be used to fetch data from databases,
* external services, etc in parallel. This example just sets the lastModified date in the header and adds it to the
* derived data for the JSP.
*
*/
@MinimumAuthenticationLevel(AuthenticationLevel.identified)
public class LastModifiedComponent extends FrontierComponent implements FrontierLifecycleAware
{
@Override
public void onStart()
{
long lastModified = new Random().nextInt(Integer.MAX_VALUE);
addDerivedData("lastModified", new Date(lastModified).toGMTString());
getRequestState().setLastModifiedResponseHeader(lastModified);
}
@Override
public void onEnd()
{
}
}
#
# Sample selenium helper for checking cookie and header values
#
if(options[:bcookie])
assert(cookie_value == bcookie_value, "Cookie value does not match with the passed value")
else
assert(cookie_value != "", "Cookie value maybe empty")
end
home_traffic = browser.browser_network_traffic(format = :xml)
if (ele.attributes["method"] == "GET" && ele.attributes["url"]== link_to_check) then
ele.elements.each('responseHeaders/header') do |hdr|
if(hdr.attributes["name"] == "Pragma" && !(hdr.text == pragma_value))
puts("Returning false for Pragma header as header text is " + hdr.text)
return false
end
#
# Sample selenium test script for checking UI elements
#
@env.selenium.stop
browser.start_new_browser_session(:captureNetworkTraffic => true)
browser.open_link(@app_home_link)
frontier_home_page.last_modified_component_link.click_and_wait
browser.open_link(link + "&ef=f&doTiming=true")
sign_in_page.assert_presence
sign_in_page.pagekey.wait_for_presence
#Assert Cookies and headers
frontier_helper.verify_all_cookies
puts("All cookies asserted")
assert_equal(frontier_helper.verify_all_headers(:link_to_check => link + "&ef=f&doTiming=true"), true)
puts("All headers asserted")
puts("Frontier Last Modified component in Guest case")
@brikis98
Copy link
Author

brikis98 commented Aug 9, 2011

See Testing Frontier, LinkedIn's Web Framework for more information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment