View Javadoc

1   /*
2    * Copyright (c) 2002-2014, Mairie de 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.plugins.updater.service;
35  
36  import fr.paris.lutece.plugins.updater.service.catalog.CatalogInfos;
37  import fr.paris.lutece.portal.service.plugin.Plugin;
38  import fr.paris.lutece.portal.service.plugin.PluginService;
39  import fr.paris.lutece.test.LuteceTestCase;
40  
41  import java.util.Collection;
42  
43  
44  /**
45   * UpdateService tests
46   */
47  public class UpdateServiceTest extends LuteceTestCase
48  {
49      public UpdateServiceTest( String testName )
50      {
51          super( testName );
52      }
53  
54      /**
55       * Test of getUpdateInfos method, of class UpdateService.
56       */
57      public void testGetUpdateInfos(  )
58      {
59          System.out.println( "getUpdateInfos" );
60  
61          Collection<Plugin> listPlugins = PluginService.getPluginList(  );
62          UpdateService instance = new UpdateService(  );
63          instance.getUpdateInfos( listPlugins );
64      }
65  
66      /**
67       * Test of getNewPluginsInfos method, of class UpdateService.
68       */
69      public void testGetNewPluginsInfos(  )
70      {
71          System.out.println( "getNewPluginsInfos" );
72  
73          Collection<Plugin> listPlugins = PluginService.getPluginList(  );
74          UpdateService instance = new UpdateService(  );
75          instance.getNewPluginsInfos( listPlugins );
76      }
77  
78      /**
79       * Test of deployPlugin method, of class UpdateService.
80       */
81      public void testDeployPlugin(  )
82      {
83          System.out.println( "deployPlugin" );
84  
85          String strPluginName = "calendar";
86          String strVersion = "2.0.1";
87          UpdateService instance = new UpdateService(  );
88          instance.deployPlugin( strPluginName, strVersion );
89      }
90  
91      /**
92       * Test of isCompliantWithCurrentCore method, of class UpdateService.
93       */
94      public void testIsCompliantWithCurrentCore(  )
95      {
96          System.out.println( "isCompliantWithCurrentCore" );
97  
98          UpdateService instance = new UpdateService(  );
99  
100         CatalogInfos ci = new CatalogInfos(  );
101         ci.setCoreVersionMin( "2.0.0" );
102         ci.setCoreVersionMax( "3.0.0" );
103         assertTrue( instance.isCompliantWithCurrentCore( ci ) );
104 
105         ci.setCoreVersionMin( "2.0.0" );
106         ci.setCoreVersionMax( null );
107         assertTrue( instance.isCompliantWithCurrentCore( ci ) );
108 
109         ci.setCoreVersionMin( "4.0.0" );
110         ci.setCoreVersionMax( "5.0.0" );
111         assertFalse( instance.isCompliantWithCurrentCore( ci ) );
112     }
113 
114     /**
115      * Test of getStatus method, of class UpdateService.
116      */
117     public void testGetStatus(  )
118     {
119         System.out.println( "getStatus" );
120 
121         UpdateService instance = new UpdateService(  );
122         int result = instance.getStatus(  );
123     }
124 
125     /**
126      * Test of checkUpdate method, of class UpdateService.
127      */
128     public void testCheckUpdate(  )
129     {
130         System.out.println( "checkUpdate" );
131 
132         Collection<Plugin> listPlugins = null;
133         UpdateService instance = new UpdateService(  );
134         instance.checkUpdate( listPlugins );
135     }
136 
137     /**
138      * Test of downloadPlugin method, of class UpdateService.
139      */
140     public void testDownloadPlugin(  ) throws UpdaterDownloadException
141     {
142         System.out.println( "downloadPlugin" );
143 
144         String strPluginName = "calendar";
145         String strVersion = "2.0.2";
146         UpdateService instance = new UpdateService(  );
147         instance.downloadPlugin( strPluginName, strVersion );
148     }
149 
150     /**
151      * Test of downloadPluginUpgrade method, of class UpdateService.
152      */
153     public void testDownloadPluginUpgrade(  ) throws UpdaterDownloadException
154     {
155         System.out.println( "downloadPluginUpgrade" );
156 
157         String strPluginName = "calendar";
158         String strVersion = "2.0.2";
159         String strVersionFrom = "2.0.1";
160         UpdateService instance = new UpdateService(  );
161         instance.downloadPluginUpgrade( strPluginName, strVersion, strVersionFrom );
162     }
163 }