Git Product home page Git Product logo

Comments (4)

ekuefler avatar ekuefler commented on May 5, 2024

Thanks for helping add support here! I've added the line to support Cobertura by default in 3b88efb.

I'd like to understand your Play issue so that GwtMockito can support it without people having to fork code. Are these the only two lines you added?

classPool.appendClassPath(new LoaderClassPath(Enhancer.class.getClassLoader()));
classPool.appendClassPath(new ApplicationClassesClasspath());

You can extend GwtMockitoTestRunner to override getAdditionalClassPaths , adding your own classpath entries. However, that only supports String right now, not ClassPath objects from Javassist. Are LoaderClassPath and ApplicationClassesClasspath actually ClassPath objects defined by the Play library? If so, it wouldn't be hard to add another overridable version of getAdditionalClassPaths letting you return ClassPath objects.

from gwtmockito.

mvmn avatar mvmn commented on May 5, 2024

Are these the only two lines you added?

Not quite, there are two more changes:

protected ClassLoader getParentClassloader() {
    // return ClassLoader.getSystemClassLoader();
    return Play.classloader;
}

And (see GwtMockitoTestRunner.class.getClassLoader() replaced with Play GwtMockitoTestRunner.class.getClassLoader() ):

    @Override
    public Class<?> loadClass(String name) throws ClassNotFoundException {
        // If the class is in a blacklisted package, load it with the default classloader.
        for (String blacklistedPackage : getPackagesToLoadViaStandardClassloader()) {
            if (name.startsWith(blacklistedPackage)) {
                //return GwtMockitoTestRunner.class.getClassLoader().loadClass(name);
                return PlayGwtMockitoTestRunner.class.getClassLoader().loadClass(name);
            }
        }

        // Otherwise load it with our custom classloader.
        return super.loadClass(name);
    }

Are LoaderClassPath and ApplicationClassesClasspath actually ClassPath objects defined by the Play library? If so, it wouldn't be hard to add another overridable version of getAdditionalClassPaths letting you return ClassPath objects.

Yes, I suppose that'd do the trick. Thanks!

from gwtmockito.

ekuefler avatar ekuefler commented on May 5, 2024

Cool, thanks, I'll take a look at adding these as additional customization options before the next release, sounds like your workaround should work for now.

from gwtmockito.

mvmn avatar mvmn commented on May 5, 2024

Yes, I'm fine with workaround for now. Just wanted to share it.
Thanks for your effort.

from gwtmockito.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.