use of org.apereo.cas.services.util.RegisteredServiceJsonSerializer in project cas by apereo.
the class DeleteResourceBasedRegisteredServiceWatcherTests method verifyTempFilesIgnored.
@Test
public void verifyTempFilesIgnored() throws Exception {
val result = new AtomicBoolean(false);
val mockAppContext = mock(ConfigurableApplicationContext.class);
doAnswer(args -> {
val clazz = args.getArgument(0).getClass();
result.set(clazz.equals(CasRegisteredServiceDeletedEvent.class));
return null;
}).when(mockAppContext).publishEvent(any());
val registry = new AbstractResourceBasedServiceRegistry(new ClassPathResource("services"), List.of(new RegisteredServiceJsonSerializer()), mockAppContext, new ArrayList<>()) {
@Override
protected String[] getExtensions() {
return new String[] { "json" };
}
};
var results = registry.load();
assertFalse(results.isEmpty());
val watcher = new DeleteResourceBasedRegisteredServiceWatcher(registry);
watcher.accept(new File(".Sample-1.json"));
assertFalse(result.get());
watcher.accept(new File("Sample-1.json.swp"));
assertFalse(result.get());
assertEquals(1, registry.size());
}
use of org.apereo.cas.services.util.RegisteredServiceJsonSerializer in project cas by apereo.
the class DeleteResourceBasedRegisteredServiceWatcherTests method verifyOperationNotFound.
@Test
public void verifyOperationNotFound() throws Exception {
val result = new AtomicBoolean(false);
val mockAppContext = mock(ConfigurableApplicationContext.class);
doAnswer(args -> {
val clazz = args.getArgument(0).getClass();
result.set(clazz.equals(CasRegisteredServicesLoadedEvent.class));
return null;
}).when(mockAppContext).publishEvent(any());
val watcher = new DeleteResourceBasedRegisteredServiceWatcher(new AbstractResourceBasedServiceRegistry(new ClassPathResource("services"), List.of(new RegisteredServiceJsonSerializer()), mockAppContext, new ArrayList<>()) {
@Override
protected String[] getExtensions() {
return new String[] { "json" };
}
});
watcher.accept(new File("removed.json"));
assertTrue(result.get());
}
use of org.apereo.cas.services.util.RegisteredServiceJsonSerializer in project cas by apereo.
the class JsonServiceRegistryTests method verifyExistingDefinitionForCompatibility2.
@Test
public void verifyExistingDefinitionForCompatibility2() throws Exception {
val resource = new ClassPathResource("returnMappedAttributeReleasePolicyTest2.json");
val serializer = new RegisteredServiceJsonSerializer();
val service = serializer.from(resource.getInputStream());
assertNotNull(service);
assertNotNull(service.getAttributeReleasePolicy());
val policy = (ReturnMappedAttributeReleasePolicy) service.getAttributeReleasePolicy();
assertNotNull(policy);
assertEquals(2, policy.getAllowedAttributes().size());
}
use of org.apereo.cas.services.util.RegisteredServiceJsonSerializer in project cas by apereo.
the class JsonServiceRegistryTests method verifyExistingDefinitionForCompatibility1.
@Test
public void verifyExistingDefinitionForCompatibility1() throws Exception {
val resource = new ClassPathResource("returnMappedAttributeReleasePolicyTest1.json");
val serializer = new RegisteredServiceJsonSerializer();
val service = serializer.from(resource.getInputStream());
assertNotNull(service);
assertNotNull(service.getAttributeReleasePolicy());
val policy = (ReturnMappedAttributeReleasePolicy) service.getAttributeReleasePolicy();
assertNotNull(policy);
assertEquals(2, policy.getAllowedAttributes().size());
}
use of org.apereo.cas.services.util.RegisteredServiceJsonSerializer in project cas by apereo.
the class CasServicesStreamingKafkaConfiguration method registeredServiceKafkaListenerContainerFactory.
@Bean
@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
@ConditionalOnMissingBean(name = "registeredServiceKafkaListenerContainerFactory")
public ConcurrentKafkaListenerContainerFactory<String, DistributedCacheObject> registeredServiceKafkaListenerContainerFactory(final CasConfigurationProperties casProperties) {
val kafka = casProperties.getServiceRegistry().getStream().getKafka();
val factory = new KafkaObjectFactory<String, DistributedCacheObject>(kafka.getBootstrapAddress());
factory.setConsumerGroupId("registeredServices");
val mapper = new RegisteredServiceJsonSerializer().getObjectMapper();
return factory.getKafkaListenerContainerFactory(new StringDeserializer(), new JsonDeserializer<>(DistributedCacheObject.class, mapper));
}
Aggregations