IRC Archive for channel #xwiki on 15 May 2013
Last modified by Vincent Massol on 2013/05/15 23:45
<jvelo1> has quit
00:42 <abusenius_> has quit
01:58 <jvelo> has joined #xwiki
03:45 <jvelo> has quit
04:30 <Denis1> has joined #xwiki
05:51 <Denis1> has quit
07:00 <SvenDowideit_> has quit
07:00 <Lamium1> has quit
07:00 <kstuart> has quit
07:00 <sburjan`> has quit
07:00 <tekzilla> has quit
07:00 <sdumitriu> has quit
07:00 <tillo> has quit
07:00 <ekarlso-> has quit
07:00 <bouquetf1> has quit
07:00 <lynxt> has quit
07:00 <npm_> has quit
07:03 <npm_> has joined #xwiki
07:03 <kstuart> has joined #xwiki
07:03 <sdumitriu> has joined #xwiki
07:03 <SvenDowideit_> has joined #xwiki
07:03 <sburjan`> has joined #xwiki
07:03 <tillo> has joined #xwiki
07:03 <kstuart> has quit
07:03 <kstuart> has joined #xwiki
07:31 <dirk_schmitt> has joined #xwiki
08:08 <mflorea> has joined #xwiki
08:14 <kstuart> has quit
08:14 <kstuart> has joined #xwiki
08:15 <mflorea1> has joined #xwiki
08:16 <msmeria> has joined #xwiki
08:16 <qwebirc27617> has joined #xwiki
08:16 <mflorea> has quit
08:20 <vmassol> has joined #xwiki
08:20 <mflorea1> has quit
08:21 <vmassol> has quit
08:35 <qwebirc27617> has quit
08:36 <Denis> has joined #xwiki
08:37 <qwebirc27617> has joined #xwiki
08:44 <qwebirc27617> Hello, I'd like to ask a question. How is it with support AD and bug when was create duplicate username for one ldap identity? I cannot find solution. Could you please get me link to solution?
08:45 <mflorea> has joined #xwiki
08:45 <sdumitriu> has quit
08:46 <sdumitriu> has joined #xwiki
09:10 <tmortagne> has joined #xwiki
09:26 <dirk_schmitt> has quit
09:38 <vmassol> has joined #xwiki
09:52 <sburjan> has joined #xwiki
10:43 <tdelafosse> has joined #xwiki
10:52 <gdelhumeau> has joined #xwiki
11:05 <Slashman> has joined #xwiki
11:26 <vmassol> has quit
11:27 <vmassol> has joined #xwiki
11:45 <vmassol> has quit
12:07 <qwebirc27617> has quit
12:07 <qwebirc27617> has joined #xwiki
12:15 <npm__> has joined #xwiki
12:15 <npm_> has quit
12:15 <vmassol> has joined #xwiki
12:30 <vmassol> has quit
13:09 <vmassol> has joined #xwiki
13:10 <mflorea> has quit
13:23 <vmassol> has quit
13:28 <Denis> has quit
13:36 <evalica> has joined #xwiki
13:41 <bouquetf1> is now known as <bouquetf>
13:56 <Denis> has joined #xwiki
14:03 <vmassol> has joined #xwiki
14:07 <mflorea> has joined #xwiki
14:13 <GuillaumeF> has joined #xwiki
14:26 <vmassol> creating repo on conttrib for alex
14:51 <jvelo> has joined #xwiki
14:51 <jvelo> hi friends
14:52 <jvelo> I have a question regarding component testing. I'm trying to figure out how to have the CM not being mocked in a mockito component test
14:53 <jvelo> I've tried to add CM.class to ComponentList, but it does not work
14:53 <jvelo> (ping vmassol )
14:53 <vmassol> hi jvelo
14:53 <vmassol> you're using MockitoComponentMockingRule ?
14:53 <jvelo> hi
14:54 <jvelo> yes
14:54 <vmassol> add it as an exclusion
14:54 <vmassol> in the MockitoComponentMockingRule you have a signature for listing exclusions
14:55 <jvelo> that's different from ComponentList ?
14:55 <vmassol> you should check the javadoc for MockitoComponentMockingRule
14:55 <vmassol> ComponentList will be used to decide what components are registered against the CM
14:55 <jvelo> ok I see
14:55 <SvenDowideit_> has quit
14:55 <SvenDowideit_> has joined #xwiki
14:56 <SvenDowideit_> is now known as <SvenDowideit>
14:56 <vmassol> now if your code has an @Inject on any component
14:56 <vmassol> that component will still be mocked
14:56 <vmassol> unless you exclude it in the MockitoComponentMockingRule constructor
14:56 <jvelo> ok
14:56 <jvelo> it can only take implementations, right ?
14:57 <jvelo> not roles
14:57 <vmassol> yes impls
14:58 <jvelo> that's strange no ?
14:58 <vmassol> so
14:58 <vmassol> you'll need to exclude it but you'll also need to make it available through @ComponentList ;)
14:58 <vmassol> as otherwise no impl will be found for it
14:59 <jvelo> because you get injected roles, and you have to exclude impl
14:59 <tmortagne> the MockitoComponentMockingRule constructor takes roles, not implementation AFAIK
14:59 <tmortagne> that's @ComponentList which takes implementations
14:59 <vmassol> checking sources
14:59 <vmassol> because in the source the variable is named excludedComponentImplementationDependencies
14:59 <jvelo> tmortagne: does not seem so
14:59 <jvelo> from the javadoc
14:59 <tmortagne> I saw examples with roles when I had the same issue
15:00 <vmassol> but indeed I see:
15:00 <vmassol> if (!this.excludedComponentImplementationDependencies.contains(roleTypeClass)
15:00 <vmassol> which means I need to fix the variable name
15:00 <tmortagne> @Rule
15:00 <tmortagne> new MockitoComponentMockingRule<DefaultLoggerManager>(DefaultLoggerManager.class,
15:00 <tmortagne> Arrays.asList(ObservationManager.class));
15:00 <tmortagne> for example
15:00 <jvelo> hmm it actually works with roles
15:01 <jvelo> so some naming is wrong I guess
15:01 <tmortagne> vmassol: would we improve it a bit to make @ComponentList enough ? I don't really see the point in having both actually
15:01 <vmassol> yep i'll fix it
15:01 <vmassol> you could manually mock it
15:01 <tmortagne> s/would/should/
15:01 <vmassol> but yes not a lot of use cases probably
15:02 <jvelo> thanks for the info, works great with CM.class in ComponentList + in excl.
15:02 <tmortagne> even so you just need to mock it before lookupping the component
15:02 <vmassol> would need to think more about it tmortagne to see which one should imply the other
15:02 <tmortagne> also CM is a bit of a special case IMO since it supposed to put itself in there so we should not need to exclude it for it not not me mocked
15:03 <tmortagne> s/not not me mocked/to not be mocked/
15:03 <jvelo> yes CM could be not mocked by default
15:05 <jvelo> it's a great testing environment BTW guys
15:05 <jvelo> much easier to work with than the previous one
15:05 <tmortagne> yep these minor issue put aside testing with this is great
15:14 <vmassol> jvelo: I've updated the doc at http://dev.xwiki.org/xwiki/bin/view/Community/Testing#HJavaUnitTesting
15:42 <jvelo> vmassol: thanks
16:14 <alexch> has joined #xwiki
16:20 <msmeria> has quit
16:36 <alexch> has quit
16:36 <sburjan> has quit
16:43 <mflorea> has quit
16:52 <Denis> has quit
17:10 <vmassol> tmortagne: I've commented on XCOMMONS-399
17:11 <vmassol> I'm surprised that your change works
17:11 <vmassol> because I know several tests that tell the CM to return mocks
17:11 <tmortagne> vmassol: I don't really see what your comment has to do with my change
17:12 <vmassol> I don't know if it has to do about your change but it has to do about the issue description :)
17:12 <tmortagne> XCOMMONS-399 is about injecting the CM itself instead of creating a mocked ComponentManager
17:12 <vmassol> yep and I don't like it
17:12 <vmassol> it's used at several places
17:13 <tmortagne> a mocked ComponentManager ?
17:13 <vmassol> yes
17:13 <tmortagne> in your comment you are talking about mocked components
17:13 <tmortagne> non mocked ComponentManager
17:13 <tmortagne> s/non/not/
17:13 <vmassol> the mocked CM will return mock instances of other components
17:13 <vmassol> it should not use the real instances
17:13 <vmassol> (since they're not there)
17:14 <vmassol> basically there are 2 choices:
17:14 <vmassol> - option 1: force the registration of mocked components so that the real CM can return mocked instances
17:14 <vmassol> (this is what you've done basically)
17:14 <vmassol> - option 2 (what was there before): control what the CM returns by mocking it
17:15 <vmassol> what I'm saying is that option 1 is a change from what we've been doing and it needs to modify some unit tests
17:15 <vmassol> (existing unit tests)
17:16 <tmortagne> ok you did not understood what I did here
17:16 <tmortagne> let me rephrase the title
17:16 <tmortagne> look at the description
17:16 <tmortagne> here
17:17 <tmortagne> I did what we talked about with jvelo
17:17 <vmassol> we mentioned 2 things with jvelo
17:17 <tmortagne> yes
17:17 <tmortagne> I did the second one
17:17 <vmassol> one had to do with @ComponentList and exclusions
17:18 <vmassol> and the other was about not mocking @Inject CM
17:18 <tmortagne> (03:02:46 PM) tmortagne: also CM is a bit of a special case IMO since it supposed to put itself in there so we should not need to exclude it for it not not me mocked
17:18 <tmortagne> (03:03:12 PM) tmortagne: s/not not me mocked/to not be mocked/
17:18 <tmortagne> (03:03:27 PM) jvelo: yes CM could be not mocked by default
17:19 <vmassol> for example here's what I see in one unit test:
17:19 <tmortagne> and thats what I did, CM is properly injecting itself as it supposed to
17:19 <vmassol> ComponentManager componentManager = mocker.getInstance(ComponentManager.class);
17:19 <vmassol> when(componentManager.getInstance(BlockRenderer.class, "xhtml/1.0")).thenReturn(xhtmlRenderer);
17:19 <vmassol> this will still work with your change?
17:19 <tmortagne> why not ?
17:19 <tmortagne> in this test componentManager == mocker
17:20 <tmortagne> actualy no
17:20 <tmortagne> I did not worked on that
17:20 <tmortagne> I worked on injection
17:20 <tmortagne> this is lookup
17:20 <tmortagne> nothing to do here
17:21 <tmortagne> again the point is to exclude ComponentManager from dependencies to mock
17:22 <vmassol> yes I get this, you'll get the real CM instead of a mock one
17:22 <vmassol> so if you use @ComponentList, you'll get to see the components added from there
17:22 <vmassol> from that injected CM
17:23 <tmortagne> yes since it's going to be the same CM
17:24 <vmassol> so in:
17:24 <vmassol> ComponentManager componentManager = mocker.getInstance(ComponentManager.class);
17:24 <vmassol> when(componentManager.getInstance(BlockRenderer.class, "xhtml/1.0")).thenReturn(xhtmlRenderer);
17:24 <vmassol> componentManager == mocker
17:25 <tmortagne> I don't know, what I did does not have anything to do with that
17:25 <tmortagne> this is not injection
17:25 <vmassol> it's the same
17:25 <tmortagne> of course not
17:25 <vmassol> I don't see how it'll continue to work
17:25 <tmortagne> what I did is preventing to create a mock when taking care of the tested component
17:25 <vmassol> yep exactly
17:25 <tmortagne> it's not the same
17:25 <vmassol> so you no longer get a mock CM
17:26 <vmassol> but the real one
17:26 <vmassol> thus the when() should fail
17:26 <tmortagne> in the component
17:26 <vmassol> (since it can work only on a mock)
17:26 <tmortagne> in the mocked component
17:26 <tmortagne> not in the test
17:26 <tmortagne> again it not not have anything to do with getInstance
17:26 <vmassol> getinstance will jsut return what's registered in the CM
17:27 <vmassol> and before a mock CM was registered in the CM (mocker)
17:27 <tmortagne> if you registered one probably
17:27 <tmortagne> I don't know you test
17:28 <GuillaumeF> has quit
17:28 <vmassol> woudl be nice to explain why you need this in the jira issue
17:29 <vmassol> it's a good idea to not talk about the implementation but about the need in a jira desciption btw
17:29 <tmortagne> vmassol: I already explain that I want to component to get its CM instead of some empty mock
17:29 <vmassol> and?
17:29 <vmassol> why?
17:29 <vmassol> you already have access to the real CM
17:30 <vmassol> that's mocker
17:30 <vmassol> (if you need it)
17:30 <tmortagne> it's not for the test, it's for the component
17:30 <vmassol> now if you want to control what the code executes you need a mock
17:30 <tmortagne> the component will expect to et it's CM
17:30 <vmassol> yes but that's bad
17:30 <tmortagne> no it's not bad
17:30 <vmassol> because you don't control anyomre what gets executed
17:30 <tmortagne> you pout component in ComponentList so that the component can use them
17:31 <tmortagne> and the component will just crash because it been injected with en empty CM
17:31 <tmortagne> that is what is bad
17:31 <vmassol> ok now I undertsand the use case, this should be the descirption of the issue :)
17:31 <vmassol> (and the title)
17:32 <vmassol> but I still think
17:32 <vmassol> that your change broke several tests IMO
17:32 <vmassol> that need to be rewritten
17:32 <vmassol> could you try running DefaultOfficeViewerScriptServiceTest
17:32 <vmassol> (fails for me in my IDE)
17:33 <tmortagne> vmassol: jenkins does not have any failing test so no there does not seems to be any test
17:34 <vmassol> the thing is i t breaks exactly where I tihnk it shoudl break
17:35 <vmassol> again
17:35 <vmassol> here are the lines:
17:35 <vmassol> BlockRenderer xhtmlRenderer = mock(BlockRenderer.class);
17:35 <vmassol> when(componentManager.getInstance(BlockRenderer.class, "xhtml/1.0")).thenReturn(xhtmlRenderer);
17:35 <vmassol> I still don't see how this can work...
17:36 <tmortagne> and I don't see how this is related to my change only with these lines, let me look at the complete test
17:36 <vmassol> for this to work, mocker.getInstance needs to return a mock
17:38 <tmortagne> ook so what you forgot to say is that MockitoComponentMockingRule take a component that has an injected CM
17:38 <tmortagne> this is the main part
17:38 <tmortagne> if it did not had injected CM it would not change anything to the lines you listed
17:39 <vmassol> ofc but we're talking only about that :)
17:39 <vmassol> @Inject CM
17:39 <vmassol> that's the purpose of your change
17:40 <vmassol> so with your change the way to rewrite this test now is to register a mock component against the real CM
17:40 <vmassol> (whereas before you did not need to register anything, you simply told mockito what to return)
17:40 <vmassol> again I'm not against it but it's change on how we write unit tests
17:40 <vmassol> and the tests needs to be modified
17:41 <tmortagne> looks like there is an issue with Jenkins then
17:42 <tmortagne> according to jenkins commons hasn't been built in 2 days it seems
17:43 <vmassol> you also need to modify the documentation
17:44 <vmassol> (to explain that CM is not mocked)
17:48 <GuillaumeF> has joined #xwiki
17:48 <tmortagne> jenkins does not seems to react to github anymore, platform has the same issue
17:49 <tmortagne> looks like the issue started 7h ago
17:49 <tmortagne> forcing commons, to rebuild everything
17:54 <vmassol> tmortagne: I think there's a bug in XWiki#getRequestWikiName
17:54 <vmassol> if you have: http://localhost/xwiki/wiki/someWiki/view/Main/WebHome
17:54 <vmassol> shouldn't the wiki be "somewiki"?
17:55 <vmassol> it's going to be "someWiki" right now (if there's no wiki descriptor)
17:55 <vmassol> // Use the name from the subdomain
17:55 <vmassol> wikiName = servername;
17:55 <vmassol> should be
17:55 <vmassol> wikiName = servername.lowercase();
17:56 <vmassol> (toLowerCase())
17:56 <vmassol> right?
17:57 <tmortagne> checking something
18:00 <tmortagne> in theory wiki id should always be lower case in practice
18:00 <tmortagne> through the UI
18:01 <tmortagne> in practice we have very few places forcing lower cases
18:02 <vmassol> ok I'll ensure it's lowercased in the url module
18:02 <tmortagne> from what I can see in the code it's possible to create a wiki database with upper case, depending if the database supports it
18:03 <vmassol> my point is that some places force lowercase and some don't so we need consistency
18:03 <tmortagne> well right now only the UI force lower case
18:03 <vmassol> not just the ui
18:04 <vmassol> for example
18:04 <vmassol> // Use the name from the located wiki descriptor
18:04 <vmassol> wikiName = StringUtils.removeStart(wikiDefinition.getName(), "XWikiServer").toLowerCase();
18:04 <tmortagne> I mean when dealing with the real database
18:05 <tmortagne> XWiki#setDatabase or hibernatestore never touch the database name
18:05 <tmortagne> not on lower/upper case at least
18:05 <tmortagne> should probably be fixed too
18:06 <tmortagne> at least in XWikiContext#setDatabase
18:09 <qwebirc27617> has quit
18:12 <Slashman> has quit
18:29 <Slashman> has joined #xwiki
18:51 <vmassol> has quit
18:52 <tmortagne> has quit
18:55 <evalica> has quit
18:56 <evalica> has joined #xwiki
19:08 <evalica> has quit
19:11 <ram_> has joined #xwiki
19:12 <ram_> hi
19:12 <Denis> has joined #xwiki
19:13 <ram_> somebody's there?
19:13 <ram_> jlllklkkkl
19:19 <ram_> has left #xwiki
19:24 <tdelafosse> has quit
19:27 <gdelhumeau> has quit
19:28 <abusenius_> has joined #xwiki
19:45 <GuillaumeF> has quit
20:06 <sdumitriu1> has joined #xwiki
20:34 <sdumitriu1> has quit
20:38 <sdumitriu1> has joined #xwiki
20:48 <Denis> has quit
21:00 <vmassol> has joined #xwiki
23:29 <vmassol> has quit
23:45 <sdumitriu1> has quit