Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session
SOLVED

java.lang.IllegalArgumentException: Illegal page name. Error while updating mockito to 4.11.0

Avatar

Level 2

Hi Everyone,

 

I have updated the mockito version from 3.3.3 to 4.11.0 and my existing test cases started to break. I am getting below error:

ERROR!
java.lang.IllegalArgumentException: Illegal page name.
at createPage(ModelTest.java:74)

I am creating page from aemContext as aemContext.create().page("/content/test/us/en/home");

I tried to update the io.wcm.testing.aem-mock.junit5 version to 5.0.0, still getting the same error.

 

Regards

Kanika

1 Accepted Solution

Avatar

Correct answer by
Level 7

Well, I would raise a question in maling list of https://wcm.io/ project. In my humble opinion it is an issue of incompatiblity between mockito 3.x and newer 

View solution in original post

9 Replies

Avatar

Level 7

Can provide full stacktrace ? Have you used an IDE to check for possible compile errors? 

Avatar

Level 2

In eclipse I am not seeing any errors. But when I am doing maven build it is failing  and below errors are coming:

[ERROR] SearchModelTest.setUp:38->createPage:46 » IllegalArgument Illegal page name.
[ERROR] SearchModelTest.setUp:38->createPage:46 » IllegalArgument Illegal page name.
[ERROR] SearchModelTest.setUp:38->createPage:46 » IllegalArgument Illegal page name.
[ERROR] SearchModelTest.setUp:38->createPage:46 » IllegalArgument Illegal page name.

Avatar

Level 7

That is not a stacktrace. To solve the issue think simple:

  1.  What is "java.lang.IllegalArgumentException" ?
    I found a good explanation at https://www.tutorialspoint.com/how-to-solve-an-illegalargumentexception-in-java
  2. You wrote: You upgraded your mockito version from 3.x - wich worked fine- to a newer version.
    So, in case the content didn't change the source of your trouble must be in the newer version. 

Conclusion:

In lifecycle of software development is does happen often, there are fundamental changes in newer versions of framework. So you have to dig in into the stacktrace and look in wich of your class and method the exception raise. Use the debug fearture from your IDE and the documentation from mockito framework to solve it.

Avatar

Level 2

I already debug it and in IDE there are no errors and test cases are pass. Also when I try to run single test case through maven it is pass. Also I checked the mockito documentation nothing is mentioned related to aemContext. As I already mentioned that error is coming while creatin page from aemContext:

aemContext.create().page("/content/test/us/en/home");

java.lang.IllegalArgumentException: Illegal page name.
at io.wcm.testing.mock.aem.MockPageManager.create(MockPageManager.java:100)
at io.wcm.testing.mock.aem.builder.ContentBuilder.page(ContentBuilder.java:148)
at io.wcm.testing.mock.aem.builder.ContentBuilder.page(ContentBuilder.java:102)

 

I upgraded the version of io.wcm as well but no luck.

Avatar

Correct answer by
Level 7

Well, I would raise a question in maling list of https://wcm.io/ project. In my humble opinion it is an issue of incompatiblity between mockito 3.x and newer 

Avatar

Community Advisor

Hi @kanikaa32870678 

 

Can you please debug and check if the aemContext is coming or not? Also please check the exact log on what it is saying.

 

Hope this helps!


Thanks,
Kiran Vedantam.

Avatar

Level 2

Yes aemContext is coming and only those test cases are failing where I have used aemContext.create().page("/content/test/us/en/home") and it was working fine with mockito 3.3.3 version.

Getting page from pageManager is working fine like aemContext.pageManager().getPage(pagePath) is working. 

Avatar

Community Advisor

@kanikaa32870678 Probably the path might be invalid. Also, check the arguments that need to be passed to the function. 

Page page = context.pageManager().create("/content/test/...", ...);

Avatar

Level 2

Path is correct, it was working fine with mockito 3.3.3 and I am creating page directly from aemcontext as aemContext.create().page("/content/test/us/en/home") .