Obtain MgnlContext from Jetty

View: New views
7 Messages — Rating Filter:   Alert me  

Obtain MgnlContext from Jetty

by Matteo Pelucco :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi all,
is there a way to do this:

1) launch jetty from a test (jUnit / testng) in embedded mode
2) deploy magnolia inside

--- till here up&running

3) obtain MgnlContext instance from jetty

???
Matteo


----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <user-list-unsubscribe@...>
----------------------------------------------------------------


Re: Obtain MgnlContext from Jetty

by Jan Haderka-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Did you look at Magnolia integration tests? You might get some
inspiration there.
HTH,
Jan


On Fri, 2009-10-23 at 16:59 +0200, Matteo Pelucco wrote:

> Hi all,
> is there a way to do this:
>
> 1) launch jetty from a test (jUnit / testng) in embedded mode
> 2) deploy magnolia inside
>
> --- till here up&running
>
> 3) obtain MgnlContext instance from jetty
>
> ???
> Matteo
>
>
> ----------------------------------------------------------------
> For list details see
> http://www.magnolia-cms.com/home/community/mailing-lists.html
> To unsubscribe, E-mail to: <user-list-unsubscribe@...>
> ----------------------------------------------------------------


----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <user-list-unsubscribe@...>
----------------------------------------------------------------


Redirects in Magnolia

by Jared Barboza :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I have a multi-level navigation menu setup on a customers' magnolia
site. It's driven by the model.navigation.horizontalNavigation property
in one of our freemarker templates. I currently have a page "blog" that
needs to redirect to http://blog.company.com instead it is pointing to
/index/company/blog.html.

Anyone know how/if I can setup a redirect within Magnolia to point
requests to /index/company/blog.html to http://blog.company.com? I've
tried setting up a VirtualURIMapping but that only seems to work
internally not externally.


Jared Barboza
Software Developer
Wake}fly Inc.
http://:www.wakefly.com
33 Lyman Street, Suite 310
Westborough, MA 01581
p: 508.616.2042 x23


----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <user-list-unsubscribe@...>
----------------------------------------------------------------


Re: Redirects in Magnolia

by Jan Haderka-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Try this virtual URI mapping:

class:   i.m.cms.beans.config.RegexpVirtualURIMapping
fromURI: /index/company/blog.html
toURI:   redirect:http://blog.company.com

should do the trick.

HTH,
Jan



On Fri, 2009-10-23 at 12:07 -0400, Jared Barboza wrote:

> I have a multi-level navigation menu setup on a customers' magnolia
> site. It's driven by the model.navigation.horizontalNavigation property
> in one of our freemarker templates. I currently have a page "blog" that
> needs to redirect to http://blog.company.com instead it is pointing to
> /index/company/blog.html.
>
> Anyone know how/if I can setup a redirect within Magnolia to point
> requests to /index/company/blog.html to http://blog.company.com? I've
> tried setting up a VirtualURIMapping but that only seems to work
> internally not externally.
>
>
> Jared Barboza
> Software Developer
> Wake}fly Inc.
> http://:www.wakefly.com
> 33 Lyman Street, Suite 310
> Westborough, MA 01581
> p: 508.616.2042 x23
>
>
> ----------------------------------------------------------------
> For list details see
> http://www.magnolia-cms.com/home/community/mailing-lists.html
> To unsubscribe, E-mail to: <user-list-unsubscribe@...>
> ----------------------------------------------------------------


----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <user-list-unsubscribe@...>
----------------------------------------------------------------


Re: Obtain MgnlContext from Jetty

by gregoryjoseph :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Essentially, what you're asking is if there's a way to get an object  
out of a running web-app, from outside the container that runs said  
web-app. Unless you expose the object in question through mechanisms  
such as jmx, rmi, jndi or other forms of webservices, the answer is  
no ;)

In our "tests", as far as I can remember, what we do is somehow manage  
to get some predictable output from the webapp the tests deploy (i.e a  
template that prints out the content of the context's attributes for  
instance) and in the test, compare that output with what we expect.  
It's not exactly satisfying nor very flexible, .. nor very easy/fast  
to work with. If you come up with other ideas, please share!

-g


On Oct 23, 2009, at 4:59 PM, Matteo Pelucco wrote:

