public void ShouldPatchLinesInBaseBatThatCallJavaDirectly() { // Arrange const string badFileContent = @" foo java bar baz qak java qoo ajava"; var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData> { { @"c:\temp\neo4j\neo-v1234\bin\neo4j.bat", new MockFileData("foo") }, { @"c:\temp\neo4j\neo-v1234\bin\base.bat", new MockFileData(badFileContent) } }); var server = new NeoServer(new NeoServerConfiguration(), null, null, fileSystem, null); server.Context.NeoBasePath = @"c:\temp\neo4j\neo-v1234\"; // Act server.ApplyWorkaroundForJavaResolutionIssue(); // Assert const string goodFileContent = @" foo ""%javaPath%\bin\java.exe"" bar baz qak java qoo ajava"; var content = fileSystem.File.ReadAllText(@"c:\temp\neo4j\neo-v1234\bin\base.bat"); Assert.Equal(goodFileContent, content); }
public override bool OnStart() { // Set the maximum number of concurrent connections ServicePointManager.DefaultConnectionLimit = 12; // For information on handling configuration changes // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357. _Server = new NeoServer(CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("Neo4jConnectionString"))); //_Server = new NeoServer(CloudStorageAccount.DevelopmentStorageAccount); _Server.DownloadAndInstall(); _Server.Start(); return base.OnStart(); }
public void ShouldThrowExceptionIfJavaExeDoesNotExist() { // Arrange var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>()); var server = new NeoServer(new NeoServerConfiguration(), null, null, fileSystem, null); server.Context.JavaDirectoryPath = @"c:\temp\neo4j\jre7\"; // Assert var ex = Assert.Throws<ApplicationException>(() // Act => server.InterrogateJavaArtifact()); Assert.Equal(@"After downloading and unzipping the Java blob, we expected but failed to find java.exe at jre7\bin\java.exe. On disk, this path corresponds to: c:\temp\neo4j\jre7\jre7\bin\java.exe", ex.Message); }
public void ShouldSilentlyExitIfBaseBatDoesNotExist() { // Arrange var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData> { { @"c:\temp\neo4j\neo-v1234\bin\neo4j.bat", new MockFileData("foo") } }); var server = new NeoServer(new NeoServerConfiguration(), null, null, fileSystem, null); server.Context.NeoBasePath = @"c:\temp\neo4j\neo-v1234\"; // Act server.ApplyWorkaroundForJavaResolutionIssue(); // Assert // Nothing crashed }
public void ShouldSetJavaHomePathInContext() { // Arrange var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData> { { @"c:\temp\neo4j\jre7\jre7\bin\java.exe", new MockFileData("") } }); var server = new NeoServer(new NeoServerConfiguration(), null, null, fileSystem, null); server.Context.JavaDirectoryPath = @"c:\temp\neo4j\jre7\"; // Act server.InterrogateJavaArtifact(); // Assert Assert.Equal(@"c:\temp\neo4j\jre7\jre7\", server.Context.JavaHomePath); }
public void ShouldSetPathIntoContext() { // Arrange var roleEnvironment = Substitute.For<IRoleEnvironment>(); roleEnvironment .GetLocalResource("foo") .Returns(new MockLocalResource { RootPath = @"t:\SomePath" }); var server = new NeoServer( new NeoServerConfiguration { NeoLocalResourceName = "foo" }, roleEnvironment, null, null, null); // Act server.InitializeLocalResource(); // Asset Assert.Equal(@"t:\SomePath", server.Context.LocalResourcePath); }
public void ShouldPatchIpAndPortAndSsl(string input, string expected) { // Arrange var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData> { { @"c:\temp\neo4j\neo-v1234\conf\neo4j-server.properties", new MockFileData(input) } }); var server = new NeoServer(new NeoServerConfiguration(), null, null, fileSystem, null); server.Context.NeoEndpoint = new IPEndPoint(IPAddress.Parse("1.2.3.4"), 5678); server.Context.NeoBasePath = @"c:\temp\neo4j\neo-v1234\"; // Act server.ApplyEndpointConfiguration(); // Assert var content = fileSystem.File.ReadAllText(@"c:\temp\neo4j\neo-v1234\conf\neo4j-server.properties"); Assert.Equal(expected, content); }
public void ShouldWrapRoleEnvironmentExceptionWhenLocalResourceDoesNotExist() { // Arrange var thrownException = (RoleEnvironmentException)typeof (RoleEnvironmentException) .GetConstructors(BindingFlags.NonPublic | BindingFlags.Instance) .Single(c => c.GetParameters().Count() == 1) .Invoke(new object[] { "The local resource isn't defined or doesn't exist." }); var roleEnvironment = Substitute.For<IRoleEnvironment>(); roleEnvironment .GetLocalResource("foo") .Returns(ci => { throw thrownException; }); var server = new NeoServer( new NeoServerConfiguration { NeoLocalResourceName = "foo"}, roleEnvironment, null, null, null); // Assert var exposedException = Assert.Throws<ApplicationException>( // Act () => server.InitializeLocalResource()); Assert.Same(thrownException, exposedException.InnerException); }