public void Lookup_By_Url_Alias(string urlAsString, int nodeMatch)
		{
			var routingContext = GetRoutingContext(urlAsString);
			var url = routingContext.UmbracoContext.CleanedUmbracoUrl; //very important to use the cleaned up umbraco url
			var docRequest = new PublishedContentRequest(url, routingContext);
			var lookup = new LookupByAlias();
			
			var result = lookup.TrySetDocument(docRequest);

			Assert.IsTrue(result);
			Assert.AreEqual(docRequest.DocumentId, nodeMatch);
		}
		//FIXME: this is temporary and should be obsoleted

		void HandlePageNotFound(PublishedContentRequest docRequest)
        {
			var url = NotFoundHandlerHelper.GetLegacyUrlForNotFoundHandlers();
            LogHelper.Debug<LookupByNotFoundHandlers>("Running for legacy url='{0}'.", () => url);

            foreach (var handler in GetNotFoundHandlers())
            {
                IPublishedContentLookup lookup = null;

                LogHelper.Debug<LookupByNotFoundHandlers>("Handler '{0}'.", () => handler.GetType().FullName);

                // replace with our own implementation
                if (handler is global::umbraco.SearchForAlias)
                    lookup = new LookupByAlias();
                else if (handler is global::umbraco.SearchForProfile)
                    lookup = new LookupByProfile();
                else if (handler is global::umbraco.SearchForTemplate)
                    lookup = new LookupByNiceUrlAndTemplate();
                else if (handler is global::umbraco.handle404)
                    lookup = new LookupByLegacy404();

                if (lookup != null)
                {
                    LogHelper.Debug<LookupByNotFoundHandlers>("Replace handler '{0}' by new lookup '{1}'.", () => handler.GetType().FullName, () => lookup.GetType().FullName);
                    if (lookup.TrySetDocument(docRequest))
                    {
                        // do NOT set docRequest.PublishedContent again here as 
                        // it would clear any template that the finder might have set
                        LogHelper.Debug<LookupByNotFoundHandlers>("Lookup '{0}' found node with id={1}.", () => lookup.GetType().FullName, () => docRequest.PublishedContent.Id);
                        if (docRequest.Is404)
                            LogHelper.Debug<LookupByNotFoundHandlers>("Lookup '{0}' set status to 404.", () => lookup.GetType().FullName);

                        // if we found a document, break, don't look at more handler -- we're done
                        break;
                    }

                    // if we did not find a document, continue, look at other handlers
                    continue;
                }

                // else it's a legacy handler, run

				if (handler.Execute(url) && handler.redirectID > 0)
                {
					docRequest.PublishedContent = docRequest.RoutingContext.PublishedContentStore.GetDocumentById(
						docRequest.RoutingContext.UmbracoContext,
						handler.redirectID);

                    if (!docRequest.HasNode)
                    {
                        LogHelper.Debug<LookupByNotFoundHandlers>("Handler '{0}' found node with id={1} which is not valid.", () => handler.GetType().FullName, () => handler.redirectID);
                        break;
                    }

                    LogHelper.Debug<LookupByNotFoundHandlers>("Handler '{0}' found valid node with id={1}.", () => handler.GetType().FullName, () => handler.redirectID);

                    if (docRequest.RoutingContext.UmbracoContext.HttpContext.Response.StatusCode == 404)
                    {
                        LogHelper.Debug<LookupByNotFoundHandlers>("Handler '{0}' set status code to 404.", () => handler.GetType().FullName);
                        docRequest.Is404 = true;
                    }

                    //// check for caching
                    //if (handler.CacheUrl)
                    //{
                    //    if (url.StartsWith("/"))
                    //        url = "/" + url;

                    //    var cacheKey = (currentDomain == null ? "" : currentDomain.Name) + url;
                    //    var culture = currentDomain == null ? null : currentDomain.Language.CultureAlias;
                    //    SetCache(cacheKey, new CacheEntry(handler.redirectID.ToString(), culture));

                    //    HttpContext.Current.Trace.Write("NotFoundHandler",
                    //        string.Format("Added to cache '{0}', {1}.", url, handler.redirectID));
                    //}

                    // if we found a document, break, don't look at more handler -- we're done
                    break;
                }

                // if we did not find a document, continue, look at other handlers
            }
        }
        //FIXME: this is temporary and should be obsoleted

        void HandlePageNotFound(PublishedContentRequest docRequest)
        {
            var url = NotFoundHandlerHelper.GetLegacyUrlForNotFoundHandlers();

            LogHelper.Debug <LookupByNotFoundHandlers>("Running for legacy url='{0}'.", () => url);

            foreach (var handler in GetNotFoundHandlers())
            {
                IPublishedContentLookup lookup = null;

                LogHelper.Debug <LookupByNotFoundHandlers>("Handler '{0}'.", () => handler.GetType().FullName);

                // replace with our own implementation
                if (handler is global::umbraco.SearchForAlias)
                {
                    lookup = new LookupByAlias();
                }
                else if (handler is global::umbraco.SearchForProfile)
                {
                    lookup = new LookupByProfile();
                }
                else if (handler is global::umbraco.SearchForTemplate)
                {
                    lookup = new LookupByNiceUrlAndTemplate();
                }
                else if (handler is global::umbraco.handle404)
                {
                    lookup = new LookupByLegacy404();
                }

                if (lookup != null)
                {
                    LogHelper.Debug <LookupByNotFoundHandlers>("Replace handler '{0}' by new lookup '{1}'.", () => handler.GetType().FullName, () => lookup.GetType().FullName);
                    if (lookup.TrySetDocument(docRequest))
                    {
                        // do NOT set docRequest.PublishedContent again here as
                        // it would clear any template that the finder might have set
                        LogHelper.Debug <LookupByNotFoundHandlers>("Lookup '{0}' found node with id={1}.", () => lookup.GetType().FullName, () => docRequest.PublishedContent.Id);
                        if (docRequest.Is404)
                        {
                            LogHelper.Debug <LookupByNotFoundHandlers>("Lookup '{0}' set status to 404.", () => lookup.GetType().FullName);
                        }

                        // if we found a document, break, don't look at more handler -- we're done
                        break;
                    }

                    // if we did not find a document, continue, look at other handlers
                    continue;
                }

                // else it's a legacy handler, run

                if (handler.Execute(url) && handler.redirectID > 0)
                {
                    docRequest.PublishedContent = docRequest.RoutingContext.PublishedContentStore.GetDocumentById(
                        docRequest.RoutingContext.UmbracoContext,
                        handler.redirectID);

                    if (!docRequest.HasNode)
                    {
                        LogHelper.Debug <LookupByNotFoundHandlers>("Handler '{0}' found node with id={1} which is not valid.", () => handler.GetType().FullName, () => handler.redirectID);
                        break;
                    }

                    LogHelper.Debug <LookupByNotFoundHandlers>("Handler '{0}' found valid node with id={1}.", () => handler.GetType().FullName, () => handler.redirectID);

                    if (docRequest.RoutingContext.UmbracoContext.HttpContext.Response.StatusCode == 404)
                    {
                        LogHelper.Debug <LookupByNotFoundHandlers>("Handler '{0}' set status code to 404.", () => handler.GetType().FullName);
                        docRequest.Is404 = true;
                    }

                    //// check for caching
                    //if (handler.CacheUrl)
                    //{
                    //    if (url.StartsWith("/"))
                    //        url = "/" + url;

                    //    var cacheKey = (currentDomain == null ? "" : currentDomain.Name) + url;
                    //    var culture = currentDomain == null ? null : currentDomain.Language.CultureAlias;
                    //    SetCache(cacheKey, new CacheEntry(handler.redirectID.ToString(), culture));

                    //    HttpContext.Current.Trace.Write("NotFoundHandler",
                    //        string.Format("Added to cache '{0}', {1}.", url, handler.redirectID));
                    //}

                    // if we found a document, break, don't look at more handler -- we're done
                    break;
                }

                // if we did not find a document, continue, look at other handlers
            }
        }