Search in sources :

Example 1 with PluginWrapper

use of hudson.PluginWrapper in project hudson-2.x by hudson.

the class PluginUtil method getWrapper.

public static PluginWrapper getWrapper(final Plugin plugin) {
    assert plugin != null;
    try {
        Field field = Plugin.class.getDeclaredField("wrapper");
        field.setAccessible(true);
        return (PluginWrapper) field.get(plugin);
    } catch (Exception e) {
        throw new RuntimeException("Failed to access PluginWrapper", e);
    }
}
Also used : Field(java.lang.reflect.Field) PluginWrapper(hudson.PluginWrapper)

Example 2 with PluginWrapper

use of hudson.PluginWrapper in project hudson-2.x by hudson.

the class UpdateSite method getUpdates.

/**
     * Returns the list of plugins that are updates to currently installed ones.
     *
     * @return
     *      can be empty but never null.
     */
public List<Plugin> getUpdates() {
    Data data = getData();
    // fail to determine
    if (data == null)
        return Collections.emptyList();
    List<Plugin> r = new ArrayList<Plugin>();
    for (PluginWrapper pw : Hudson.getInstance().getPluginManager().getPlugins()) {
        Plugin p = pw.getUpdateInfo();
        if (p != null)
            r.add(p);
    }
    return r;
}
Also used : ArrayList(java.util.ArrayList) PluginWrapper(hudson.PluginWrapper)

Example 3 with PluginWrapper

use of hudson.PluginWrapper in project blueocean-plugin by jenkinsci.

the class BlueI18nTest method test_200_response_locale_match.

@Test
public void test_200_response_locale_match() {
    PluginWrapper plugin = BlueI18n.getPlugin("blueocean-dashboard");
    if (plugin == null) {
        // Skip. See waitForPluginLoaded() above.
        return;
    }
    String dashboardVersion = plugin.getVersion();
    Map<String, Object> response1 = get("/blue/rest/i18n/blueocean-dashboard/" + dashboardVersion + "/jenkins.plugins.blueocean.dashboard.Messages/de", HttpServletResponse.SC_OK, Map.class);
    Assert.assertEquals("ok", response1.get("status"));
    Assert.assertTrue(((Map<String, Object>) response1.get("data")).containsKey("common.date.duration.format"));
}
Also used : PluginWrapper(hudson.PluginWrapper) Test(org.junit.Test) BaseTest(io.jenkins.blueocean.service.embedded.BaseTest)

Example 4 with PluginWrapper

use of hudson.PluginWrapper in project blueocean-plugin by jenkinsci.

the class BlueI18n method getBundle.

@CheckForNull
private JSONObject getBundle(BundleParams bundleParams, Locale locale) {
    PluginWrapper plugin = bundleParams.getPlugin();
    if (plugin == null) {
        return null;
    }
    try {
        ResourceBundle resourceBundle = ResourceBundle.getBundle(bundleParams.bundleName, locale, plugin.classLoader);
        JSONObject bundleJSON = new JSONObject();
        for (String key : resourceBundle.keySet()) {
            bundleJSON.put(key, resourceBundle.getString(key));
        }
        return bundleJSON;
    } catch (MissingResourceException e) {
    // fall through and return null.
    }
    return null;
}
Also used : JSONObject(net.sf.json.JSONObject) MissingResourceException(java.util.MissingResourceException) PluginWrapper(hudson.PluginWrapper) ResourceBundle(java.util.ResourceBundle) CheckForNull(javax.annotation.CheckForNull)

Example 5 with PluginWrapper

use of hudson.PluginWrapper in project blueocean-plugin by jenkinsci.

the class BlueI18nTest method test_404_response_unknown_bundle.

@Test
public void test_404_response_unknown_bundle() {
    PluginWrapper plugin = BlueI18n.getPlugin("blueocean-dashboard");
    if (plugin == null) {
        // Skip. See waitForPluginLoaded() above.
        return;
    }
    String dashboardVersion = plugin.getVersion();
    Map<String, Object> response1 = get("/blue/rest/i18n/blueocean-dashboard/" + dashboardVersion + "/jenkins.plugins.blueocean.dashboard.XXXUnknown/en", HttpServletResponse.SC_NOT_FOUND, Map.class);
    Assert.assertEquals("error", response1.get("status"));
    Assert.assertEquals("Unknown plugin or resource bundle: blueocean-dashboard/" + dashboardVersion + "/jenkins.plugins.blueocean.dashboard.XXXUnknown/en", response1.get("message"));
}
Also used : PluginWrapper(hudson.PluginWrapper) Test(org.junit.Test) BaseTest(io.jenkins.blueocean.service.embedded.BaseTest)

Aggregations

PluginWrapper (hudson.PluginWrapper)19 BaseTest (io.jenkins.blueocean.service.embedded.BaseTest)5 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)4 File (java.io.File)3 JSONObject (net.sf.json.JSONObject)3 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 CheckForNull (javax.annotation.CheckForNull)2 Jenkins (jenkins.model.Jenkins)2 PluginManager (hudson.PluginManager)1 Initializer (hudson.init.Initializer)1 Node (hudson.model.Node)1 DescriptorImpl (hudson.node_monitors.ArchitectureMonitor.DescriptorImpl)1 IOException2 (hudson.util.IOException2)1 BlueExtensionClassContainer (io.jenkins.blueocean.rest.model.BlueExtensionClassContainer)1 BufferedReader (java.io.BufferedReader)1 InputStreamReader (java.io.InputStreamReader)1