use of org.codice.alliance.nsili.common.Nsili in project alliance by codice.
the class NsiliSourceTest method buildSource.
private NsiliSource buildSource() throws Exception {
NsiliSource source;
Nsili nsili = mock(Nsili.class);
Response clientResponse = mock(Response.class);
when(clientResponse.getEntity()).thenReturn("");
InputStream mockInputStream = mock(InputStream.class);
when(nsili.getIorFile()).thenReturn(mockInputStream);
SecureCxfClientFactory factory = getMockFactory(nsili);
HashMap<String, String[]> resultAttributes = new HashMap<>();
HashMap<String, List<String>> sortableAttributes = generateMockSortableAttributes();
source = Mockito.spy(new NsiliSource(factory, resultAttributes, sortableAttributes, new NsiliFilterDelegate(attributeInformationMap, NsiliConstants.NSIL_ALL_VIEW), orb));
source.setIorUrl(IOR_URL);
source.setServerUsername(NsiliSource.SERVER_USERNAME);
source.setServerPassword(NsiliSource.SERVER_PASSWORD);
source.setMaxHitCount(MAX_HIT_COUNT);
source.setId(ID);
source.setPollInterval(POLL_INTERVAL);
source.setDataModelMgr(getMockDataModelMgr());
source.setCatalogMgr(getMockCatalogMgr());
source.setFilterAdapter(new GeotoolsFilterAdapterImpl());
source.setNumberWorkerThreads(6);
source.setAdditionalQueryParams("and (not NSIL_PRODUCT:NSIL_CARD.status = 'OBSOLETE')");
// Suppress CORBA communications to test refresh
doNothing().when(source).init();
when(mockAvailabilityTask.isAvailable()).thenReturn(true);
source.setAvailabilityTask(mockAvailabilityTask);
return source;
}
use of org.codice.alliance.nsili.common.Nsili in project alliance by codice.
the class NsiliSource method getIorStringFromHttpSource.
/**
* Uses the SecureClientCxfFactory to obtain the IOR string from the provided URL via HTTP(S).
*/
private void getIorStringFromHttpSource() {
createClientFactory();
Nsili nsili = factory.getClient();
try (InputStream inputStream = nsili.getIorFile()) {
iorString = IOUtils.toString(inputStream, StandardCharsets.ISO_8859_1.name());
// Remove leading/trailing whitespace as the CORBA init can't handle that.
iorString = iorString.trim();
} catch (IOException e) {
LOGGER.debug("{} : Unable to process IOR String.", sourceId, e);
} catch (Exception e) {
LOGGER.debug("{} : Error retrieving IOR file for {}.", sourceId, iorUrl, e);
}
}
Aggregations