use of org.neo4j.server.CommunityNeoServer in project neo4j by neo4j.
the class TransactionGuardIntegrationTest method terminateLongRunningDriverQuery.
@Test
public void terminateLongRunningDriverQuery() throws Exception {
GraphDatabaseAPI database = startDatabaseWithTimeout();
CommunityNeoServer neoServer = startNeoServer((GraphDatabaseFacade) database);
org.neo4j.driver.v1.Config driverConfig = getDriverConfig();
try (Driver driver = GraphDatabase.driver("bolt://localhost:" + boltPortDatabaseWithTimeout, driverConfig);
Session session = driver.session()) {
org.neo4j.driver.v1.Transaction transaction = session.beginTransaction();
transaction.run("create (n)").consume();
transaction.success();
fakeClock.forward(3, TimeUnit.SECONDS);
try {
transaction.run("create (n)").consume();
fail("Transaction should be already terminated by execution guard.");
} catch (Exception expected) {
// ignored
}
}
assertDatabaseDoesNotHaveNodes(database);
}
use of org.neo4j.server.CommunityNeoServer in project neo4j by neo4j.
the class DBMSModuleTest method shouldNotRegisterUserServiceWhenAuthDisabled.
@SuppressWarnings("unchecked")
@Test
public void shouldNotRegisterUserServiceWhenAuthDisabled() throws Exception {
WebServer webServer = mock(WebServer.class);
Config config = mock(Config.class);
CommunityNeoServer neoServer = mock(CommunityNeoServer.class);
when(neoServer.baseUri()).thenReturn(new URI("http://localhost:7575"));
when(neoServer.getWebServer()).thenReturn(webServer);
when(config.get(GraphDatabaseSettings.auth_enabled)).thenReturn(false);
DBMSModule module = new DBMSModule(webServer, config);
module.start();
verify(webServer).addJAXRSClasses(anyList(), anyString(), anyCollection());
verify(webServer, never()).addJAXRSClasses(Matchers.argThat(new ArgumentMatcher<List<String>>() {
@Override
public boolean matches(Object argument) {
List<String> argumentList = (List<String>) argument;
return argumentList.contains(UserService.class.getName());
}
@Override
public void describeTo(Description description) {
description.appendText("<List containing " + UserService.class.getName() + ">");
}
}), anyString(), anyCollection());
}
use of org.neo4j.server.CommunityNeoServer in project neo4j by neo4j.
the class ManagementApiModuleTest method shouldRegisterASingleUri.
@Test
public void shouldRegisterASingleUri() throws Exception {
WebServer webServer = mock(WebServer.class);
CommunityNeoServer neoServer = mock(CommunityNeoServer.class);
when(neoServer.baseUri()).thenReturn(new URI("http://localhost:7575"));
when(neoServer.getWebServer()).thenReturn(webServer);
Map<String, String> params = new HashMap();
String managementPath = "/db/manage";
params.put(ServerSettings.management_api_path.name(), managementPath);
Config config = Config.embeddedDefaults(params);
when(neoServer.getConfig()).thenReturn(config);
ManagementApiModule module = new ManagementApiModule(webServer, config);
module.start();
verify(webServer).addJAXRSClasses(any(List.class), anyString(), anyCollection());
}
use of org.neo4j.server.CommunityNeoServer in project neo4j by neo4j.
the class ThirdPartyJAXRSModuleTest method shouldReportThirdPartyPackagesAtSpecifiedMount.
@Test
public void shouldReportThirdPartyPackagesAtSpecifiedMount() throws Exception {
// Given
WebServer webServer = mock(WebServer.class);
CommunityNeoServer neoServer = mock(CommunityNeoServer.class);
when(neoServer.baseUri()).thenReturn(new URI("http://localhost:7575"));
when(neoServer.getWebServer()).thenReturn(webServer);
when(neoServer.getDatabase()).thenReturn(mock(Database.class));
Config config = mock(Config.class);
List<ThirdPartyJaxRsPackage> jaxRsPackages = new ArrayList<ThirdPartyJaxRsPackage>();
String path = "/third/party/package";
jaxRsPackages.add(new ThirdPartyJaxRsPackage("org.example.neo4j", path));
when(config.get(ServerSettings.third_party_packages)).thenReturn(jaxRsPackages);
// When
ThirdPartyJAXRSModule module = new ThirdPartyJAXRSModule(webServer, config, NullLogProvider.getInstance(), neoServer);
module.start();
// Then
verify(webServer).addJAXRSPackages(any(List.class), anyString(), anyCollection());
}
Aggregations