Example #1
0
        public void TestInvalidDocument()
        {
            Type t = Type.GetType("Mono.Runtime");

            if (t != null)
            {
                Console.WriteLine("Running Test Correct on Window system, Mono cannot use WebRequest Unsupported.");
                Console.WriteLine("Test Skipped");
            }
            else
            {
                Environment.CurrentDirectory = TestContext.CurrentContext.TestDirectory;
                string arg  = "";
                string arg2 = "";

                string dir = Directory.GetCurrentDirectory();
                arg  = dir + "/Logger/";
                arg2 = dir + "/Cache/";

                if (!Directory.Exists(arg))
                {
                    Directory.CreateDirectory(arg);
                }
                if (!Directory.Exists(arg2))
                {
                    Directory.CreateDirectory(arg2);
                }

                OSXJVServer server = new OSXJVServer();
                server.Start(arg, arg2);

                server.Stop();
            }
        }
Example #2
0
        public void StopTestAlreadyStoppedOrNotRunning()
        {
            Console.WriteLine("StopTestAlreadyStoppedOrNotRunning");
            OSXJVServer server = new OSXJVServer();

            Assert.IsTrue(server.Stop());
        }
Example #3
0
        public void StopTest()
        {
            Console.WriteLine("StopTest");

            Environment.CurrentDirectory = TestContext.CurrentContext.TestDirectory;
            string arg  = "";
            string arg2 = "";

            string dir = Directory.GetCurrentDirectory();

            arg  = dir + "/Logger/";
            arg2 = dir + "/Cache/";

            if (!Directory.Exists(arg))
            {
                Directory.CreateDirectory(arg);
            }
            if (!Directory.Exists(arg2))
            {
                Directory.CreateDirectory(arg2);
            }

            OSXJVServer server = new OSXJVServer();

            server.Start(arg, arg2);
            Assert.IsTrue(server.Stop());
        }
Example #4
0
        public void HttpserverTest()
        {
            Console.WriteLine("HttpserverTest");
            OSXJVServer server = new OSXJVServer();

            Assert.IsNotNull(server);
        }
Example #5
0
        public void TestCorrectDocument(string data, string type, string expected)
        {
            Console.WriteLine("TestCorrectDocument");

            Type t = Type.GetType("Mono.Runtime");

            if (t != null)
            {
                Console.WriteLine("Running Test Correct on Window system, Mono cannot use WebRequest Unsupported.");
                Console.WriteLine("Test Skipped");
            }
            else
            {
                Environment.CurrentDirectory = TestContext.CurrentContext.TestDirectory;
                string arg  = "";
                string arg2 = "";

                string dir = Directory.GetCurrentDirectory();
                arg  = dir + "/Logger/";
                arg2 = dir + "/Cache/";

                if (!Directory.Exists(arg))
                {
                    Directory.CreateDirectory(arg);
                }
                if (!Directory.Exists(arg2))
                {
                    Directory.CreateDirectory(arg2);
                }

                OSXJVServer server = new OSXJVServer();

                server.Start(arg, arg2);

                WebRequest request = WebRequest.Create("http://localhost:8082/Process");
                request.ContentType = type;
                request.Method      = WebRequestMethods.Http.Post;

                byte[] bytes = Encoding.ASCII.GetBytes(data);
                request.ContentLength = bytes.Length;
                Stream os = request.GetRequestStream();
                os.Write(bytes, 0, bytes.Length);
                os.Close();
                WebResponse resp = request.GetResponse();

                StreamReader sr =
                    new StreamReader(resp.GetResponseStream());

                JObject obj = JObject.Parse(sr.ReadToEnd());

                Console.WriteLine(obj.ToString());
                Console.WriteLine("Actual: {0}", obj.Property("view").Value.ToString());
                Console.WriteLine("Expected: {0}", expected);

                Assert.AreEqual(obj.Property("view").Value.ToString(), expected);

                server.Stop();
            }
        }
Example #6
0
        /// <summary>
        /// The Main function that starts the HttpServer
        /// </summary>
        /// <param name="args">Pass Cache Folder and Logger (Optional)</param>
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine("Using Default Cache Directory Path and Logger Directory Path");
                string dir = Directory.GetCurrentDirectory();
                Array.Resize(ref args, 2);
                args[0] = dir + "/Cache/";
                args[1] = dir + "/Logger/";
                if (!Directory.Exists(args[0]))
                {
                    Directory.CreateDirectory(args[0]);
                }
                if (!Directory.Exists(args[1]))
                {
                    Directory.CreateDirectory(args[1]);
                }
            }

            if (args[0] == args[1])
            {
                Console.WriteLine("Cache location and Log location is the same. Please enter two different locations");
            }
            else
            {
                try
                {
                    OSXJVServer s = new OSXJVServer();
                    s.Start(args[0], args[1]);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    Console.WriteLine("Press any key to exit");
                    Console.Read();
                }
            }
        }