コード例 #1
1
		public HtmlFragmentResponse Execute()
		{
			Hashtable velocityContext = new Hashtable();

			string serverName = request.ServerName;
			string categoryName = GetCategory();
            string projectName = request.ProjectName;
			string buildName = request.BuildName;

			velocityContext["serverName"] = serverName;
			velocityContext["categoryName"] = categoryName;
			velocityContext["projectName"] = projectName;
			velocityContext["buildName"] = buildName;

			velocityContext["farmLink"] = linkFactory.CreateFarmLink("Dashboard", FarmReportFarmPlugin.ACTION_NAME);

			if (serverName != string.Empty)
			{
				velocityContext["serverLink"] = linkFactory.CreateServerLink(request.ServerSpecifier, ServerReportServerPlugin.ACTION_NAME);
			}

            if (categoryName != string.Empty)
            {
                IServerSpecifier serverSpecifier;
                try
                {
                    serverSpecifier = request.ServerSpecifier;
                }
                catch (ThoughtWorks.CruiseControl.Core.CruiseControlException)
                {
                    serverSpecifier = null;
                }

                if (serverSpecifier != null)
                {
                    velocityContext["categoryLink"] = new GeneralAbsoluteLink(categoryName, linkFactory
                        .CreateServerLink(serverSpecifier, "ViewServerReport")
                        .Url + "?Category=" + HttpUtility.UrlEncode(categoryName));
                }
                else
                {
                    velocityContext["categoryLink"] = new GeneralAbsoluteLink(categoryName, linkFactory
                        .CreateFarmLink( "Dashboard", FarmReportFarmPlugin.ACTION_NAME )
                        .Url + "?Category=" + HttpUtility.UrlEncode(categoryName));
                }
            }


			if (projectName != string.Empty)
			{
				velocityContext["projectLink"] = linkFactory.CreateProjectLink(request.ProjectSpecifier,  ProjectReportProjectPlugin.ACTION_NAME);
			}

			if (buildName != string.Empty)
			{
				velocityContext["buildLink"] = linkFactory.CreateBuildLink(request.BuildSpecifier,  BuildReportBuildPlugin.ACTION_NAME);
			}

			return velocityViewGenerator.GenerateView("TopMenu.vm", velocityContext);
		}
コード例 #2
0
        public HtmlFragmentResponse Execute()
        {
            Hashtable velocityContext = new Hashtable();

            string serverName   = request.ServerName;
            string categoryName = GetCategory();
            string projectName  = request.ProjectName;
            string buildName    = request.BuildName;

            velocityContext["serverName"]   = serverName;
            velocityContext["categoryName"] = categoryName;
            velocityContext["projectName"]  = projectName;
            velocityContext["buildName"]    = buildName;

            velocityContext["farmLink"] = linkFactory.CreateFarmLink("Dashboard", FarmReportFarmPlugin.ACTION_NAME);

            if (serverName != string.Empty)
            {
                velocityContext["serverLink"] = linkFactory.CreateServerLink(request.ServerSpecifier, ServerReportServerPlugin.ACTION_NAME);
            }

            if (categoryName != string.Empty)
            {
                IServerSpecifier serverSpecifier;
                try
                {
                    serverSpecifier = request.ServerSpecifier;
                }
                catch (ThoughtWorks.CruiseControl.Core.CruiseControlException)
                {
                    serverSpecifier = null;
                }

                if (serverSpecifier != null)
                {
                    velocityContext["categoryLink"] = new GeneralAbsoluteLink(categoryName, linkFactory
                                                                              .CreateServerLink(serverSpecifier, "ViewServerReport")
                                                                              .Url + "?Category=" + HttpUtility.UrlEncode(categoryName));
                }
                else
                {
                    velocityContext["categoryLink"] = new GeneralAbsoluteLink(categoryName, linkFactory
                                                                              .CreateFarmLink("Dashboard", FarmReportFarmPlugin.ACTION_NAME)
                                                                              .Url + "?Category=" + HttpUtility.UrlEncode(categoryName));
                }
            }


            if (projectName != string.Empty)
            {
                velocityContext["projectLink"] = linkFactory.CreateProjectLink(request.ProjectSpecifier, ProjectReportProjectPlugin.ACTION_NAME);
            }

            if (buildName != string.Empty)
            {
                velocityContext["buildLink"] = linkFactory.CreateBuildLink(request.BuildSpecifier, BuildReportBuildPlugin.ACTION_NAME);
            }

            return(velocityViewGenerator.GenerateView("TopMenu.vm", velocityContext));
        }
コード例 #3
0
		public void ShouldReturnRedirectToFarmReport()
		{
			IAbsoluteLink link = new GeneralAbsoluteLink("", "http://here");
			linkFactoryMock.ExpectAndReturn("CreateFarmLink", link, "", FarmReportFarmPlugin.ACTION_NAME);

			IResponse response = action.Execute(null);

			Assert.AreEqual("http://here", ((RedirectResponse) response).Url);
			VerifyAll();
		}
コード例 #4
0
		public void ShouldGenerateBuildLinks()
		{
			string action = "my action";
			IBuildSpecifier buildSpecifier1 = (IBuildSpecifier) new DynamicMock(typeof(IBuildSpecifier)).MockInstance;
			IBuildSpecifier buildSpecifier2 = (IBuildSpecifier) new DynamicMock(typeof(IBuildSpecifier)).MockInstance;
			IAbsoluteLink link1 = new GeneralAbsoluteLink("link 1");
			IAbsoluteLink link2 = new GeneralAbsoluteLink("link 2");

			linkFactoryMock.ExpectAndReturn("CreateStyledBuildLink", link1, buildSpecifier1, action);
			linkFactoryMock.ExpectAndReturn("CreateStyledBuildLink", link2, buildSpecifier2, action);

			IAbsoluteLink[] returnedLinks = linkListFactory.CreateStyledBuildLinkList(new IBuildSpecifier[] { buildSpecifier1, buildSpecifier2 }, action);

			Assert.AreEqual(2, returnedLinks.Length);
			Assert.AreEqual(link1, returnedLinks[0]);
			Assert.AreEqual(link2, returnedLinks[1]);

			VerifyAll();
		}
コード例 #5
0
		public void ShouldGenerateServerLinks()
		{
			string action = "ViewServerReport";
			IServerSpecifier serverSpecifier1 = new DefaultServerSpecifier("myserver");
			IServerSpecifier serverSpecifier2 = new DefaultServerSpecifier("myotherserver");

			IAbsoluteLink link1 = new GeneralAbsoluteLink("link 1");
			IAbsoluteLink link2 = new GeneralAbsoluteLink("link 2");

			linkFactoryMock.ExpectAndReturn("CreateServerLink", link1, serverSpecifier1, action);
			linkFactoryMock.ExpectAndReturn("CreateServerLink", link2, serverSpecifier2, action);

			IAbsoluteLink[] returnedLinks = linkListFactory.CreateServerLinkList(new IServerSpecifier[] { serverSpecifier1, serverSpecifier2 }, action);

			Assert.AreEqual(2, returnedLinks.Length);
			Assert.AreEqual(link1, returnedLinks[0]);
			Assert.AreEqual(link2, returnedLinks[1]);

			VerifyAll();
		}
コード例 #6
0
		public void ShouldBuildViewForRecentBuilds()
		{
			IBuildSpecifier[] buildSpecifiers = new IBuildSpecifier [] {build2Specifier, build1Specifier };
			IAbsoluteLink[] buildLinks = new IAbsoluteLink[] { new GeneralAbsoluteLink("link1"), new GeneralAbsoluteLink("link2") };
			string buildRows = "renderred Links";
			string recentBuilds = "recentBuilds";
			Hashtable context1 = new Hashtable();
			Hashtable context2 = new Hashtable();

			farmServiceMock.ExpectAndReturn("GetMostRecentBuildSpecifiers", buildSpecifiers, projectSpecifier, 10, null);
			linkListFactoryMock.ExpectAndReturn("CreateStyledBuildLinkList", buildLinks, buildSpecifiers, build1Specifier, BuildReportBuildPlugin.ACTION_NAME);
			context1["links"] = buildLinks;
			velocityTransformerMock.ExpectAndReturn("Transform", buildRows, @"BuildRows.vm", new HashtableConstraint(context1));

			context2["buildRows"] = buildRows;
			IAbsoluteLink allBuildsLink = new GeneralAbsoluteLink("foo");
			linkFactoryMock.ExpectAndReturn("CreateProjectLink", allBuildsLink, projectSpecifier, "", ViewAllBuildsProjectPlugin.ACTION_NAME);
			context2["allBuildsLink"] = allBuildsLink;
			velocityTransformerMock.ExpectAndReturn("Transform", recentBuilds, @"RecentBuilds.vm", new HashtableConstraint(context2));

			Assert.AreEqual(recentBuilds, lister.BuildRecentBuildsTable(build1Specifier, null));

			VerifyAll();
		}
コード例 #7
0
		public void ShouldGenerateBuildViewIfServerAndProjectAndBuildSpecified()
		{
			// Setup
			IProjectSpecifier projectSpecifier = new DefaultProjectSpecifier(new DefaultServerSpecifier("myServer"), "myProject");
			IBuildSpecifier buildSpecifier = new DefaultBuildSpecifier(projectSpecifier, "myBuild");
			cruiseRequestWrapperMock.ExpectAndReturn("ServerName", "myServer");
			cruiseRequestWrapperMock.ExpectAndReturn("ProjectName", "myProject");
			cruiseRequestWrapperMock.ExpectAndReturn("BuildName", "myBuild");
			cruiseRequestWrapperMock.ExpectAndReturn("BuildSpecifier", buildSpecifier);
			cruiseRequestWrapperMock.ExpectAndReturn("ProjectSpecifier", projectSpecifier);

			pluginLinkCalculatorMock.ExpectAndReturn("GetBuildPluginLinks", links, buildSpecifier);
			string recentBuildsView = "";
			recentBuildsViewBuilderMock.ExpectAndReturn("BuildRecentBuildsTable", recentBuildsView, buildSpecifier, null);

			IBuildSpecifier nextBuildSpecifier = new DefaultBuildSpecifier(projectSpecifier, "next");
			IBuildSpecifier previousBuildSpecifier = new DefaultBuildSpecifier(projectSpecifier, "previous");
			IAbsoluteLink latestLink = new GeneralAbsoluteLink("test latest");
			IAbsoluteLink nextLink = new GeneralAbsoluteLink("test next");
			IAbsoluteLink previousLink = new GeneralAbsoluteLink("test previous");

			buildNameRetrieverMock.ExpectAndReturn("GetNextBuildSpecifier", nextBuildSpecifier, buildSpecifier, null);
			buildNameRetrieverMock.ExpectAndReturn("GetPreviousBuildSpecifier", previousBuildSpecifier, buildSpecifier, null);

			string action = BuildReportBuildPlugin.ACTION_NAME;

			linkFactoryMock.ExpectAndReturn("CreateProjectLink", latestLink, projectSpecifier, LatestBuildReportProjectPlugin.ACTION_NAME);
			linkFactoryMock.ExpectAndReturn("CreateBuildLink", nextLink, nextBuildSpecifier, "", action);
			linkFactoryMock.ExpectAndReturn("CreateBuildLink", previousLink, previousBuildSpecifier, "", action);

			velocityContext["links"] = links;
			velocityContext["recentBuildsTable"] = recentBuildsView;
			velocityContext["latestLink"] = latestLink;
			velocityContext["nextLink"] = nextLink;
			velocityContext["previousLink"] = previousLink;

			velocityViewGeneratorMock.ExpectAndReturn("GenerateView", velocityResponse, @"BuildSideBar.vm", new HashtableConstraint(velocityContext));

			// Execute
			HtmlFragmentResponse returnedResponse = sideBarViewBuilder.Execute(cruiseRequestWrapperMock.MockInstance as ICruiseRequest);

			// Verify
			Assert.AreEqual(velocityResponse, returnedResponse);
			VerifyAll();
		}
コード例 #8
0
		public void ShouldGenerateServerViewIfServerButNoProjectSpecified()
		{
			// Setup
			IServerSpecifier serverSpecifier = new DefaultServerSpecifier("myServer");
			cruiseRequestWrapperMock.ExpectAndReturn("ServerName", "myServer");
			cruiseRequestWrapperMock.ExpectAndReturn("ProjectName", "");
			cruiseRequestWrapperMock.ExpectAndReturn("ServerSpecifier", serverSpecifier);

			pluginLinkCalculatorMock.ExpectAndReturn("GetServerPluginLinks", links, serverSpecifier);

            ProjectStatus ps = new ProjectStatus("", "myCategory", null, 0, 0, null, DateTime.Now, null, null, DateTime.Now, null, "", 0, new List<ParameterBase>());
			ProjectStatusOnServer[] psosa = new ProjectStatusOnServer[] { new ProjectStatusOnServer(ps, serverSpecifier) };
			ProjectStatusListAndExceptions pslae = new ProjectStatusListAndExceptions(psosa, new CruiseServerException[0]);
			farmServiceMock.ExpectAndReturn("GetProjectStatusListAndCaptureExceptions", pslae, serverSpecifier, (string)null);

			IAbsoluteLink link = new GeneralAbsoluteLink("link");
			IAbsoluteLink[] categoryLinks = new GeneralAbsoluteLink[] { new GeneralAbsoluteLink("myCategory", "?Category=myCategory") };
			linkFactoryMock.ExpectAndReturn("CreateServerLink", link, serverSpecifier, ServerReportServerPlugin.ACTION_NAME);
			linkFactoryMock.ExpectAndReturn("CreateServerLink", link, serverSpecifier, ServerReportServerPlugin.ACTION_NAME);

			velocityContext["links"] = links;
			velocityContext["serverlink"] = link;
			velocityContext["showCategories"] = true;
			velocityContext["categorylinks"] = categoryLinks;

			velocityViewGeneratorMock.ExpectAndReturn("GenerateView", velocityResponse, @"ServerSideBar.vm", new HashtableConstraint(velocityContext));

			// Execute
            HtmlFragmentResponse returnedResponse = sideBarViewBuilder.Execute(cruiseRequestWrapperMock.MockInstance as ICruiseRequest);

			// Verify
			Assert.AreEqual(velocityResponse, returnedResponse);
			VerifyAll();
		}
コード例 #9
0
		public void ShouldGetProjectDetailsAndUseCorrectTemplate()
		{
			// Setup
			ExternalLink[] links = new ExternalLink[] { new ExternalLink("foo", "bar") };
			IProjectSpecifier projectSpecifier = new DefaultProjectSpecifier(new DefaultServerSpecifier("myServer"), "myProject");
			//IBuildSpecifier buildSpecifier = new DefaultBuildSpecifier(projectSpecifier, "myBuild");
            IBuildSpecifier buildSpecifier = new DefaultBuildSpecifier(projectSpecifier, "log20050818103522Lbuild.0.0.0.9.xml");

			Hashtable expectedContext = new Hashtable();

            DynamicMock requestStub = new DynamicMock(typeof(IRequest));
            IRequest request = (IRequest)requestStub.MockInstance;

            cruiseRequestMock.SetupResult("Request", request);
            requestStub.SetupResult("ApplicationPath", "myAppPath");
            
            farmServiceMock.ExpectAndReturn("GetRSSFeed", "", projectSpecifier);
            
			expectedContext["projectName"] = "myProject";
			expectedContext["externalLinks"] = links;
			expectedContext["noLogsAvailable"] = false;
			expectedContext["mostRecentBuildUrl"] = "buildUrl";

            expectedContext["applicationPath"] = "myAppPath";
            expectedContext["rssDataPresent"] = false;
            expectedContext["rss"] = new GeneralAbsoluteLink("RSS", @"http://localhost/myServer");


			IResponse response = new HtmlFragmentResponse("myView");

            cruiseRequestMock.ExpectAndReturn("ProjectSpecifier", projectSpecifier);
            cruiseRequestMock.ExpectAndReturn("ProjectSpecifier", projectSpecifier);
			farmServiceMock.ExpectAndReturn("GetMostRecentBuildSpecifiers", new IBuildSpecifier[] { buildSpecifier }, projectSpecifier, 1, null);
			farmServiceMock.ExpectAndReturn("GetExternalLinks", links, projectSpecifier, null);
			linkFactoryMock.ExpectAndReturn("CreateProjectLink", new GeneralAbsoluteLink("foo", "buildUrl"), projectSpecifier, LatestBuildReportProjectPlugin.ACTION_NAME);

            linkFactoryMock.ExpectAndReturn("CreateProjectLink", new GeneralAbsoluteLink("RSS", @"myServer"), projectSpecifier, ThoughtWorks.CruiseControl.WebDashboard.Plugins.RSS.RSSFeed.ACTION_NAME);


            farmServiceMock.ExpectAndReturn("GetMostRecentBuildSpecifiers", new IBuildSpecifier[] { buildSpecifier }, projectSpecifier, ProjectReportProjectPlugin.AmountOfBuildsToRetrieve, null);
            expectedContext["graphDayInfo"] = new NMock.Constraints.IsTypeOf(typeof(ArrayList));
            
            expectedContext["highestAmountPerDay"] = 1;
            expectedContext["dateMultiPlier"] = 1;

            expectedContext["OKPercent"] = 100;
            expectedContext["NOKPercent"] = 0;

            expectedContext["server"] = new DefaultServerSpecifier("myServer");
            expectedContext["StatusMessage"] = string.Empty;
            expectedContext["status"] = null;
            expectedContext["StartStopButtonName"] = "StartBuild";
            expectedContext["StartStopButtonValue"] = "Start";
            expectedContext["ForceAbortBuildButtonName"] = "ForceBuild";
            expectedContext["ForceAbortBuildButtonValue"] = "Force";

			viewGeneratorMock.ExpectAndReturn("GenerateView", response, @"ProjectReport.vm", new HashtableConstraint(expectedContext));


			// Execute
			IResponse returnedResponse = plugin.Execute(cruiseRequest);

			// Verify
			Assert.AreEqual(response, returnedResponse);
			VerifyAll();
		}