You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jspwiki.apache.org by "Andrew Jaquith (JIRA)" <ji...@apache.org> on 2008/01/28 06:45:34 UTC
[jira] Created: (JSPWIKI-167) Confusing PageRenamerTest interaction
with WikiContext
Confusing PageRenamerTest interaction with WikiContext
------------------------------------------------------
Key: JSPWIKI-167
URL: https://issues.apache.org/jira/browse/JSPWIKI-167
Project: JSPWiki
Issue Type: Bug
Components: Core & storage
Affects Versions: 2.6.1
Environment: All
Reporter: Andrew Jaquith
Assignee: Janne Jalkanen
Priority: Minor
In testing some 3.0-related brach code, I noticed something very odd in the way PageRenamerTest, PageRenamer, and WikiContext interact.
The symptoms: PageRenamer.testReferrerNoWikiName() kept failing.
The test lines that are strange are these (lines 171-186):
m_engine.saveText("Test","foo");
m_engine.saveText("TestPage2", "[Test] [Test#anchor] test Test [test] [link|test] [link|test]");
WikiPage p = m_engine.getPage("TestPage");
WikiContext context = new WikiContext(m_engine, p);
m_engine.renamePage(context, "Test", "TestPage", true);
This seems straightforward enough -- when we save a page that has references in it, all of the pages that refer to it should update their references.
But there are some weird things going on. I can't figure out why 'p' is getting assigned page 'TestPage,'... it's a page that doesn't exist. Interestingly, when using a debugger to see what 'context' contains, its page property is set to page "Main". That's because 'TestPage' doesn't exist, and the default is to substitute the "Main" page. This is important! Hold on for why...
Now then, moving over to PageRenamer, we have a private method updateReferrerOnRename with the following signature:
private void updateReferrerOnRename(WikiContext context, String oldName, String newName, boolean changeReferrer, String referrerName)
The "context" parameter is the same context supplied to renamePage() above. Thus, the context that's passed, in this particular test case, will have the page "Main" associated with it.
Further down in updateReferrerOnRename() is this snippet:
if (context.getPage() != null)
{
(lots of magic happens where the references are updated and the page is re-saved...)
}
Now then, here's the thing that's bothering me. The 'context' variable doesn't have anything to do with either the page that's being renamed or to the pages that refer to the renamed page. Moreover, if the context's getPage() happens to return null, then renaming the page won't update references to it, even though the page will actually be renamed! This is bizarre.
This particular case is strange because of the line:
WikiPage p = m_engine.getPage("TestPage")
If we'd specified the original page ("Test"), then everything would've magically worked ok. And in the current JSPWiki scheme of things, even specifying a non-existent page ("TestPage") works ok, because the WikiContext will magically default to page "Main". But this, it seems to me, is more accidental than deliberate.
What if WikiContexts aren't guaranteed to return a WikiPage from getPage()? It is one of those hypothetical (3.0 branch) cases that caused my test case to fail.
Am I missing something here? I must be...
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (JSPWIKI-167) Confusing PageRenamerTest
interaction with WikiContext
Posted by "Janne Jalkanen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/JSPWIKI-167?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12563087#action_12563087 ]
Janne Jalkanen commented on JSPWIKI-167:
----------------------------------------
By the way... WikiContext.getPage() is guaranteed to always return a valid WikiPage. We have lots of code which assumes this, so not doing that is probably going to be pretty deadly all over the code.
> Confusing PageRenamerTest interaction with WikiContext
> ------------------------------------------------------
>
> Key: JSPWIKI-167
> URL: https://issues.apache.org/jira/browse/JSPWIKI-167
> Project: JSPWiki
> Issue Type: Bug
> Components: Core & storage
> Affects Versions: 2.6.1
> Environment: All
> Reporter: Andrew Jaquith
> Assignee: Janne Jalkanen
> Priority: Minor
> Original Estimate: 0.5h
> Remaining Estimate: 0.5h
>
> In testing some 3.0-related brach code, I noticed something very odd in the way PageRenamerTest, PageRenamer, and WikiContext interact.
> The symptoms: PageRenamer.testReferrerNoWikiName() kept failing.
> The test lines that are strange are these (lines 171-186):
> {code}
> m_engine.saveText("Test","foo");
> m_engine.saveText("TestPage2", "[Test] [Test#anchor] test Test [test] [link|test] [link|test]");
> WikiPage p = m_engine.getPage("TestPage");
> WikiContext context = new WikiContext(m_engine, p);
> m_engine.renamePage(context, "Test", "TestPage", true);
> {code}
> This seems straightforward enough -- when we save a page that has references in it, all of the pages that refer to it should update their references.
> But there are some weird things going on. I can't figure out why 'p' is getting assigned page 'TestPage,'... it's a page that doesn't exist. Interestingly, when using a debugger to see what 'context' contains, its page property is set to page "Main". That's because 'TestPage' doesn't exist, and the default is to substitute the "Main" page. This is important! Hold on for why...
> Now then, moving over to PageRenamer, we have a private method updateReferrerOnRename with the following signature:
> {code}
> private void updateReferrerOnRename(WikiContext context, String oldName, String newName, boolean changeReferrer, String referrerName)
> {code}
> The "context" parameter is the same context supplied to renamePage() above. Thus, the context that's passed, in this particular test case, will have the page "Main" associated with it.
> Further down in updateReferrerOnRename() is this snippet:
> {code}
> if (context.getPage() != null)
> {
> (lots of magic happens where the references are updated and the page is re-saved...)
> }
> {code}
> Now then, here's the thing that's bothering me. The 'context' variable doesn't have anything to do with either the page that's being renamed or to the pages that refer to the renamed page. Moreover, if the context's getPage() happens to return null, then renaming the page won't update references to it, even though the page will actually be renamed! This is bizarre.
> This particular case is strange because of the line:
> {code}
> WikiPage p = m_engine.getPage("TestPage")
> {code}
> If we'd specified the original page ("Test"), then everything would've magically worked ok. And in the current JSPWiki scheme of things, even specifying a non-existent page ("TestPage") works ok, because the WikiContext will magically default to page "Main". But this, it seems to me, is more accidental than deliberate.
> What if WikiContexts aren't guaranteed to return a WikiPage from getPage()? It is one of those hypothetical (3.0 branch) cases that caused my test case to fail.
> Am I missing something here? I must be...
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Resolved: (JSPWIKI-167) Confusing PageRenamerTest
interaction with WikiContext
Posted by "Andrew Jaquith (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/JSPWIKI-167?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Andrew Jaquith resolved JSPWIKI-167.
------------------------------------
Resolution: Fixed
Fix Version/s: 2.6.1
Solved by guaranteeing that new WikiContexts *always* set their internal WikiPage reference.
> Confusing PageRenamerTest interaction with WikiContext
> ------------------------------------------------------
>
> Key: JSPWIKI-167
> URL: https://issues.apache.org/jira/browse/JSPWIKI-167
> Project: JSPWiki
> Issue Type: Bug
> Components: Core & storage
> Affects Versions: 2.6.1
> Environment: All
> Reporter: Andrew Jaquith
> Assignee: Andrew Jaquith
> Priority: Minor
> Fix For: 2.6.1
>
> Original Estimate: 0.5h
> Remaining Estimate: 0.5h
>
> In testing some 3.0-related brach code, I noticed something very odd in the way PageRenamerTest, PageRenamer, and WikiContext interact.
> The symptoms: PageRenamer.testReferrerNoWikiName() kept failing.
> The test lines that are strange are these (lines 171-186):
> {code}
> m_engine.saveText("Test","foo");
> m_engine.saveText("TestPage2", "[Test] [Test#anchor] test Test [test] [link|test] [link|test]");
> WikiPage p = m_engine.getPage("TestPage");
> WikiContext context = new WikiContext(m_engine, p);
> m_engine.renamePage(context, "Test", "TestPage", true);
> {code}
> This seems straightforward enough -- when we save a page that has references in it, all of the pages that refer to it should update their references.
> But there are some weird things going on. I can't figure out why 'p' is getting assigned page 'TestPage,'... it's a page that doesn't exist. Interestingly, when using a debugger to see what 'context' contains, its page property is set to page "Main". That's because 'TestPage' doesn't exist, and the default is to substitute the "Main" page. This is important! Hold on for why...
> Now then, moving over to PageRenamer, we have a private method updateReferrerOnRename with the following signature:
> {code}
> private void updateReferrerOnRename(WikiContext context, String oldName, String newName, boolean changeReferrer, String referrerName)
> {code}
> The "context" parameter is the same context supplied to renamePage() above. Thus, the context that's passed, in this particular test case, will have the page "Main" associated with it.
> Further down in updateReferrerOnRename() is this snippet:
> {code}
> if (context.getPage() != null)
> {
> (lots of magic happens where the references are updated and the page is re-saved...)
> }
> {code}
> Now then, here's the thing that's bothering me. The 'context' variable doesn't have anything to do with either the page that's being renamed or to the pages that refer to the renamed page. Moreover, if the context's getPage() happens to return null, then renaming the page won't update references to it, even though the page will actually be renamed! This is bizarre.
> This particular case is strange because of the line:
> {code}
> WikiPage p = m_engine.getPage("TestPage")
> {code}
> If we'd specified the original page ("Test"), then everything would've magically worked ok. And in the current JSPWiki scheme of things, even specifying a non-existent page ("TestPage") works ok, because the WikiContext will magically default to page "Main". But this, it seems to me, is more accidental than deliberate.
> What if WikiContexts aren't guaranteed to return a WikiPage from getPage()? It is one of those hypothetical (3.0 branch) cases that caused my test case to fail.
> Am I missing something here? I must be...
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (JSPWIKI-167) Confusing PageRenamerTest
interaction with WikiContext
Posted by "Andrew Jaquith (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/JSPWIKI-167?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12563164#action_12563164 ]
Andrew Jaquith commented on JSPWIKI-167:
----------------------------------------
Having looked at the ReferenceManager code, it's fairly straightforward (although because it's chained as a filter, it's not very efficient).
Changing my WikiActionBeanFactory (3.0) code so that the WikiContext's page is always set solved the issue. But I'm still not happy about this dependency... it certainly isn't documented. I'll do a little more digging and see if I can figure out what's going on. Maybe annotate the docs and put in a FIXME somewhere.
As a total aside:
I am not sure that WikiContext NEEDS to always return a page, at least in the core code (I can't speak for the JSPs). What was remarkable about my tests (and I ran all of them) was how FEW of them choked due to not setting the wiki page when creating a WikiContext in WikiActionBeanFactory. I still have about 25 unrelated test failures to chase down elsewhere in my 3.0 branch before it tests clean. After that, I'm going to relax the "setPage on context creation" again and see what it breaks. :)
In the meantime, I'm going to close this bug.
> Confusing PageRenamerTest interaction with WikiContext
> ------------------------------------------------------
>
> Key: JSPWIKI-167
> URL: https://issues.apache.org/jira/browse/JSPWIKI-167
> Project: JSPWiki
> Issue Type: Bug
> Components: Core & storage
> Affects Versions: 2.6.1
> Environment: All
> Reporter: Andrew Jaquith
> Assignee: Janne Jalkanen
> Priority: Minor
> Original Estimate: 0.5h
> Remaining Estimate: 0.5h
>
> In testing some 3.0-related brach code, I noticed something very odd in the way PageRenamerTest, PageRenamer, and WikiContext interact.
> The symptoms: PageRenamer.testReferrerNoWikiName() kept failing.
> The test lines that are strange are these (lines 171-186):
> {code}
> m_engine.saveText("Test","foo");
> m_engine.saveText("TestPage2", "[Test] [Test#anchor] test Test [test] [link|test] [link|test]");
> WikiPage p = m_engine.getPage("TestPage");
> WikiContext context = new WikiContext(m_engine, p);
> m_engine.renamePage(context, "Test", "TestPage", true);
> {code}
> This seems straightforward enough -- when we save a page that has references in it, all of the pages that refer to it should update their references.
> But there are some weird things going on. I can't figure out why 'p' is getting assigned page 'TestPage,'... it's a page that doesn't exist. Interestingly, when using a debugger to see what 'context' contains, its page property is set to page "Main". That's because 'TestPage' doesn't exist, and the default is to substitute the "Main" page. This is important! Hold on for why...
> Now then, moving over to PageRenamer, we have a private method updateReferrerOnRename with the following signature:
> {code}
> private void updateReferrerOnRename(WikiContext context, String oldName, String newName, boolean changeReferrer, String referrerName)
> {code}
> The "context" parameter is the same context supplied to renamePage() above. Thus, the context that's passed, in this particular test case, will have the page "Main" associated with it.
> Further down in updateReferrerOnRename() is this snippet:
> {code}
> if (context.getPage() != null)
> {
> (lots of magic happens where the references are updated and the page is re-saved...)
> }
> {code}
> Now then, here's the thing that's bothering me. The 'context' variable doesn't have anything to do with either the page that's being renamed or to the pages that refer to the renamed page. Moreover, if the context's getPage() happens to return null, then renaming the page won't update references to it, even though the page will actually be renamed! This is bizarre.
> This particular case is strange because of the line:
> {code}
> WikiPage p = m_engine.getPage("TestPage")
> {code}
> If we'd specified the original page ("Test"), then everything would've magically worked ok. And in the current JSPWiki scheme of things, even specifying a non-existent page ("TestPage") works ok, because the WikiContext will magically default to page "Main". But this, it seems to me, is more accidental than deliberate.
> What if WikiContexts aren't guaranteed to return a WikiPage from getPage()? It is one of those hypothetical (3.0 branch) cases that caused my test case to fail.
> Am I missing something here? I must be...
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (JSPWIKI-167) Confusing PageRenamerTest
interaction with WikiContext
Posted by "Janne Jalkanen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/JSPWIKI-167?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12563088#action_12563088 ]
Janne Jalkanen commented on JSPWIKI-167:
----------------------------------------
Sorry, meant PageRenamer, not ReferenceManager...
> Confusing PageRenamerTest interaction with WikiContext
> ------------------------------------------------------
>
> Key: JSPWIKI-167
> URL: https://issues.apache.org/jira/browse/JSPWIKI-167
> Project: JSPWiki
> Issue Type: Bug
> Components: Core & storage
> Affects Versions: 2.6.1
> Environment: All
> Reporter: Andrew Jaquith
> Assignee: Janne Jalkanen
> Priority: Minor
> Original Estimate: 0.5h
> Remaining Estimate: 0.5h
>
> In testing some 3.0-related brach code, I noticed something very odd in the way PageRenamerTest, PageRenamer, and WikiContext interact.
> The symptoms: PageRenamer.testReferrerNoWikiName() kept failing.
> The test lines that are strange are these (lines 171-186):
> {code}
> m_engine.saveText("Test","foo");
> m_engine.saveText("TestPage2", "[Test] [Test#anchor] test Test [test] [link|test] [link|test]");
> WikiPage p = m_engine.getPage("TestPage");
> WikiContext context = new WikiContext(m_engine, p);
> m_engine.renamePage(context, "Test", "TestPage", true);
> {code}
> This seems straightforward enough -- when we save a page that has references in it, all of the pages that refer to it should update their references.
> But there are some weird things going on. I can't figure out why 'p' is getting assigned page 'TestPage,'... it's a page that doesn't exist. Interestingly, when using a debugger to see what 'context' contains, its page property is set to page "Main". That's because 'TestPage' doesn't exist, and the default is to substitute the "Main" page. This is important! Hold on for why...
> Now then, moving over to PageRenamer, we have a private method updateReferrerOnRename with the following signature:
> {code}
> private void updateReferrerOnRename(WikiContext context, String oldName, String newName, boolean changeReferrer, String referrerName)
> {code}
> The "context" parameter is the same context supplied to renamePage() above. Thus, the context that's passed, in this particular test case, will have the page "Main" associated with it.
> Further down in updateReferrerOnRename() is this snippet:
> {code}
> if (context.getPage() != null)
> {
> (lots of magic happens where the references are updated and the page is re-saved...)
> }
> {code}
> Now then, here's the thing that's bothering me. The 'context' variable doesn't have anything to do with either the page that's being renamed or to the pages that refer to the renamed page. Moreover, if the context's getPage() happens to return null, then renaming the page won't update references to it, even though the page will actually be renamed! This is bizarre.
> This particular case is strange because of the line:
> {code}
> WikiPage p = m_engine.getPage("TestPage")
> {code}
> If we'd specified the original page ("Test"), then everything would've magically worked ok. And in the current JSPWiki scheme of things, even specifying a non-existent page ("TestPage") works ok, because the WikiContext will magically default to page "Main". But this, it seems to me, is more accidental than deliberate.
> What if WikiContexts aren't guaranteed to return a WikiPage from getPage()? It is one of those hypothetical (3.0 branch) cases that caused my test case to fail.
> Am I missing something here? I must be...
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.