[savara-commits] savara SVN: r203 - in tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src: test/org/jboss/savara/tools/bpel/model/component and 1 other directory.

do-not-reply at jboss.org do-not-reply at jboss.org
Sun Mar 21 09:22:31 EDT 2010


Author: objectiser
Date: 2010-03-21 09:22:30 -0400 (Sun, 21 Mar 2010)
New Revision: 203

Modified:
   tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/CatchAll.java
   tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Else.java
   tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Elseif.java
   tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/ForEach.java
   tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/If.java
   tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/test/org/jboss/savara/tools/bpel/model/component/ForEachTest.java
   tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/test/org/jboss/savara/tools/bpel/model/component/IfTest.java
Log:
Add more tests for getting uri.

Modified: tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/CatchAll.java
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/CatchAll.java	2010-03-19 23:11:21 UTC (rev 202)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/CatchAll.java	2010-03-21 13:22:30 UTC (rev 203)
@@ -96,7 +96,7 @@
 		String ret="";
 		
 		if (elem instanceof BPELActivity) {
-			ret += "@activity";
+			ret = "@activity";
 		}
 		
 		return(ret);

Modified: tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Else.java
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Else.java	2010-03-19 23:11:21 UTC (rev 202)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Else.java	2010-03-21 13:22:30 UTC (rev 203)
@@ -94,5 +94,15 @@
 		return(m_activity);
 	}
 	
+	protected String getLocalURIPart(BPELElement elem) {
+		String ret="";
+		
+		if (elem instanceof BPELActivity) {
+			ret = "@activity";
+		}
+		
+		return(ret);
+	}
+	
 	private BPELElement m_activity;
 }

Modified: tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Elseif.java
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Elseif.java	2010-03-19 23:11:21 UTC (rev 202)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Elseif.java	2010-03-21 13:22:30 UTC (rev 203)
@@ -124,6 +124,16 @@
 		return(m_activity);
 	}
 	
+	protected String getLocalURIPart(BPELElement elem) {
+		String ret="";
+		
+		if (elem instanceof BPELActivity) {
+			ret = "@activity";
+		}
+		
+		return(ret);
+	}
+	
 	private Condition m_condition;
 	private BPELElement m_activity;
 }

Modified: tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/ForEach.java
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/ForEach.java	2010-03-19 23:11:21 UTC (rev 202)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/ForEach.java	2010-03-21 13:22:30 UTC (rev 203)
@@ -110,5 +110,15 @@
 		getSource().setComponentURI(getURI());
 	}
 
+	protected String getLocalURIPart(BPELElement elem) {
+		String ret="";
+		
+		if (elem instanceof Scope) {
+			ret += "@scope";
+		}
+		
+		return(ret);
+	}
+	
 	private Scope m_scope=null;
 }

Modified: tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/If.java
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/If.java	2010-03-19 23:11:21 UTC (rev 202)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/If.java	2010-03-21 13:22:30 UTC (rev 203)
@@ -265,6 +265,21 @@
 		return(m_elsePath);
 	}
 	
+	protected String getLocalURIPart(BPELElement elem) {
+		String ret="";
+		
+		if (elem instanceof Elseif) {
+			int pos=getElseIfPaths().indexOf(elem);
+			ret = "@elseif."+pos;
+		} else if (elem instanceof Else) {
+			ret = "@else";
+		} else {
+			ret = "@activity";
+		}
+		
+		return(ret);
+	}
+	
 	private static Log logger=LogFactory.getLog(If.class);
 	
 	private Condition m_condition=null;

Modified: tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/test/org/jboss/savara/tools/bpel/model/component/ForEachTest.java
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/test/org/jboss/savara/tools/bpel/model/component/ForEachTest.java	2010-03-19 23:11:21 UTC (rev 202)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/test/org/jboss/savara/tools/bpel/model/component/ForEachTest.java	2010-03-21 13:22:30 UTC (rev 203)
@@ -127,4 +127,87 @@
 									getLocalName());
 		}
 	}
+	
+	public void testGetURI() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<process xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+		       		"<forEach xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+						"<startCounterValue/>"+
+						"<finalCounterValue/>"+
+						"<completionCondition/>"+
+						"<scope>"+
+				       		"<sequence>"+
+				       			"<receive/>"+
+			       			"</sequence>"+
+		       			"</scope>"+
+					"</forEach>"+
+			       "<sequence/>"+
+	       		"</process>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			e.printStackTrace();
+			fail("Failed to convert to doc");
+		}
+		
+		Process component=new Process(model, elem);		
+		
+		BPELActivity topact=component.getActivity();
+		
+		if ((topact instanceof ForEach) == false) {
+			fail("Top level activity is not ForEach");
+		}
+		
+		ForEach fe=(ForEach)topact;
+		
+		Scope innerScope=fe.getScope();
+		
+		if (innerScope == null) {
+			fail("Inner scope not set");
+		}
+		
+		if ((innerScope.getActivity() instanceof Sequence) == false) {
+			fail("Inner scope activity is not a sequence");
+		}
+		
+		Sequence seq=(Sequence)innerScope.getActivity();
+		
+		if (seq.getActivities().size() != 1) {
+			fail("Expecting 1 child activities: "+
+							seq.getActivities().size());
+		}
+		
+		if ((seq.getActivities().get(0) instanceof Receive) == false) {
+			fail("First activity should be receive");
+		}
+		
+		Receive recv=(Receive)seq.getActivities().get(0);
+		
+		String uri=recv.getURI();
+		
+		if (uri == null) {
+			fail("URI is null");
+		}
+		
+		if (uri.equals("//@activity/@scope/@activity/@activities.0") == false) {
+			fail("URI is invalid: "+uri);
+		}
+	}	
 }

