Ejemplo n.º 1
0
        public void fromXmlString8Test()
        {
            Map <string, CarOptions> obj_ = (Map <string, CarOptions>)SerializeXmlObject.fromXmlStringObject("<Util.Util.Map types=\"`2[[System.String, mscorlib], [Util.CarOptions, Util]]\"><mscorlib.System.String class=\"Util.Util.ListableKey\" key=\"\" value=\"hello\" /><Util.Util.CarOptions class=\"Util.Util.ListableKey\" value=\"SunRoof\" /></Util.Util.Map>");

            Assert.AreEqual(1, obj_.size());
            Assert.AreEqual(CarOptions.SunRoof, obj_.getVal("hello"));
        }
Ejemplo n.º 2
0
        public void fromXmlString7Test()
        {
            MyList <CarOptions> obj_ = (MyList <CarOptions>)SerializeXmlObject.fromXmlStringObject("<Util.Util.MyList types=\"`1[[Util.CarOptions, Util]]\"><Util.Util.CarOptions class=\"mscorlib.System.Collections.IEnumerable\" value=\"SunRoof\" /></Util.Util.MyList>");

            Assert.AreEqual(1, obj_.size());
            Assert.AreEqual(CarOptions.SunRoof, obj_.get(0));
        }
Ejemplo n.º 3
0
        public void fromXmlString13Test()
        {
            ArrayClass arr_ = (ArrayClass)SerializeXmlObject.fromXmlStringObject("<StreamTests.StreamTests.ArrayClass><array field=\"sampleArray\" class=\"StreamTests.StreamTests.ArrayClass\" type=\"mscorlib.System.Int32\"><mscorlib.System.Int32 value=\"5\" /><mscorlib.System.Int32 value=\"3\" /></array></StreamTests.StreamTests.ArrayClass>");

            Assert.AreEqual(2, arr_.getSampleArray().Length);
            Assert.AreEqual(5, arr_.getSampleArray().ElementAt(0));
            Assert.AreEqual(3, arr_.getSampleArray().ElementAt(1));
        }
Ejemplo n.º 4
0
        /*public void setFiles(String _assembly, String _resourcesFile)
         * {
         *  assembly = _assembly;
         *  List<String> list_ = StreamZipFile.zippedFiles(_assembly);
         *  if (list_.isEmpty())
         *  {
         *      list_ = StreamTextFile.files(_resourcesFile);
         *  }
         *  files = new Map<String, String>();
         *  foreach (String f in list_)
         *  {
         *      if (f.EndsWith(PNG) || f.EndsWith(JPG))
         *      {
         *          try
         *          {
         *              files.put(f, toBaseSixtyFour(f));
         *          }
         *          catch (Exception)
         *          {
         *              //e.printStackTrace();
         *          }
         *          continue;
         *      }
         *      if (f.EndsWith(TXT))
         *      {
         *          try
         *          {
         *              BufferedImage buff_ = ConverterBufferedImageIo.readImage(f);
         *              String txt_ = ConverterBufferedImage.toBaseSixtyFour(buff_, FORMAT_PNG);
         *              files.put(f, txt_);
         *          }
         *          catch (Exception)
         *          {
         *              files.put(f, StreamTextFile.getContentFileInJar(assembly, f));
         *          }
         *      }
         *      if (f.EndsWith(HTML) || f.EndsWith(XML) || f.EndsWith(CSS) || f.EndsWith(PROPERTIES))
         *      {
         *          files.put(f, StreamTextFile.getContentFileInJar(assembly, f));
         *      }
         *  }
         * }*/
        public void loadConfiguration(String _conf)
        {
            string confFile_ = _conf.ToLower();
            bool   found_    = false;
            String fileName_ = EMPTY_STRING;

            foreach (Entry <String, String> e in files.entryList())
            {
                if (e.getKey().ToLower().Equals(confFile_))
                {
                    fileName_ = e.getKey();
                    found_    = true;
                    break;
                }
            }
            String content_;

            if (found_)
            {
                content_ = files.getVal(fileName_);
            }
            else
            {
                content_ = StreamTextFile.getContentFileInJar(assembly, _conf);
            }
            content_ = content_.Replace("<.", "<" + assembly + ".");
            content_ = content_.Replace("</.", "</" + assembly + ".");
            //content_ = content_.Replace(".]", assembly + "]");
            XmlDocument doc_    = XmlParser.parseSax(content_);
            XmlNodeList list_   = doc_.GetElementsByTagName("*");
            int         length_ = list_.Count;

            for (int i = 0; i < length_; i++)
            {
                XmlElement elt_   = list_.Item(i) as XmlElement;
                string     class_ = elt_.GetAttribute("class");
                class_ = class_.Replace(".]", assembly + "]");
                if (class_.StartsWith("."))
                {
                    elt_.SetAttribute("class", assembly + class_);
                }
            }
            content_ = XmlParser.toXml(doc_);
            session  = (Configuration)SerializeXmlObject.fromXmlStringObject(content_);
            session.setAssembly(assembly);
            foreach (String b in session.getBeans().getKeys())
            {
                Bean bean_ = session.getBeans().getVal(b);
                if (bean_.getClassName().StartsWith("."))
                {
                    bean_.setClassName(assembly + bean_.getClassName().Replace(".]", assembly + "]"));
                }
                else
                {
                    bean_.setClassName(bean_.getClassName().Replace(".]", assembly + "]"));
                }
            }
        }
