Search in sources :

Example 11 with Tag

use of org.junit.jupiter.api.Tag in project logging-log4j2 by apache.

the class ConfigurationFactoryTest method json.

@Test
@Tag("json")
@LoggerContextSource("log4j-test1.json")
void json(final LoggerContext context) throws IOException {
    checkConfiguration(context);
    final Path logFile = Paths.get("target", "test-json.log");
    checkFileLogger(context, logFile);
}
Also used : Path(java.nio.file.Path) Test(org.junit.jupiter.api.Test) Tag(org.junit.jupiter.api.Tag) LoggerContextSource(org.apache.logging.log4j.core.test.junit.LoggerContextSource)

Example 12 with Tag

use of org.junit.jupiter.api.Tag in project logging-log4j2 by apache.

the class ScriptConditionTest method testSelectFilesToDelete3.

@Test
@Tag("groovy")
public void testSelectFilesToDelete3() {
    final Configuration config = new DefaultConfiguration();
    // creates the ScriptManager
    config.initialize();
    final List<PathWithAttributes> pathList = new ArrayList<>();
    pathList.add(new PathWithAttributes(Paths.get("/path/1/abc/a.txt"), new DummyFileAttributes()));
    pathList.add(new PathWithAttributes(Paths.get("/path/2/abc/bbb.txt"), new DummyFileAttributes()));
    pathList.add(new PathWithAttributes(Paths.get("/path/3/abc/c.txt"), new DummyFileAttributes()));
    final String scriptText = // 
    "" + // 
    "import java.nio.file.*;" + // 
    "def pattern = ~/(\\d*)[\\/\\\\]abc[\\/\\\\].*\\.txt/;" + // 
    "assert pattern.getClass() == java.util.regex.Pattern;" + "def copy = pathList.collect{it};" + // 
    "pathList.each { pathWithAttribs -> \n" + // 
    "  def relative = basePath.relativize pathWithAttribs.path;" + // 
    "  println 'relative path: ' + relative;" + "  def str = relative.toString();" + // 
    "  def m = pattern.matcher(str);" + // 
    "  if (m.find()) {" + // 
    "    def index = m.group(1) as int;" + // 
    "    println 'extracted index: ' + index;" + "    def isOdd = (index % 2) == 1;" + // 
    "    println 'is odd: ' + isOdd;" + "    if (isOdd) { copy.remove pathWithAttribs}" + // 
    "  }" + // 
    "}" + "println copy;" + "copy;";
    final ScriptPlugin script = new ScriptPlugin("test", "groovy", scriptText);
    final ScriptCondition condition = ScriptCondition.createCondition(script, config);
    final Path base = Paths.get("/path");
    final List<PathWithAttributes> result = condition.selectFilesToDelete(base, pathList);
    assertEquals(1, result.size());
    assertEquals(Paths.get("/path/2/abc/bbb.txt"), result.get(0).getPath());
}
Also used : Path(java.nio.file.Path) PathWithAttributes(org.apache.logging.log4j.core.appender.rolling.action.PathWithAttributes) DefaultConfiguration(org.apache.logging.log4j.core.config.DefaultConfiguration) Configuration(org.apache.logging.log4j.core.config.Configuration) ArrayList(java.util.ArrayList) DefaultConfiguration(org.apache.logging.log4j.core.config.DefaultConfiguration) DummyFileAttributes(org.apache.logging.log4j.core.test.appender.rolling.action.DummyFileAttributes) ScriptPlugin(org.apache.logging.log4j.script.ScriptPlugin) Test(org.junit.jupiter.api.Test) Tag(org.junit.jupiter.api.Tag)

Example 13 with Tag

use of org.junit.jupiter.api.Tag in project mongo-java-driver by mongodb.

the class LoadBalancedClusterTest method synchronousConcurrentTest.