Modified: tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/test/org/jboss/savara/tools/bpel/model/component/IfTest.java
===================================================================
--- tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/test/org/jboss/savara/tools/bpel/model/component/IfTest.java	2010-03-19 23:11:21 UTC (rev 202)
+++ tools/eclipse/trunk/plugins/org.jboss.savara.tools.bpel/src/test/org/jboss/savara/tools/bpel/model/component/IfTest.java	2010-03-21 13:22:30 UTC (rev 203)
@@ -868,4 +868,319 @@
 							getFirstChild().getLocalName());
 		}
 	}	
+	
+	public void testGetURIIf() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<process xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+					"<sequence>"+
+		       		"<if xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+				       "<condition/>"+
+				       		"<sequence>"+
+				       			"<receive/>"+
+			       			"</sequence>"+
+				       "<elseif>"+
+				       "<condition/>"+
+			       			"<sequence>"+
+			       				"<invoke/>"+
+			       			"</sequence>"+
+				       "</elseif>"+
+				       "<elseif>"+
+				       "<condition/>"+
+		       				"<sequence>"+
+		       					"<reply/>"+
+		       				"</sequence>"+
+				       "</elseif>"+
+				       "<else>"+
+		       				"<sequence>"+
+		       					"<throw/>"+
+		       				"</sequence>"+
+				       "</else>"+
+				     "</if>"+
+			       "</sequence>"+
+	       		"</process>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			e.printStackTrace();
+			fail("Failed to convert to doc");
+		}
+		
+		Process component=new Process(model, elem);		
+		
+		BPELActivity topact=component.getActivity();
+		
+		if ((topact instanceof Sequence) == false) {
+			fail("Top level activity is not Sequence");
+		}
+		
+		Sequence seq=(Sequence)topact;
+		
+		if (seq.getActivities().size() != 1) {
+			fail("Should have 1 activity: "+seq.getActivities().size());
+		}
+		
+		if ((seq.getActivities().get(0) instanceof If) == false) {
+			fail("Activty should be If");
+		}
+		
+		If ifelem=(If)seq.getActivities().get(0);
+		
+		if ((ifelem.getActivity() instanceof Sequence) == false) {
+			fail("Inner scope activity is not a sequence");
+		}
+		
+		Sequence innerseq=(Sequence)ifelem.getActivity();
+		
+		if (innerseq.getActivities().size() != 1) {
+			fail("Expecting 1 child activities: "+
+					innerseq.getActivities().size());
+		}
+		
+		if ((innerseq.getActivities().get(0) instanceof Receive) == false) {
+			fail("First activity should be receive");
+		}
+		
+		Receive recv=(Receive)innerseq.getActivities().get(0);
+		
+		String uri=recv.getURI();
+		
+		if (uri == null) {
+			fail("URI is null");
+		}
+		
+		if (uri.equals("//@activity/@activities.0/@activity/@activities.0") == false) {
+			fail("URI is invalid: "+uri);
+		}
+	}	
+
+	public void testGetURIIfElseIf() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<process xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+					"<sequence>"+
+		       		"<if xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+				       "<condition/>"+
+				       		"<sequence>"+
+				       			"<receive/>"+
+			       			"</sequence>"+
+				       "<elseif>"+
+				       "<condition/>"+
+			       			"<sequence>"+
+			       				"<invoke/>"+
+			       			"</sequence>"+
+				       "</elseif>"+
+				       "<elseif>"+
+				       "<condition/>"+
+		       				"<sequence>"+
+		       					"<reply/>"+
+		       				"</sequence>"+
+				       "</elseif>"+
+				       "<else>"+
+		       				"<sequence>"+
+		       					"<throw/>"+
+		       				"</sequence>"+
+				       "</else>"+
+				     "</if>"+
+			       "</sequence>"+
+	       		"</process>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			e.printStackTrace();
+			fail("Failed to convert to doc");
+		}
+		
+		Process component=new Process(model, elem);		
+		
+		BPELActivity topact=component.getActivity();
+		
+		if ((topact instanceof Sequence) == false) {
+			fail("Top level activity is not Sequence");
+		}
+		
+		Sequence seq=(Sequence)topact;
+		
+		if (seq.getActivities().size() != 1) {
+			fail("Should have 1 activity: "+seq.getActivities().size());
+		}
+		
+		if ((seq.getActivities().get(0) instanceof If) == false) {
+			fail("Activty should be If");
+		}
+		
+		If ifelem=(If)seq.getActivities().get(0);
+
+		if (ifelem.getElseIfPaths().size() != 2) {
+			fail("Expecting 2 elseIf paths: "+ifelem.getElseIfPaths().size());
+		}
+		
+		Elseif eif=ifelem.getElseIfPaths().get(1);
+		
+		if ((eif.getActivity() instanceof Sequence) == false) {
+			fail("ElseIf activity not a sequence");
+		}
+		
+		Sequence innerseq=(Sequence)eif.getActivity();
+		
+		if (innerseq.getActivities().size() != 1) {
+			fail("Expecting 1 child activities: "+
+					innerseq.getActivities().size());
+		}
+		
+		if ((innerseq.getActivities().get(0) instanceof Reply) == false) {
+			fail("First activity should be Reply");
+		}
+		
+		Reply reply=(Reply)innerseq.getActivities().get(0);
+		
+		String uri=reply.getURI();
+		
+		if (uri == null) {
+			fail("URI is null");
+		}
+		
+		if (uri.equals("//@activity/@activities.0/@elseif.1/@activity/@activities.0") == false) {
+			fail("URI is invalid: "+uri);
+		}
+	}	
+
+	public void testGetURIIfElse() {
+		BPELLanguageModel model=new DefaultBPELLanguageModel(null);
+
+		String xml="<process xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+					"<sequence>"+
+		       		"<if xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">"+
+				       "<condition/>"+
+				       		"<sequence>"+
+				       			"<receive/>"+
+			       			"</sequence>"+
+				       "<elseif>"+
+				       "<condition/>"+
+			       			"<sequence>"+
+			       				"<invoke/>"+
+			       			"</sequence>"+
+				       "</elseif>"+
+				       "<elseif>"+
+				       "<condition/>"+
+		       				"<sequence>"+
+		       					"<reply/>"+
+		       				"</sequence>"+
+				       "</elseif>"+
+				       "<else>"+
+		       				"<sequence>"+
+		       					"<throw/>"+
+		       				"</sequence>"+
+				       "</else>"+
+				     "</if>"+
+			       "</sequence>"+
+	       		"</process>";
+		
+		org.w3c.dom.Element elem=null;
+		
+		try {
+			javax.xml.parsers.DocumentBuilderFactory factory=
+				javax.xml.parsers.DocumentBuilderFactory.newInstance();
+			
+			factory.setNamespaceAware(true);
+			
+			javax.xml.parsers.DocumentBuilder builder=
+						factory.newDocumentBuilder();
+			
+			java.io.InputStream is=new java.io.ByteArrayInputStream(xml.getBytes());
+			
+			org.w3c.dom.Document doc=builder.parse(is);
+			elem = doc.getDocumentElement();
+			
+			is.close();
+		} catch(Exception e) {
+			e.printStackTrace();
+			fail("Failed to convert to doc");
+		}
+		
+		Process component=new Process(model, elem);		
+		
+		BPELActivity topact=component.getActivity();
+		
+		if ((topact instanceof Sequence) == false) {
+			fail("Top level activity is not Sequence");
+		}
+		
+		Sequence seq=(Sequence)topact;
+		
+		if (seq.getActivities().size() != 1) {
+			fail("Should have 1 activity: "+seq.getActivities().size());
+		}
+		
+		if ((seq.getActivities().get(0) instanceof If) == false) {
+			fail("Activty should be If");
+		}
+		
+		If ifelem=(If)seq.getActivities().get(0);
+
+		if (ifelem.getElsePath() == null) {
+			fail("Else not set");
+		}
+		
+		Else els=ifelem.getElsePath();
+		
+		if ((els.getActivity() instanceof Sequence) == false) {
+			fail("Else activity not a sequence");
+		}
+		
+		Sequence innerseq=(Sequence)els.getActivity();
+		
+		if (innerseq.getActivities().size() != 1) {
+			fail("Expecting 1 child activities: "+
+					innerseq.getActivities().size());
+		}
+		
+		if ((innerseq.getActivities().get(0) instanceof Throw) == false) {
+			fail("First activity should be Throw");
+		}
+		
+		Throw thr=(Throw)innerseq.getActivities().get(0);
+		
+		String uri=thr.getURI();
+		
+		if (uri == null) {
+			fail("URI is null");
+		}
+		
+		if (uri.equals("//@activity/@activities.0/@else/@activity/@activities.0") == false) {
+			fail("URI is invalid: "+uri);
+		}
+	}	
 }



More information about the savara-commits mailing list