1. Project Clover database Fri Jul 3 2015 14:17:25 CEST
  2. Package info.magnolia.module.blossom.web

File BlossomRequestMappingHandlerAdapterTest.java

 

Code metrics

0
24
3
2
102
44
3
0.12
8
1.5
1

Classes

Class Line # Actions
BlossomRequestMappingHandlerAdapterTest 50 23 0% 2 0
1.0100%
BlossomRequestMappingHandlerAdapterTest.BlossomRequestMappingHandlerAdapterTestConfig 52 1 0% 1 0
1.0100%
 

Contributing tests

This file is covered by 2 tests. .

Source view

1    /**
2    * This file Copyright (c) 2014-2015 Magnolia International
3    * Ltd. (http://www.magnolia-cms.com). All rights reserved.
4    *
5    *
6    * This file is dual-licensed under both the Magnolia
7    * Network Agreement and the GNU General Public License.
8    * You may elect to use one or the other of these licenses.
9    *
10    * This file is distributed in the hope that it will be
11    * useful, but AS-IS and WITHOUT ANY WARRANTY; without even the
12    * implied warranty of MERCHANTABILITY or FITNESS FOR A
13    * PARTICULAR PURPOSE, TITLE, or NONINFRINGEMENT.
14    * Redistribution, except as permitted by whichever of the GPL
15    * or MNA you select, is prohibited.
16    *
17    * 1. For the GPL license (GPL), you can redistribute and/or
18    * modify this file under the terms of the GNU General
19    * Public License, Version 3, as published by the Free Software
20    * Foundation. You should have received a copy of the GNU
21    * General Public License, Version 3 along with this program;
22    * if not, write to the Free Software Foundation, Inc., 51
23    * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24    *
25    * 2. For the Magnolia Network Agreement (MNA), this file
26    * and the accompanying materials are made available under the
27    * terms of the MNA which accompanies this distribution, and
28    * is available at http://www.magnolia-cms.com/mna.html
29    *
30    * Any modifications to this file must keep this entire header
31    * intact.
32    *
33    */
34    package info.magnolia.module.blossom.web;
35   
36    import static org.junit.Assert.assertFalse;
37    import static org.junit.Assert.assertTrue;
38   
39    import info.magnolia.module.blossom.view.UuidRedirectViewResolver;
40   
41    import org.junit.Test;
42    import org.springframework.context.annotation.AnnotationConfigApplicationContext;
43    import org.springframework.context.annotation.Bean;
44   
45    /**
46    * Tests for BlossomRequestMappingHandlerAdapter.
47    *
48    * @since 3.0.2
49    */
 
50    public class BlossomRequestMappingHandlerAdapterTest {
51   
 
52    public static class BlossomRequestMappingHandlerAdapterTestConfig {
53   
 
54  2 toggle @Bean
55    public BlossomRequestMappingHandlerAdapter handlerAdapter() {
56  2 return new BlossomRequestMappingHandlerAdapter();
57    }
58    }
59   
 
60  1 toggle @Test
61    public void testDetection() {
62   
63  1 AnnotationConfigApplicationContext wac = new AnnotationConfigApplicationContext();
64  1 wac.register(BlossomRequestMappingHandlerAdapterTestConfig.class);
65  1 wac.refresh();
66   
67  1 BlossomRequestMappingHandlerAdapter handlerAdapter = wac.getBean(BlossomRequestMappingHandlerAdapter.class);
68   
69  1 assertTrue(handlerAdapter.isRedirectViewName(UuidRedirectViewResolver.REDIRECT_MAIN_CONTENT_PLACEHOLDER));
70  1 assertTrue(handlerAdapter.isRedirectViewName(UuidRedirectViewResolver.REDIRECT_CURRENT_CONTENT_PLACEHOLDER));
71   
72  1 assertTrue(handlerAdapter.isRedirectViewName("website:123"));
73  1 assertTrue(handlerAdapter.isRedirectViewName("dms:123"));
74   
75  1 assertFalse(handlerAdapter.isRedirectViewName("main.ftl"));
76  1 assertFalse(handlerAdapter.isRedirectViewName("main.jsp"));
77   
78  1 assertFalse(handlerAdapter.isRedirectViewName("workspace:123"));
79    }
80   
 
81  1 toggle @Test
82    public void testDetectionWithCustomPatterns() {
83   
84  1 AnnotationConfigApplicationContext wac = new AnnotationConfigApplicationContext();
85  1 wac.register(BlossomRequestMappingHandlerAdapterTestConfig.class);
86  1 wac.refresh();
87   
88  1 BlossomRequestMappingHandlerAdapter handlerAdapter = wac.getBean(BlossomRequestMappingHandlerAdapter.class);
89  1 handlerAdapter.setRedirectPatterns("prefix:*");
90   
91  1 assertTrue(handlerAdapter.isRedirectViewName(UuidRedirectViewResolver.REDIRECT_MAIN_CONTENT_PLACEHOLDER));
92  1 assertTrue(handlerAdapter.isRedirectViewName(UuidRedirectViewResolver.REDIRECT_CURRENT_CONTENT_PLACEHOLDER));
93   
94  1 assertTrue(handlerAdapter.isRedirectViewName("prefix:123"));
95   
96  1 assertFalse(handlerAdapter.isRedirectViewName("website:123"));
97  1 assertFalse(handlerAdapter.isRedirectViewName("dms:123"));
98   
99  1 assertFalse(handlerAdapter.isRedirectViewName("main.ftl"));
100  1 assertFalse(handlerAdapter.isRedirectViewName("main.jsp"));
101    }
102    }