001: package salomeTMF_plug.pluginxlsxml.Commun;
002:
003: import java.io.IOException;
004: import java.net.HttpURLConnection;
005: import java.net.MalformedURLException;
006: import java.net.URL;
007:
008: import org.objectweb.salome_tmf.ihm.main.SalomeTMFContext;
009:
010: /**
011: * Fonction permettant de tester la présence de différents plugins Salomé
012: */
013: public class TestPresencePlugin {
014:
015: /**
016: * Definit la chemin du plugin requirement
017: */
018: final static String REQUIREMENT_PLUGIN = "/plugins/requirements/requirements.jar";
019: final static String ABBOTSCRIPTRUNNER_PLUGIN = "/plugins/abbotScriptRunner/abbotScriptRunner.jar";
020: final static String BEANSHELL_PLUGIN = "/plugins/beanshell/beanshell.jar";
021: final static String SIMPLEJUNIT_PLUGIN = "/plugins/simpleJunit/simpleJunit.jar";
022:
023: /**
024: * Fonction qui teste la présence du plugin Requirement
025: * @return true or false
026: */
027: public static boolean testDeLaPresenceDuPluginRequirement() {
028: URL _urlBase = SalomeTMFContext.getInstance().getUrlBase();
029: String urlTexte = _urlBase.toString();
030: urlTexte = urlTexte.substring(0, urlTexte.lastIndexOf("/"));
031: String urlATester = urlTexte + REQUIREMENT_PLUGIN;
032: try {
033: HttpURLConnection conn = (HttpURLConnection) new URL(
034: urlATester).openConnection();
035: conn.connect();
036: return conn.getResponseCode() == HttpURLConnection.HTTP_OK;
037: } catch (MalformedURLException e) {
038: return false;
039: } catch (IOException e) {
040: return false;
041: }
042: }
043:
044: /**
045: * Fonction qui teste la présence du plugin Abbot
046: * @return true or false
047: */
048: public static boolean testDeLaPresenceDuPluginAbbotScriptRunner() {
049: URL _urlBase = SalomeTMFContext.getInstance().getUrlBase();
050: String urlTexte = _urlBase.toString();
051: urlTexte = urlTexte.substring(0, urlTexte.lastIndexOf("/"));
052: String urlATester = urlTexte + ABBOTSCRIPTRUNNER_PLUGIN;
053: try {
054: HttpURLConnection conn = (HttpURLConnection) new URL(
055: urlATester).openConnection();
056: conn.connect();
057: return conn.getResponseCode() == HttpURLConnection.HTTP_OK;
058: } catch (MalformedURLException e) {
059: return false;
060: } catch (IOException e) {
061: return false;
062: }
063: }
064:
065: /**
066: * Fonction qui teste la présence du plugin BeanShel
067: * @return true or false
068: */
069: public static boolean testDeLaPresenceDuPluginBeanShell() {
070: URL _urlBase = SalomeTMFContext.getInstance().getUrlBase();
071: String urlTexte = _urlBase.toString();
072: urlTexte = urlTexte.substring(0, urlTexte.lastIndexOf("/"));
073: String urlATester = urlTexte + BEANSHELL_PLUGIN;
074: try {
075: HttpURLConnection conn = (HttpURLConnection) new URL(
076: urlATester).openConnection();
077: conn.connect();
078: return conn.getResponseCode() == HttpURLConnection.HTTP_OK;
079: } catch (MalformedURLException e) {
080: return false;
081: } catch (IOException e) {
082: return false;
083: }
084: }
085:
086: /**
087: * Fonction qui teste la présence du plugin SimpleJUnit
088: * @return true or false
089: */
090: public static boolean testDeLaPresenceDuPluginSimpleJunit() {
091: URL _urlBase = SalomeTMFContext.getInstance().getUrlBase();
092: String urlTexte = _urlBase.toString();
093: urlTexte = urlTexte.substring(0, urlTexte.lastIndexOf("/"));
094: String urlATester = urlTexte + SIMPLEJUNIT_PLUGIN;
095: try {
096: HttpURLConnection conn = (HttpURLConnection) new URL(
097: urlATester).openConnection();
098: conn.connect();
099: return conn.getResponseCode() == HttpURLConnection.HTTP_OK;
100: } catch (MalformedURLException e) {
101: return false;
102: } catch (IOException e) {
103: return false;
104: }
105: }
106:
107: }
|