1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.extension.test

File TestExtensionHandler.java

 

Coverage histogram

../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

2
8
4
1
78
47
5
0.62
2
4
1.25

Classes

Class Line # Actions
TestExtensionHandler 45 8 0% 5 0
1.0100%
 

Contributing tests

This file is covered by 39 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.extension.test;
21   
22    import java.util.HashMap;
23    import java.util.HashSet;
24    import java.util.Map;
25    import java.util.Set;
26   
27    import javax.inject.Named;
28    import javax.inject.Singleton;
29   
30    import org.xwiki.component.annotation.Component;
31    import org.xwiki.extension.ExtensionException;
32    import org.xwiki.extension.InstallException;
33    import org.xwiki.extension.InstalledExtension;
34    import org.xwiki.extension.LocalExtension;
35    import org.xwiki.extension.UninstallException;
36    import org.xwiki.extension.handler.internal.AbstractExtensionHandler;
37    import org.xwiki.job.Request;
38   
39    /**
40    * Basic handler used for tests.
41    */
42    @Component
43    @Named("test")
44    @Singleton
 
45    public class TestExtensionHandler extends AbstractExtensionHandler
46    {
47    private Map<String, Set<LocalExtension>> extensions = new HashMap<String, Set<LocalExtension>>();
48   
 
49  35 toggle public Map<String, Set<LocalExtension>> getExtensions()
50    {
51  35 return this.extensions;
52    }
53   
 
54  1287 toggle @Override
55    public void install(LocalExtension localExtension, String namespace, Request request) throws InstallException
56    {
57  1287 Set<LocalExtension> namespaceExtensions = this.extensions.get(namespace);
58  1287 if (namespaceExtensions == null) {
59  340 namespaceExtensions = new HashSet<LocalExtension>();
60  340 this.extensions.put(namespace, namespaceExtensions);
61    }
62   
63  1287 namespaceExtensions.add(localExtension);
64    }
65   
 
66  42 toggle @Override
67    public void uninstall(InstalledExtension installedExtension, String namespace, Request request)
68    throws UninstallException
69    {
70  42 this.extensions.get(namespace).remove(installedExtension);
71    }
72   
 
73  1221 toggle @Override
74    public void initialize(LocalExtension localExtension, String namespace) throws ExtensionException
75    {
76  1221 install(localExtension, namespace, null);
77    }
78    }