Java源码示例:org.testcontainers.containers.Neo4jContainer

示例1
Map<String, Object> prepareNeo4j() {
	String neo4jUrl = Optional.ofNullable(System.getenv(SYS_PROPERTY_NEOJ4_URL)).orElse("");
	String neo4jPassword = Optional.ofNullable(System.getenv(SYS_PROPERTY_NEO4J_PASSWORD)).orElse("");

	if (neo4jUrl.isEmpty() || neo4jPassword.isEmpty()) {
		neo4jContainer = new Neo4jContainer<>().withAdminPassword("benchmark");
		neo4jContainer.start();
		neo4jUrl = neo4jContainer.getBoltUrl();
		neo4jPassword = neo4jContainer.getAdminPassword();
	}

	return Map.of(
		"org.neo4j.driver.authentication.password", neo4jPassword,
		"org.neo4j.driver.authentication.username", "neo4j",
		"org.neo4j.driver.uri", neo4jUrl
	);
}
 
示例2
Map<String, Object> prepareNeo4j() {
	String neo4jUrl = Optional.ofNullable(System.getenv(SYS_PROPERTY_NEOJ4_URL)).orElse("");
	String neo4jPassword = Optional.ofNullable(System.getenv(SYS_PROPERTY_NEO4J_PASSWORD)).orElse("");

	if (neo4jUrl.isEmpty() || neo4jPassword.isEmpty()) {
		neo4jContainer = new Neo4jContainer<>().withAdminPassword("benchmark");
		neo4jContainer.start();
		neo4jUrl = neo4jContainer.getBoltUrl();
		neo4jPassword = neo4jContainer.getAdminPassword();
	}

	return Map.of(
		"org.neo4j.driver.authentication.password", neo4jPassword,
		"org.neo4j.driver.authentication.username", "neo4j",
		"org.neo4j.driver.uri", neo4jUrl
	);
}
 
示例3
Map<String, Object> prepareNeo4j() {
	String neo4jUrl = Optional.ofNullable(System.getenv(SYS_PROPERTY_NEOJ4_URL)).orElse("");
	String neo4jPassword = Optional.ofNullable(System.getenv(SYS_PROPERTY_NEO4J_PASSWORD)).orElse("");

	if (neo4jUrl.isEmpty() || neo4jPassword.isEmpty()) {
		neo4jContainer = new Neo4jContainer<>().withAdminPassword("benchmark");
		neo4jContainer.start();
		neo4jUrl = neo4jContainer.getBoltUrl();
		neo4jPassword = neo4jContainer.getAdminPassword();
	}

	return Map.of(
		"org.neo4j.driver.authentication.password", neo4jPassword,
		"org.neo4j.driver.authentication.username", "neo4j",
		"org.neo4j.driver.uri", neo4jUrl
	);
}
 
示例4
Map<String, Object> prepareNeo4j() {
	String neo4jUrl = Optional.ofNullable(System.getenv(SYS_PROPERTY_NEOJ4_URL)).orElse("");
	String neo4jPassword = Optional.ofNullable(System.getenv(SYS_PROPERTY_NEO4J_PASSWORD)).orElse("");
	neo4jUrl = "bolt://localhost:7687";
	neo4jPassword = "benchmark";
	if (neo4jUrl.isEmpty() || neo4jPassword.isEmpty()) {
		neo4jContainer = new Neo4jContainer<>().withAdminPassword("benchmark");
		neo4jContainer.start();
		neo4jUrl = neo4jContainer.getBoltUrl();
		neo4jPassword = neo4jContainer.getAdminPassword();
	}

	return Map.of(
		"spring.data.neo4j.password", neo4jPassword,
		"spring.data.neo4j.username", "neo4j",
		"spring.data.neo4j.uri", neo4jUrl
	);
}
 
示例5
@Override
public void initialize(ConfigurableApplicationContext configurableApplicationContext) {
	final Neo4jContainer<?> neo4jContainer = new Neo4jContainer<>("neo4j:4.0.0-enterprise")
		.withEnv("NEO4J_ACCEPT_LICENSE_AGREEMENT", "yes");
	neo4jContainer.start();
	configurableApplicationContext
		.addApplicationListener((ApplicationListener<ContextClosedEvent>) event -> neo4jContainer.stop());
	TestPropertyValues
		.of(
			"org.neo4j.driver.uri=" + neo4jContainer.getBoltUrl(),
			"org.neo4j.driver.authentication.username=neo4j",
			"org.neo4j.driver.authentication.password=" + neo4jContainer.getAdminPassword()
		)
		.applyTo(configurableApplicationContext.getEnvironment());
}
 
示例6
@Override
public void initialize(ConfigurableApplicationContext configurableApplicationContext) {
	final Neo4jContainer<?> neo4jContainer = new Neo4jContainer<>("neo4j:4.0").withoutAuthentication();
	neo4jContainer.start();
	configurableApplicationContext
		.addApplicationListener((ApplicationListener<ContextClosedEvent>) event -> neo4jContainer.stop());
	TestPropertyValues.of("org.neo4j.driver.uri=" + neo4jContainer.getBoltUrl())
		.applyTo(configurableApplicationContext.getEnvironment());
}
 
示例7
@Override
public void initialize(ConfigurableApplicationContext configurableApplicationContext) {
    final Neo4jContainer<?> neo4jContainer = new Neo4jContainer<>("neo4j:4.0").withoutAuthentication();
    neo4jContainer.start();
    configurableApplicationContext
            .addApplicationListener((ApplicationListener<ContextClosedEvent>) event -> neo4jContainer.stop());
    TestPropertyValues.of("org.neo4j.driver.uri=" + neo4jContainer.getBoltUrl())
            .applyTo(configurableApplicationContext.getEnvironment());
}