Package org.jruby.runtime.profile

Source Code of org.jruby.runtime.profile.ProfilingTest

package org.jruby.runtime.profile;

import junit.framework.TestCase;
import org.jruby.Ruby;
import org.jruby.RubyInstanceConfig;
import org.jruby.exceptions.RaiseException;
import org.jruby.runtime.load.LoadService;
import org.jruby.util.JRubyThreadContextTest;

/**
* @author Andre Kullmann
*/
public class ProfilingTest extends TestCase {

    public ProfilingTest(final String testName) {
        super(testName);
    }


    /**
     * Tests the {@link org.jruby.runtime.profile.ProfilingServiceLookup} too
     */
    public void testNoProfilingServerAvailableIfProfilingIsDisabled() {
        RubyInstanceConfig config = Ruby.getGlobalRuntime().getInstanceConfig();

        RubyInstanceConfig configOne = new RubyInstanceConfig(config);
        configOne.setProfilingMode(RubyInstanceConfig.ProfilingMode.OFF );

        Ruby ruby = Ruby.newInstance( configOne );

        assertNull(ruby.getProfilingService());
    }
    /**
     * Tests the {@link org.jruby.runtime.profile.ProfilingServiceLookup} too
     */
    public void testProfilingServiceLookupWorks() {
        try {
            RubyInstanceConfig config = Ruby.getGlobalRuntime().getInstanceConfig();

            RubyInstanceConfig configOne = new RubyInstanceConfig(config);

            configOne.setProfilingService( TestProfilingService.class.getName() );
            configOne.setProfilingMode(RubyInstanceConfig.ProfilingMode.SERVICE);
            Ruby ruby = Ruby.newInstance( configOne );

            assertNotNull( ruby.getProfiledMethods() );
            assertNotNull( ruby.getProfilingService() );
            assertTrue(ruby.getProfilingService() instanceof TestProfilingService);
        } catch( RaiseException e ) {
            //e.printStackTrace();
            // TODO hwo to mock org.jruby.exceptions.RaiseException: (LoadError) no such file to load -- jruby/profiler/shutdown_hook
        }
    }
}
TOP

Related Classes of org.jruby.runtime.profile.ProfilingTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.