@RepeatedTest(value = 10, name = RepeatedTest.LONG_DISPLAY_NAME)
@Tag("Slow")
public void synchronousConcurrentTest() throws InterruptedException, ExecutionException, TimeoutException {
    String srvHostName = "foo.bar.com";
    ServerAddress resolvedServerAddress = new ServerAddress("host1");
    ClusterableServer expectedServer = mock(ClusterableServer.class);
    ClusterSettings clusterSettings = ClusterSettings.builder().serverSelectionTimeout(5, MILLISECONDS).mode(ClusterConnectionMode.LOAD_BALANCED).srvHost(srvHostName).build();
    ClusterableServerFactory serverFactory = mockServerFactory(resolvedServerAddress, expectedServer);
    Duration srvResolutionTime = Duration.ofSeconds(5);
    DnsSrvRecordMonitorFactory dnsSrvRecordMonitorFactory = mock(DnsSrvRecordMonitorFactory.class);
    when(dnsSrvRecordMonitorFactory.create(eq(srvHostName), eq(clusterSettings.getSrvServiceName()), any())).thenAnswer(invocation -> new TestDnsSrvRecordMonitor(invocation.getArgument(2)).sleepTime(srvResolutionTime));
    cluster = new LoadBalancedCluster(new ClusterId(), clusterSettings, serverFactory, dnsSrvRecordMonitorFactory);
    int numThreads = 100;
    ExecutorService executorService = Executors.newFixedThreadPool(numThreads);
    List<Future<?>> futures = new ArrayList<>(numThreads);
    for (int i = 0; i < numThreads; i++) {
        futures.add(executorService.submit(() -> {
            boolean success = false;
            while (!success) {
                try {
                    cluster.selectServer(mock(ServerSelector.class));
                    success = true;
                } catch (MongoTimeoutException e) {
                // this is expected
                }
            }
            // Keep going for a little while
            for (int j = 0; j < 100; j++) {
                cluster.selectServer(mock(ServerSelector.class));
            }
        }));
    }
    for (Future<?> future : futures) {
        future.get(10, SECONDS);
    }
    executorService.shutdownNow();
}
Also used : ClusterSettings(com.mongodb.connection.ClusterSettings) ClusterId(com.mongodb.connection.ClusterId) ServerAddress(com.mongodb.ServerAddress) ArrayList(java.util.ArrayList) Duration(java.time.Duration) MongoTimeoutException(com.mongodb.MongoTimeoutException) ExecutorService(java.util.concurrent.ExecutorService) Future(java.util.concurrent.Future) RepeatedTest(org.junit.jupiter.api.RepeatedTest) Tag(org.junit.jupiter.api.Tag)

Example 14 with Tag

use of org.junit.jupiter.api.Tag in project cas by apereo.

the class RedisServerTicketRegistryTests method verifyBadTicketDecoding.

@RepeatedTest(1)
@Tag("TicketRegistryTestWithEncryption")
public void verifyBadTicketDecoding() throws Exception {
    val originalAuthn = CoreAuthenticationTestUtils.getAuthentication();
    getNewTicketRegistry().addTicket(new TicketGrantingTicketImpl(ticketGrantingTicketId, originalAuthn, NeverExpiresExpirationPolicy.INSTANCE));
    val tgt = getNewTicketRegistry().getTicket(ticketGrantingTicketId, TicketGrantingTicket.class);
    assertNotNull(tgt);
    val secondRegistry = new RedisTicketRegistry(ticketRedisTemplate, 0);
    secondRegistry.setCipherExecutor(CipherExecutor.noOp());
    val ticket = secondRegistry.getTicket(ticketGrantingTicketId);
    assertNull(ticket);
    assertTrue(secondRegistry.getTickets().isEmpty());
    assertEquals(0, getNewTicketRegistry().stream().count());
}
Also used : lombok.val(lombok.val) TicketGrantingTicketImpl(org.apereo.cas.ticket.TicketGrantingTicketImpl) RepeatedTest(org.junit.jupiter.api.RepeatedTest) Tag(org.junit.jupiter.api.Tag)

Example 15 with Tag

use of org.junit.jupiter.api.Tag in project cas by apereo.

the class AdaptiveMultifactorAuthenticationTriggerTests method verifyNoProviders.

@Test
@Order(0)
@Tag("DisableProviderRegistration")
public void verifyNoProviders() {
    val props = new CasConfigurationProperties();
    props.getAuthn().getAdaptive().getPolicy().getRequireMultifactor().put("mfa-dummy", ".+London.+");
    val trigger = new AdaptiveMultifactorAuthenticationTrigger(null, props, this.applicationContext);
    assertThrows(AuthenticationException.class, () -> trigger.isActivated(authentication, registeredService, this.httpRequest, this.httpResponse, mock(Service.class)));
}
Also used : lombok.val(lombok.val) CasConfigurationProperties(org.apereo.cas.configuration.CasConfigurationProperties) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test) Tag(org.junit.jupiter.api.Tag)

Aggregations

Tag (org.junit.jupiter.api.Tag)43 Test (org.junit.jupiter.api.Test)35 lombok.val (lombok.val)9 CasConfigurationProperties (org.apereo.cas.configuration.CasConfigurationProperties)6 Order (org.junit.jupiter.api.Order)6 TestMethodOrder (org.junit.jupiter.api.TestMethodOrder)6 ArrayList (java.util.ArrayList)5 RepeatedTest (org.junit.jupiter.api.RepeatedTest)5 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)5 FeatureFlag (org.janusgraph.testutil.FeatureFlag)4 AbstractTest (com.microsoft.sqlserver.testframework.AbstractTest)3 Path (java.nio.file.Path)3 SQLException (java.sql.SQLException)3 Random (java.util.Random)3 ExecutorService (java.util.concurrent.ExecutorService)3 JanusGraphVertex (org.janusgraph.core.JanusGraphVertex)3 PropertyKey (org.janusgraph.core.PropertyKey)3 SQLServerConnection (com.microsoft.sqlserver.jdbc.SQLServerConnection)2 SQLServerDataSource (com.microsoft.sqlserver.jdbc.SQLServerDataSource)2 ServerAddress (com.mongodb.ServerAddress)2