View Javadoc
1   /*
2    * Copyright (c) 2002-2025, City of Paris
3    * All rights reserved.
4    *
5    * Redistribution and use in source and binary forms, with or without
6    * modification, are permitted provided that the following conditions
7    * are met:
8    *
9    *  1. Redistributions of source code must retain the above copyright notice
10   *     and the following disclaimer.
11   *
12   *  2. Redistributions in binary form must reproduce the above copyright notice
13   *     and the following disclaimer in the documentation and/or other materials
14   *     provided with the distribution.
15   *
16   *  3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its
17   *     contributors may be used to endorse or promote products derived from
18   *     this software without specific prior written permission.
19   *
20   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23   * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
24   * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27   * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28   * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30   * POSSIBILITY OF SUCH DAMAGE.
31   *
32   * License 1.0
33   */
34  package fr.paris.lutece.portal.web;
35  
36  import javax.servlet.http.HttpServletRequest;
37  
38  import org.apache.commons.lang3.StringUtils;
39  import org.springframework.mock.web.MockHttpServletRequest;
40  import org.springframework.mock.web.MockHttpServletResponse;
41  import org.springframework.mock.web.MockServletConfig;
42  
43  import fr.paris.lutece.portal.service.security.SecurityService;
44  import fr.paris.lutece.test.LuteceTestCase;
45  
46  /**
47   * PortalJspBean Test Class
48   *
49   */
50  public class PortalJspBeanTest extends LuteceTestCase
51  {
52      /**
53       * Test of getContent method, of class fr.paris.lutece.portal.web.PortalJspBean.
54       */
55      public void testGetContent( ) throws Exception
56      {
57          HttpServletRequest request = new MockHttpServletRequest( );
58          LocalVariables.setLocal( new MockServletConfig( ), request, new MockHttpServletResponse( ) );
59          PortalJspBean instance = new PortalJspBean( );
60  
61          String result = instance.getContent( request );
62          assertTrue( StringUtils.isNotEmpty( result ) );
63      }
64  
65      /**
66       * Test of getStartUpFailurePage method, of class fr.paris.lutece.portal.web.PortalJspBean.
67       */
68      public void testGetStartUpFailurePage( )
69      {
70          HttpServletRequest request = new MockHttpServletRequest( );
71          PortalJspBean instance = new PortalJspBean( );
72          String result = instance.getStartUpFailurePage( request );
73          assertTrue( StringUtils.isNotEmpty( result ) );
74      }
75  
76      /**
77       * Test of getError500Page method, of class fr.paris.lutece.portal.web.PortalJspBean.
78       */
79      public void testGetError500Page( )
80      {
81          HttpServletRequest request = new MockHttpServletRequest( );
82          PortalJspBean instance = new PortalJspBean( );
83          String result = instance.getError500Page( request, "Cause" );
84          assertTrue( StringUtils.isNotEmpty( result ) );
85      }
86  
87      /**
88       * Test of getError404Page method, of class fr.paris.lutece.portal.web.PortalJspBean.
89       */
90      public void testGetError404Page( )
91      {
92          HttpServletRequest request = new MockHttpServletRequest( );
93          PortalJspBean instance = new PortalJspBean( );
94          String result = instance.getError404Page( request );
95          assertTrue( StringUtils.isNotEmpty( result ) );
96      }
97  
98      /**
99       * Test of getCredits method, of class fr.paris.lutece.portal.web.PortalJspBean.
100      */
101     public void testGetCredits( )
102     {
103         HttpServletRequest request = new MockHttpServletRequest( );
104         PortalJspBean instance = new PortalJspBean( );
105         String result = instance.getCredits( request );
106         assertTrue( StringUtils.isNotEmpty( result ) );
107     }
108 
109     /**
110      * Test of getLegalInfos method, of class fr.paris.lutece.portal.web.PortalJspBean.
111      */
112     public void testGetLegalInfos( )
113     {
114         HttpServletRequest request = new MockHttpServletRequest( );
115         PortalJspBean instance = new PortalJspBean( );
116         String result = instance.getLegalInfos( request );
117         assertTrue( StringUtils.isNotEmpty( result ) );
118     }
119 
120     /**
121      * Test of redirectLogin method, of class fr.paris.lutece.portal.web.PortalJspBean.
122      */
123     public void testRedirectLogin( )
124     {
125         if ( SecurityService.isAuthenticationEnable( ) )
126         {
127             HttpServletRequest request = new MockHttpServletRequest( );
128             PortalJspBean instance = new PortalJspBean( );
129             String result = instance.redirectLogin( request );
130             assertTrue( StringUtils.isNotEmpty( result ) );
131         }
132     }
133 
134     /**
135      * Test of getLoginNextUrl method, of class fr.paris.lutece.portal.web.PortalJspBean.
136      */
137     public void testGetLoginNextUrl( )
138     {
139         if ( SecurityService.isAuthenticationEnable( ) )
140         {
141             HttpServletRequest request = new MockHttpServletRequest( );
142             PortalJspBean.getLoginNextUrl( request );
143         }
144     }
145 
146     @Override
147     public void tearDown( ) throws Exception
148     {
149         LocalVariables.setLocal( null, null, null );
150         super.tearDown( );
151     }
152 }