use of org.neo4j.configuration.helpers.SocketAddress in project neo4j by neo4j.
the class CommunityDiscoverableURIsTest method shouldLookupBoltPortInRegisterIfConfigured.
@Test
void shouldLookupBoltPortInRegisterIfConfigured() {
var register = new ConnectorPortRegister();
register.register(BoltConnector.NAME, new InetSocketAddress(1337));
var uris = communityDiscoverableURIs(Config.newBuilder().set(BoltConnector.advertised_address, new SocketAddress("apple.com", 0)).set(BoltConnector.enabled, true).build(), register);
var map = toMap(uris);
assertEquals("bolt://apple.com:1337", map.get("bolt_direct"));
assertEquals("neo4j://apple.com:1337", map.get("bolt_routing"));
}
use of org.neo4j.configuration.helpers.SocketAddress in project neo4j by neo4j.
the class SimpleUriBuilderTest method shouldIncludeScheme.
@Test
void shouldIncludeScheme() {
var uri1 = SimpleUriBuilder.buildURI(new SocketAddress("neo4j.example.org", 443), false);
var uri2 = SimpleUriBuilder.buildURI(new SocketAddress("neo4j.example.org", 80), true);
assertEquals("http", uri1.getScheme());
assertEquals("https", uri2.getScheme());
}
use of org.neo4j.configuration.helpers.SocketAddress in project neo4j by neo4j.
the class SimpleUriBuilderTest method shouldIncludePortWhenNecessary.
@Test
void shouldIncludePortWhenNecessary() {
var uri1 = SimpleUriBuilder.buildURI(new SocketAddress("neo4j.example.org", 80), false);
var uri2 = SimpleUriBuilder.buildURI(new SocketAddress("neo4j.example.org", 443), true);
var uri3 = SimpleUriBuilder.buildURI(new SocketAddress("neo4j.example.org", 443), false);
var uri4 = SimpleUriBuilder.buildURI(new SocketAddress("neo4j.example.org", 80), true);
var uri5 = SimpleUriBuilder.buildURI(new SocketAddress("neo4j.example.org", 7690), false);
assertEquals(-1, uri1.getPort());
assertEquals(-1, uri2.getPort());
assertEquals(443, uri3.getPort());
assertEquals(80, uri4.getPort());
assertEquals(7690, uri5.getPort());
}
use of org.neo4j.configuration.helpers.SocketAddress in project neo4j by neo4j.
the class Jetty9WebServerIT method shouldBeAbleToRestart.
@Test
public void shouldBeAbleToRestart() throws Throwable {
// given
webServer = new Jetty9WebServer(NullLogProvider.getInstance(), Config.defaults(), NetworkConnectionTracker.NO_OP, mock(ByteBufferPool.class));
webServer.setHttpAddress(new SocketAddress("127.0.0.1", 7878));
// when
webServer.start();
webServer.stop();
webServer.start();
// then no exception
}
use of org.neo4j.configuration.helpers.SocketAddress in project neo4j by neo4j.
the class SingleInstanceGetRoutingTableProcedureTest method shouldUseClientProvidedHostAndAdvertisedPortAsAdvertisedAddress.
@RoutingConfigsTest
void shouldUseClientProvidedHostAndAdvertisedPortAsAdvertisedAddress(Config config, String clientAddress) throws Exception {
// given
var advertisedBoldPort = 8776;
var defaultBoltPort = 7687;
var advertisedBoltAddress = new SocketAddress("neo4j.com", advertisedBoldPort);
config.set(BoltConnector.advertised_address, advertisedBoltAddress);
var clientProvidedHost = clientAddress == null ? "mydomain.com" : clientAddress.split(":")[0];
var ctxContents = new MapValueBuilder();
ctxContents.add(ADDRESS_CONTEXT_KEY, Values.stringValue(clientProvidedHost));
var ctx = ctxContents.build();
var portRegister = mock(ConnectorPortRegister.class);
when(portRegister.getLocalAddress(BoltConnector.NAME)).thenReturn(new HostnamePort("neo4j.com", advertisedBoldPort));
var databaseManager = databaseManagerMock(config, true);
var logProvider = new AssertableLogProvider();
var procedure = newProcedure(databaseManager, portRegister, config, logProvider);
var expectedAddress = new SocketAddress(clientProvidedHost, defaultBoltPort);
// when
var result = invoke(procedure, ID, ctx);
// then
assertEquals(singletonList(expectedAddress), result.readEndpoints());
assertEquals(expectedWriters(expectedAddress), result.writeEndpoints());
assertEquals(singletonList(expectedAddress), result.routeEndpoints());
}
Aggregations