Skip to content

Commit

Permalink
Forwarding tests
Browse files Browse the repository at this point in the history
  • Loading branch information
technige committed Jun 27, 2016
1 parent b502948 commit 2c82adb
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
Expand Up @@ -56,9 +56,9 @@ public Response getDiscoveryDocument() throws URISyntaxException
{
String managementUri = configuration.get( ServerSettings.management_api_path ).getPath() + "/";
String dataUri = configuration.get( ServerSettings.rest_api_path ).getPath() + "/";
String boltUri = "bolt://" + configuration.get( GraphDatabaseSettings.bolt_advertised_address );
String boltAddress = configuration.get( GraphDatabaseSettings.bolt_advertised_address ).toString();

return outputFormat.ok( new DiscoveryRepresentation( managementUri, dataUri, boltUri ) );
return outputFormat.ok( new DiscoveryRepresentation( managementUri, dataUri, boltAddress ) );
}

@GET
Expand Down
Expand Up @@ -28,22 +28,22 @@ public class DiscoveryRepresentation extends MappingRepresentation
private static final String DISCOVERY_REPRESENTATION_TYPE = "discovery";
private final String managementUri;
private final String dataUri;
private final String boltUri;
private final String boltAddress;

public DiscoveryRepresentation( String managementUri, String dataUri, String boltUri )
public DiscoveryRepresentation( String managementUri, String dataUri, String boltAddress )
{
super( DISCOVERY_REPRESENTATION_TYPE );
this.managementUri = managementUri;
this.dataUri = dataUri;
this.boltUri = boltUri;
this.boltAddress = boltAddress;
}

@Override
protected void serialize( MappingSerializer serializer )
{
serializer.putRelativeUri( MANAGEMENT_URI_KEY, managementUri );
serializer.putRelativeUri( DATA_URI_KEY, dataUri );
serializer.putAbsoluteUri( BOLT_URI_KEY, boltUri );
serializer.putAbsoluteUri( BOLT_URI_KEY, "bolt://" + boltAddress );
}

}
Expand Up @@ -67,7 +67,7 @@ public void shouldForwardHttpAndHost() throws Exception
String responseEntityBody = new String( data );

assertTrue( responseEntityBody.contains( "http://foobar.com" ) );
assertFalse( responseEntityBody.contains( "localhost" ) );
assertFalse( responseEntityBody.contains( "http://localhost" ) );
}
finally
{
Expand Down Expand Up @@ -99,7 +99,7 @@ public void shouldForwardHttpsAndHost() throws Exception
String responseEntityBody = new String( data );

assertTrue( responseEntityBody.contains( "https://foobar.com" ) );
assertFalse( responseEntityBody.contains( "localhost" ) );
assertFalse( responseEntityBody.contains( "https://localhost" ) );
}
finally
{
Expand Down Expand Up @@ -131,7 +131,7 @@ public void shouldForwardHttpAndHostOnDifferentPort() throws Exception
String responseEntityBody = new String( data );

assertTrue( responseEntityBody.contains( "http://foobar.com:9999" ) );
assertFalse( responseEntityBody.contains( "localhost" ) );
assertFalse( responseEntityBody.contains( "http://localhost" ) );
}
finally
{
Expand Down Expand Up @@ -162,7 +162,7 @@ public void shouldForwardHttpAndFirstHost() throws Exception
String responseEntityBody = new String( data );

assertTrue( responseEntityBody.contains( "http://foobar.com" ) );
assertFalse( responseEntityBody.contains( "localhost" ) );
assertFalse( responseEntityBody.contains( "http://localhost" ) );
}
finally
{
Expand Down Expand Up @@ -194,7 +194,7 @@ public void shouldForwardHttpsAndHostOnDifferentPort() throws Exception
String responseEntityBody = new String( data );

assertTrue( responseEntityBody.contains( "https://foobar.com:9999" ) );
assertFalse( responseEntityBody.contains( "localhost" ) );
assertFalse( responseEntityBody.contains( "https://localhost" ) );
}
finally
{
Expand Down Expand Up @@ -224,7 +224,7 @@ public void shouldUseRequestUriWhenNoXForwardHeadersPresent() throws Exception

assertFalse( responseEntityBody.contains( "https://foobar.com" ) );
assertFalse( responseEntityBody.contains( ":0" ) );
assertTrue( responseEntityBody.contains( "localhost" ) );
assertTrue( responseEntityBody.contains( "http://localhost" ) );
}
finally
{
Expand Down
Expand Up @@ -34,8 +34,9 @@ public void shouldCreateAMapContainingDataAndManagementURIs() throws Exception
{
String managementUri = "/management";
String dataUri = "/data";
String boltUri = "bolt://localhost:7687";
DiscoveryRepresentation dr = new DiscoveryRepresentation( managementUri, dataUri, boltUri );
String boltAddress = "localhost:7687";
String boltUri = "bolt://" + boltAddress;
DiscoveryRepresentation dr = new DiscoveryRepresentation( managementUri, dataUri, boltAddress );

Map<String, Object> mapOfUris = RepresentationTestAccess.serialize( dr );

Expand Down

0 comments on commit 2c82adb

Please sign in to comment.