package salomeTMF_plug.pluginxlsxml.Commun;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import org.objectweb.salome_tmf.ihm.main.SalomeTMFContext;
/**
* Fonction permettant de tester la prsence de diffrents plugins Salom
*/
public class TestPresencePlugin {
/**
* Definit la chemin du plugin requirement
*/
final static String REQUIREMENT_PLUGIN = "/plugins/requirements/requirements.jar";
final static String ABBOTSCRIPTRUNNER_PLUGIN = "/plugins/abbotScriptRunner/abbotScriptRunner.jar";
final static String BEANSHELL_PLUGIN = "/plugins/beanshell/beanshell.jar";
final static String SIMPLEJUNIT_PLUGIN = "/plugins/simpleJunit/simpleJunit.jar";
/**
* Fonction qui teste la prsence du plugin Requirement
* @return true or false
*/
public static boolean testDeLaPresenceDuPluginRequirement(){
URL _urlBase = SalomeTMFContext.getInstance().getUrlBase();
String urlTexte = _urlBase.toString();
urlTexte = urlTexte.substring(0, urlTexte.lastIndexOf("/"));
String urlATester = urlTexte + REQUIREMENT_PLUGIN;
try
{
HttpURLConnection conn = (HttpURLConnection) new URL(urlATester).openConnection();
conn.connect();
return conn.getResponseCode() == HttpURLConnection.HTTP_OK;
}
catch (MalformedURLException e) { return false; }
catch (IOException e) { return false; }
}
/**
* Fonction qui teste la prsence du plugin Abbot
* @return true or false
*/
public static boolean testDeLaPresenceDuPluginAbbotScriptRunner(){
URL _urlBase = SalomeTMFContext.getInstance().getUrlBase();
String urlTexte = _urlBase.toString();
urlTexte = urlTexte.substring(0, urlTexte.lastIndexOf("/"));
String urlATester = urlTexte + ABBOTSCRIPTRUNNER_PLUGIN;
try
{
HttpURLConnection conn = (HttpURLConnection) new URL(urlATester).openConnection();
conn.connect();
return conn.getResponseCode() == HttpURLConnection.HTTP_OK;
}
catch (MalformedURLException e) { return false; }
catch (IOException e) { return false; }
}
/**
* Fonction qui teste la prsence du plugin BeanShel
* @return true or false
*/
public static boolean testDeLaPresenceDuPluginBeanShell(){
URL _urlBase = SalomeTMFContext.getInstance().getUrlBase();
String urlTexte = _urlBase.toString();
urlTexte = urlTexte.substring(0, urlTexte.lastIndexOf("/"));
String urlATester = urlTexte + BEANSHELL_PLUGIN;
try
{
HttpURLConnection conn = (HttpURLConnection) new URL(urlATester).openConnection();
conn.connect();
return conn.getResponseCode() == HttpURLConnection.HTTP_OK;
}
catch (MalformedURLException e) { return false; }
catch (IOException e) { return false; }
}
/**
* Fonction qui teste la prsence du plugin SimpleJUnit
* @return true or false
*/
public static boolean testDeLaPresenceDuPluginSimpleJunit(){
URL _urlBase = SalomeTMFContext.getInstance().getUrlBase();
String urlTexte = _urlBase.toString();
urlTexte = urlTexte.substring(0, urlTexte.lastIndexOf("/"));
String urlATester = urlTexte + SIMPLEJUNIT_PLUGIN;
try
{
HttpURLConnection conn = (HttpURLConnection) new URL(urlATester).openConnection();
conn.connect();
return conn.getResponseCode() == HttpURLConnection.HTTP_OK;
}
catch (MalformedURLException e) { return false; }
catch (IOException e) { return false; }
}
}
|