Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Henri Tremblay
    @henri-tremblay
    amanuelyohannes
    @amanuelyohannes
    okay nice idea
    Thank you.
    will it be okay if i share you my code snippet ?
    Henri Tremblay
    @henri-tremblay
    If you have access to plural sight, this course is good: https://app.pluralsight.com/library/courses/java-testing-introduction/table-of-contents
    amanuelyohannes
    @amanuelyohannes
    i dont have access right now but i will check it,
    Yes, you can share some code
    amanuelyohannes
    @amanuelyohannes
    okay tnx
    @Override
    protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
    if (!StringUtils.isBlank(request.getParameter("link"))) {
    //save the new post
    final LinkPost linkPost = new LinkPost();
    linkPost.setLink(request.getParameter("link"));
    linkPost.setTitle(request.getParameter("title"));
    postService.saveOrUpdate(linkPost);
    return new ModelAndView("redirect:/homepage.blr");
    }
    return super.handleRequestInternal(request, response);
    }
    i have a home page which aallows user to post text, link and qoute. This method in my controller class handles requests related to "link". it sets the titles and link save and desplays it in my home page
    Henri Tremblay
    @henri-tremblay
    Looking at this, you only need to mock postService
    So you will have something like:
    ```
    PostService server = createMock(PostService.class);
    postService.saveOrUpdate(linkPost);
    replay(postService);
    call to you controller
    verify(postService);
    amanuelyohannes
    @amanuelyohannes
    okay thanks
    but how can i make test my controller properly handle the request and respond?
    and another thing shouldn't i test my ModelAndView?
    Henri Tremblay
    @henri-tremblay
    You should look at SpringMVC test suite
    amanuelyohannes
    @amanuelyohannes
    Thank you so much.
    Henri Tremblay
    @henri-tremblay
    no problem. Have fun
    gaurav20-07
    @gaurav20-07
    Hi.
    I am trying to use EasyMock with IntelliJ. How to go about it?
    Henri Tremblay
    @henri-tremblay
    What do you need? It's like any java library. You add it to the classpath.
    There is nothing specific to IntelliJ
    holubec-petr
    @holubec-petr
    Hi, are you considering support for Kotlin? Now, in my opinion base on our project, it's usable but with some tricky problems. One of the biggest problem is "inconsistent stack height" when mocking class with Kotlin specific constructs (like lambdas or default parameter values). Thanks for your answer.
    Henri Tremblay
    @henri-tremblay
    @holubec-petr Sorry... I really missed your question. I am all in favour of supporting Kotlin. However, I don't know what the current problems are. Can you elaborate on the "inconsistent stack height"? What is it?
    Henri Tremblay
    @henri-tremblay
    @/all EasyMock 3.5 was just delivered tonight. A lot of cool improvements and bug fixes https://github.com/easymock/easymock/releases/tag/easymock-3.5
    mallorygiles
    @mallorygiles
    Will there be support for using default methods of interfaces. Right now if I try to create a partial mock and then call a method on that mock that calls a default interface method, it calls that method (doesn't automatically mock it like other abstract methods). If I try to add as a mock by using addMockedMethod, I get java.lang.IllegalArgumentException: Method not found (or private)
    Henri Tremblay
    @henri-tremblay
    @mallorygiles Highly interesting. They won't be mocked by default since they are not abstract
    But we should be able to mock them
    Which flavor of addMockedMethod are you using?
    Henri Tremblay
    @henri-tremblay
    So B b = partialMockBuilder(B.class) .addMockedMethod(A.class.getMethod("value")) .createMock(); this will work
    But you are right, default methods are not searched for. That's a required enhancement
    Can you file an issue?
    mallorygiles
    @mallorygiles
    Thanks for the workaround. I'll file the issue.
    Henri Tremblay
    @henri-tremblay
    @mallorygiles I haven't seen any issue yet :-)
    mallorygiles
    @mallorygiles
    Sorry, I got side tracked. Submitted the easymock/easymock#203.
    Michael Lück
    @thuri
    Hi, a while ago we updated easymock 3.5. We have custom implementations inheriting from the Capture class. Because the default constructor is deprecated now, I get warnings in eclipse and need to now how I have to change the code in order to remove the warnings. How can I call Easymock.newCapture for a custom capture class?
    Henri Tremblay
    @henri-tremblay
    You can't. But this is interesting. I wasn't expecting someone to inherit this class. What are you doing on top of the original Capture?
    Gary Gregory
    @garydgregory
    Hi. When can we expect 4.1? I'd like to test Apache Commons builds on Java 13-EA and those fail ATM. For example https://travis-ci.org/apache/commons-configuration/jobs/535552012
    Henri Tremblay
    @henri-tremblay
    @garydgregory Really really late answer... I missed your notification. I would have release sooner otherwise.
    I need to before the end of the year. Anyone who wants to help is welcome.