예제 #1
0
        /// <summary> Runs the test.
        /// </summary>
        public virtual void runTest()
        {
            sawCacheDump = false;

            try {
            VelocityContext vc = new VelocityContext();
            System.Object foo = null;

            /*
            *  first, we need a classloader to make our foo object
            */

            TestClassloader cl = new TestClassloader();
            //UPGRADE_ISSUE: Method 'java.lang.ClassLoader.loadClass' was not converted. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1000_javalangClassLoader"'
            System.Type fooclass = cl.loadClass("Foo");
            System.Type temp_Class;
            temp_Class = fooclass;
            foo = temp_Class;

            /*
            *  put it into the context
            */
            vc.put("foo", foo);

            /*
            *  and render something that would use it
            *  that will get it into the introspector cache
            */
            System.IO.StringWriter writer = new System.IO.StringWriter();
            ve.evaluate(vc, writer, "test", "$foo.doIt()");

            /*
            *  Check to make sure ok.  note the obvious
            *  dependency on the Foo class...
            */

            if (!writer.ToString().Equals(OUTPUT)) {
            fail("Output from doIt() incorrect");
            }

            /*
            * and do it again :)
            */
            cl = new TestClassloader();
            //UPGRADE_ISSUE: Method 'java.lang.ClassLoader.loadClass' was not converted. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1000_javalangClassLoader"'
            fooclass = cl.loadClass("Foo");
            System.Type temp_Class2;
            temp_Class2 = fooclass;
            foo = temp_Class2;

            vc.put("foo", foo);

            writer = new System.IO.StringWriter();
            ve.evaluate(vc, writer, "test", "$foo.doIt()");

            if (!writer.ToString().Equals(OUTPUT)) {
            fail("Output from doIt() incorrect");
            }
            } catch (System.Exception ee) {
            System.Console.Out.WriteLine("ClassloaderChangeTest : " + ee);
            }

            if (!sawCacheDump) {
            fail("Didn't see introspector cache dump.");
            }
        }
예제 #2
0
        /// <summary> Runs the test.
        /// </summary>
        public virtual void  runTest()
        {
            sawCacheDump = false;

            try {
                VelocityContext vc  = new VelocityContext();
                System.Object   foo = null;

                /*
                 *  first, we need a classloader to make our foo object
                 */

                TestClassloader cl = new TestClassloader();
                //UPGRADE_ISSUE: Method 'java.lang.ClassLoader.loadClass' was not converted. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1000_javalangClassLoader"'
                System.Type fooclass = cl.loadClass("Foo");
                System.Type temp_Class;
                temp_Class = fooclass;
                foo        = temp_Class;

                /*
                 *  put it into the context
                 */
                vc.put("foo", foo);

                /*
                 *  and render something that would use it
                 *  that will get it into the introspector cache
                 */
                System.IO.StringWriter writer = new System.IO.StringWriter();
                ve.evaluate(vc, writer, "test", "$foo.doIt()");

                /*
                 *  Check to make sure ok.  note the obvious
                 *  dependency on the Foo class...
                 */

                if (!writer.ToString().Equals(OUTPUT))
                {
                    fail("Output from doIt() incorrect");
                }

                /*
                 * and do it again :)
                 */
                cl = new TestClassloader();
                //UPGRADE_ISSUE: Method 'java.lang.ClassLoader.loadClass' was not converted. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1000_javalangClassLoader"'
                fooclass = cl.loadClass("Foo");
                System.Type temp_Class2;
                temp_Class2 = fooclass;
                foo         = temp_Class2;

                vc.put("foo", foo);

                writer = new System.IO.StringWriter();
                ve.evaluate(vc, writer, "test", "$foo.doIt()");

                if (!writer.ToString().Equals(OUTPUT))
                {
                    fail("Output from doIt() incorrect");
                }
            } catch (System.Exception ee) {
                System.Console.Out.WriteLine("ClassloaderChangeTest : " + ee);
            }

            if (!sawCacheDump)
            {
                fail("Didn't see introspector cache dump.");
            }
        }