LCOV - code coverage report
Current view: top level - server/plugins - TestServerPlugin.java (source / functions) Hit Total Coverage
Test: _coverage_report.dat Lines: 17 21 81.0 %
Date: 2022-11-19 15:00:39 Functions: 5 7 71.4 %

          Line data    Source code
       1             : // Copyright (C) 2016 The Android Open Source Project
       2             : //
       3             : // Licensed under the Apache License, Version 2.0 (the "License");
       4             : // you may not use this file except in compliance with the License.
       5             : // You may obtain a copy of the License at
       6             : //
       7             : // http://www.apache.org/licenses/LICENSE-2.0
       8             : //
       9             : // Unless required by applicable law or agreed to in writing, software
      10             : // distributed under the License is distributed on an "AS IS" BASIS,
      11             : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      12             : // See the License for the specific language governing permissions and
      13             : // limitations under the License.
      14             : 
      15             : package com.google.gerrit.server.plugins;
      16             : 
      17             : import com.google.gerrit.server.PluginUser;
      18             : import com.google.gerrit.server.config.GerritRuntime;
      19             : import java.nio.file.Path;
      20             : 
      21             : public class TestServerPlugin extends ServerPlugin {
      22             :   private final ClassLoader classLoader;
      23             :   private String sysName;
      24             :   private String httpName;
      25             :   private String sshName;
      26             : 
      27             :   public TestServerPlugin(
      28             :       String name,
      29             :       String pluginCanonicalWebUrl,
      30             :       PluginUser user,
      31             :       ClassLoader classLoader,
      32             :       String sysName,
      33             :       String httpName,
      34             :       String sshName,
      35             :       Path dataDir)
      36             :       throws InvalidPluginException {
      37          12 :     super(
      38             :         name,
      39             :         pluginCanonicalWebUrl,
      40             :         user,
      41             :         null,
      42             :         null,
      43             :         null,
      44             :         dataDir,
      45             :         classLoader,
      46             :         null,
      47             :         GerritRuntime.DAEMON);
      48          12 :     this.classLoader = classLoader;
      49          12 :     this.sysName = sysName;
      50          12 :     this.httpName = httpName;
      51          12 :     this.sshName = sshName;
      52          12 :     loadGuiceModules();
      53          12 :   }
      54             : 
      55             :   private void loadGuiceModules() throws InvalidPluginException {
      56             :     try {
      57          12 :       this.sysModule = load(sysName, classLoader);
      58          12 :       this.httpModule = load(httpName, classLoader);
      59          12 :       this.sshModule = load(sshName, classLoader);
      60           0 :     } catch (ClassNotFoundException e) {
      61           0 :       throw new InvalidPluginException("Unable to load plugin Guice Modules", e);
      62          12 :     }
      63          12 :   }
      64             : 
      65             :   @Override
      66             :   public String getVersion() {
      67           0 :     return "1.0";
      68             :   }
      69             : 
      70             :   @Override
      71             :   protected boolean canReload() {
      72           0 :     return false;
      73             :   }
      74             : 
      75             :   @Override
      76             :   // Widen access modifier in derived class
      77             :   public void start(PluginGuiceEnvironment env) throws Exception {
      78          12 :     super.start(env);
      79          12 :   }
      80             : 
      81             :   @Override
      82             :   // Widen access modifier in derived class
      83             :   public void stop(PluginGuiceEnvironment env) {
      84          12 :     super.stop(env);
      85          12 :   }
      86             : 
      87             :   @Override
      88             :   public PluginContentScanner getContentScanner() {
      89           9 :     return null;
      90             :   }
      91             : }

Generated by: LCOV version 1.16+git.20220603.dfeb750