/// <summary>Returns a Jetty server ready to be configured and the started.</summary> /// <remarks> /// Returns a Jetty server ready to be configured and the started. This server /// is only available when the test method has been annotated with /// <see cref="TestJetty"/> /// . Refer to /// <see cref="HTestCase"/> /// header for details. /// <p/> /// Once configured, the Jetty server should be started. The server will be /// automatically stopped when the test method ends. /// </remarks> /// <returns>a Jetty server ready to be configured and the started.</returns> public static Server GetJettyServer() { Org.Apache.Hadoop.Test.TestJettyHelper helper = TestJettyTl.Get(); if (helper == null || helper.server == null) { throw new InvalidOperationException("This test does not use @TestJetty"); } return(helper.server); }
/// <summary> /// Returns the base URL (SCHEMA://HOST:PORT) of the test Jetty server /// (see /// <see cref="GetJettyServer()"/> /// ) once started. /// </summary> /// <returns>the base URL (SCHEMA://HOST:PORT) of the test Jetty server.</returns> public static Uri GetJettyURL() { Org.Apache.Hadoop.Test.TestJettyHelper helper = TestJettyTl.Get(); if (helper == null || helper.server == null) { throw new InvalidOperationException("This test does not use @TestJetty"); } try { string scheme = (helper.ssl) ? "https" : "http"; return(new Uri(scheme + "://" + helper.server.GetConnectors()[0].GetHost() + ":" + helper.server.GetConnectors()[0].GetPort())); } catch (UriFormatException ex) { throw new RuntimeException("It should never happen, " + ex.Message, ex); } }