use of org.nhindirect.common.rest.AbstractSecuredService in project nhin-d by DirectProject.
the class DefaultRESTServiceModule_createServiceTest method testCreateServiceFromModule.
@Test
public void testCreateServiceFromModule() throws Exception {
final Injector configInjector = Guice.createInjector(DefaultRESTServiceModule.create("http://bogus", new OpenServiceSecurityManager()));
AbstractSecuredService service = (AbstractSecuredService) configInjector.getInstance(AddressService.class);
assertTrue(service instanceof DefaultAddressService);
service = (AbstractSecuredService) configInjector.getInstance(AnchorService.class);
assertTrue(service instanceof DefaultAnchorService);
service = (AbstractSecuredService) configInjector.getInstance(CertificateService.class);
assertTrue(service instanceof DefaultCertificateService);
service = (AbstractSecuredService) configInjector.getInstance(CertPolicyService.class);
assertTrue(service instanceof DefaultCertPolicyService);
service = (AbstractSecuredService) configInjector.getInstance(DNSService.class);
assertTrue(service instanceof DefaultDNSService);
service = (AbstractSecuredService) configInjector.getInstance(DomainService.class);
assertTrue(service instanceof DefaultDomainService);
service = (AbstractSecuredService) configInjector.getInstance(SettingService.class);
assertTrue(service instanceof DefaultSettingService);
service = (AbstractSecuredService) configInjector.getInstance(TrustBundleService.class);
assertTrue(service instanceof DefaultTrustBundleService);
}
use of org.nhindirect.common.rest.AbstractSecuredService in project nhin-d by DirectProject.
the class BaseTestPlan method getService.
public static AbstractSecuredService getService(String serviceURL, String serviceName) {
final Class<?> clazz = serviceClassMap.get(serviceName);
if (clazz == null)
throw new IllegalArgumentException("Service name " + serviceName + " is an unknown service");
try {
final Constructor<?> ctr = clazz.getDeclaredConstructor(String.class, HttpClient.class, ServiceSecurityManager.class);
final AbstractSecuredService service = (AbstractSecuredService) ctr.newInstance(serviceURL, HttpClientFactory.createHttpClient(), getTestServiceSecurityManager());
return service;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of org.nhindirect.common.rest.AbstractSecuredService in project nhin-d by DirectProject.
the class DefaultRESTServiceProvider method get.
@SuppressWarnings("unchecked")
@Override
public T get() {
AbstractSecuredService retVal = null;
try {
final Constructor<?> ctr = clazz.getDeclaredConstructor(String.class, HttpClient.class, ServiceSecurityManager.class);
retVal = (AbstractSecuredService) ctr.newInstance(serviceURL, client, securityManager);
} catch (Exception e) {
throw new IllegalStateException("REST service provider is not configured correctly.");
}
return (T) retVal;
}
Aggregations