我正在尝试测试一个属性存在约束,它是Enterprise特性,因此我在Gradle构建中切换到了企业库:
implementation group: 'org.neo4j.driver', name: 'neo4j-java-driver', version: '4.4.2'
implementation group: 'org.neo4j', name: 'neo4j-enterprise', version: '3.5.0-beta01'
implementation group: 'org.neo4j', name: 'neo4j-cypher-dsl', version: '2021.4.2'
testImplementation group: 'org.neo4j.test', name: 'neo4j-harness-enterprise', version: '3.5.0-beta01'下面是测试类:
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class ExistenceConstraintTest {
private final Driver driver;
public ExistenceConstraintTest() {
ServerControls serverControls = TestServerBuilders.newInProcessBuilder()
// .withConfig("gds.enterprise.license_file", "/path/to/my/license/keyfile")
.newServer();
driver = GraphDatabase.driver(serverControls.boltURI());
}
@BeforeAll
void createConstraints() {
try (Session session = driver.session()) {
session.run("CREATE CONSTRAINT " +
"ON (node:Label) " +
"ASSERT EXISTS(node.property)");
}
}
@Test
void test() {
}
}包含许可文件路径的withConfig行被注释掉,因为我不确定是否需要它。当我运行这个程序时,我会得到以下错误:
org.neo4j.driver.exceptions.DatabaseException: Unable to create CONSTRAINT ON ( label:Label ) ASSERT exists(label.property):
Property existence constraint requires Neo4j Enterprise Edition该错误表明,尽管使用了Gradle配置,测试仍然使用Community。我在构建或配置中遗漏了什么吗?
此外,我还必须在约束中使用带有ASSERT的旧风格语法,因为当前版本的新样式将失败:
org.neo4j.driver.exceptions.ClientException: Invalid input ' ': expected 'e/E' (line 1, column 22 (offset: 21))
"CREATE CONSTRAINT FOR (node:Label) REQUIRE Label.property IS NOT NULL"发布于 2022-01-10 13:27:15
这个错误是一个错误,因此,而不是这样做;
"CREATE CONSTRAINT ON (node:Label) ASSERT EXISTS(Label.property)"尝试;
"CREATE CONSTRAINT ON (node:Label) ASSERT EXISTS(node.property)"注意,在检查是否存在时,var节点具有该属性。
发布于 2022-01-12 11:43:24
当我使用EnterpriseInProcessServerBuilder时,似乎是可行的:
ServerControls serverControls = new EnterpriseInProcessServerBuilder()
.newServer();https://stackoverflow.com/questions/70651623
复制相似问题