>
> Hi all,
> is there a way to do this:
>
> 1) launch jetty from a test (jUnit / testng) in embedded mode
> 2) deploy magnolia inside
>
> --- till here up&running
>
> 3) obtain MgnlContext instance from jetty
>
> ???
> Matteo
>
>
> ----------------------------------------------------------------
> For list details see
> http://www.magnolia-cms.com/home/community/mailing-lists.html
> To unsubscribe, E-mail to: <user-list-unsubscribe@...>
> ----------------------------------------------------------------


----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <user-list-unsubscribe@...>
----------------------------------------------------------------


RE: Redirects in Magnolia

by Jared Barboza :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Jan,
        That worked perfectly. Thanks!

Jared Barboza
Software Developer
Wake}fly Inc.
http://:www.wakefly.com
33 Lyman Street, Suite 310
Westborough, MA 01581
p: 508.616.2042 x23

-----Original Message-----
From: user-list-owner@...
[mailto:user-list-owner@...] On Behalf Of Jan Haderka
Sent: Monday, October 26, 2009 4:26 AM
To: Magnolia User-List
Subject: Re: [magnolia-user] Redirects in Magnolia


Try this virtual URI mapping:

class:   i.m.cms.beans.config.RegexpVirtualURIMapping
fromURI: /index/company/blog.html
toURI:   redirect:http://blog.company.com

should do the trick.

HTH,
Jan



On Fri, 2009-10-23 at 12:07 -0400, Jared Barboza wrote:
> I have a multi-level navigation menu setup on a customers' magnolia
> site. It's driven by the model.navigation.horizontalNavigation
property
> in one of our freemarker templates. I currently have a page "blog"
that

> needs to redirect to http://blog.company.com instead it is pointing to
> /index/company/blog.html.
>
> Anyone know how/if I can setup a redirect within Magnolia to point
> requests to /index/company/blog.html to http://blog.company.com? I've
> tried setting up a VirtualURIMapping but that only seems to work
> internally not externally.
>
>
> Jared Barboza
> Software Developer
> Wake}fly Inc.
> http://:www.wakefly.com
> 33 Lyman Street, Suite 310
> Westborough, MA 01581
> p: 508.616.2042 x23
>
>
> ----------------------------------------------------------------
> For list details see
> http://www.magnolia-cms.com/home/community/mailing-lists.html
> To unsubscribe, E-mail to: <user-list-unsubscribe@...>
> ----------------------------------------------------------------


----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <user-list-unsubscribe@...>
----------------------------------------------------------------


----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <user-list-unsubscribe@...>
----------------------------------------------------------------


Re: Obtain MgnlContext from Jetty

by Matteo Pelucco :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Grégory Joseph ha scritto:

>
> Essentially, what you're asking is if there's a way to get an object out
> of a running web-app, from outside the container that runs said web-app.
> Unless you expose the object in question through mechanisms such as jmx,
> rmi, jndi or other forms of webservices, the answer is no ;)
>
> In our "tests", as far as I can remember, what we do is somehow manage
> to get some predictable output from the webapp the tests deploy (i.e a
> template that prints out the content of the context's attributes for
> instance) and in the test, compare that output with what we expect. It's
> not exactly satisfying nor very flexible, .. nor very easy/fast to work
> with. If you come up with other ideas, please share!

I Grég, nice point.
I have 3 observation:

1) Using Jetty is possible to have a webapp container context
programmatically.

*****
WebAppContext jettyCtx = new WebAppContext(server, WEBAPPDIR,
"/magnoliaAuthor");
ServletContext sc = jettyCtx.getServletContext();
                       
HttpServletRequest request = createStrictMock(HttpServletRequest.class);
HttpServletResponse response = createStrictMock(HttpServletResponse.class);
                       
WebContext webCtx = ContextFactory.getInstance().createWebContext(
request, response, sc);
MgnlContext.setInstance(webCtx);
***

But when we try to create a Magnolia Context using the factory, it fails.
So, is it possible to transform a generic context in a Magnolia Context?

2) Think about scheduled jobs. They are command executed during normal
webapp lifecycle, without passing from request / response mechanism.
The idea is to launch a test very similar to that scheduled job...

3) Ok, if we can not obtain MgnlContext instance and consequentially
have repository access, we can manage to use Selenium to automatically
launch interaction test within testNG / jUnit.
But I agree with you, expecially for small/medium project, the effort is
too much.

Matteo



----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <user-list-unsubscribe@...>
----------------------------------------------------------------