Permalink
Browse files

IISExpressTestClient started.. why IIS non-express fail now

  • Loading branch information...
1 parent 4b4a7aa commit 907f708788994d7b7c67dc33c9a21da3179d1472 @fschwiet fschwiet committed Aug 9, 2011
View
4 Raven.Tests/IISClientTestBase.cs
@@ -8,7 +8,7 @@ public abstract class IISClientTestBase
{
protected const string WebDirectory = @".\RavenIISTestWeb\";
- public string DeployWebProjectToTestDirectory()
+ public static string DeployWebProjectToTestDirectory()
{
var fullPath = Path.GetFullPath(WebDirectory);
if (!Directory.Exists(fullPath))
@@ -18,7 +18,7 @@ public string DeployWebProjectToTestDirectory()
return fullPath;
}
- private string GetRavenWebSource()
+ private static string GetRavenWebSource()
{
foreach (var path in new[] { @".\..\..\..\Raven.Web", @".\_PublishedWebsites\Raven.Web" })
{
View
24 Raven.Tests/IISExpressTestClient.cs
@@ -1,20 +1,38 @@
using System;
using Raven.Client;
+using Raven.Client.Document;
+using Raven.Tests.Util;
namespace Raven.Tests
{
class IISExpressTestClient : IISClientTestBase, IDisposable
{
- private ProcessDriver _iisExpress;
+ public static int Port = 8084;
+
+ private IISExpressDriver _iisExpress;
public override IDocumentStore GetDocumentStore()
{
- throw new NotImplementedException();
+ if (_iisExpress == null)
+ {
+ _iisExpress = new IISExpressDriver();
+
+ _iisExpress.Start(DeployWebProjectToTestDirectory(), 8084);
+ }
+
+ return new DocumentStore()
+ {
+ Url = _iisExpress.Url
+ };
}
public void Dispose()
{
- throw new NotImplementedException();
+ if (_iisExpress != null)
+ {
+ _iisExpress.Dispose();
+ _iisExpress = null;
+ }
}
}
}
View
1 Raven.Tests/Raven.Tests.csproj
@@ -605,6 +605,7 @@
<Compile Include="Triggers\RefuseBigAttachmentPutTrigger.cs" />
<Compile Include="Triggers\VetoCapitalNamesPutTrigger.cs" />
<Compile Include="Util\IISConfig.cs" />
+ <Compile Include="Util\IISExpressDriver.cs" />
<Compile Include="Util\ProcessDriver.cs" />
<Compile Include="Util\RavenDBDriver.cs" />
<Compile Include="Util\ReflectionUtilTest.cs" />
View
28 Raven.Tests/Util/IISExpressDriver.cs
@@ -0,0 +1,28 @@
+using System;
+
+namespace Raven.Tests.Util
+{
+ class IISExpressDriver : ProcessDriver
+ {
+ public string Url { get; private set; }
+
+ protected override void Shutdown()
+ {
+ _process.StandardInput.Write("Q");
+
+ if (!_process.WaitForExit(10000))
+ throw new Exception("IISExpress did not halt within 10 seconds.");
+ }
+
+ public void Start(string physicalPath, int port)
+ {
+ var sitePhysicalDirectory = physicalPath;
+ StartProcess("c:\\program files (x86)\\IIS Express\\IISExpress.exe",
+ "/port: " + port + " /path:" + sitePhysicalDirectory);
+
+ var match = WaitForConsoleOutputMatching(@"Successfully registered URL ""([^""]*)""");
+
+ Url = match.Groups[1].Value;
+ }
+ }
+}
View
25 Raven.Tests/Util/ProcessDriver.cs
@@ -1,17 +1,19 @@
using System.Diagnostics;
+using System.Text.RegularExpressions;
namespace Raven.Tests.Util
{
public abstract class ProcessDriver
{
protected Process _process;
- public void StartProcess(string exePath)
+ protected void StartProcess(string exePath, string arguments = "")
{
ProcessStartInfo psi = new ProcessStartInfo(exePath);
- psi.LoadUserProfile = false;
-
+ psi.LoadUserProfile = false;
+
+ psi.Arguments = arguments;
psi.UseShellExecute = false;
psi.RedirectStandardError = true;
psi.RedirectStandardInput = true;
@@ -21,6 +23,8 @@ public void StartProcess(string exePath)
_process = Process.Start(psi);
}
+ protected virtual void Shutdown() { }
+
public void Dispose()
{
if (_process != null)
@@ -34,6 +38,19 @@ public void Dispose()
}
}
- protected abstract void Shutdown();
+ protected Match WaitForConsoleOutputMatching(string pattern)
+ {
+ Match match;
+ while(true)
+ {
+ var nextLine = _process.StandardOutput.ReadLine();
+
+ match = Regex.Match(nextLine, pattern);
+
+ if (match.Success)
+ break;
+ }
+ return match;
+ }
}
}
View
15 Raven.Tests/Util/RavenDBDriver.cs
@@ -69,18 +69,9 @@ public void Start()
StartProcess(exePath);
- while(true)
- {
- var nextLine = _process.StandardOutput.ReadLine();
-
- var match = Regex.Match(nextLine, @"^Server Url: (http://.*/)\s*$");
-
- if (!match.Success)
- continue;
-
- Url = match.Groups[1].Value;
- break;
- }
+ Match match = WaitForConsoleOutputMatching(@"^Server Url: (http://.*/)\s*$");
+
+ Url = match.Groups[1].Value;
}
public IDocumentStore GetDocumentStore()

0 comments on commit 907f708

Please sign in to comment.