/// <exception cref="System.Exception"></exception>
        public virtual void TestEncodeDecodeCookie()
        {
            PersistentCookieStore cookieStore = new PersistentCookieStore(database);
            string cookieName   = "foo";
            string cookieVal    = "bar";
            bool   isSecure     = false;
            bool   httpOnly     = false;
            string cookiePath   = "baz";
            string cookieDomain = "foo.com";
            // expiration date - 1 day from now
            Calendar cal = Calendar.GetInstance();

            cal.SetTime(new DateTime());
            int numDaysToAdd = 1;

            cal.Add(Calendar.Date, numDaysToAdd);
            DateTime          expirationDate = cal.GetTime();
            BasicClientCookie cookie         = new BasicClientCookie(cookieName, cookieVal);

            cookie.SetExpiryDate(expirationDate);
            cookie.SetSecure(isSecure);
            cookie.SetDomain(cookieDomain);
            cookie.SetPath(cookiePath);
            string encodedCookie = cookieStore.EncodeCookie(new SerializableCookie(cookie));

            Apache.Http.Cookie.Cookie fetchedCookie = cookieStore.DecodeCookie(encodedCookie);
            NUnit.Framework.Assert.AreEqual(cookieName, fetchedCookie.GetName());
            NUnit.Framework.Assert.AreEqual(cookieVal, fetchedCookie.GetValue());
            NUnit.Framework.Assert.AreEqual(expirationDate, fetchedCookie.GetExpiryDate());
            NUnit.Framework.Assert.AreEqual(cookiePath, fetchedCookie.GetPath());
            NUnit.Framework.Assert.AreEqual(cookieDomain, fetchedCookie.GetDomain());
        }
 /// <exception cref="System.Exception"></exception>
 public virtual void TestEncodeDecodeCookie()
 {
     PersistentCookieStore cookieStore = new PersistentCookieStore(database);
     string cookieName = "foo";
     string cookieVal = "bar";
     bool isSecure = false;
     bool httpOnly = false;
     string cookiePath = "baz";
     string cookieDomain = "foo.com";
     // expiration date - 1 day from now
     Calendar cal = Calendar.GetInstance();
     cal.SetTime(new DateTime());
     int numDaysToAdd = 1;
     cal.Add(Calendar.Date, numDaysToAdd);
     DateTime expirationDate = cal.GetTime();
     BasicClientCookie cookie = new BasicClientCookie(cookieName, cookieVal);
     cookie.SetExpiryDate(expirationDate);
     cookie.SetSecure(isSecure);
     cookie.SetDomain(cookieDomain);
     cookie.SetPath(cookiePath);
     string encodedCookie = cookieStore.EncodeCookie(new SerializableCookie(cookie));
     Apache.Http.Cookie.Cookie fetchedCookie = cookieStore.DecodeCookie(encodedCookie);
     NUnit.Framework.Assert.AreEqual(cookieName, fetchedCookie.GetName());
     NUnit.Framework.Assert.AreEqual(cookieVal, fetchedCookie.GetValue());
     NUnit.Framework.Assert.AreEqual(expirationDate, fetchedCookie.GetExpiryDate());
     NUnit.Framework.Assert.AreEqual(cookiePath, fetchedCookie.GetPath());
     NUnit.Framework.Assert.AreEqual(cookieDomain, fetchedCookie.GetDomain());
 }
        /// <exception cref="System.IO.IOException"></exception>
        /// <exception cref="System.TypeLoadException"></exception>
        private void ReadObject(ObjectInputStream @in)
        {
            string name  = (string)@in.ReadObject();
            string value = (string)@in.ReadObject();

            clientCookie = new BasicClientCookie(name, value);
            clientCookie.SetComment((string)@in.ReadObject());
            clientCookie.SetDomain((string)@in.ReadObject());
            clientCookie.SetExpiryDate((DateTime)@in.ReadObject());
            clientCookie.SetPath((string)@in.ReadObject());
            clientCookie.SetVersion(@in.ReadInt());
            clientCookie.SetSecure(@in.ReadBoolean());
        }
 /// <exception cref="System.IO.IOException"></exception>
 /// <exception cref="System.TypeLoadException"></exception>
 private void ReadObject(ObjectInputStream @in)
 {
     string name = (string)@in.ReadObject();
     string value = (string)@in.ReadObject();
     clientCookie = new BasicClientCookie(name, value);
     clientCookie.SetComment((string)@in.ReadObject());
     clientCookie.SetDomain((string)@in.ReadObject());
     clientCookie.SetExpiryDate((DateTime)@in.ReadObject());
     clientCookie.SetPath((string)@in.ReadObject());
     clientCookie.SetVersion(@in.ReadInt());
     clientCookie.SetSecure(@in.ReadBoolean());
 }