ResourceHandler resources = new ResourceHandler();
URL resource = EndToEndTest.class.getResource("/endtoend");
resources.setBaseResource(Resource.newResource(resource));
newServer.addHandler(resources);
Context context = new Context(newServer, "/", Context.SESSIONS);
context.addEventListener(new GuiceServletContextListener());
Map<String, String> initParams = Maps.newHashMap();
String modules = Joiner.on(":")
.join(SocialApiGuiceModule.class.getName(),
SampleModule.class.getName(),
GadgetAdminModule.class.getName(),
DefaultGuiceModule.class.getName(),
PropertiesModule.class.getName(),
OAuthModule.class.getName(),
OAuth2Module.class.getName(),
OAuth2PersistenceModule.class.getName(),
OAuth2MessageModule.class.getName(),
OAuth2HandlerModule.class.getName()
);
initParams.put(GuiceServletContextListener.MODULES_ATTRIBUTE, modules);
context.setInitParams(initParams);
// Attach the gadget rendering servlet
ServletHolder gadgetServletHolder = new ServletHolder(new GadgetRenderingServlet());
context.addServlet(gadgetServletHolder, GADGET_BASE);
// Attach DataServiceServlet, wrapped in a proxy to fake errors
ServletHolder restServletHolder = new ServletHolder(new ForceErrorServlet(
new DataServiceServlet()));
restServletHolder.setInitParameter("handlers", "org.apache.shindig.handlers");
context.addServlet(restServletHolder, SOCIAL_REST_BASE);
context.addFilter(AuthenticationServletFilter.class, SOCIAL_REST_BASE, 0);
// Attach JsonRpcServlet, wrapped in a proxy to fake errors
ServletHolder rpcServletHolder = new ServletHolder(new ForceErrorServlet(new JsonRpcServlet()));
rpcServletHolder.setInitParameter("handlers", "org.apache.shindig.handlers");
context.addServlet(rpcServletHolder, SOCIAL_RPC_BASE);
context.addFilter(AuthenticationServletFilter.class, SOCIAL_RPC_BASE, 0);
context.addServlet(rpcServletHolder, GADGET_RPC_BASE);
context.addFilter(AuthenticationServletFilter.class, GADGET_RPC_BASE, 0);
context.addServlet(rpcServletHolder, RPC_BASE);
context.addFilter(AuthenticationServletFilter.class, RPC_BASE, 0);
// Attach the ConcatProxyServlet - needed for rewritten JS
ServletHolder concatHolder = new ServletHolder(new ConcatProxyServlet());
context.addServlet(concatHolder, CONCAT_BASE);
// Attach the JsServlet - needed for rewritten JS
ServletHolder jsHolder = new ServletHolder(new JsServlet());
context.addServlet(jsHolder, JS_BASE);
// Attach MakeRequestServlet
ServletHolder makeRequestHolder = new ServletHolder(new MakeRequestServlet());
context.addServlet(makeRequestHolder, MAKE_REQUEST_BASE);
// Attach an EchoServlet, used to test proxied rendering
ServletHolder echoHolder = new ServletHolder(new EchoServlet());
context.addServlet(echoHolder, "/echo");
return newServer;
}