Search in sources :

Example 6 with PublisherIdentifier

use of org.apereo.cas.util.PublisherIdentifier in project cas by apereo.

the class DistributedCacheObjectTests method verifySerialization.

@Test
public void verifySerialization() throws Exception {
    val o = DistributedCacheObject.<String>builder().value("objectValue").publisherIdentifier(new PublisherIdentifier()).build();
    val file = new File(FileUtils.getTempDirectoryPath(), UUID.randomUUID().toString() + ".json");
    MAPPER.writeValue(file, o);
    val readPolicy = MAPPER.readValue(file, DistributedCacheObject.class);
    assertEquals(o, readPolicy);
}
Also used : lombok.val(lombok.val) PublisherIdentifier(org.apereo.cas.util.PublisherIdentifier) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 7 with PublisherIdentifier

use of org.apereo.cas.util.PublisherIdentifier in project cas by apereo.

the class DistributedCacheObjectTests method verifyNullValue.

@Test
public void verifyNullValue() {
    val o = DistributedCacheObject.<String>builder().value("objectValue").publisherIdentifier(new PublisherIdentifier()).build();
    assertTrue(o.getProperties().isEmpty());
    o.getProperties().put("key", null);
    o.getProperties().put("key2", "12.54");
    assertNull(o.getProperty("nothing", String.class));
    assertNull(o.getProperty("key", String.class));
    assertThrows(ClassCastException.class, () -> o.getProperty("key2", Long.class));
}
Also used : lombok.val(lombok.val) PublisherIdentifier(org.apereo.cas.util.PublisherIdentifier) Test(org.junit.jupiter.api.Test)

Example 8 with PublisherIdentifier

use of org.apereo.cas.util.PublisherIdentifier in project cas by apereo.

the class DistributedCacheObjectTests method verifyAction.

@Test
public void verifyAction() {
    val o = DistributedCacheObject.<String>builder().value("objectValue").publisherIdentifier(new PublisherIdentifier()).build();
    assertNotNull(o.toString());
    assertNotNull(o.getValue());
    assertTrue(o.getTimestamp() > 0);
    assertTrue(o.getProperties().isEmpty());
    o.getProperties().put("key", "value");
    assertFalse(o.getProperties().isEmpty());
    assertNotNull(o.getProperty("key", String.class));
    assertTrue(o.containsProperty("key"));
}
Also used : lombok.val(lombok.val) PublisherIdentifier(org.apereo.cas.util.PublisherIdentifier) Test(org.junit.jupiter.api.Test)

Example 9 with PublisherIdentifier

use of org.apereo.cas.util.PublisherIdentifier in project cas by apereo.

the class DeleteTicketsMessageQueueCommandTests method verifyDeleteTickets.

@Test
public void verifyDeleteTickets() throws Exception {
    val ticket = new TicketGrantingTicketImpl("TGT", CoreAuthenticationTestUtils.getAuthentication(), NeverExpiresExpirationPolicy.INSTANCE);
    ticketRegistry.getObject().addTicket(ticket);
    val cmd = new DeleteTicketsMessageQueueCommand(new PublisherIdentifier());
    cmd.execute(ticketRegistry.getObject());
    assertTrue(ticketRegistry.getObject().getTickets().isEmpty());
}
Also used : lombok.val(lombok.val) DeleteTicketsMessageQueueCommand(org.apereo.cas.ticket.queue.DeleteTicketsMessageQueueCommand) TicketGrantingTicketImpl(org.apereo.cas.ticket.TicketGrantingTicketImpl) PublisherIdentifier(org.apereo.cas.util.PublisherIdentifier) Test(org.junit.jupiter.api.Test)

Example 10 with PublisherIdentifier

use of org.apereo.cas.util.PublisherIdentifier in project cas by apereo.

the class DeleteTicketMessageQueueCommandTests method verifyDeleteTicket.

@Test
public void verifyDeleteTicket() throws Exception {
    val ticket = new TicketGrantingTicketImpl("TGT", CoreAuthenticationTestUtils.getAuthentication(), NeverExpiresExpirationPolicy.INSTANCE);
    ticketRegistry.getObject().addTicket(ticket);
    val cmd = new DeleteTicketMessageQueueCommand(new PublisherIdentifier(), ticket.getId());
    cmd.execute(ticketRegistry.getObject());
    assertTrue(ticketRegistry.getObject().getTickets().isEmpty());
}
Also used : lombok.val(lombok.val) DeleteTicketMessageQueueCommand(org.apereo.cas.ticket.queue.DeleteTicketMessageQueueCommand) TicketGrantingTicketImpl(org.apereo.cas.ticket.TicketGrantingTicketImpl) PublisherIdentifier(org.apereo.cas.util.PublisherIdentifier) Test(org.junit.jupiter.api.Test)

Aggregations

lombok.val (lombok.val)24 PublisherIdentifier (org.apereo.cas.util.PublisherIdentifier)24 Test (org.junit.jupiter.api.Test)23 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)13 InMemoryServiceRegistry (org.apereo.cas.services.InMemoryServiceRegistry)7 StaticApplicationContext (org.springframework.context.support.StaticApplicationContext)7 CasRegisteredServiceDeletedEvent (org.apereo.cas.support.events.service.CasRegisteredServiceDeletedEvent)5 TicketGrantingTicketImpl (org.apereo.cas.ticket.TicketGrantingTicketImpl)4 DistributedCacheObject (org.apereo.cas.util.cache.DistributedCacheObject)4 File (java.io.File)3 RegisteredService (org.apereo.cas.services.RegisteredService)3 CasRegisteredServiceSavedEvent (org.apereo.cas.support.events.service.CasRegisteredServiceSavedEvent)3 RegexRegisteredService (org.apereo.cas.services.RegexRegisteredService)2 RegisteredServiceJsonSerializer (org.apereo.cas.services.util.RegisteredServiceJsonSerializer)2 CasRegisteredServiceLoadedEvent (org.apereo.cas.support.events.service.CasRegisteredServiceLoadedEvent)2 Assertions (org.junit.jupiter.api.Assertions)2 Tag (org.junit.jupiter.api.Tag)2 Executable (org.junit.jupiter.api.function.Executable)2 Objects (java.util.Objects)1 UUID (java.util.UUID)1