span> this.objectName = properties.getProperty("orchestra.jmx.objectName");
} catch (final IOException e) {
- Misc.fastDynamicLog(OrchestraManagementServlet.LOG, Level.SEVERE,"OrchestraManagement - getOrchestraProperties :"
+ Misc.fastDynamicLog(OrchestraManagementServlet.LOG, Level.SEVERE, "OrchestraManagement - getOrchestraProperties :"
+ "Unable to load property file !\n" + Misc.getStackTraceFrom(e));
throw new OrchestraManagementException("Unable to load property file !",
"OrchestraManagement - getOrchestraProperties : Unable to load property file !\n" + Misc.getStackTraceFrom(e));
@@ -895,13 +978,12 @@
}
}
-
/**
- * This function return the process name corresponding to an uuid.
- * First the function check if a correspondence is registered in the list, in this case,
- * the response can be directly return
- * in the other case, the response is ask to orchestra server.
- *
+ * This function return the process name corresponding to an uuid. First the
+ * function check if a correspondence is registered in the list, in this case,
+ * the response can be directly return in the other case, the response is ask
+ * to orchestra server.
+ *
* @param correspondenceList
* @param uuid
* @return
@@ -924,7 +1006,7 @@
// if we didn't find a correspondence in the list
if (res == -1) {
-//System.out.println("ask orchestra for uuid : " + uuid.toString());
+ // System.out.println("ask orchestra for uuid : " + uuid.toString());
// check if the API fields are null or not
if (this.queryDefinitionAPI == null) {
@@ -935,13 +1017,15 @@
try {
processDef = this.queryDefinitionAPI.getProcessDefinition(uuid);
} catch (final ProcessNotFoundException e) {
- Misc.fastDynamicLog(OrchestraManagementServlet.LOG, Level.SEVERE, "Error while accessing process (id = " + uuid.toString() + " ) "
- + "The process was not found on orchestra !");
+ Misc.fastDynamicLog(
+ OrchestraManagementServlet.LOG, Level.SEVERE, "Error while accessing process (id = " + uuid.toString() + " ) "
+ + "The process was not found on orchestra !");
throw new OrchestraManagementException("Error while accessing process (id = " + uuid.toString() + " )"
+ "The process was not found on orchestra !",
"OrchestraManagement - searchProcessName : " + Misc.getStackTraceFrom(e));
} catch (final Exception e) {
- Misc.fastDynamicLog(OrchestraManagementServlet.LOG, Level.SEVERE, "Error while accessing process (id = " + uuid.toString() + " )");
+ Misc.fastDynamicLog(
+ OrchestraManagementServlet.LOG, Level.SEVERE, "Error while accessing process (id = " + uuid.toString() + " )");
throw new OrchestraManagementException("Error while accessing process (id = " + uuid.toString() + " )",
"OrchestraManagement - searchProcessName : " + Misc.getStackTraceFrom(e));
}
@@ -949,7 +1033,8 @@
if (processDef != null) {
processName = processDef.getName();
} else {
- Misc.fastDynamicLog(OrchestraManagementServlet.LOG, Level.SEVERE, "Error while accessing process (id = " + uuid.toString() + " )");
+ Misc.fastDynamicLog(
+ OrchestraManagementServlet.LOG, Level.SEVERE, "Error while accessing process (id = " + uuid.toString() + " )");
throw new OrchestraManagementException("Error while accessing process (id = " + uuid.toString() + " )",
"OrchestraManagement - searchProcessName : The orchestra returned object is null");
}
@@ -961,7 +1046,8 @@
}
// if we found a correspondence in the list
else {
-//System.out.println("found uuid : " + uuid.toString() + " in our table");
+ // System.out.println("found uuid : " + uuid.toString() +
+ // " in our table");
if (correspondenceList != null) {
final ProcessUuidNName tmp = correspondenceList.get(res);
processName = tmp.getProcessName();
@@ -971,14 +1057,14 @@
return processName;
}
-
/**
* The class use to construct the correspondence list between the process uuid
* and the process name.
- *
+ *
* @author Mathieu Crassin
*/
protected class ProcessUuidNName {
+
private String processUUID = null;
private String processName = null;
@@ -996,10 +1082,10 @@
}
-
/**
- * This method scan a list to check if a correspondence with a given uuid is here
- *
+ * This method scan a list to check if a correspondence with a given uuid is
+ * here
+ *
* @author Mathieu Crassin
* @param correspondenceList
* @param processUUID
@@ -1017,7 +1103,6 @@
return -1;
}
-
public void sessionLogout() throws OrchestraManagementException {
this.getThreadLocalRequest().getSession().invalidate();
}
@@ -1037,7 +1122,7 @@
}
try {
final byte[] bpmnResource =
- this.queryDefinitionAPI.getProcessResource(new ProcessDefinitionUUID(processId), "process.bpmn");
+ this.queryDefinitionAPI.getProcessResource(new ProcessDefinitionUUID(processId), "process.bpmn");
if (bpmnResource != null) {
return Base64.encodeToString(DesignerModelUtils.getSerializedDesignerModel(bpmnResource), false);
}
--- trunk/OrchestraPVM/console/war/src/test/java/org/ow2/orchestra/console/GWTConsole/server/TestOrchestraManagementServlet.java 2011-04-22 12:44:34 UTC (rev 5856)
+++ trunk/OrchestraPVM/console/war/src/test/java/org/ow2/orchestra/console/GWTConsole/server/TestOrchestraManagementServlet.java 2011-04-22 12:57:01 UTC (rev 5857)
@@ -31,17 +31,16 @@
import org.ow2.orchestra.console.GWTConsole.client.ListProcess.MProcess;
import org.ow2.orchestra.facade.uuid.ProcessDefinitionUUID;
-
/**
* @author Jean-Yves Goubet
- *
- * class to test the orchestra management servlet
+ *
+ * class to test the orchestra management servlet
*/
public class TestOrchestraManagementServlet extends TestCase {
/**
* Test connection parameters
- *
+ *
* @author Mathieu Crassin
*/
public final void testConnectionParameters() {
@@ -112,55 +111,42 @@
}
/*
- public void testIOException() {
-
- try {
- getOrchestraProperties();
- } catch (OrchestraManagementException e) {
- System.out.println("-----------------------------------------------------------");
- System.out.println("MOCK exception testConnectionParameters");
- e.printStackTrace();
- System.out.println("-----------------------------------------------------------");
- }
-
- // now, we have to start reading the file
- try{
- // Open the file that is the first
- // command line parameter
- File file = new File("conf/orchestra.properties");
- FileInputStream fstream = null;
- if (file.exists()) {
- fstream = new FileInputStream(file);
- } else {
- fstream = Thread.currentThread().getContextClassLoader().getResourceAsStream("orchestra.properties").
- }
- // Get the object of DataInputStream
- DataInputStream in = new DataInputStream(fstream);
- BufferedReader br = new BufferedReader(new InputStreamReader(in));
- br.readLine();
- } catch (Exception e) {
- System.out.println("-----------------------------------------------------------");
- System.out.println("MOCK exception testConnectionParameters");
- e.printStackTrace();
- System.out.println("-----------------------------------------------------------");
- }
-
- // and try getting properties
- boolean error = false;
- try {
- getOrchestraProperties();
- } catch (OrchestraManagementException e) {
- error = true;
-
- Assert.assertEquals(e.getMessage(), "Unable to load property file !");
- Assert.assertTrue(
- e.getDetails().contains("OrchestraManagement - getOrchestraProperties : Unable to load property file !\n")
- );
- }
-
- Assert.assertEquals(false, error);
-
- } */
+ * public void testIOException() {
+ *
+ * try { getOrchestraProperties(); } catch (OrchestraManagementException
+ * e) { System.out.println(
+ * "-----------------------------------------------------------");
+ * System.out.println("MOCK exception testConnectionParameters");
+ * e.printStackTrace(); System.out.println(
+ * "-----------------------------------------------------------"); }
+ *
+ * // now, we have to start reading the file try{ // Open the file that is
+ * the first // command line parameter File file = new
+ * File("conf/orchestra.properties"); FileInputStream fstream = null; if
+ * (file.exists()) { fstream = new FileInputStream(file); } else { fstream
+ * = Thread.currentThread().getContextClassLoader().getResourceAsStream(
+ * "orchestra.properties"). } // Get the object of DataInputStream
+ * DataInputStream in = new DataInputStream(fstream); BufferedReader br =
+ * new BufferedReader(new InputStreamReader(in)); br.readLine(); } catch
+ * (Exception e) { System.out.println(
+ * "-----------------------------------------------------------");
+ * System.out.println("MOCK exception testConnectionParameters");
+ * e.printStackTrace(); System.out.println(
+ * "-----------------------------------------------------------"); }
+ *
+ * // and try getting properties boolean error = false; try {
+ * getOrchestraProperties(); } catch (OrchestraManagementException e) {
+ * error = true;
+ *
+ * Assert.assertEquals(e.getMessage(), "Unable to load property file !");
+ * Assert.assertTrue( e.getDetails().contains(
+ * "OrchestraManagement - getOrchestraProperties : Unable to load property file !\n"
+ * ) ); }
+ *
+ * Assert.assertEquals(false, error);
+ *
+ * }
+ */
}
LocalTestOrchestraManagementServlet mock = null;
@@ -170,15 +156,15 @@
}
mock.testBasic();
-// mock.testWithNonExistingFile();
-// mock.testIOException();
+ // mock.testWithNonExistingFile();
+ // mock.testIOException();
System.out.println("END of testConnectionParameters");
}
/**
* Test the getContentFile function.
- *
+ *
* @author Mathieu Crassin
* @throws OrchestraManagementException
*/
@@ -208,7 +194,7 @@
}
// create data to write
- final byte []data = "" is my data string !".getBytes();
+ final byte[] data = "" is my data string !".getBytes();
if (data == null) {
System.out.println("testGetContentFile: Error while setting data to write !");
}
@@ -229,16 +215,18 @@
}
// use the function to test
boolean exception = false;
- byte []founddata1 = null;
+ byte[] founddata1 = null;
try {
founddata1 = this.getContentFile(testfilewithdata.getAbsolutePath());
} catch (final OrchestraManagementException e) {
exception = true;
}
// check
- Assert.assertEquals(false, exception); // verify that no exception occurred
+ Assert.assertEquals(false, exception); // verify that no exception
+ // occurred
for (int i = 0; i < data.length; i++) {
- Assert.assertEquals(data[i], founddata1[i]); // verify that data are correct
+ Assert.assertEquals(data[i], founddata1[i]); // verify that data are
+ // correct
}
// test with a file that contains nothing
@@ -252,7 +240,7 @@
}
// call the function to test
exception = false;
- byte []founddata2 = null;
+ byte[] founddata2 = null;
try {
founddata2 = this.getContentFile(emptytestfile.getAbsolutePath());
} catch (final OrchestraManagementException e) {
@@ -266,7 +254,7 @@
// call the function
exception = false;
@SuppressWarnings("unused")
- byte []founddata3 = null;
+ byte[] founddata3 = null;
try {
founddata3 = this.getContentFile(System.getProperty("java.io.tmpdir")
+ File.separator + "myfilethatdoesntexists.txt");
@@ -274,7 +262,7 @@
// check that we catch the correct exception
Assert.assertTrue(e instanceof OrchestraManagementException);
Assert.assertTrue(e.getMessage().equals("Internal server error while accessing file !"));
- Assert.assertTrue(((OrchestraManagementException)e).getDetails()
+ Assert.assertTrue(((OrchestraManagementException) e).getDetails()
.contains("OrchestraManagement - getContentFile : File not found !"));
}
@@ -282,14 +270,14 @@
// call the function
exception = false;
@SuppressWarnings("unused")
- byte []founddata4 = null;
+ byte[] founddata4 = null;
try {
founddata4 = this.getContentFile(null);
} catch (final Exception e) {
// check that we catch the correct exception
Assert.assertTrue(e instanceof OrchestraManagementException);
Assert.assertTrue(e.getMessage().equals("Internal server error while accessing file !"));
- Assert.assertTrue(((OrchestraManagementException)e).getDetails()
+ Assert.assertTrue(((OrchestraManagementException) e).getDetails()
.contains("OrchestraManagement - getContentFile : The file name is a null pointer !\n"));
}
@@ -317,15 +305,12 @@
System.out.println("END of testGetContentFile");
}
-
-
-
/**
* @author Mathieu Crassin
- *
- * test deployBar function
- * by mocking getContentFile & getAPIs to control function.
- *
+ *
+ * test deployBar function by mocking getContentFile & getAPIs to
+ * control function.
+ *
*/
public final void testDeployToOrchestra() {
System.out.println("START of testDeployToOrchestra");
@@