use of org.restlet.Context in project OpenAM by OpenRock.
the class TokenEndpointResourceTest method shouldThrowServerErrorForExceptionsThatAreNotOAuth2RestletExceptions.
@Test
public void shouldThrowServerErrorForExceptionsThatAreNotOAuth2RestletExceptions() {
//Given
Context context = new Context();
Request request = new Request();
Response response = new Response(request);
tokenEndpointResource.init(context, request, response);
//When
tokenEndpointResource.doCatch(new NullPointerException());
//Then
assertEquals(response.getStatus(), Status.CLIENT_ERROR_BAD_REQUEST);
assertEquals(response.getEntityAsText(), "{\"error\":\"server_error\"}");
}
use of org.restlet.Context in project xwiki-platform by xwiki.
the class XWikiRestletServlet method createApplication.
@Override
protected Application createApplication(Context context) {
Context applicationContext = context.createChildContext();
/* Retrieve the component manager and make it available in the restlet application context. */
ComponentManager componentManager = getComponentManager();
applicationContext.getAttributes().put(Constants.XWIKI_COMPONENT_MANAGER, componentManager);
JaxRsApplication application;
try {
application = componentManager.getInstance(JaxRsApplication.class);
} catch (ComponentLookupException e) {
log("Failed to lookup default JAX-RS Application", e);
return null;
}
application.setContext(applicationContext);
// Make the servlet available
try {
JaxRsServletProvider applicationProvider = componentManager.getInstance(JaxRsServletProvider.class);
applicationProvider.setApplication(this);
} catch (ComponentLookupException e) {
log("Failed to lookup JaxRsApplicationProvider. Dyncamically added/removed resources won'tbe supported", e);
}
return application;
}
use of org.restlet.Context in project helix by apache.
the class HelixAdminWebApp method start.
public synchronized void start() throws Exception {
LOG.info("helixAdminWebApp starting");
if (_component == null) {
_zkClient = new ZkClient(_zkServerAddress, ZkClient.DEFAULT_SESSION_TIMEOUT, ZkClient.DEFAULT_CONNECTION_TIMEOUT, new ZNRecordSerializer());
_rawZkClient = new ZkClient(_zkServerAddress, ZkClient.DEFAULT_SESSION_TIMEOUT, ZkClient.DEFAULT_CONNECTION_TIMEOUT, new ByteArraySerializer());
_component = new Component();
_component.getServers().add(Protocol.HTTP, _helixAdminPort);
Context applicationContext = _component.getContext().createChildContext();
applicationContext.getAttributes().put(RestAdminApplication.ZKSERVERADDRESS, _zkServerAddress);
applicationContext.getAttributes().put(RestAdminApplication.PORT, "" + _helixAdminPort);
applicationContext.getAttributes().put(RestAdminApplication.ZKCLIENT, _zkClient);
applicationContext.getAttributes().put(ResourceUtil.ContextKey.RAW_ZKCLIENT.toString(), _rawZkClient);
_adminApp = new RestAdminApplication(applicationContext);
// Attach the application to the component and start it
_component.getDefaultHost().attach(_adminApp);
_component.start();
}
LOG.info("helixAdminWebApp started on port: " + _helixAdminPort);
}
Aggregations