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);
}
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());
}
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();
}
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());
}
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)));
}
Aggregations