Ejemplo n.º 5
0
        public void fromXmlString10Test()
        {
            TreeMap <string, CarOptions> obj_ = (TreeMap <string, CarOptions>)SerializeXmlObject.fromXmlStringObject("<Util.Util.TreeMap types=\"`2[[System.String, mscorlib], [Util.CarOptions, Util]]\"><StreamTests.StreamTests.ReverseComparer class=\"Util.Util.ListableKey\" Comparer=\"\" /><mscorlib.System.String class=\"Util.Util.ListableKey\" key=\"\" value=\"2\" /><Util.Util.CarOptions class=\"Util.Util.ListableKey\" value=\"FogLights\" /><mscorlib.System.String class=\"Util.Util.ListableKey\" key=\"\" value=\"1\" /><Util.Util.CarOptions class=\"Util.Util.ListableKey\" value=\"SunRoof\" /></Util.Util.TreeMap>");

            Assert.AreEqual(2, obj_.size());
            Assert.AreEqual("2", obj_.getKey(0));
            Assert.AreEqual(CarOptions.FogLights, obj_.getValue(0));
            Assert.AreEqual("1", obj_.getKey(1));
            Assert.AreEqual(CarOptions.SunRoof, obj_.getValue(1));
        }
Ejemplo n.º 6
0
        public void toXmlString10Test()
        {
            TreeMap <String, CarOptions> opts2_ = new TreeMap <String, CarOptions>(new ReverseComparer());

            opts2_.put("1", CarOptions.SunRoof);
            opts2_.put("2", CarOptions.FogLights);
            Assert.AreEqual("<Util.Util.TreeMap types=\"`2[[System.String, mscorlib], [Util.CarOptions, Util]]\"><StreamTests.StreamTests.ReverseComparer class=\"Util.Util.ListableKey\" Comparer=\"\"/><mscorlib.System.String class=\"Util.Util.ListableKey\" key=\"\" value=\"2\"/><Util.Util.CarOptions class=\"Util.Util.ListableKey\" value=\"FogLights\"/><mscorlib.System.String class=\"Util.Util.ListableKey\" key=\"\" value=\"1\"/><Util.Util.CarOptions class=\"Util.Util.ListableKey\" value=\"SunRoof\"/></Util.Util.TreeMap>", SerializeXmlObject.toXmlString(opts2_));
        }
Ejemplo n.º 7
0
 public void toXmlString7Test()
 {
     Assert.AreEqual("<StreamTests.StreamTests.Rate value=\"1/2\"/>", SerializeXmlObject.toXmlString(new Rate(1, 2)));
 }
Ejemplo n.º 8
0
 public void toXmlString8Test()
 {
     Assert.AreEqual("<StreamTests.StreamTests.Composite><mscorlib.System.Int64 field=\"num\" class=\"StreamTests.StreamTests.Composite\" value=\"1\"/><mscorlib.System.Int64 field=\"den\" class=\"StreamTests.StreamTests.Composite\" value=\"2\"/></StreamTests.StreamTests.Composite>", SerializeXmlObject.toXmlString(new Composite(1, 2)));
 }
Ejemplo n.º 9
0
        public void toXmlString5Test()
        {
            Map <String, CarOptions> opts2_ = new Map <String, CarOptions>();

            opts2_.put("1", CarOptions.SunRoof);
            Assert.AreEqual("<Util.Util.Map types=\"`2[[System.String, mscorlib], [Util.CarOptions, Util]]\"><mscorlib.System.String class=\"Util.Util.ListableKey\" key=\"\" value=\"1\"/><Util.Util.CarOptions class=\"Util.Util.ListableKey\" value=\"SunRoof\"/></Util.Util.Map>", SerializeXmlObject.toXmlString(opts2_));
        }
Ejemplo n.º 10
0
        public void toXmlString6Test()
        {
            int k_ = 4;

            Assert.AreEqual("<mscorlib.System.Int32 value=\"4\"/>", SerializeXmlObject.toXmlString(k_));
        }
Ejemplo n.º 11
0
        public void toXmlString3Test()
        {
            MyList <CarOptions> opts_ = new MyList <CarOptions>();

            opts_.Add(CarOptions.SunRoof);
            Assert.AreEqual("<Util.Util.MyList types=\"`1[[Util.CarOptions, Util]]\"><Util.Util.CarOptions class=\"mscorlib.System.Collections.IEnumerable\" value=\"SunRoof\"/></Util.Util.MyList>", SerializeXmlObject.toXmlString(opts_));
        }
Ejemplo n.º 12
0
 public void toXmlString4Test()
 {
     Assert.AreEqual("<mscorlib.System.String value=\"hello\"/>", SerializeXmlObject.toXmlString("hello"));
 }
Ejemplo n.º 13
0
        public void fromXmlString12Test()
        {
            char obj_ = (char)SerializeXmlObject.fromXmlStringObject("<mscorlib.System.Char value=\"1\" />");

            Assert.AreEqual('1', obj_);
        }
Ejemplo n.º 14
0
        public void fromXmlString1Test()
        {
            long obj_ = (long)SerializeXmlObject.fromXmlStringObject("<mscorlib.System.Int64 value=\"1\" />");

            Assert.AreEqual(1, obj_);
        }
Ejemplo n.º 15
0
        public void toXmlString11Test()
        {
            CarOptions j_ = CarOptions.Spoiler | CarOptions.SunRoof;

            Assert.AreEqual("<Util.Util.CarOptions value=\"SunRoof, Spoiler\"/>", SerializeXmlObject.toXmlString(j_));
        }
Ejemplo n.º 16
0
        public void toXmlString13Test()
        {
            ArrayClass arr_ = new ArrayClass();

            int[] i_ = new int[2];
            i_[0] = 5;
            i_[1] = 3;
            arr_.setSampleArray(i_);
            Assert.AreEqual("<StreamTests.StreamTests.ArrayClass><array field=\"sampleArray\" class=\"StreamTests.StreamTests.ArrayClass\" type=\"mscorlib.System.Int32\"><mscorlib.System.Int32 value=\"5\"/><mscorlib.System.Int32 value=\"3\"/></array></StreamTests.StreamTests.ArrayClass>", SerializeXmlObject.toXmlString(arr_));
        }
Ejemplo n.º 17
0
        public void fromXmlString3Test()
        {
            string obj_ = (string)SerializeXmlObject.fromXmlStringObject("<mscorlib.System.String value=\"hello\" />");

            Assert.AreEqual("hello", obj_);
        }
Ejemplo n.º 18
0
        public void toXmlString1Test()
        {
            long i_ = 1;

            Assert.AreEqual("<mscorlib.System.Int64 value=\"1\"/>", SerializeXmlObject.toXmlString(i_));
        }
Ejemplo n.º 19
0
        public void fromXmlString4Test()
        {
            int obj_ = (int)SerializeXmlObject.fromXmlStringObject("<mscorlib.System.Int32 value=\"4\" />");

            Assert.AreEqual(4, obj_);
        }
Ejemplo n.º 20
0
        public void fromXmlString6Test()
        {
            Composite obj_ = (Composite)SerializeXmlObject.fromXmlStringObject("<StreamTests.StreamTests.Composite><mscorlib.System.Int64 field=\"num\" class=\"StreamTests.StreamTests.Composite\" value=\"1\" /><mscorlib.System.Int64 field=\"den\" class=\"StreamTests.StreamTests.Composite\" value=\"2\" /></StreamTests.StreamTests.Composite>");

            Assert.AreEqual(new Composite(1, 2), obj_);
        }
Ejemplo n.º 21
0
        public void fromXmlString5Test()
        {
            Rate obj_ = (Rate)SerializeXmlObject.fromXmlStringObject("<StreamTests.StreamTests.Rate value=\"1/2\" />");

            Assert.AreEqual(new Rate(1, 2), obj_);
        }
Ejemplo n.º 22
0
        public void fromXmlString11Test()
        {
            CarOptions obj_ = (CarOptions)SerializeXmlObject.fromXmlStringObject("<Util.Util.CarOptions value=\"Spoiler, SunRoof\" />");

            Assert.AreEqual(CarOptions.Spoiler | CarOptions.SunRoof, obj_);
        }
Ejemplo n.º 23
0
        public void toXmlString12Test()
        {
            char i_ = '1';

            Assert.AreEqual("<mscorlib.System.Char value=\"1\"/>", SerializeXmlObject.toXmlString(i_));
        }