Ejemplo n.º 1
0
        public bool streamTests(
			DbSystem	dbSystem)
        {
            IStream			bufferStream;
            IStream			encoderStream;
            IStream			decoderStream;
            OStream			fileOStream;
            Stream			s;
            StreamReader	sr;
            string			sFileData;

            beginTest( "Creating IStream from buffer");
            try
            {
                bufferStream = dbSystem.openBufferIStream( TEST_STREAM_STRING);
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "calling openBufferIStream");
                return( false);
            }
            endTest( false, true);

            beginTest( "Creating base 64 encoder stream");
            try
            {
                encoderStream = dbSystem.openBase64Encoder( bufferStream, true);
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "calling openBase64Encoder");
                return( false);
            }
            endTest( false, true);

            beginTest( "Creating base 64 decoder stream");
            try
            {
                decoderStream = dbSystem.openBase64Decoder( encoderStream);
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "calling openBase64Decoder");
                return( false);
            }
            endTest( false, true);

            beginTest( "Creating file output stream");
            try
            {
                fileOStream = dbSystem.openFileOStream( "Output_Stream", true);
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "calling openFileOStream");
                return( false);
            }
            endTest( false, true);

            beginTest( "Writing from input stream to output stream");
            try
            {
                dbSystem.writeToOStream( decoderStream, fileOStream);
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "calling writeToOStream");
                return( false);
            }
            fileOStream.close();
            endTest( false, true);

            beginTest( "Comparing output stream data to original data");

            s = File.OpenRead( "Output_Stream");
            sr = new StreamReader( s);
            sFileData = sr.ReadLine();
            if (sFileData != TEST_STREAM_STRING)
            {
                endTest( false, false);
                System.Console.WriteLine( "Stream data does not match original string");
                System.Console.WriteLine( "File Data:\n[{0}]", sFileData);
                System.Console.WriteLine( "Original String:\n[{0}]", TEST_STREAM_STRING);
                return( false);
            }

            endTest( false, true);
            return( true);
        }
Ejemplo n.º 2
0
        public bool importTests(
            Db			db,
            DbSystem	dbSystem)
        {
            DOMNode	doc = null;
            IStream	istream = null;

            // Create a document

            beginTest( "Import documents test");

            // Document #1

            try
            {
                istream = dbSystem.openBufferIStream( sDoc1);
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "calling openBufferIStream - doc 1");
                return( false);
            }

            try
            {
                doc = db.importDocument( istream, (uint)PredefinedXFlaimCollections.XFLM_DATA_COLLECTION,
                                    doc, null);
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "calling importDocument - doc 1");
                return( false);
            }

            // Document #2

            try
            {
                istream = dbSystem.openBufferIStream( sDoc2);
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "calling openBufferIStream - doc 2");
                return( false);
            }

            try
            {
                doc = db.importDocument( istream, (uint)PredefinedXFlaimCollections.XFLM_DATA_COLLECTION,
                    doc, null);
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "calling importDocument - doc 2");
                return( false);
            }

            // Index definition

            try
            {
                istream = dbSystem.openBufferIStream( sIndexDef);
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "calling openBufferIStream - index def");
                return( false);
            }

            try
            {
                doc = db.importDocument( istream, (uint)PredefinedXFlaimCollections.XFLM_DICT_COLLECTION,
                    doc, null);
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "calling importDocument - index def");
                return( false);
            }
            endTest( false, true);

            return( true);
        }