use of org.apereo.cas.util.PublisherIdentifier in project cas by apereo.
the class CasServicesStreamingKafkaConfigurationTests method verifySerialization.
@Test
public void verifySerialization() throws Exception {
val o = DistributedCacheObject.<RegisteredService>builder().value(RegisteredServiceTestUtils.getRegisteredService()).publisherIdentifier(new PublisherIdentifier()).build();
val file = new File(FileUtils.getTempDirectoryPath(), UUID.randomUUID().toString() + ".json");
val mapper = new RegisteredServiceJsonSerializer().getObjectMapper();
mapper.writeValue(file, o);
val readPolicy = mapper.readValue(file, DistributedCacheObject.class);
assertEquals(o, readPolicy);
}
use of org.apereo.cas.util.PublisherIdentifier in project cas by apereo.
the class CasServicesStreamingKafkaConfigurationTests method verifyAction.
@Test
public void verifyAction() throws Exception {
val registeredService = RegisteredServiceTestUtils.getRegisteredService();
var obj = registeredServiceDistributedCacheManager.get(registeredService);
assertNull(obj);
assertFalse(registeredServiceDistributedCacheManager.contains(registeredService));
val cache = DistributedCacheObject.<RegisteredService>builder().value(registeredService).publisherIdentifier(casRegisteredServiceStreamPublisherIdentifier).build();
registeredServiceDistributedCacheManager.set(registeredService, cache, true);
Thread.sleep(2000);
assertFalse(registeredServiceDistributedCacheManager.getAll().isEmpty());
obj = registeredServiceDistributedCacheManager.get(registeredService);
assertNotNull(obj);
var c = registeredServiceDistributedCacheManager.findAll(obj1 -> obj1.getValue().equals(registeredService));
assertFalse(c.isEmpty());
registeredServiceDistributedCacheManager.remove(registeredService, cache, true);
Thread.sleep(5000);
c = registeredServiceDistributedCacheManager.findAll(obj1 -> obj1.getValue().equals(registeredService));
assertTrue(c.isEmpty());
registeredServiceDistributedCacheManager.clear();
assertTrue(registeredServiceDistributedCacheManager.getAll().isEmpty());
}
use of org.apereo.cas.util.PublisherIdentifier in project cas by apereo.
the class RegisteredServiceKafkaDistributedCacheManagerTests method verifyOperation.
@Test
public void verifyOperation() {
val service = RegisteredServiceTestUtils.getRegisteredService();
assertFalse(registeredServiceDistributedCacheManager.contains(service));
assertTrue(registeredServiceDistributedCacheManager.getAll().isEmpty());
assertTrue(registeredServiceDistributedCacheManager.findAll(Objects::nonNull).isEmpty());
val item = new DistributedCacheObject<RegisteredService>(Map.of(), System.currentTimeMillis(), service, new PublisherIdentifier());
assertNotNull(registeredServiceDistributedCacheManager.set(service, item, true));
assertNotNull(registeredServiceDistributedCacheManager.set(service, item, false));
assertNotNull(registeredServiceDistributedCacheManager.update(service, item, true));
assertNotNull(registeredServiceDistributedCacheManager.update(service, item, false));
}
use of org.apereo.cas.util.PublisherIdentifier in project cas by apereo.
the class RegisteredServiceHazelcastDistributedCacheManagerTests method verifyPublisher.
@Test
public void verifyPublisher() {
val registeredService = RegisteredServiceTestUtils.getRegisteredService();
val casRegisteredServiceStreamPublisherIdentifier = new PublisherIdentifier("123456");
val publisher = new DefaultCasRegisteredServiceStreamPublisher(mgr);
publisher.publish(registeredService, new CasRegisteredServiceDeletedEvent(this, registeredService), casRegisteredServiceStreamPublisherIdentifier);
publisher.publish(registeredService, new CasRegisteredServiceSavedEvent(this, registeredService), casRegisteredServiceStreamPublisherIdentifier);
publisher.publish(registeredService, new CasRegisteredServiceLoadedEvent(this, registeredService), casRegisteredServiceStreamPublisherIdentifier);
assertFalse(mgr.getAll().isEmpty());
}
use of org.apereo.cas.util.PublisherIdentifier in project cas by apereo.
the class RegisteredServiceKafkaDistributedCacheListenerTests method verifyRemoval.
@Test
public void verifyRemoval() {
val service = RegisteredServiceTestUtils.getRegisteredService();
val item = new DistributedCacheObject<RegisteredService>(Map.of("event", CasRegisteredServiceDeletedEvent.class.getSimpleName()), System.currentTimeMillis(), service, new PublisherIdentifier());
assertDoesNotThrow(new Executable() {
@Override
public void execute() throws Throwable {
listener.registeredServiceDistributedCacheKafkaListener(item);
}
});
}
Aggregations