How to use getAllPropertyFilesOnClassloader method of org.testcontainers.utility.ClasspathScanner class

Best Testcontainers-java code snippet using org.testcontainers.utility.ClasspathScanner.getAllPropertyFilesOnClassloader

Source:ClasspathScanner.java Github

copy

Full Screen

...15 @VisibleForTesting16 static Stream<URL> scanFor(final String name, ClassLoader... classLoaders) {17 return Stream18 .of(classLoaders)19 .flatMap(classLoader -> getAllPropertyFilesOnClassloader(classLoader, name))20 .filter(Objects::nonNull)21 .sorted(22 Comparator23 .comparing(ClasspathScanner::filesFileSchemeFirst) // resolve 'local' files first24 .thenComparing(URL::toString) // sort alphabetically for the sake of determinism25 )26 .distinct();27 }28 private static Integer filesFileSchemeFirst(final URL t) {29 return t.getProtocol().equals("file") ? 0 : 1;30 }31 /**32 * @param name the resource name to search for33 * @return distinct, ordered stream of resources found by searching this class' classloader and the current thread's34 * context classloader. Results are currently alphabetically sorted.35 */36 static Stream<URL> scanFor(final String name) {37 return scanFor(38 name,39 ClasspathScanner.class.getClassLoader(),40 Thread.currentThread().getContextClassLoader()41 );42 }43 @Nullable44 private static Stream<URL> getAllPropertyFilesOnClassloader(final ClassLoader it, final String s) {45 try {46 return Collections.list(it.getResources(s)).stream();47 } catch (Exception e) {48 log.error("Unable to read configuration from classloader {} - this is probably a bug", it, e);49 return Stream.empty();50 }51 }52}...

Full Screen

Full Screen

getAllPropertyFilesOnClassloader

Using AI Code Generation

copy

Full Screen

1public class TestContainersConfiguration {2 public static void main(String[] args) {3 System.out.println("All Property Files on Classloader : " + ClasspathScanner.getAllPropertyFilesOnClassloader());4 System.out.println("Load Properties : " + TestcontainersConfiguration.getInstance().loadProperties());5 System.out.println("Get Env Var Or Property : " + TestcontainersConfiguration.getInstance().getEnvVarOrProperty("TESTCONTAINERS_RYUK_DISABLED", "true"));6 System.out.println("Get Testcontainers Properties : " + TestcontainersConfiguration.getInstance().getTestcontainersProperties());7 }8}9Load Properties : {TESTCONTAINERS_RYUK_DISABLED=true}10Get Testcontainers Properties : {TESTCONTAINERS_RYUK_DISABLED=true}

Full Screen

Full Screen

getAllPropertyFilesOnClassloader

Using AI Code Generation

copy

Full Screen

1import org.testcontainers.utility.ClasspathScanner;2import java.util.Properties;3import java.util.Set;4public class TestClasspathScanner {5 public static void main(String[] args) {6 Set<String> files = ClasspathScanner.getAllPropertyFilesOnClasspath();7 for (String file : files) {8 Properties properties = ClasspathScanner.loadProperties(file);9 System.out.println(file + ": " + properties);10 }11 }12}13testcontainers.properties: {TESTCONTAINERS_RYUK_DISABLED=false, TESTCONTAINERS_RYUK_CONTAINER_IMAGE=quay.io/testcontainers/ryuk:0.2.3, TESTCONTAINERS_RYUK_TIMEOUT=60000, TESTCONTAINERS_RYUK_TCP_PORT=0, TESTCONTAINERS_RYUK_UDP_PORT=0, TESTCONTAINERS_RYUK_DEBUG=false, TESTCONTAINERS_RYUK_CONTAINER_NAME=ryuk-4d4e8d4f-2e7a-4f5e-8d3c-3c5e9c0b5f5a, TESTCONTAINERS_RYUK_CONTAINER_LABELS=, TESTCONTAINERS_RYUK_CONTAINER_NETWORK=bridge, TESTCONTAINERS_RYUK_CONTAINER_NETWORK_ALIAS=, TESTCONTAINERS_RYUK_CONTAINER_GROUP=, TESTCONTAINERS_RYUK_CONTAINER_USER=, TESTCONTAINERS_RYUK_CONTAINER_WORKING_DIRECTORY=, TESTCONTAINERS_RYUK_CONTAINER_HOSTNAME=, TESTCONTAINERS_RYUK_CONTAINER_HOSTNAME_EXTERNAL=, TESTCONTAINERS_RYUK_CONTAINER_ENVIRONMENT=, TESTCONTAINERS_RYUK_CONTAINER_EXTRA_HOSTS=, TESTCONTAINERS_RYUK_CONTAINER_PRIVILEGED_MODE=false, TESTCONTAINERS_RYUK_CONTAINER_CAPABILITIES=, TESTCONTAINERS_RYUK_CONTAINER_DNS_SERVERS=, TESTCONTAINERS_RYUK_CONTAINER_DNS_SEARCH_DOMAINS=, TESTCONTAINERS_RYUK_CONTAINER_TMPFS=, TESTCONTAINERS_RYUK_CONTAINER_LOG_LEVEL=INFO, TESTCONTAINERS_RYUK_CONTAINER_LOG_FILE=, TESTCONTAINERS_RYUK_CONTAINER_REMOVE_VOLUMES=false, TESTCONTAINERS_RYUK_CONTAINER_REMOVE_ON

Full Screen

Full Screen

getAllPropertyFilesOnClassloader

Using AI Code Generation

copy

Full Screen

1import org.testcontainers.utility.ClasspathScanner;2import java.util.Properties;3import java.util.Set;4public class TestClasspathScanner {5 public static void main(String[] args) {6 Set<String> files = ClasspathScanner.getAllPropertyFilesOnClasspath();7 for (String file : files) {8 Properties properties = ClasspathScanner.loadProperties(file);9 System.out.println(file + ": " + properties);10 }11 }12}13testcontainers.properties: {TESTCONTAINERS_RYUK_DISABLED=false, TESTCONTAINERS_RYUK_CONTAINER_IMAGE=quay.io/testcontainers/ryuk:0.2.3, TESTCONTAINERS_RYUK_TIMEOUT=60000, TESTCONTAINERS_RYUK_TCP_PORT=0, TESTCONTAINERS_RYUK_UDP_PORT=0, TESTCONTAINERS_RYUK_DEBUG=false, TESTCONTAINERS_RYUK_CONTAINER_NAME=ryuk-4d4e8d4f-2e7a-4f5e-8d3c-3c5e9c0b5f5a, TESTCONTAINERS_RYUK_CONTAINER_LABELS=, TESTCONTAINERS_RYUK_CONTAINER_NETWORK=bridge, TESTCONTAINERS_RYUK_CONTAINER_NETWORK_ALIAS=, TESTCONTAINERS_RYUK_CONTAINER_GROUP=, TESTCONTAINERS_RYUK_CONTAINER_USER=, TESTCONTAINERS_RYUK_CONTAINER_WORKING_DIRECTORY=, TESTCONTAINERS_RYUK_CONTAINER_HOSTNAME=, TESTCONTAINERS_RYUK_CONTAINER_HOSTNAME_EXTERNAL=, TESTCONTAINERS_RYUK_CONTAINER_ENVIRONMENT=, TESTCONTAINERS_RYUK_CONTAINER_EXTRA_HOSTS=, TESTCONTAINERS_RYUK_CONTAINER_PRIVILEGED_MODE=false, TESTCONTAINERS_RYUK_CONTAINER_CAPABILITIES=, TESTCONTAINERS_RYUK_CONTAINER_DNS_SERVERS=, TESTCONTAINERS_RYUK_CONTAINER_DNS_SEARCH_DOMAINS=, TESTCONTAINERS_RYUK_CONTAINER_TMPFS=, TESTCONTAINERS_RYUK_CONTAINER_LOG_LEVEL=INFO, TESTCONTAINERS_RYUK_CONTAINER_LOG_FILE=, TESTCONTAINERS_RYUK_CONTAINER_REMOVE_VOLUMES=false, TESTCONTAINERS_RYUK_CONTAINER_REMOVE_ON

Full Screen

Full Screen

getAllPropertyFilesOnClassloader

Using AI Code Generation

copy

Full Screen

1import org.testcontainers.utility.ClasspathScanner;2import java.util.Properties;3import java.util.Set;4public class TestClasspathScanner {5 public static void main(String[] args) {6 Set<String> files = ClasspathScanner.getAllPropertyFilesOnClasspath();7 for (String file : files) {8 Properties properties = ClasspathScanner.loadProperties(file);9 System.out.println(file + ": " + properties);10 }11 }12}13testcontainers.properties: {TESTCONTAINERS_RYUK_DISABLED=false, TESTCONTAINERS_RYUK_CONTAINER_IMAGE=quay.io/testcontainers/ryuk:0.2.3, TESTCONTAINERS_RYUK_TIMEOUT=60000, TESTCONTAINERS_RYUK_TCP_PORT=0, TESTCONTAINERS_RYUK_UDP_PORT=0, TESTCONTAINERS_RYUK_DEBUG=false, TESTCONTAINERS_RYUK_CONTAINER_NAME=ryuk-4d4e8d4f-2e7a-4f5e-8d3c-3c5e9c0b5f5a, TESTCONTAINERS_RYUK_CONTAINER_LABELS=, TESTCONTAINERS_RYUK_CONTAINER_NETWORK=bridge, TESTCONTAINERS_RYUK_CONTAINER_NETWORK_ALIAS=, TESTCONTAINERS_RYUK_CONTAINER_GROUP=, TESTCONTAINERS_RYUK_CONTAINER_USER=, TESTCONTAINERS_RYUK_CONTAINER_WORKING_DIRECTORY=, TESTCONTAINERS_RYUK_CONTAINER_HOSTNAME=, TESTCONTAINERS_RYUK_CONTAINER_HOSTNAME_EXTERNAL=, TESTCONTAINERS_RYUK_CONTAINER_ENVIRONMENT=, TESTCONTAINERS_RYUK_CONTAINER_EXTRA_HOSTS=, TESTCONTAINERS_RYUK_CONTAINER_PRIVILEGED_MODE=false, TESTCONTAINERS_RYUK_CONTAINER_CAPABILITIES=, TESTCONTAINERS_RYUK_CONTAINER_DNS_SERVERS=, TESTCONTAINERS_RYUK_CONTAINER_DNS_SEARCH_DOMAINS=, TESTCONTAINERS_RYUK_CONTAINER_TMPFS=, TESTCONTAINERS_RYUK_CONTAINER_LOG_LEVEL=INFO, TESTCONTAINERS_RYUK_CONTAINER_LOG_FILE=, TESTCONTAINERS_RYUK_CONTAINER_REMOVE_VOLUMES=false, TESTCONTAINERS_RYUK_CONTAINER_REMOVE_ON

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Testcontainers-java automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in ClasspathScanner

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful