Ejemplo n.º 1
0
        public virtual string[] GetSites()
        {
            List <string> sites = new List <string>();

            // check for AWStats folder existance
            if (!Directory.Exists(AwStatsFolder))
            {
                return(sites.ToArray());
            }

            string configFileName = ConfigFileName.ToLower();
            int    idx            = configFileName.IndexOf("[domain_name]");

            if (idx == -1)
            {
                return(sites.ToArray()); // wrong config file name pattern
            }
            string configPrefix = configFileName.Substring(0, idx);
            string configSuffix = configFileName.Substring(idx + 13);

            // get all files in AWStats directory
            string[] files = Directory.GetFiles(AwStatsFolder,
                                                ConfigFileName.ToLower().Replace("[domain_name]", "*"));

            foreach (string file in files)
            {
                string fileName = Path.GetFileName(file);
                string site     = fileName.Substring(configPrefix.Length,
                                                     fileName.Length - configPrefix.Length - configSuffix.Length);
                sites.Add(site);
            }
            return(sites.ToArray());
        }
        public void ConfigExample()
        {
            var path = @"E:\wwwroot\App_Config\Include\ForwardingSecurityEvents.config.example";
            var sut  = new ConfigFileName(path);

            Assert.AreEqual("ForwardingSecurityEvents.config", sut.FileName);
        }
Ejemplo n.º 3
0
        public virtual StatsSite GetSite(string siteId)
        {
            string configFileName = ConfigFileName.Replace("[DOMAIN_NAME]", siteId);
            string configFilePath = Path.Combine(AwStatsFolder, configFileName);

            if (!File.Exists(configFilePath))
            {
                return(null);
            }

            StatsSite site = new StatsSite();

            site.Name   = siteId;
            site.SiteId = siteId;

            // process stats URL
            string url = null;

            if (!String.IsNullOrEmpty(StatisticsUrl))
            {
                url = StringUtils.ReplaceStringVariable(StatisticsUrl, "domain_name", site.Name);
                url = StringUtils.ReplaceStringVariable(url, "site_id", siteId);
            }

            site.StatisticsUrl = url;

            return(site);
        }
        public void Disabled()
        {
            var path = @"E:\wwwroot\App_Config\Include\ForwardingSecurityEvents.disabled";
            var sut  = new ConfigFileName(path);

            Assert.AreEqual(@"ForwardingSecurityEvents.disabled", sut.DisabledFileName);
        }
Ejemplo n.º 5
0
        public override int GetHashCode()
        {
            int hashName = ConfigFileExtension == null ? 0 : ConfigFileName.GetHashCode();
            int hashCode = 0;

            if (ConfigFileExtension != null)
            {
                hashCode = ConfigFileExtension.GetHashCode();
            }
            return(hashName ^ hashCode);
        }
Ejemplo n.º 6
0
 public bool Equals(ProjectConfigMaster other)
 {
     if (ReferenceEquals(other, null))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(ConfigFileExtension.Equals(other.ConfigFileExtension) && ConfigFileName.Equals(other.ConfigFileName));
 }
Ejemplo n.º 7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string ConfigFileName;

            // make sure the correct config file is used
            if (Environment.CommandLine.Contains("/appconfigfile="))
            {
                // this happens when we use fastcgi-mono-server4
                ConfigFileName = Environment.CommandLine.Substring(
                    Environment.CommandLine.IndexOf("/appconfigfile=") + "/appconfigfile=".Length);

                if (ConfigFileName.IndexOf(" ") != -1)
                {
                    ConfigFileName = ConfigFileName.Substring(0, ConfigFileName.IndexOf(" "));
                }
            }
            else
            {
                // this is the normal behaviour when running with local http server
                ConfigFileName = AppDomain.CurrentDomain.BaseDirectory + Path.DirectorySeparatorChar + "web.config";
            }

            new TAppSettingsManager(ConfigFileName);
            this.ServerUrl = TAppSettingsManager.GetValue("Server.Url", "demo.openpetra.org");

            // check for valid user
            TOpenPetraOrgSessionManager myServer = new TOpenPetraOrgSessionManager();

            if (myServer.IsUserLoggedIn())
            {
                // redirect to the main application
                this.Response.Redirect("/Main.aspx");
                return;
            }

            this.Filename = GetDownloadFile();
            this.Filename = this.Filename.Replace("-", "-" + ServerUrl + "-");

            if (Request["download"] == this.Filename)
            {
                DownloadFile();
                return;
            }

            this.Language = "en";
            if ((Request.UserLanguages.Length > 1) &&
                Request.UserLanguages[0].StartsWith("de"))
            {
                this.Language = "de";
            }
        }
Ejemplo n.º 8
0
        /// THE RETURN VALUE MEANS "PARAMETERS WRE OK"!!!!! BAD!!
        private static int DoInputGenerationRound(
            CommandLineArguments args,
            string outputDir,
            int round,
            ref TimeSpan totalTime,
            string tempDir,
            string executionLogFileName,
            int randomseed,
            Collection <string> methodsToOmit,
            Collection <string> constructorsToOmit)
        {
            // Calculate time for next invocation of Randoop.
            TimeSpan timeForNextInvocation = CalculateNextTimeLimit(args.TimeLimit, totalTime,
                                                                    new TimeSpan(0, 0, args.restartTimeSeconds));

            // Analyze last execution.
            int lastPlanId;

            AnalyzeLastExecution(executionLogFileName, out lastPlanId, outputDir);

            // Create a new randoop configuration.
            RandoopConfiguration config = ConfigFileCreator.CreateConfigFile(args, outputDir, lastPlanId,
                                                                             timeForNextInvocation, round, executionLogFileName, randomseed);

            string configFileName = tempDir + "\\config" + round + ".xml";

            config.Save(configFileName);
            FileInfo configFileInfo = new FileInfo(configFileName);

            // Launch new instance of Randoop.
            Console.WriteLine("------------------------------------");
            Console.WriteLine("Spawning new input generator process (round " + round + ")");

            Process p = new Process();

            p.StartInfo.FileName              = Enviroment.RandoopBareExe;
            p.StartInfo.Arguments             = ConfigFileName.ToString(configFileInfo);
            p.StartInfo.UseShellExecute       = false;
            p.StartInfo.ErrorDialog           = true;
            p.StartInfo.RedirectStandardError = true;
            p.StartInfo.CreateNoWindow        = false;
            p.StartInfo.WorkingDirectory      = tempDir;


            Console.WriteLine("Spawning process: ");
            Console.WriteLine(Util.PrintProcess(p));

            // Give it 30 seconds to load reflection info, etc.
            int waitTime = (Convert.ToInt32(timeForNextInvocation.TotalSeconds) + 30) * 1000;

            Console.WriteLine("Will wait " + waitTime + " milliseconds for process to terminate.");

            p.Start();

            if (!p.WaitForExit(waitTime))
            {
                // Process didn't terminate. Kill it forcefully.
                Console.WriteLine("Killing process " + p.Id);
                try
                {
                    p.Kill();
                }
                catch (InvalidOperationException)
                {
                    // p has already terminated. No problem.
                }
                p.WaitForExit();
            }

            // Update total time.
            totalTime += p.ExitTime - p.StartTime;

            string err = p.StandardError.ReadToEnd();

            // Randoop terminated with error.
            if (p.ExitCode != 0)
            {
                if (err.Contains(Enviroment.RandoopBareInternalErrorMessage))
                {
                    Console.WriteLine(err);
                    Console.WriteLine("*** RandoopBare had an internal error. Exiting.");
                    return(p.ExitCode);
                }

                if (err.Contains(Enviroment.RandoopBareInvalidUserParametersErrorMessage))
                {
                    Console.WriteLine(err);
                    Console.WriteLine("*** RandoopBare terminated normally. Exiting.");
                    return(p.ExitCode);
                }
            }

            return(0);
        }
Ejemplo n.º 9
0
        private static void Main2(string[] args)
        {
            NLogConfigManager.CreateFileConfig();
            Logger = NLog.LogManager.GetCurrentClassLogger();

            if (args.Length != 1)
            {
                throw new InvalidUserParamsException(
                          "RandoopBare takes exactly one argument but was "
                          + "given the following arguments:"
                          + System.Environment.NewLine
                          + Util.PrintArray(args));;
            }

            // Parse XML file with generation parameters.
            string configFileName       = ConfigFileName.Parse(args[0]);
            RandoopConfiguration config = LoadConfigFile(configFileName);

            // Set the random number generator.
            if (config.randomSource == RandomSource.SystemRandom)
            {
                Logger.Debug("Randoom seed = " + config.randomseed);
                SystemRandom random = new SystemRandom();
                random.Init(config.randomseed);
                Enviroment.Random = random;
            }
            else
            {
                Util.Assert(config.randomSource == RandomSource.Crypto);
                Logger.Debug("Randoom seed = new System.Security.Cryptography.RNGCryptoServiceProvider()");
                Enviroment.Random = new CryptoRandom();
            }

            if (!Directory.Exists(config.outputdir))
            {
                throw new InvalidUserParamsException("output directory does not exist: "
                                                     + config.outputdir);
            }

            Collection <Assembly> assemblies = Misc.LoadAssemblies(config.assemblies);

            ////[email protected] for substituting MessageBox.Show() - start
            ////Instrument instrumentor = new Instrument();
            //foreach (FileName asm in config.assemblies)
            //{
            //    Instrument.MethodInstrument(asm.fileName, "System.Windows.Forms.MessageBox::Show", "System.Logger.Debug");
            //}
            ////[email protected] for substituting MessageBox.Show() - end

            IReflectionFilter filter1 = new VisibilityFilter(config);
            ConfigFilesFilter filter2 = new ConfigFilesFilter(config);

            Logger.Debug("========== REFLECTION PATTERNS:");
            filter2.PrintFilter(Console.Out);

            IReflectionFilter filter = new ComposableFilter(filter1, filter2);

            Collection <Type> typesToExplore = ReflectionUtils.GetExplorableTypes(assemblies);

            PlanManager planManager = new PlanManager(config);

            planManager.builderPlans.AddEnumConstantsToPlanDB(typesToExplore);
            planManager.builderPlans.AddConstantsToTDB(config);

            Logger.Debug("========== INITIAL PRIMITIVE VALUES:");
            planManager.builderPlans.PrintPrimitives(Console.Out);

            StatsManager stats = new StatsManager(config);

            Logger.Debug("Analyzing assembly.");

            ActionSet actions;

            try
            {
                actions = new ActionSet(typesToExplore, filter);
            }
            catch (EmpytActionSetException)
            {
                string msg = "After filtering based on configuration files, no remaining methods or constructors to explore.";
                throw new InvalidUserParamsException(msg);
            }

            Logger.Debug("Generating tests.");

            RandomExplorer explorer =
                new RandomExplorer(typesToExplore, filter, true, config.randomseed, config.arraymaxsize, stats, actions);
            ITimer t = new Timer(config.timelimit);

            try
            {
                explorer.Explore(t, planManager, config.methodweighing, config.forbidnull, true, config.fairOpt);
            }
            catch (Exception e)
            {
                Logger.Error("Explorer raised exception {0}", e.ToString());
                throw;
            }
        }
Ejemplo n.º 10
0
 private void ClearDataList()
 {
     dataList.Clear();
     exist.Clear();
     ConfigFileName.Clear();
 }