use of org.neo4j.logging.AssertableLogProvider in project neo4j by neo4j.
the class FileRoleRepositoryTest method shouldFailOnReadingInvalidEntries.
@Test
public void shouldFailOnReadingInvalidEntries() throws Throwable {
// Given
AssertableLogProvider logProvider = new AssertableLogProvider();
fs.mkdirs(roleFile.getParentFile());
// First line is correctly formatted, second line has an extra field
FileRepositorySerializer.writeToFile(fs, roleFile, UTF8.encode("neo4j:admin\n" + "admin:admin:\n"));
// When
roleRepository = new FileRoleRepository(fs, roleFile, logProvider);
thrown.expect(IllegalStateException.class);
thrown.expectMessage(startsWith("Failed to read role file '"));
try {
roleRepository.start();
}// Then
catch (IllegalStateException e) {
assertThat(roleRepository.numberOfRoles(), equalTo(0));
logProvider.assertExactly(AssertableLogProvider.inLog(FileRoleRepository.class).error("Failed to read role file \"%s\" (%s)", roleFile.getAbsolutePath(), "wrong number of line fields [line 2]"));
throw e;
}
}
use of org.neo4j.logging.AssertableLogProvider in project neo4j by neo4j.
the class MultiRealmAuthManagerTest method setUp.
@Before
public void setUp() throws Throwable {
config = Config.defaults();
users = CommunitySecurityModule.getUserRepository(config, NullLogProvider.getInstance(), fsRule.get());
authStrategy = mock(AuthenticationStrategy.class);
logProvider = new AssertableLogProvider();
manager = createAuthManager(true);
userManager = manager.getUserManager();
}
use of org.neo4j.logging.AssertableLogProvider in project neo4j by neo4j.
the class AsyncLogTest method shouldLogAsynchronously.
@Test
public void shouldLogAsynchronously() throws Exception {
// given
AssertableLogProvider logging = new AssertableLogProvider();
Log log = logging.getLog(getClass());
DeferredSender events = new DeferredSender();
AsyncLog asyncLog = new AsyncLog(events, log);
// when
log(invocation.decorate(asyncLog));
// then
logging.assertNoLoggingOccurred();
// when
events.process();
// then
MatcherBuilder matcherBuilder = new MatcherBuilder(inLog(getClass()));
log(matcherBuilder);
logging.assertExactly(matcherBuilder.matcher());
}
use of org.neo4j.logging.AssertableLogProvider in project neo4j by neo4j.
the class UserFunctionIT method shouldLogLikeThereIsNoTomorrow.
@Test
public void shouldLogLikeThereIsNoTomorrow() throws Throwable {
// Given
AssertableLogProvider logProvider = new AssertableLogProvider();
db.shutdown();
db = new TestGraphDatabaseFactory().setInternalLogProvider(logProvider).setUserLogProvider(logProvider).newImpermanentDatabaseBuilder().setConfig(GraphDatabaseSettings.plugin_dir, plugins.getRoot().getAbsolutePath()).newGraphDatabase();
// When
try (Transaction ignore = db.beginTx()) {
Result res = db.execute("RETURN org.neo4j.procedure.logAround()");
while (res.hasNext()) {
res.next();
}
}
// Then
AssertableLogProvider.LogMatcherBuilder match = inLog(Procedures.class);
logProvider.assertAtLeastOnce(match.debug("1"), match.info("2"), match.warn("3"), match.error("4"));
}
use of org.neo4j.logging.AssertableLogProvider in project neo4j-documentation by neo4j.
the class NeoServerPortConflictDocIT method shouldComplainIfServerPortIsAlreadyTaken.
@Test
public void shouldComplainIfServerPortIsAlreadyTaken() throws IOException, InterruptedException {
ListenSocketAddress contestedAddress = new ListenSocketAddress("localhost", 9999);
try (ServerSocket ignored = new ServerSocket(contestedAddress.getPort(), 0, InetAddress.getByName(contestedAddress.getHostname()))) {
AssertableLogProvider logProvider = new AssertableLogProvider();
CommunityNeoServer server = CommunityServerBuilder.server(logProvider).onAddress(contestedAddress).usingDataDir(folder.directory(name.getMethodName()).getAbsolutePath()).build();
try {
server.start();
fail("Should have reported failure to start");
} catch (ServerStartupException e) {
assertThat(e.getMessage(), containsString("Starting Neo4j failed"));
}
logProvider.assertAtLeastOnce(AssertableLogProvider.inLog(containsString("CommunityNeoServer")).error("Failed to start Neo4j on %s: %s", contestedAddress, format("Address %s is already in use, cannot bind to it.", contestedAddress)));
server.stop();
}
}
Aggregations