本文整理汇总了Java中org.neo4j.driver.v1.exceptions.ClientException类的典型用法代码示例。如果您正苦于以下问题:Java ClientException类的具体用法?Java ClientException怎么用?Java ClientException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ClientException类属于org.neo4j.driver.v1.exceptions包,在下文中一共展示了ClientException类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: shouldNotCreateACopyOfTheGivenStateSinceItsADifferentEntityState
import org.neo4j.driver.v1.exceptions.ClientException; //导入依赖的package包/类
@Test (expected = ClientException.class)
public void shouldNotCreateACopyOfTheGivenStateSinceItsADifferentEntityState() throws Throwable {
// This is in a try-block, to make sure we close the driver after the test
try (Driver driver = GraphDatabase
.driver(neo4j.boltURI(), Config.build().withEncryption().toConfig()); Session session = driver.session()) {
// Given
session.run("CREATE (e:Entity {key:'immutableValue'})-[:CURRENT {date:593910000000}]->(s:State {key:'initialValue'})");
session.run("MATCH (e:Entity {key:'immutableValue'})-[:CURRENT {date:593910000000}]->(s:State {key:'initialValue'}) CREATE (e)-[:HAS_STATE {startDate:593910000000}]->(s)");
session.run("MATCH (e:Entity) CREATE (e)-[:HAS_STATE {startDate:593900000000, endDate:59391000000}]->(s:State:Test {key:'initialValue'})");
session.run("MATCH (sc:State)<-[:CURRENT]-(e:Entity)-[:HAS_STATE]->(s:Test) CREATE (sc)-[:PREVIOUS {date:593900000000}]->(s)");
session.run("CREATE (e:EntityBis {key:'immutableValue'})-[:CURRENT {date:593910000000}]->(s:State {key:'initialValue'})");
session.run("MATCH (e:EntityBis)-[:CURRENT]->(s:State) CREATE (e)-[:HAS_STATE {startDate:593910000000}]->(s)");
StatementResult result = session.run("MATCH (e:Entity), (:EntityBis)-[:HAS_STATE]->(s:State) WITH e, s CALL graph.versioner.patch.from(e, s) YIELD node RETURN node");
Node currentState = result.single().get("node").asNode();
}
}
开发者ID:h-omer,项目名称:neo4j-versioner-core,代码行数:18,代码来源:UpdateTest.java
示例2: shouldNotRollbackToTheGivenStateSinceItsADifferentEntityState
import org.neo4j.driver.v1.exceptions.ClientException; //导入依赖的package包/类
@Test (expected = ClientException.class)
public void shouldNotRollbackToTheGivenStateSinceItsADifferentEntityState() throws Throwable {
// This is in a try-block, to make sure we close the driver after the test
try (Driver driver = GraphDatabase
.driver(neo4j.boltURI(), Config.build().withEncryption().toConfig()); Session session = driver.session()) {
// Given
session.run("CREATE (e:Entity {key:'immutableValue'})-[:CURRENT {date:593910000000}]->(s:State {key:'initialValue'})");
session.run("MATCH (e:Entity {key:'immutableValue'})-[:CURRENT {date:593910000000}]->(s:State {key:'initialValue'}) CREATE (e)-[:HAS_STATE {startDate:593910000000}]->(s)");
session.run("MATCH (e:Entity) CREATE (e)-[:HAS_STATE {startDate:593900000000, endDate:59391000000}]->(s:State:Test {key:'initialValue'})");
session.run("MATCH (sc:State)<-[:CURRENT]-(e:Entity)-[:HAS_STATE]->(s:Test) CREATE (sc)-[:PREVIOUS {date:593900000000}]->(s)");
session.run("CREATE (e:EntityBis {key:'immutableValue'})-[:CURRENT {date:593910000000}]->(s:State {key:'initialValue'})");
session.run("MATCH (e:EntityBis)-[:CURRENT]->(s:State) CREATE (e)-[:HAS_STATE {startDate:593910000000}]->(s)");
StatementResult result = session.run("MATCH (e:Entity), (:EntityBis)-[:HAS_STATE]->(s:State) WITH e, s CALL graph.versioner.rollback.to(e, s) YIELD node RETURN node");
}
}
开发者ID:h-omer,项目名称:neo4j-versioner-core,代码行数:17,代码来源:RollbackTest.java
示例3: flush
import org.neo4j.driver.v1.exceptions.ClientException; //导入依赖的package包/类
private void flush() {
try {
// delete edges
deleteEdges();
// delete vertices
deleteVertices();
// create vertices
createVertices();
// create edges
createEdges();
// update edges
updateEdges();
// update vertices (after edges to be able to locate the vertex if referenced by an edge)
updateVertices();
}
catch (ClientException ex) {
// log error
if (logger.isErrorEnabled())
logger.error("Error committing transaction [{}]", transaction.hashCode(), ex);
// throw original exception
throw ex;
}
}
开发者ID:SteelBridgeLabs,项目名称:neo4j-gremlin-bolt,代码行数:24,代码来源:Neo4JSession.java
示例4: tryValidate
import org.neo4j.driver.v1.exceptions.ClientException; //导入依赖的package包/类
private ExerciseValidation tryValidate(TraineeSession session, String statement, Exercise currentExercise) {
try {
List<Map<String, Object>> actualResult = computeActualResult(statement, currentExercise);
return session.validate(actualResult);
} catch (ClientException e) {
return new ExerciseValidation(false, format("An execution error occurred:%n%s", e.getMessage()));
}
}
开发者ID:fbiville,项目名称:hands-on-neo4j-devoxx-fr-2017,代码行数:9,代码来源:CypherSessionFallbackCommand.java
示例5: warmUpResetSSL
import org.neo4j.driver.v1.exceptions.ClientException; //导入依赖的package包/类
/**
* warm up the Neo4j caches if the server has just been turned on.
* https://neo4j.com/developer/kb/warm-the-cache-to-improve-performance-from-cold-start/
* also, if there is an SSL issue when changing databases, attempt to fix it by running
* some fix up code.
*
* @param props C2SProperties object.
*/
static void warmUpResetSSL(C2SProperties props) {
try {
Neo4jDriver.warmUp(props);
} catch (ClientException ce) {
if (ce.getMessage().contains("SSLEngine problem")) {
System.err.println("SSL Engine issue");
}
} catch (ServiceUnavailableException unavail) {
System.err.println("*** Make sure the Neo4j database is up and running correctly. ***");
unavail.printStackTrace();
System.exit(1);
}
}
开发者ID:DTG-FRESCO,项目名称:cyp2sql,代码行数:22,代码来源:C2SMain.java
示例6: getFormattedMessage
import org.neo4j.driver.v1.exceptions.ClientException; //导入依赖的package包/类
/**
* Interpret the cause of a Bolt exception and translate it into a sensible error message.
*/
@Nonnull
String getFormattedMessage(@Nonnull final Throwable e) {
AnsiFormattedText msg = AnsiFormattedText.s().colorRed();
if (isDebugEnabled()) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(baos);
e.printStackTrace(ps);
msg.append(new String(baos.toByteArray(), StandardCharsets.UTF_8));
} else {
//noinspection ThrowableResultOfMethodCallIgnored
final Throwable cause = getRootCause(e);
if (cause instanceof AnsiFormattedException) {
msg = msg.append(((AnsiFormattedException) cause).getFormattedMessage());
} else if (cause instanceof ClientException &&
cause.getMessage() != null && cause.getMessage().contains("Missing username")) {
// Username and password was not specified
msg = msg.append(cause.getMessage())
.append("\nPlease specify --username, and optionally --password, as argument(s)")
.append("\nor as environment variable(s), NEO4J_USERNAME, and NEO4J_PASSWORD respectively.")
.append("\nSee --help for more info.");
} else {
if (cause.getMessage() != null) {
msg = msg.append(cause.getMessage());
} else {
msg = msg.append(cause.getClass().getSimpleName());
}
}
}
return msg.formattedString();
}
开发者ID:neo4j,项目名称:cypher-shell,代码行数:37,代码来源:AnsiLogger.java
示例7: testNestedDeep
import org.neo4j.driver.v1.exceptions.ClientException; //导入依赖的package包/类
@Test
public void testNestedDeep() {
assertEquals("@|RED nested deep|@", logger.getFormattedMessage(
new ClientException("outer",
new ClientException("nested",
new ClientException("nested deep")))));
}
开发者ID:neo4j,项目名称:cypher-shell,代码行数:8,代码来源:AnsiLoggerTest.java
示例8: setup
import org.neo4j.driver.v1.exceptions.ClientException; //导入依赖的package包/类
@Before
public void setup() throws CommandException {
statementParser = new ShellStatementParser();
badLineError = new ClientException("Found a bad line");
doThrow(badLineError).when(cmdExecuter).execute(contains("bad"));
doReturn(System.out).when(logger).getOutputStream();
}
开发者ID:neo4j,项目名称:cypher-shell,代码行数:8,代码来源:NonInteractiveShellRunnerTest.java
示例9: errorsShouldThrow
import org.neo4j.driver.v1.exceptions.ClientException; //导入依赖的package包/类
@Test
public void errorsShouldThrow() throws IOException, CommandException {
ClientException kaboom = new ClientException("Error kaboom");
doThrow(kaboom).when(statementExecuter).execute(anyString());
StringShellRunner runner = new StringShellRunner(parse("nan anana"), statementExecuter, logger);
int code = runner.runUntilEnd();
assertEquals("Wrong exit code", 1, code);
verify(logger).printError(kaboom);
}
开发者ID:neo4j,项目名称:cypher-shell,代码行数:13,代码来源:StringShellRunnerTest.java
示例10: setup
import org.neo4j.driver.v1.exceptions.ClientException; //导入依赖的package包/类
@Before
public void setup() throws Exception {
statementParser = new ShellStatementParser();
logger = mock(Logger.class);
cmdExecuter = mock(StatementExecuter.class);
txHandler = mock(TransactionHandler.class);
historyFile = temp.newFile();
badLineError = new ClientException("Found a bad line");
userMessagesHandler = mock(UserMessagesHandler.class);
when(userMessagesHandler.getWelcomeMessage()).thenReturn("Welcome to cypher-shell!");
when(userMessagesHandler.getExitMessage()).thenReturn("Exit message");
doThrow(badLineError).when(cmdExecuter).execute(contains("bad"));
doReturn(System.out).when(logger).getOutputStream();
}
开发者ID:neo4j,项目名称:cypher-shell,代码行数:16,代码来源:InteractiveShellRunnerTest.java
示例11: Neo4JBoltTransport
import org.neo4j.driver.v1.exceptions.ClientException; //导入依赖的package包/类
public Neo4JBoltTransport(Configuration config) throws MessageOutputConfigurationException {
configuration = config;
fields = new LinkedList<String>();;
Session session = null;
try {
driver = GraphDatabase.driver( config.getString(Neo4jOutput.CK_NEO4J_URL),
AuthTokens.basic(config.getString(Neo4jOutput.CK_NEO4J_USER), config.getString(Neo4jOutput.CK_NEO4J_PASSWORD)) );
session = driver.session();
//run initialization query only once
String createQueryOnce = config.getString(Neo4jOutput.CK_NEO4J_STARTUP_QUERY);
if (createQueryOnce.length() > 0)
session.run(createQueryOnce);
}
catch (ClientException e){
throw new MessageOutputConfigurationException("Malformed neo4j configuration: " + e );
}
finally {
session.close();
}
//get message fields needed by cypher query
String createQuery = config.getString(Neo4jOutput.CK_NEO4J_QUERY);
LOG.debug("Bolt protocol, create query: " + createQuery);
Matcher m = Pattern.compile("\\{([^{}]*)\\}").matcher(createQuery);
while (m.find()) {
fields.add(m.group(1));
LOG.debug("Found field in cypher statement: " + m.group(1));
}
LOG.info("Identified " + fields.size() + " fields in graph create query.");
parsedCreateQery = parseQuery(createQuery);
}
开发者ID:mariussturm,项目名称:graylog-plugin-output-neo4j,代码行数:40,代码来源:Neo4JBoltTransport.java
示例12: postQuery
import org.neo4j.driver.v1.exceptions.ClientException; //导入依赖的package包/类
private void postQuery(String query, Map<String, Object> mapping) {
Session session = null;
try {
session = driver.session();
session.run(query, mapping).consume();
}
catch (ClientException e) {
LOG.debug("Could not push message to Graph Database: " + e.getMessage());
}
finally{
if (session != null && session.isOpen())
session.close();
}
}
开发者ID:mariussturm,项目名称:graylog-plugin-output-neo4j,代码行数:15,代码来源:Neo4JBoltTransport.java
示例13: testNested
import org.neo4j.driver.v1.exceptions.ClientException; //导入依赖的package包/类
@Test
public void testNested() {
assertEquals("@|RED nested|@", logger.getFormattedMessage(new ClientException("outer",
new CommandException("nested"))));
}
开发者ID:neo4j,项目名称:cypher-shell,代码行数:6,代码来源:AnsiLoggerTest.java
示例14: testNullMessage
import org.neo4j.driver.v1.exceptions.ClientException; //导入依赖的package包/类
@Test
public void testNullMessage() {
assertEquals("@|RED ClientException|@", logger.getFormattedMessage(new ClientException(null)));
assertEquals("@|RED NullPointerException|@",
logger.getFormattedMessage(new ClientException("outer", new NullPointerException(null))));
}
开发者ID:neo4j,项目名称:cypher-shell,代码行数:7,代码来源:AnsiLoggerTest.java
注:本文中的org.neo4j.driver.v1.exceptions.ClientException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论