Author: scabanovich
Date: 2008-02-21 11:30:15 -0500 (Thu, 21 Feb 2008)
New Revision: 6506
Modified:
trunk/esb/tests/org.jboss.tools.esb.core.test/src/org/jboss/tools/esb/core/test/ESBModelTest.java
Log:
JBIDE-1670 Tests added
Modified:
trunk/esb/tests/org.jboss.tools.esb.core.test/src/org/jboss/tools/esb/core/test/ESBModelTest.java
===================================================================
---
trunk/esb/tests/org.jboss.tools.esb.core.test/src/org/jboss/tools/esb/core/test/ESBModelTest.java 2008-02-21
16:27:34 UTC (rev 6505)
+++
trunk/esb/tests/org.jboss.tools.esb.core.test/src/org/jboss/tools/esb/core/test/ESBModelTest.java 2008-02-21
16:30:15 UTC (rev 6506)
@@ -62,11 +62,7 @@
*/
public void testJMSExample() {
- IFile f = project.getFile(new Path("esb-1.0.1/jboss-esb-jms.xml"));
- assertTrue("Cannot find jboss-esb-jms.xml", f != null);
- XModelObject object = EclipseResourceUtil.createObjectForResource(f);
- assertTrue("Cannot create model for jboss-esb-jms.xml", object != null);
- assertTrue("Wrong entity for jboss-esb-jms.xml",
ESBConstants.ENT_ESB_FILE_101.equals(object.getModelEntity().getName()));
+ XModelObject object = getFileObject("esb-1.0.1",
"jboss-esb-jms.xml");
StringBuffer errorList = new StringBuffer();
checkAttributeValue(object,
@@ -89,11 +85,7 @@
}
public void testFTPExample() {
- IFile f = project.getFile(new Path("esb-1.0.1/jboss-esb-ftp.xml"));
- assertTrue("Cannot find jboss-esb-ftp.xml", f != null);
- XModelObject object = EclipseResourceUtil.createObjectForResource(f);
- assertTrue("Cannot create model for jboss-esb-ftp.xml", object != null);
- assertTrue("Wrong entity for jboss-esb-ftp.xml",
ESBConstants.ENT_ESB_FILE_101.equals(object.getModelEntity().getName()));
+ XModelObject object = getFileObject("esb-1.0.1",
"jboss-esb-ftp.xml");
StringBuffer errorList = new StringBuffer();
checkAttributeValue(object,
@@ -101,69 +93,32 @@
"hostname",
"@FTP_HOSTNAME@",
errorList);
- checkAttributeValue(object,
- "Providers/FTPprovider/helloFTPChannel/Filter",
- "username",
- "@FTP_USERNAME@",
- errorList);
- checkAttributeValue(object,
- "Providers/FTPprovider/helloFTPChannel/Filter",
- "password",
- "@FTP_PASSWORD@",
- errorList);
- checkAttributeValue(object,
- "Providers/FTPprovider/helloFTPChannel/Filter",
- "read only",
- "true",
- errorList);
- checkAttributeValue(object,
- "Providers/FTPprovider/helloFTPChannel/Filter",
- "passive",
- "false",
- errorList);
- checkAttributeValue(object,
- "Providers/FTPprovider/helloFTPChannel/Filter",
- "directory",
- "@FTP_DIRECTORY@",
- errorList);
- checkAttributeValue(object,
- "Providers/FTPprovider/helloFTPChannel/Filter",
- "input suffix",
- ".dat",
- errorList);
- checkAttributeValue(object,
- "Providers/FTPprovider/helloFTPChannel/Filter",
- "work suffix",
- ".esbWorking",
- errorList);
- checkAttributeValue(object,
- "Providers/FTPprovider/helloFTPChannel/Filter",
- "post delete",
- "false",
- errorList);
- checkAttributeValue(object,
- "Providers/FTPprovider/helloFTPChannel/Filter",
- "post suffix",
- ".COMPLETE",
- errorList);
- checkAttributeValue(object,
- "Providers/FTPprovider/helloFTPChannel/Filter",
- "error delete",
- "false",
- errorList);
- checkAttributeValue(object,
- "Providers/FTPprovider/helloFTPChannel/Filter",
- "error suffix",
- ".HAS_ERROR",
- errorList);
+ String ftpFilterPath = "Providers/FTPprovider/helloFTPChannel/Filter";
+ String[][] ftpFilterAttrValues = {
+ {"username", "@FTP_USERNAME@"},
+ {"password", "@FTP_PASSWORD@"},
+ {"read only", "true"},
+ {"passive", "false"},
+ {"directory", "@FTP_DIRECTORY@"},
+ {"input suffix", ".dat"},
+ {"work suffix", ".esbWorking"},
+ {"post delete", "false"},
+ {"post suffix", ".COMPLETE"},
+ {"error delete", "false"},
+ {"error suffix", ".HAS_ERROR"},
+
+ };
+ checkAttributes(object, ftpFilterPath, ftpFilterAttrValues, errorList);
+
+ String ftpGatewayPath = "Services/myFileListener/Listeners/FtpGateway";
checkAttributeValue(object,
- "Services/myFileListener/Listeners/FtpGateway",
+ ftpGatewayPath,
"bus id ref",
"helloFTPChannel",
errorList);
checkAttributeValue(object,
- "Services/myFileListener/Listeners/FtpGateway/remoteFileSystemStrategy-configFile",
+ ftpGatewayPath + "/remoteFileSystemStrategy-configFile",
"value",
"/ftpfile-cache-config.xml",
errorList);
@@ -172,6 +127,151 @@
assertTrue(errorList.toString(), errorList.length() == 0);
}
+ public void testHibernateExample() {
+ XModelObject object = getFileObject("esb-1.0.1",
"jboss-esb-hibernate.xml");
+ StringBuffer errorList = new StringBuffer();
+
+ String hibProviderPath = "Providers/Hibernateprovider";
+ checkAttributeValue(object,
+ hibProviderPath,
+ "hibernate cfg file",
+ "hibernate.cfg.xml",
+ errorList);
+
+ String hibFilterPath = hibProviderPath +
"/helloHibernateChannel/org.jboss.soa.esb.samples.quickstart.hibernateaction.Order";
+ String[][] hibFilterAttrValues = {
+ {"class name",
"org.jboss.soa.esb.samples.quickstart.hibernateaction.Order"},
+ {"event", "onLoad,onDelete"},
+ };
+ checkAttributes(object, hibFilterPath, hibFilterAttrValues, errorList);
+
+ String hibListenerPath =
"Services/myJmsListener/Listeners/HibernateGateway";
+ String[][] hibListeneAttrValues = {
+ {"bus id ref", "helloHibernateChannel"},
+ {"max threads", "1"},
+ {"is gateway", "true"}
+ };
+ checkAttributes(object, hibListenerPath, hibListeneAttrValues, errorList);
+
+ assertTrue(errorList.toString(), errorList.length() == 0);
+ }
+
+ public void testJBRExample() {
+ XModelObject object = getFileObject("esb-1.0.1",
"jboss-esb-jbr.xml");
+
+ StringBuffer errorList = new StringBuffer();
+
+ String jbrProviderPath = "Providers/JBR-Http";
+ String[][] jbrProviderAttrValues = {
+ {"protocol", "http"},
+ {"host", "localhost"},
+ };
+ checkAttributes(object, jbrProviderPath, jbrProviderAttrValues, errorList);
+
+ String jbrBusPath = jbrProviderPath + "/Http-1";
+ String[][] jbrBusAttrValues = {
+ {"port", "9876"},
+ };
+ checkAttributes(object, jbrBusPath, jbrBusAttrValues, errorList);
+
+ String jbrListenerPath = "Services/MyWssService/Listeners/Http-Gateway";
+ String[][] jbrListenerAttrValues = {
+ {"bus id ref", "Http-1"},
+ {"max threads", "1"},
+ {"is gateway", "true"},
+ };
+ checkAttributes(object, jbrListenerPath, jbrListenerAttrValues, errorList);
+
+ assertTrue(errorList.toString(), errorList.length() == 0);
+ }
+
+ public void testFSExample() {
+ XModelObject object = getFileObject("esb-1.0.1",
"jboss-esb-fs.xml");
+
+ StringBuffer errorList = new StringBuffer();
+
+ String fsProviderPath = "Providers/FSprovider1";
+
+ String fsFilterPath = fsProviderPath + "/helloFileChannel/Filter";
+ String[][] fsFilterAttrValues = {
+ {"directory", "@INPUTDIR@"},
+ {"input suffix", ".dat"},
+ {"work suffix", ".esbWorking"},
+ {"post delete", "false"},
+ {"post directory", "@OUTPUTDIR@"},
+ {"post suffix", ".sentToEsb"},
+ {"error delete", "false"},
+ {"error directory", "@ERRORDIR@"},
+ {"error suffix", ".IN_ERROR"},
+
+ };
+ checkAttributes(object, fsFilterPath, fsFilterAttrValues, errorList);
+
+ String fsListenerPath = "Services/myFileListener/Listeners/FileGateway";
+ String[][] fsListenerAttrValues = {
+ {"bus id ref", "helloFileChannel"},
+ {"max threads", "1"},
+ {"is gateway", "true"},
+ {"poll frequency seconds", "10"}
+ };
+ checkAttributes(object, fsListenerPath, fsListenerAttrValues, errorList);
+
+ assertTrue(errorList.toString(), errorList.length() == 0);
+ }
+
+ public void testSQLExample() {
+ XModelObject object = getFileObject("esb-1.0.1",
"jboss-esb-sql.xml");
+
+ StringBuffer errorList = new StringBuffer();
+
+ String sqlProviderPath = "Providers/SQLprovider";
+ String[][] sqlProviderAttrValues = {
+ {"url", "jdbc:hsqldb:hsql://localhost:1703"},
+ {"driver", "org.hsqldb.jdbcDriver"},
+ {"username", "sa"},
+ {"password", ""},
+ };
+ checkAttributes(object, sqlProviderPath, sqlProviderAttrValues, errorList);
+
+ String sqlFilterPath = "Providers/SQLprovider" +
"/helloSQLChannel/Filter";
+ String[][] sqlFilterAttrValues = {
+ {"tablename", "GATEWAY_TABLE"},
+ {"status column", "STATUS_COL"},
+ {"order by", "DATA_COLUMN"},
+ {"where condition", "DATA_COLUMN like 'data%'"},
+ {"message id column", "UNIQUE_ID"}
+ };
+ checkAttributes(object, sqlFilterPath, sqlFilterAttrValues, errorList);
+
+ String sqlListenerPath = "Services/myJmsListener/Listeners/SqlGateway";
+ String[][] sqlListenerAttrValues = {
+ {"bus id ref", "helloSQLChannel"},
+ {"max threads", "1"},
+ {"is gateway", "true"}
+ };
+ checkAttributes(object, sqlListenerPath, sqlListenerAttrValues, errorList);
+
+ assertTrue(errorList.toString(), errorList.length() == 0);
+ }
+
+
+ XModelObject getFileObject(String parentPath, String xmlname) {
+ IFile f = project.getFile(new Path(parentPath + "/" + xmlname));
+ assertTrue("Cannot find " + xmlname, f != null);
+ XModelObject object = EclipseResourceUtil.createObjectForResource(f);
+ assertTrue("Cannot create model for " + xmlname, object != null);
+ assertTrue("Wrong entity for " + xmlname,
ESBConstants.ENT_ESB_FILE_101.equals(object.getModelEntity().getName()));
+ return object;
+ }
+
+ void checkAttributes(XModelObject object, String path, String[][] attrValuePairs,
StringBuffer errorList) {
+ for (int i = 0; i < attrValuePairs.length; i++) {
+ String attrName = attrValuePairs[i][0];
+ String attrValue = attrValuePairs[i][1];
+ checkAttributeValue(object, path, attrName, attrValue, errorList);
+ }
+ }
+
protected boolean checkAttributeValue(XModelObject object, String path, String
attribute, String testValue, StringBuffer errorList) {
XModelObject child = object.getChildByPath(path);
if(child == null) {