package org.apereo.cas.logging;

import org.apereo.cas.configuration.CasConfigurationProperties;
import org.apereo.cas.util.junit.EnabledIfPortOpen;

import lombok.val;
import org.apache.logging.log4j.core.LoggerContext;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.function.Executable;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import software.amazon.awssdk.core.SdkSystemSetting;

import java.util.stream.IntStream;

import static org.junit.jupiter.api.Assertions.*;

/**
 * This is {@link CloudWatchAppenderTests}.
 *
 * @author Misagh Moayyed
 * @since 6.2.0
 */
@EnabledIfPortOpen(port = 4566)
@Tag("AmazonWebServices")
@EnableConfigurationProperties(CasConfigurationProperties.class)
public class CloudWatchAppenderTests {
    static {
        System.setProperty(SdkSystemSetting.AWS_ACCESS_KEY_ID.property(), "AKIAIPPIGGUNIO74C63Z");
        System.setProperty(SdkSystemSetting.AWS_SECRET_ACCESS_KEY.property(), "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");
    }

    @Test
    public void verifyOperation() {
        val context = LoggerContext.getContext(false);
        val logger = context.getLogger(CloudWatchAppender.class.getName());
        val appender = (CloudWatchAppender) logger.getAppenders().get("CloudWatchAppender");
        assertNotNull(appender);
        assertDoesNotThrow(new Executable() {
            @Override
            public void execute() {
                IntStream.range(1, 20).forEach(idx -> logger.info("Testing CloudWatchAppender [{}]...", idx));
            }
        });
        appender.stop();
    }
}

@@ -143,16 +143,50 @@
 tOpen;%0A%0A
+import lombok.extern.slf4j.Slf4j;%0A
 import l
@@ -445,24 +445,78 @@
 Properties;%0A
+import org.springframework.core.io.ClassPathResource;%0A
 import softw
@@ -1193,62 +1193,207 @@
 n() 
-%7B%0A        val context = LoggerContext.getContext(false
+throws Exception %7B%0A        val config = new ClassPathResource(%22log4j2-test.xml%22);%0A        val context = LoggerContext.getContext(CloudWatchAppenderTests.class.getClassLoader(), false, config.getURI()
 );%0A 
@@ -1463,24 +1463,75 @@
 getName());%0A
+        System.out.println(logger.getAppenders());%0A
         val 
@@ -1607,24 +1607,62 @@
 Appender%22);%0A
+        System.out.println(appender);%0A
         asse

fix test cases