public void AddPacketToSendQueueTest() { BonCodeAJP13ServerConnection target = new BonCodeAJP13ServerConnection(); // TODO: Initialize to an appropriate value BonCodeAJP13Packet singlePacket = null; // TODO: Initialize to an appropriate value target.AddPacketToSendQueue(singlePacket); Assert.Inconclusive("A method that does not return a value cannot be verified."); }
public void AbortConnectionTest() { BonCodeAJP13ServerConnection target = new BonCodeAJP13ServerConnection(); // TODO: Initialize to an appropriate value bool expected = false; // TODO: Initialize to an appropriate value bool actual; target.AbortConnection = expected; actual = target.AbortConnection; Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public void BeginConnectionTest() { BonCodeAJP13ServerConnection target = new BonCodeAJP13ServerConnection(); // TODO: Initialize to an appropriate value target.BeginConnection(); Assert.Inconclusive("A method that does not return a value cannot be verified."); }
public void SetTcpClientTest() { BonCodeAJP13ServerConnection target = new BonCodeAJP13ServerConnection(); // TODO: Initialize to an appropriate value TcpClient expected = null; // TODO: Initialize to an appropriate value target.SetTcpClient = expected; Assert.Inconclusive("Write-only properties cannot be verified."); }
public void ReceivedDataCollectionTest() { BonCodeAJP13ServerConnection target = new BonCodeAJP13ServerConnection(); // TODO: Initialize to an appropriate value BonCodeAJP13PacketCollection actual; actual = target.ReceivedDataCollection; Assert.Inconclusive("Verify the correctness of this test method."); }
public void ServerTest() { BonCodeAJP13ServerConnection target = new BonCodeAJP13ServerConnection(); // TODO: Initialize to an appropriate value string expected = string.Empty; // TODO: Initialize to an appropriate value string actual; target.Server = expected; actual = target.Server; Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public void FlushDelegateFunctionTest() { BonCodeAJP13ServerConnection target = new BonCodeAJP13ServerConnection(); // TODO: Initialize to an appropriate value FlushPacketsCollectionDelegate expected = null; // TODO: Initialize to an appropriate value target.FlushDelegateFunction = expected; Assert.Inconclusive("Write-only properties cannot be verified."); }
public void PortTest() { BonCodeAJP13ServerConnection target = new BonCodeAJP13ServerConnection(); // TODO: Initialize to an appropriate value int expected = 0; // TODO: Initialize to an appropriate value int actual; target.Port = expected; actual = target.Port; Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public void BonCodeAJP13ServerConnectionConstructorTest5() { BonCodeAJP13Packet singlePacket = null; // TODO: Initialize to an appropriate value BonCodeAJP13ServerConnection target = new BonCodeAJP13ServerConnection(singlePacket); Assert.Inconclusive("TODO: Implement code to verify target"); }
public void BonCodeAJP13ServerConnectionConstructorTest3() { BonCodeAJP13ServerConnection target = new BonCodeAJP13ServerConnection(); Assert.Inconclusive("TODO: Implement code to verify target"); }
public void BonCodeAJP13ServerConnectionConstructorTest2() { string server = string.Empty; // TODO: Initialize to an appropriate value int port = 0; // TODO: Initialize to an appropriate value BonCodeAJP13PacketCollection packetsToSend = null; // TODO: Initialize to an appropriate value BonCodeAJP13ServerConnection target = new BonCodeAJP13ServerConnection(server, port, packetsToSend); Assert.Inconclusive("TODO: Implement code to verify target"); }
static void Main(string[] args) { //KeyTest(); //sample setting //Console.WriteLine("Sample Setting " + Properties.Settings.Default.SampleSetting); //read parameters from console first parameter is server second port if (args.Length >= 1) { myURL = (string)args[0]; } if (args.Length >= 2) { myServer = (string)args[1]; } if (args.Length >= 3) { myPort = (string)args[2]; } string myDNS = myServer; // +":" + myPort; ushort iPort = Convert.ToUInt16(myPort); //test search byte[] sourceBytes = new byte[20] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A }; byte[] searchBytes = new byte[2] { 0x02, 0x04 }; int foundPos = ByteSearch(sourceBytes, searchBytes, 0); Console.WriteLine(Environment.GetFolderPath(Environment.SpecialFolder.InternetCache)); Console.WriteLine(BonCodeAJP13Settings.BONCODEAJP13_LOG_DIR); ConnectViaString(myDNS, myData); //test config //Test myTest = new Test(); //myTest.fHeaderTest(); //log level //Console.WriteLine("Log Level " + BonCodeAJP13Settings.BONCODEAJP13_LOG_LEVEL); //create intance of forward request BonCodeAJP13ForwardRequest FR = new BonCodeAJP13ForwardRequest(BonCodeAJP13HTTPMethods.BONCODEAJP13_GET, "HTTP/1.1", myURL, "::1", "::1", myServer,iPort ,false,1); //create cping request BonCodeAJP13ForwardRequest FR2 = new BonCodeAJP13ForwardRequest(BonCodeAJP13HTTPMethods.BONCODEAJP13_GET, "HTTP/1.1", myURL, "::1", "::1", myServer, iPort, false, 1); byte[] testBytes = FR.GetDataBytes(); //this returns the contructed databytes //byte[] testBytes = FR.WriteServerTestPacket(); Console.WriteLine("Server: {0} , Port: {1}, URL: {2}", myServer, myPort, myURL); //call server request BonCodeAJP13ServerConnection sconn = new BonCodeAJP13ServerConnection(FR,true); sconn.Server = myServer; sconn.Port = System.Convert.ToInt32(myPort); sconn.FlushDelegateFunction = PrintFlush; //this function will do the printing to console //run connection sconn.BeginConnection(); //write the response to screen that has not been flushed yet foreach (Object oIterate in sconn.ReceivedDataCollection) { BonCodeAJP13Packet Packet = oIterate as BonCodeAJP13Packet; //only objects derived from this class should be in the collection Console.WriteLine(Packet.GetDataString()); } Console.WriteLine("Last Size:" + sconn.ReceivedDataCollection.Count); //call connect function //ConnectViaString(myDNS, myData); //Connect(myDNS, testBytes); int a = 2; a++; }
/// <summary> /// Main process hook for IIS invocation. /// </summary> public void ProcessRequest(HttpContext context) { //check execution string executionFeedback = CheckExecution(context.Request.ServerVariables); bool blnProceed = true; /* debug: dump headers string strOut = GetHeaders(context.Request.ServerVariables); context.Response.Write(strOut); */ if (executionFeedback.Length == 0) { //determine web doc root if needed if (BonCodeAJP13Settings.BONCODEAJP13_HEADER_SUPPORT) { BonCodeAJP13Settings.BonCodeAjp13_DocRoot = System.Web.HttpContext.Current.Server.MapPath("~"); } //check whether we are resuable, we discard and re-establish connections if MAX_BONCODEAJP13_CONCURRENT_CONNECTIONS is set to zero if (BonCodeAJP13Settings.MAX_BONCODEAJP13_CONCURRENT_CONNECTIONS == 0) { p_isReusable = false; } //determine whether we are declaring ourself as part of a reusable pool. If not we need to also take steps to //kill connections if we are close to the max of pool we maintain a ten thread margin //this allows limited processing to continue even if we are close to maxed out on connections if (p_isReusable && BonCodeAJP13Settings.MAX_BONCODEAJP13_CONCURRENT_CONNECTIONS < (p_InstanceCount + 10)) { p_isReusable = false; //new connections will be dropped immediatly }; //assign reference to context to an instance handler p_Context = context; long streamLen = context.Request.InputStream.Length; //create TcpClient to pass to AJP13 processor, this will re-use connection until this instance is destroyed if (p_TcpClient == null) { try { p_TcpClient = new TcpClient(BonCodeAJP13Settings.BONCODEAJP13_SERVER, BonCodeAJP13Settings.BONCODEAJP13_PORT); } catch (Exception e) { //check whether we had issues connecting to tomcat string errMsg = "Error connecting to Apache Tomcat instance.<hr>Please check that a Tomcat server is running at given location and port.<br>Details:<br>" + e.Message; context.Response.Write(errMsg); blnProceed = false; } //determine whether we will need to remove the connection later if (!p_isReusable) { p_FlagKillConnection = true; } else { p_FlagKillConnection = false; } } if (blnProceed) { //initialize AJP13 protocol connection BonCodeAJP13ServerConnection sconn = new BonCodeAJP13ServerConnection(); sconn.FlushDelegateFunction = PrintFlush; //this function will do the transfer to browser if we use Flush detection, we pass as delegate sconn.FlushStatusFunction = IsFlushing; //will let the implementation know if flushing is still in progress sconn.SetTcpClient = p_TcpClient; //setup basic information (base ForwardRequest package) BonCodeAJP13ForwardRequest FR = new BonCodeAJP13ForwardRequest(context.Request.ServerVariables); sconn.AddPacketToSendQueue(FR); //determine if extra ForwardRequests are needed. //We need to create a collection of Requests (for form data and file uploads etc.) if (context.Request.ContentLength > 0) { // need to create a collection of forward requests to package data in int numOfPackets = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(context.Request.ContentLength / Convert.ToDouble(BonCodeAJP13Consts.MAX_BONCODEAJP13_USERDATA_LENGTH)))); int iStart = 0; int iCount = 0; for (int i = 1; i <= numOfPackets; i++) { //we need to breakdown data into multiple FR packages to tomcat if (i * BonCodeAJP13Consts.MAX_BONCODEAJP13_USERDATA_LENGTH <= streamLen) { //we are in the middle of transferring data grab next 8188 bytes and create package iStart = (i - 1) * BonCodeAJP13Consts.MAX_BONCODEAJP13_USERDATA_LENGTH; iCount = Convert.ToInt32(BonCodeAJP13Consts.MAX_BONCODEAJP13_USERDATA_LENGTH); } else { //last user package iStart = (i - 1) * BonCodeAJP13Consts.MAX_BONCODEAJP13_USERDATA_LENGTH; iCount = Convert.ToInt32(streamLen) - iStart; } //add package to collection byte[] streamInput = new byte[iCount]; context.Request.InputStream.Read(streamInput, 0, iCount); //stream pointer moves with each read so we allways start at zero position sconn.AddPacketToSendQueue(new BonCodeAJP13ForwardRequest(streamInput)); } //add an empty Forward Request packet as terminator to collection if multiple packets are used //sconn.AddPacketToSendQueue(new BonCodeAJP13ForwardRequest(new byte[] { })); } //run connection (send and receive cycle) sconn.BeginConnection(); //write the response to browser (if not already flushed) PrintFlush(sconn.ReceivedDataCollection); //kill connections if we are not reusing connections if (p_FlagKillConnection) { KillConnection(); } }; // proceed is true } else { //execution was denied by logic, only print message context.Response.Write(executionFeedback); } }