[jbpm-commits] JBoss JBPM SVN: r3684 - projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server.
do-not-reply at jboss.org
do-not-reply at jboss.org
Tue Jan 20 05:22:54 EST 2009
Author: heiko.braun at jboss.com
Date: 2009-01-20 05:22:54 -0500 (Tue, 20 Jan 2009)
New Revision: 3684
Modified:
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/TestFacade.java
Log:
Fix test deployment on AS 5
Modified: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/TestFacade.java
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/TestFacade.java 2009-01-20 10:12:16 UTC (rev 3683)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/TestFacade.java 2009-01-20 10:22:54 UTC (rev 3684)
@@ -42,92 +42,96 @@
/**
* Test utility to simplify GWT tests.
- *
+ *
* @author Heiko.Braun <heiko.braun at jboss.com>
*/
@Path("test")
public class TestFacade
{
- private static final Log log = LogFactory.getLog(TaskMgmtFacade.class);
-
- private ExtensionManagement JBPM3Extension;
- private ProcessManagement processManagement;
+ private static final Log log = LogFactory.getLog(TaskMgmtFacade.class);
- private ExtensionManagement getManagementExtension()
- {
- if(null==this.JBPM3Extension)
- {
- ManagementFactory factory = ManagementFactory.newInstance();
- this.JBPM3Extension = factory.createExtensionManagement();
- }
+ private ExtensionManagement JBPM3Extension;
+ private ProcessManagement processManagement;
+ private static final String SAMPLE_PROCESS_PAR = "/SampleProcess.par";
- return this.JBPM3Extension;
+ private ExtensionManagement getManagementExtension()
+ {
+ if(null==this.JBPM3Extension)
+ {
+ ManagementFactory factory = ManagementFactory.newInstance();
+ this.JBPM3Extension = factory.createExtensionManagement();
+ }
- }
+ return this.JBPM3Extension;
- private ProcessManagement getProcessManagement()
- {
- if(null==this.processManagement)
- {
- ManagementFactory factory = ManagementFactory.newInstance();
- this.processManagement = factory.createProcessManagement();
- log.debug("Using ManagementFactory impl:" + factory.getClass().getName());
- }
+ }
- return this.processManagement;
- }
+ private ProcessManagement getProcessManagement()
+ {
+ if(null==this.processManagement)
+ {
+ ManagementFactory factory = ManagementFactory.newInstance();
+ this.processManagement = factory.createProcessManagement();
+ log.debug("Using ManagementFactory impl:" + factory.getClass().getName());
+ }
- @POST
- @Path("deploy/harness")
- public Response deployTestHarness()
- {
- try
- {
- InputStream in = getClass().getResourceAsStream("/WEB-INF/classes/SampleProcess.par");
+ return this.processManagement;
+ }
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- final int BUF_SIZE = 1 << 8;
- byte[] buffer = new byte[BUF_SIZE];
- int bytesRead = -1;
- while((bytesRead = in.read(buffer)) > -1) {
- out.write(buffer, 0, bytesRead);
- }
- in.close();
- byte[] data = out.toByteArray();
+ @POST
+ @Path("deploy/harness")
+ public Response deployTestHarness()
+ {
+ try
+ {
+ InputStream in = getClass().getResourceAsStream(SAMPLE_PROCESS_PAR);
- ProcessDefinitionRef def = getManagementExtension().deployNewDefinition(data);
- log.info("Deployed test process definition " + def);
-
- return createJsonResponse(def);
+ if(null==in)
+ throw new RuntimeException("Failed to read test deployment: " + SAMPLE_PROCESS_PAR);
+
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ final int BUF_SIZE = 1 << 8;
+ byte[] buffer = new byte[BUF_SIZE];
+ int bytesRead = -1;
+ while((bytesRead = in.read(buffer)) > -1) {
+ out.write(buffer, 0, bytesRead);
}
- catch (IOException e)
- {
- throw new WebApplicationException(e, 500);
- }
+ in.close();
+ byte[] data = out.toByteArray();
- }
+ ProcessDefinitionRef def = getManagementExtension().deployNewDefinition(data);
+ log.info("Deployed test process definition " + def);
- @POST
- @Path("undeploy/harness")
- public Response undeployTestHarness()
- {
- List<ProcessDefinitionRef> defs = getProcessManagement().getProcessDefinitions();
-
- for(ProcessDefinitionRef pd : defs)
+ return createJsonResponse(def);
+ }
+ catch (IOException e)
+ {
+ throw new WebApplicationException(e, 500);
+ }
+
+ }
+
+ @POST
+ @Path("undeploy/harness")
+ public Response undeployTestHarness()
+ {
+ List<ProcessDefinitionRef> defs = getProcessManagement().getProcessDefinitions();
+
+ for(ProcessDefinitionRef pd : defs)
+ {
+ if(pd.getName().equals("GWT_Test_Harness"))
{
- if(pd.getName().equals("GWT_Test_Harness"))
- {
- log.info("Remove test harness " +pd);
- getProcessManagement().removeProcessDefinition(pd.getProcessId());
- }
+ log.info("Remove test harness " +pd);
+ getProcessManagement().removeProcessDefinition(pd.getProcessId());
}
- return Response.ok().build();
- }
+ }
+ return Response.ok().build();
+ }
- private Response createJsonResponse(Object wrapper)
- {
- Gson gson = GsonFactory.createInstance();
- String json = gson.toJson(wrapper);
- return Response.ok(json).type("application/json").build();
- }
+ private Response createJsonResponse(Object wrapper)
+ {
+ Gson gson = GsonFactory.createInstance();
+ String json = gson.toJson(wrapper);
+ return Response.ok(json).type("application/json").build();
+ }
}
More information about the jbpm-commits
mailing list