CachedLookupService extends CacheLoader<CachedLookupService.HeaderStub, Endpoint> implements LookupService { @Override public Endpoint lookup(Header header) throws OxalisTransmissionException { try { return cache.get(new HeaderStub(header)); } catch (ExecutionException e) { throw new OxalisTransmissionException(e.getCause().getMessage(), e.getCause()); } } @Inject  CachedLookupService(LookupClient lookupClient,
                               @Named("prioritized") List<TransportProfile> transportProfiles); @Override Endpoint lookup(Header header); @Override Endpoint load(HeaderStub header);  }
@Test public void simple() throws Exception { Endpoint endpoint = lookupService.lookup(Header.newInstance() .receiver(participant) .documentType(documenttype) .process(process)); Assert.assertNotNull(endpoint); }
@Test public void simpleCached() throws Exception { Endpoint endpoint1 = lookupService.lookup(Header.newInstance() .receiver(participant) .documentType(documenttype) .process(process)); Endpoint endpoint2 = lookupService.lookup(Header.newInstance() .receiver(participant) .documentType(documenttype) .process(process)); Assert.assertSame(endpoint1, endpoint2); }
@Test(expectedExceptions = OxalisTransmissionException.class) public void triggerException() throws Exception { lookupService.lookup(Header.newInstance() .receiver(ParticipantIdentifier.of("9908:---")) .documentType(documenttype) .process(process)); }