Ejemplo n.º 1
0
        public virtual void TestCustomRoutes()
        {
            WebApp app = WebApps.$for <TestWebApp>("test", this, "ws").Start(new _WebApp_234()
                                                                             );
            string baseUrl = BaseUrl(app);

            try
            {
                NUnit.Framework.Assert.AreEqual("foo", GetContent(baseUrl).Trim());
                NUnit.Framework.Assert.AreEqual("foo", GetContent(baseUrl + "test").Trim());
                NUnit.Framework.Assert.AreEqual("foo1", GetContent(baseUrl + "test/1").Trim());
                NUnit.Framework.Assert.AreEqual("bar", GetContent(baseUrl + "test/bar/foo").Trim(
                                                    ));
                NUnit.Framework.Assert.AreEqual("default", GetContent(baseUrl + "test/foo/bar").Trim
                                                    ());
                NUnit.Framework.Assert.AreEqual("default1", GetContent(baseUrl + "test/foo/1").Trim
                                                    ());
                NUnit.Framework.Assert.AreEqual("default2", GetContent(baseUrl + "test/foo/bar/2"
                                                                       ).Trim());
                NUnit.Framework.Assert.AreEqual(404, GetResponseCode(baseUrl + "test/goo"));
                NUnit.Framework.Assert.AreEqual(200, GetResponseCode(baseUrl + "ws/v1/test"));
                NUnit.Framework.Assert.IsTrue(GetContent(baseUrl + "ws/v1/test").Contains("myInfo"
                                                                                          ));
            }
            finally
            {
                app.Stop();
            }
        }
Ejemplo n.º 2
0
        public virtual void TestCreateWithNonZeroPort()
        {
            WebApp app  = WebApps.$for(this).At(50000).Start();
            int    port = app.GetListenerAddress().Port;

            NUnit.Framework.Assert.AreEqual(50000, port);
            // start another WebApp with same NonZero port
            WebApp app2 = WebApps.$for(this).At(50000).Start();

            // An exception occurs (findPort disabled)
            app.Stop();
            app2.Stop();
        }
Ejemplo n.º 3
0
        public virtual void TestCreateWithPort()
        {
            // see if the ephemeral port is updated
            WebApp app  = WebApps.$for(this).At(0).Start();
            int    port = app.GetListenerAddress().Port;

            NUnit.Framework.Assert.IsTrue(port > 0);
            app.Stop();
            // try to reuse the port
            app = WebApps.$for(this).At(port).Start();
            NUnit.Framework.Assert.AreEqual(port, app.GetListenerAddress().Port);
            app.Stop();
        }
Ejemplo n.º 4
0
        public virtual void TestServePathsNoName()
        {
            WebApp app = WebApps.$for(string.Empty, this).Start();

            NUnit.Framework.Assert.AreEqual("/", app.GetRedirectPath());
            string[] expectedPaths = new string[] { "/*" };
            string[] pathSpecs     = app.GetServePathSpecs();
            NUnit.Framework.Assert.AreEqual(1, pathSpecs.Length);
            for (int i = 0; i < expectedPaths.Length; i++)
            {
                NUnit.Framework.Assert.IsTrue(ArrayUtils.Contains(pathSpecs, expectedPaths[i]));
            }
            app.Stop();
        }
Ejemplo n.º 5
0
        public virtual void TestDefaultRoutes()
        {
            WebApp app     = WebApps.$for("test", this).Start();
            string baseUrl = BaseUrl(app);

            try
            {
                NUnit.Framework.Assert.AreEqual("foo", GetContent(baseUrl + "test/foo").Trim());
                NUnit.Framework.Assert.AreEqual("foo", GetContent(baseUrl + "test/foo/index").Trim
                                                    ());
                NUnit.Framework.Assert.AreEqual("bar", GetContent(baseUrl + "test/foo/bar").Trim(
                                                    ));
                NUnit.Framework.Assert.AreEqual("default", GetContent(baseUrl + "test").Trim());
                NUnit.Framework.Assert.AreEqual("default", GetContent(baseUrl + "test/").Trim());
                NUnit.Framework.Assert.AreEqual("default", GetContent(baseUrl).Trim());
            }
            finally
            {
                app.Stop();
            }
        }
Ejemplo n.º 6
0
        public virtual void TestYARNWebAppContext()
        {
            // setting up the log context
            Runtime.SetProperty("hadoop.log.dir", "/Not/Existing/dir");
            WebApp app     = WebApps.$for("test", this).Start(new _WebApp_268());
            string baseUrl = BaseUrl(app);

            try
            {
                // should not redirect to foo
                NUnit.Framework.Assert.IsFalse("foo".Equals(GetContent(baseUrl + "static").Trim()
                                                            ));
                // Not able to access a non-existing dir, should not redirect to foo.
                NUnit.Framework.Assert.AreEqual(404, GetResponseCode(baseUrl + "logs"));
                // should be able to redirect to foo.
                NUnit.Framework.Assert.AreEqual("foo", GetContent(baseUrl).Trim());
            }
            finally
            {
                app.Stop();
            }
        }
Ejemplo n.º 7
0
 /// <exception cref="System.Exception"/>
 public static void Main(string[] args)
 {
     // For manual controller/view testing.
     WebApps.$for("test", new TestWebApp()).At(8888).InDevMode().Start().JoinThread();
 }
Ejemplo n.º 8
0
        public virtual void TestCreate()
        {
            WebApp app = WebApps.$for(this).Start();

            app.Stop();
        }