[jboss-svn-commits] JBL Code SVN: r5357 - in labs/jbossesb/trunk/product/core: common/src/org/jboss/soa/esb/common/bizclasses common/src/org/jboss/soa/esb/util common/tests/src/org/jboss/soa/esb/common common/tests/src/org/jboss/soa/esb/common/bizclasses common/tests/src/org/jboss/soa/esb/util services/src/org/jboss/soa/esb/internal/core/objectstore
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Jul 31 06:42:37 EDT 2006
Author: tfennelly
Date: 2006-07-31 06:42:18 -0400 (Mon, 31 Jul 2006)
New Revision: 5357
Added:
labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/common/bizclasses/
labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/common/bizclasses/BatchProcessUnitTest.java
labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/util/BaseBusinessObjectUnitTest.java
labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/util/BaseBusinessObjectUnitTest_testfile1.xml
labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/util/TestBob.java
Modified:
labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/common/bizclasses/BatchProcess.java
labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/common/bizclasses/OneValue.java
labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/util/BaseBusinessObject.java
labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/util/BobjStdDTOUnitTest.java
labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/internal/core/objectstore/AbstractBobjStore.java
Log:
added more unit tests
Modified: labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/common/bizclasses/BatchProcess.java
===================================================================
--- labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/common/bizclasses/BatchProcess.java 2006-07-31 08:56:43 UTC (rev 5356)
+++ labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/common/bizclasses/BatchProcess.java 2006-07-31 10:42:18 UTC (rev 5357)
@@ -1,223 +1,265 @@
/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.soa.esb.common.bizclasses;
-import java.util.*;
-import java.text.*;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.EnumMap;
+import java.util.List;
-import org.jboss.soa.esb.util.*;
+import org.jboss.soa.esb.util.BaseBusinessObject;
+import org.jboss.soa.esb.util.BobjStdDTO;
+import org.jboss.soa.esb.util.EsbUtil;
-public class BatchProcess extends BaseBusinessObject
-{
- public enum ATTRIB
- {srcApp
- ,batchNum
- ,createStamp
- ,commitStamp
- };
- private EnumMap<ATTRIB,String>m_oData;
+public class BatchProcess extends BaseBusinessObject {
- public enum CHLD_LIST
- {Hdrs
- ,Itms
- };
- public List<OneValue> m_olHeaders, m_olItems;
+ public enum ATTRIB {
+ srcApp, batchNum, createStamp, commitStamp
+ };
- /**
- * @param p_sElem String
- * @see BaseBusinessObject#BaseBusinessObject(String)
- */
- public BatchProcess(String p_sElem) {super(p_sElem);}
- /**
- * @param p_sElem String
- * @param p_lUid long
- * @see BaseBusinessObject#BaseBusinessObject(String,long)
- */
- public BatchProcess(String p_sElem, long p_lUid) {super(p_sElem, p_lUid);}
- /**
- *
- * @param p_oDto BobjStdDTO
- * @throws Exception
- * @see BaseBusinessObject#BaseBusinessObject(BobjStdDTO)
- */
+ private EnumMap<ATTRIB, String> m_oData;
- @SuppressWarnings("unchecked")
- public BatchProcess(BobjStdDTO p_oDto) throws Exception
- { super(p_oDto);
- for (ATTRIB oCurr : ATTRIB.values())
- setField(oCurr,p_oDto.getAttr(oCurr.toString()));
+ public enum CHLD_LIST {
+ Hdrs, Itms
+ };
- m_olHeaders = (List<OneValue>)p_oDto.getChildObjList
- (CHLD_LIST.Hdrs.toString(),OneValue.class);
- m_olItems = (List<OneValue>)p_oDto.getChildObjList
- (CHLD_LIST.Itms.toString(),OneValue.class);
- }//__________________________________________
- /**
- *
- * @throws Exception
- * @return BobjStdDTO
- * @see BusinessObject#toDTO()
- */
- public BobjStdDTO toDTO() throws Exception
- { BobjStdDTO oRet = super.toDTO();
- for (ATTRIB oCurr : ATTRIB.values())
- oRet.addAttr(oCurr.toString(),getField(oCurr));
+ public List<OneValue> m_olHeaders, m_olItems;
- oRet.addDto(CHLD_LIST.Hdrs.toString() ,getDtoList(OneValue.class, m_olItems));
- oRet.addDto(CHLD_LIST.Itms.toString() ,getDtoList(OneValue.class, m_olHeaders));
- return oRet;
+ /**
+ * @param p_sElem
+ * String
+ * @param p_lUid
+ * long
+ * @see BaseBusinessObject#BaseBusinessObject(String,long)
+ */
+ public BatchProcess(String p_sElem, long p_lUid) {
+ super(p_sElem, p_lUid);
+ }
- }//_________________________________________
- //Setters
- /**
- * Add a reference to a BusinessObject (it's UID) to the list of batch
- * header BusinessObjects
- * @param p_l long - The UID of the BusinessObject to add to the header list
- * @see BatchProcess#m_olHeaders
- */
- public void addHeaderUid(long p_l)
- { if(null==m_olHeaders) m_olHeaders = new ArrayList<OneValue>();
- m_olHeaders.add(OneValue.getLongValue(p_l));
- }//_____________________________________________
- /**
- * Remove an object from the header list
- * @param p_i int - index of header to remove
- * @return long - UID of the object removed
- * @see BatchProcess#addHeaderUid(long)
- */
- public long rmvHeaderAt (int p_i)
- { if (null == m_olHeaders) return -1;
- if(p_i < 0 || p_i >=m_olHeaders.size()) return -1;
- return Long.parseLong(((OneValue) m_olHeaders.remove(p_i)).m_sVal);
- }//_____________________________________________
+ /**
+ *
+ * @param p_oDto
+ * BobjStdDTO
+ * @throws Exception
+ * @see BaseBusinessObject#BaseBusinessObject(BobjStdDTO)
+ */
- /**
- * Add a reference to a BusinessObject (it's UID) to the list of batch
- * items BusinessObjects
- * @param p_l long - The UID of the BusinessObject to add to the item list
- * @see BatchProcess#m_olItems
- */
- public void addChildUid(long p_l)
- { if(null==m_olItems) m_olItems = new ArrayList<OneValue>();
- m_olItems.add(OneValue.getLongValue(p_l));
- }//_____________________________________________
+ @SuppressWarnings("unchecked")
+ public BatchProcess(BobjStdDTO p_oDto) throws Exception {
+ super(p_oDto);
+ for (ATTRIB oCurr : ATTRIB.values())
+ setField(oCurr, p_oDto.getAttr(oCurr.toString()));
- /**
- * Remove an object from the item list
- * @param p_i int - index of item to remove
- * @return long - UID of the object removed
- * @see BatchProcess#addChildUid(long)
- */
- public long rmvChildAt (int p_i)
- { if (null == m_olItems) return -1;
- if(p_i < 0 || p_i >=m_olItems.size()) return -1;
- return Long.parseLong(((OneValue) m_olItems.remove(p_i)).m_sVal);
- }//_____________________________________________
+ m_olHeaders = (List<OneValue>) p_oDto.getChildObjList(CHLD_LIST.Hdrs
+ .toString(), OneValue.class);
+ m_olItems = (List<OneValue>) p_oDto.getChildObjList(CHLD_LIST.Itms
+ .toString(), OneValue.class);
+ }// __________________________________________
- //getters
- /**
- * Return the number of header objects in this batch
- * @return int - The size of the header list
- * @see BatchProcess#m_olHeaders
- */
- public int getHeaderCount ()
- { return (null == m_olHeaders)? 0 : m_olHeaders.size();
- }//_______________________________
+ /**
+ *
+ * @throws Exception
+ * @return BobjStdDTO
+ * @see BusinessObject#toDTO()
+ */
+ public BobjStdDTO toDTO() throws Exception {
+ BobjStdDTO oRet = super.toDTO();
+ for (ATTRIB oCurr : ATTRIB.values())
+ oRet.addAttr(oCurr.toString(), getField(oCurr));
- /**
- * Get an object from the header list
- * @param p_i int - index of header object to get
- * @return long - UID of the object at requested position - or minus 1 (-1) if invalid index
- * @see BatchProcess#m_olHeaders
- */
- public long getHeaderAt (int p_i)
- { if (null == m_olHeaders) return -1;
- if(p_i < 0 || p_i >=m_olHeaders.size()) return -1;
- return Long.parseLong(((OneValue) m_olHeaders.get(p_i)).m_sVal);
- }//_____________________________________________
+ oRet.addDto(CHLD_LIST.Hdrs.toString(), getDtoList(OneValue.class,
+ m_olItems));
+ oRet.addDto(CHLD_LIST.Itms.toString(), getDtoList(OneValue.class,
+ m_olHeaders));
+ return oRet;
- /**
- * Return the number of item objects in this batch
- * @return int - The size of the item list
- * @see BatchProcess#m_olItems
- */
- public int getChildCount ()
- { return (null == m_olItems)? 0 : m_olItems.size();
- }//_______________________________
+ }// _________________________________________
- /**
- * Get an object from the item list
- * @param p_i int - index of item object to get
- * @return long - UID of the object at requested position - or minus 1 (-1) if invalid index
- * @see BatchProcess#m_olItems
- */
- public long getChildAt (int p_i)
- { if (null == m_olItems) return -1;
- if(p_i < 0 || p_i >=m_olItems.size()) return -1;
- return Long.parseLong(((OneValue) m_olItems.get(p_i)).m_sVal);
- }//_____________________________________________
+ // Setters
+ /**
+ * Add a reference to a BusinessObject (it's UID) to the list of batch
+ * header BusinessObjects
+ *
+ * @param p_l
+ * long - The UID of the BusinessObject to add to the header list
+ * @see BatchProcess#m_olHeaders
+ */
+ public void addHeaderUid(long p_l) {
+ if (null == m_olHeaders)
+ m_olHeaders = new ArrayList<OneValue>();
+ m_olHeaders.add(OneValue.getLongValue(p_l));
+ }// _____________________________________________
- private static final SimpleDateFormat s_FD
- = new SimpleDateFormat("yyyyMMdd HH:mm:ss.S");
- protected final String showStamp(ATTRIB pFld)
- { long lMillis = EsbUtil.parseLong(getField(pFld));
- if (lMillis < 1) return "";
- return s_FD.format(new Date(lMillis));
- }//_____________________________________________
- /**
- * Obtain a String[] of 'human readable' attributes that will help
- * identify the BatchProcess object
- * <p>These attributes will be stored in the batch_index table in the
- * Object store to allow for standard SQL queries. Once the desired
- * object is identified, we can access the Object table using the Object's
- * that is referenced in the batch_index table UID</p>
- * @return String[] - Batch number, Creation time, Commit time
- */
- public String[] locator()
- { String sFrom = getField(ATTRIB.srcApp);
- String sNumber = getField(ATTRIB.batchNum);
- return new String[]
- { (null==sFrom) ? "":sFrom.substring(0,Math.min(50,sFrom.length()))
- ,(null==sNumber) ? "":sNumber
- ,showStamp(ATTRIB.createStamp)
- ,showStamp(ATTRIB.commitStamp)
- };
- } //__________________________________
+ /**
+ * Remove an object from the header list
+ *
+ * @param p_i
+ * int - index of header to remove
+ * @return long - UID of the object removed
+ * @see BatchProcess#addHeaderUid(long)
+ */
+ public long rmvHeaderAt(int p_i) {
+ if (null == m_olHeaders)
+ return -1;
+ if (p_i < 0 || p_i >= m_olHeaders.size())
+ return -1;
+ return Long.parseLong(((OneValue) m_olHeaders.remove(p_i)).m_sVal);
+ }// _____________________________________________
- public String setField(ATTRIB pKey, String pVal)
- { if (null==pKey) return null;
- String sRet = (null==m_oData)? null : m_oData.remove(pKey);
- if (! EsbUtil.isNullString(pVal))
- { if (null==m_oData)
- m_oData = new EnumMap<ATTRIB,String>(ATTRIB.class);
- m_oData.put(pKey,pVal);
- }
- return sRet;
- } //__________________________________
+ /**
+ * Add a reference to a BusinessObject (it's UID) to the list of batch items
+ * BusinessObjects
+ *
+ * @param p_l
+ * long - The UID of the BusinessObject to add to the item list
+ * @see BatchProcess#m_olItems
+ */
+ public void addChildUid(long p_l) {
+ if (null == m_olItems)
+ m_olItems = new ArrayList<OneValue>();
+ m_olItems.add(OneValue.getLongValue(p_l));
+ }// _____________________________________________
- public String getField(ATTRIB pKey)
- { if (null==pKey) return null;
- if (null==m_oData) return null;
- return m_oData.get(pKey);
- } //__________________________________
-} //____________________________________________________________________________
+ /**
+ * Remove an object from the item list
+ *
+ * @param p_i
+ * int - index of item to remove
+ * @return long - UID of the object removed
+ * @see BatchProcess#addChildUid(long)
+ */
+ public long rmvChildAt(int p_i) {
+ if (null == m_olItems)
+ return -1;
+ if (p_i < 0 || p_i >= m_olItems.size())
+ return -1;
+ return Long.parseLong(((OneValue) m_olItems.remove(p_i)).m_sVal);
+ }// _____________________________________________
+
+ // getters
+ /**
+ * Return the number of header objects in this batch
+ *
+ * @return int - The size of the header list
+ * @see BatchProcess#m_olHeaders
+ */
+ public int getHeaderCount() {
+ return (null == m_olHeaders) ? 0 : m_olHeaders.size();
+ }// _______________________________
+
+ /**
+ * Get an object from the header list
+ *
+ * @param p_i
+ * int - index of header object to get
+ * @return long - UID of the object at requested position - or minus 1 (-1)
+ * if invalid index
+ * @see BatchProcess#m_olHeaders
+ */
+ public long getHeaderAt(int p_i) {
+ if (null == m_olHeaders)
+ return -1;
+ if (p_i < 0 || p_i >= m_olHeaders.size())
+ return -1;
+ return Long.parseLong(((OneValue) m_olHeaders.get(p_i)).m_sVal);
+ }// _____________________________________________
+
+ /**
+ * Return the number of item objects in this batch
+ *
+ * @return int - The size of the item list
+ * @see BatchProcess#m_olItems
+ */
+ public int getChildCount() {
+ return (null == m_olItems) ? 0 : m_olItems.size();
+ }// _______________________________
+
+ /**
+ * Get an object from the item list
+ *
+ * @param p_i
+ * int - index of item object to get
+ * @return long - UID of the object at requested position - or minus 1 (-1)
+ * if invalid index
+ * @see BatchProcess#m_olItems
+ */
+ public long getChildAt(int p_i) {
+ if (null == m_olItems)
+ return -1;
+ if (p_i < 0 || p_i >= m_olItems.size())
+ return -1;
+ return Long.parseLong(((OneValue) m_olItems.get(p_i)).m_sVal);
+ }// _____________________________________________
+
+ private static final SimpleDateFormat s_FD = new SimpleDateFormat(
+ "yyyyMMdd HH:mm:ss.S");
+
+ protected final String showStamp(ATTRIB pFld) {
+ long lMillis = EsbUtil.parseLong(getField(pFld));
+ if (lMillis < 1)
+ return "";
+ return s_FD.format(new Date(lMillis));
+ }// _____________________________________________
+
+ /**
+ * Obtain a String[] of 'human readable' attributes that will help identify
+ * the BatchProcess object.
+ * <p>
+ * These attributes will be stored in the batch_index table in the Object
+ * store to allow for standard SQL queries. Once the desired object is
+ * identified, we can access the Object table using the Object's that are
+ * referenced in the batch_index table UID
+ * </p>
+ *
+ * @return String[] - Batch number, Creation time, Commit time
+ */
+ public String[] locator() {
+ String sFrom = getField(ATTRIB.srcApp);
+ String sNumber = getField(ATTRIB.batchNum);
+ return new String[] {
+ (null == sFrom) ? "" : sFrom.substring(0, Math.min(50, sFrom
+ .length())), (null == sNumber) ? "" : sNumber,
+ showStamp(ATTRIB.createStamp), showStamp(ATTRIB.commitStamp) };
+ } // __________________________________
+
+ public String setField(ATTRIB pKey, String pVal) {
+ if (null == pKey)
+ return null;
+ String sRet = (null == m_oData) ? null : m_oData.remove(pKey);
+ if (!EsbUtil.isNullString(pVal)) {
+ if (null == m_oData)
+ m_oData = new EnumMap<ATTRIB, String>(ATTRIB.class);
+ m_oData.put(pKey, pVal);
+ }
+ return sRet;
+ } // __________________________________
+
+ public String getField(ATTRIB pKey) {
+ if (null == pKey)
+ return null;
+ if (null == m_oData)
+ return null;
+ return m_oData.get(pKey);
+ } // __________________________________
+} // ____________________________________________________________________________
Modified: labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/common/bizclasses/OneValue.java
===================================================================
--- labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/common/bizclasses/OneValue.java 2006-07-31 08:56:43 UTC (rev 5356)
+++ labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/common/bizclasses/OneValue.java 2006-07-31 10:42:18 UTC (rev 5357)
@@ -1,89 +1,98 @@
/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.soa.esb.common.bizclasses;
import org.jboss.soa.esb.util.*;
/**
- * Utility class used to serialize a String within a list
- * of child BusinessObjects
- * It provides no functionality other than allowing the inclusion of
- * a String (eventually with a role and an element name) in a list of children
+ * Utility class used to serialize a String within a list of child
+ * BusinessObjects It provides no functionality other than allowing the
+ * inclusion of a String (eventually with a role and an element name) in a list
+ * of children
*/
-public class OneValue extends BaseBusinessObject
-{
- private static final String A_VAL = "v";
- public String m_sVal;
+public class OneValue extends BaseBusinessObject {
+ private static final String A_VAL = "v";
- /**
- * @see BaseBusinessObject#BaseBusinessObject(BobjStdDTO)
- * @param p_sElem String
- */
- public OneValue(String p_sElem) {super(p_sElem);}
- /**
- * @see BaseBusinessObject#BaseBusinessObject(BobjStdDTO)
- * @param p_sElem String
- * @param p_lUid long
- */
- public OneValue(String p_sElem, long p_lUid) {super(p_sElem, p_lUid);}
+ public String m_sVal;
- /**
- * @see BaseBusinessObject#BaseBusinessObject(BobjStdDTO)
- * @param p_oDto BobjStdDTO
- * @throws Exception
- */
- public OneValue(BobjStdDTO p_oDto) throws Exception
- {super(p_oDto);
- m_sVal = p_oDto.getAttr(A_VAL);
- } //___________________________________
+ /**
+ * @see BaseBusinessObject#BaseBusinessObject(BobjStdDTO)
+ * @param p_sElem
+ * String
+ */
+ public OneValue(String p_sElem) {
+ super(p_sElem);
+ }
- /**
- * @see BusinessObject#toDTO()
- * @throws Exception
- * @return BobjStdDTO
- */
- public BobjStdDTO toDTO() throws Exception
- { BobjStdDTO oRet = super.toDTO();
- oRet.addAttr(A_VAL, m_sVal);
- return oRet;
- } //___________________________________
+ /**
+ * @see BaseBusinessObject#BaseBusinessObject(BobjStdDTO)
+ * @param p_sElem
+ * String
+ * @param p_lUid
+ * long
+ */
+ public OneValue(String p_sElem, long p_lUid) {
+ super(p_sElem, p_lUid);
+ }
- public static final OneValue getLongValue(Long p_l)
- { OneValue oCurr = new OneValue((String)null);
- if (null!=p_l)
- oCurr.m_sVal = Long.toString(p_l);
- return oCurr;
- } //___________________________________
+ /**
+ * @see BaseBusinessObject#BaseBusinessObject(BobjStdDTO)
+ * @param p_oDto
+ * BobjStdDTO
+ * @throws Exception
+ */
+ public OneValue(BobjStdDTO p_oDto) throws Exception {
+ super(p_oDto);
+ m_sVal = p_oDto.getAttr(A_VAL);
+ } // ___________________________________
- public static final OneValue getStringValue(String p_sVal)
- { return getStringValue(p_sVal,null);
- } //___________________________________
+ /**
+ * @see BusinessObject#toDTO()
+ * @throws Exception
+ * @return BobjStdDTO
+ */
+ public BobjStdDTO toDTO() throws Exception {
+ BobjStdDTO oRet = super.toDTO();
+ oRet.addAttr(A_VAL, m_sVal);
+ return oRet;
+ } // ___________________________________
- public static final OneValue getStringValue(String p_sVal, String p_sRole)
- { OneValue oCurr = new OneValue((String)null);
- oCurr.m_sVal = p_sVal;
- oCurr.setRole(p_sRole);
- return oCurr;
- } //___________________________________
+ public static final OneValue getLongValue(Long p_l) {
+ OneValue oCurr = new OneValue((String) null);
+ if (null != p_l)
+ oCurr.m_sVal = Long.toString(p_l);
+ return oCurr;
+ } // ___________________________________
-} //____________________________________________________________________________
+ public static final OneValue getStringValue(String p_sVal) {
+ return getStringValue(p_sVal, null);
+ } // ___________________________________
+
+ public static final OneValue getStringValue(String p_sVal, String p_sRole) {
+ OneValue oCurr = new OneValue((String) null);
+ oCurr.m_sVal = p_sVal;
+ oCurr.setRole(p_sRole);
+ return oCurr;
+ } // ___________________________________
+
+} // ____________________________________________________________________________
Modified: labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/util/BaseBusinessObject.java
===================================================================
--- labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/util/BaseBusinessObject.java 2006-07-31 08:56:43 UTC (rev 5356)
+++ labs/jbossesb/trunk/product/core/common/src/org/jboss/soa/esb/util/BaseBusinessObject.java 2006-07-31 10:42:18 UTC (rev 5357)
@@ -25,19 +25,20 @@
import java.util.*;
import java.lang.reflect.*;
-public class BaseBusinessObject {
+public abstract class BaseBusinessObject {
+
public BobjStdDTO toDTO() throws Exception {
- return getBaseDTO();
+ String sClass = getClass().getSimpleName();
+ BobjStdDTO oRet = new BobjStdDTO(sClass, getElemNm(), null);
+ if (hasUid())
+ try {
+ oRet.addAttr(HIDDEN.uid.toString(), Long.toString(m_lUid));
+ } catch (Exception e) {
+ }
+ putStdAtts(oRet);
+ return oRet;
}
- public String classNm() {
- return this.getClass().getSimpleName();
- }
-
- public boolean isNull() {
- return false;
- }
-
public String toString() {
try {
return this.toDTO().toXml();
@@ -50,10 +51,6 @@
return new String[] {};
}
- public String[] locator(int p_i) {
- return (0 == p_i) ? locator() : new String[] {};
- }
-
/**
* Get all locators for a given BaseBusinessObject
* <p />
@@ -65,14 +62,6 @@
return new String[][] { locator() };
}
- public final ObjLocator getObjLocator() {
- return getObjLocator(0);
- }
-
- public final ObjLocator getObjLocator(int p_i) {
- return new ObjLocator(m_lUid, locator(p_i));
- }
-
private enum ATTRIB {
elem, rol
};
@@ -83,7 +72,7 @@
private EnumMap<ATTRIB, String> m_oData;
- public String setField(ATTRIB pKey, String pVal) {
+ private String setField(ATTRIB pKey, String pVal) {
if (null == pKey)
return null;
String sRet = (null == m_oData) ? null : m_oData.remove(pKey);
@@ -95,7 +84,7 @@
return sRet;
} // __________________________________
- public String getField(ATTRIB pKey) {
+ private String getField(ATTRIB pKey) {
if (null == pKey)
return null;
if (null == m_oData)
@@ -190,11 +179,16 @@
protected BaseBusinessObject(String p_sElem, long p_lUid) {
setField(ATTRIB.elem, p_sElem);
m_lUid = p_lUid;
- if (null != getElemNm())
+
+ if (null != getElemNm()) {
return;
+ }
+
String sClass = getClass().getSimpleName();
- if (null == p_sElem)
+
+ if (null == p_sElem) {
setField(ATTRIB.elem, sClass);
+ }
} // ________________________________
protected BaseBusinessObject(BobjStdDTO p_oDto) throws Exception {
@@ -231,10 +225,10 @@
public static final BaseBusinessObject getFromDTO(BobjStdDTO p_oDto)
throws Exception {
- return new BaseBusinessObject().fromDTO(p_oDto);
+ return BaseBusinessObject.fromDTO(p_oDto);
} // ________________________________
- private BaseBusinessObject fromDTO(BobjStdDTO p_oDto) throws Exception {
+ private static BaseBusinessObject fromDTO(BobjStdDTO p_oDto) throws Exception {
if (null == p_oDto)
return null;
@@ -248,19 +242,7 @@
return oRet;
} // ________________________________
- protected BobjStdDTO getBaseDTO() {
- String sClass = getClass().getSimpleName();
- BobjStdDTO oRet = new BobjStdDTO(sClass, getElemNm(), null);
- if (hasUid())
- try {
- oRet.addAttr(HIDDEN.uid.toString(), Long.toString(m_lUid));
- } catch (Exception e) {
- }
- putStdAtts(oRet);
- return oRet;
- } // ________________________________
-
- protected void putStdAtts(BobjStdDTO p_oRet) {
+ private void putStdAtts(BobjStdDTO p_oRet) {
try {
p_oRet.addAttr(ATTRIB.rol.toString(), getRole());
// if (this instanceof XtfStorable)
@@ -284,14 +266,20 @@
} // ________________________________
public static final BobjStdDTO getDtoList(Class p_Class,
- List<? extends BaseBusinessObject> p_oList) throws Exception {
- if (null == p_oList)
+ List<? extends BaseBusinessObject> p_oBobList) throws Exception {
+
+ if (null == p_oBobList || p_oBobList.isEmpty()) {
return null;
- List<BobjStdDTO> LL = new ArrayList<BobjStdDTO>();
- for (BaseBusinessObject oCurr : p_oList)
- LL.add(oCurr.toDTO());
- String sElem = p_Class.getSimpleName();
- return (LL.size() < 1) ? null : new BobjStdDTO(sElem, null, LL);
+ }
+
+ // Create a list of DTOs from the BaseBusinessObject list...
+ List<BobjStdDTO> dtoList = new ArrayList<BobjStdDTO>();
+ for (BaseBusinessObject oCurr : p_oBobList) {
+ dtoList.add(oCurr.toDTO());
+ }
+
+ // Package up the DTO list in a parent DTO and return ...
+ return new BobjStdDTO(p_Class.getSimpleName(), null, dtoList);
} // __________________________________
public static BaseBusinessObject getRoleFromList(String p_sRole,
@@ -305,58 +293,4 @@
return oCurr;
return null;
} // __________________________________
-
- public static BaseBusinessObject getElemFromList(String p_sElemNm,
- List<? extends BaseBusinessObject> p_oL) {
- if (null == p_sElemNm)
- return null;
- if (null == p_oL)
- return null;
- for (BaseBusinessObject oCurr : p_oL)
- if (p_sElemNm.equals(oCurr.getElemNm()))
- return oCurr;
- return null;
- } // __________________________________
-
- public static BaseBusinessObject rmvElemFromList(String p_sElemNm,
- List<BaseBusinessObject> p_oL) {
- if (null == p_sElemNm)
- return null;
- if (null == p_oL)
- return null;
- for (ListIterator<BaseBusinessObject> II = p_oL.listIterator(); II
- .hasNext();) {
- BaseBusinessObject oCurr = II.next();
- if (p_sElemNm.equals(oCurr.getElemNm())) {
- II.remove();
- return oCurr;
- }
- }
- return null;
- } // __________________________________
-
- public static boolean anyFieldNull(String[] p_sa) {
- if (null == p_sa)
- return false;
- for (int i1 = 0; i1 < p_sa.length; i1++)
- if (null == p_sa[i1])
- return true;
- return false;
- } // __________________________________
-
- public static boolean allFieldsNull(String[] p_sa) {
- if (null == p_sa)
- return false;
- if (p_sa.length < 1)
- return false;
- for (int i1 = 0; i1 < p_sa.length; i1++) {
- String sCurr = p_sa[i1];
- if (null == sCurr)
- continue;
- if (sCurr.trim().length() > 0)
- return false;
- }
- return true;
- } // __________________________________
-
} // ____________________________________________________________________________
Added: labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/common/bizclasses/BatchProcessUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/common/bizclasses/BatchProcessUnitTest.java 2006-07-31 08:56:43 UTC (rev 5356)
+++ labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/common/bizclasses/BatchProcessUnitTest.java 2006-07-31 10:42:18 UTC (rev 5357)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.common.bizclasses;
+
+import junit.framework.TestCase;
+
+/**
+ * BatchProcess unit tests.
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class BatchProcessUnitTest extends TestCase {
+
+ public void test_BatchProcess() {
+
+ }
+}
Added: labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/util/BaseBusinessObjectUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/util/BaseBusinessObjectUnitTest.java 2006-07-31 08:56:43 UTC (rev 5356)
+++ labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/util/BaseBusinessObjectUnitTest.java 2006-07-31 10:42:18 UTC (rev 5357)
@@ -0,0 +1,113 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.util;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.soa.esb.StreamUtils;
+
+import junit.framework.TestCase;
+
+/**
+ * BaseBusinessObject unit tests.
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class BaseBusinessObjectUnitTest extends TestCase {
+
+ private TestBob bob;
+
+ protected void setUp() throws Exception {
+ bob = new TestBob("blah", 1234L);
+ // Set the base properties...
+ bob.setBatchNum(1234);
+ bob.setElemNm("whoosh");
+ bob.setPackage();
+ bob.setRole("sweeper");
+ bob.setSnap(1234);
+ bob.setSnapDate("12/12/2000");
+ bob.setStamp(1234);
+ bob.setUid(1234);
+ }
+
+ public void test_BaseBusinessObject() throws Exception {
+
+ // ToDTO the bob and back again...
+ BobjStdDTO dtoBefore = bob.toDTO();
+ bob = (TestBob) BaseBusinessObject.getFromDTO(dtoBefore);
+
+ // Check the base properties...
+ assertEquals(1234, bob.getBatchNum());
+ assertEquals(null, bob.getElemNm()); // REVIEW: What happened to "whoosh"
+ assertEquals("sweeper", bob.getRole());
+ assertEquals(1234, bob.getSnap());
+ assertEquals(null, bob.getSnapDate()); // REVIEW: WHat happened to the snap date of "12/12/2000"
+ assertEquals(1234, bob.getStamp());
+ assertEquals(1234, bob.getUid());
+
+ BobjStdDTO dtoAfter = bob.toDTO();
+ assertEquals(TestBob.MY_BOB_PROP_VAL, dtoAfter.getAttr(TestBob.MY_BOB_PROP));
+ assertNotSame(dtoBefore.toXml(), dtoAfter.toXml()); // REVIEW: Would have expected these to be the same!!
+
+ // Construct using the default constructor...
+ bob = new TestBob();
+ assertEquals("TestBob", bob.getElemNm());
+ }
+
+ public void test_getDtoList() throws Exception {
+ List<BaseBusinessObject> bobList = new ArrayList<BaseBusinessObject>();
+
+ bobList.add(new TestBob());
+ bobList.add(new TestBob());
+ bobList.add(new TestBob());
+
+ BobjStdDTO dto = BaseBusinessObject.getDtoList(TestBob.class, bobList);
+ String expected = new String(StreamUtils.readStream(getClass().getResourceAsStream("BaseBusinessObjectUnitTest_testfile1.xml")));
+ assertEquals(expected, dto.toXml());
+ }
+
+ public void test_getRoleFromList() throws Exception {
+ List<BaseBusinessObject> bobList = new ArrayList<BaseBusinessObject>();
+
+ bobList.add(new TestBob());
+ bobList.add(new TestBob());
+ bobList.add(new TestBob());
+
+ bobList.get(0).setRole("role0");
+ bobList.get(1).setRole("role1");
+ bobList.get(2).setRole("role2");
+
+ assertEquals(bobList.get(0), BaseBusinessObject.getRoleFromList("role0", bobList));
+ assertEquals(bobList.get(1), BaseBusinessObject.getRoleFromList("role1", bobList));
+ assertEquals(bobList.get(2), BaseBusinessObject.getRoleFromList("role2", bobList));
+
+ assertEquals(null, BaseBusinessObject.getRoleFromList(null, bobList));
+ assertEquals(null, BaseBusinessObject.getRoleFromList("blah", null));
+ }
+
+ public void test_misc() {
+ // Noddy methods - just touching to improve the coverage figures :-)
+ bob.toString();
+ bob.locator();
+ bob.allLocators();
+ }
+}
Added: labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/util/BaseBusinessObjectUnitTest_testfile1.xml
===================================================================
--- labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/util/BaseBusinessObjectUnitTest_testfile1.xml 2006-07-31 08:56:43 UTC (rev 5356)
+++ labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/util/BaseBusinessObjectUnitTest_testfile1.xml 2006-07-31 10:42:18 UTC (rev 5357)
@@ -0,0 +1 @@
+<TestBob List="yes"><it myBobProp="myBobProp-hello"/><it myBobProp="myBobProp-hello"/><it myBobProp="myBobProp-hello"/></TestBob>
\ No newline at end of file
Modified: labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/util/BobjStdDTOUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/util/BobjStdDTOUnitTest.java 2006-07-31 08:56:43 UTC (rev 5356)
+++ labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/util/BobjStdDTOUnitTest.java 2006-07-31 10:42:18 UTC (rev 5357)
@@ -21,9 +21,13 @@
*/
package org.jboss.soa.esb.util;
+import java.util.ArrayList;
+import java.util.List;
+
import org.jboss.soa.esb.StreamUtils;
import org.jboss.soa.esb.StringUtils;
import org.jboss.soa.esb.W3CDomUtils;
+import org.jboss.soa.esb.common.bizclasses.Address;
import org.w3c.dom.Document;
import junit.framework.TestCase;
@@ -96,6 +100,32 @@
assertTrue(StringUtils.equalsIgnoreLinebreaks(source, serialisedVer, false));
}
+ public void test_getChildObjList() throws Exception {
+ String source = new String(StreamUtils.readStream(
+ getClass().getResourceAsStream("BobjStdDTOUnitTest_testfile1.xml")));
+ BobjStdDTO dto = BobjStdDTO.getFromXml(source);
+
+
+ List<? extends BaseBusinessObject> bobList = dto.getChildObjList("Laddr", Address.class);
+
+ assertEquals(1, bobList.size());
+ assertTrue(bobList.get(0) instanceof Address);
+ Address address = (Address) bobList.get(0);
+ assertEquals("Argentina", address.getField(Address.ATTRIB.cntry));
+ assertEquals("1642", address.getField(Address.ATTRIB.postalZip));
+ assertEquals("Buenos Aires", address.getField(Address.ATTRIB.provSt));
+ assertEquals("Balcarce", address.getField(Address.ATTRIB.strLine1));
+ assertEquals(null, address.getField(Address.ATTRIB.strLine2));
+ assertEquals("50", address.getField(Address.ATTRIB.strNum));
+ assertEquals(null, address.getField(Address.ATTRIB.suite));
+ assertEquals("San Isidro", address.getField(Address.ATTRIB.twnCty1));
+ assertEquals(null, address.getField(Address.ATTRIB.twnCty2));
+ assertEquals(2, address.getPhoneCount());
+ assertEquals("(416)555-1212", address.getPhoneAt(0).toString());
+ assertEquals("+54(11)4555-1111 Ext 7", address.getPhoneAt(1).toString());
+
+ }
+
public void test_MiscTests() throws Exception {
String source = new String(StreamUtils.readStream(
getClass().getResourceAsStream("BobjStdDTOUnitTest_testfile1.xml")));
Added: labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/util/TestBob.java
===================================================================
--- labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/util/TestBob.java 2006-07-31 08:56:43 UTC (rev 5356)
+++ labs/jbossesb/trunk/product/core/common/tests/src/org/jboss/soa/esb/util/TestBob.java 2006-07-31 10:42:18 UTC (rev 5357)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.util;
+
+import junit.framework.TestCase;
+
+class TestBob extends BaseBusinessObject {
+
+ public static final String MY_BOB_PROP = "myBobProp";
+ public static final String MY_BOB_PROP_VAL = "myBobProp-hello";
+
+ public TestBob() {
+ super();
+ }
+
+ public TestBob(String elementName, long uid) {
+ super(elementName, uid);
+ }
+
+ public TestBob(BobjStdDTO dto) throws Exception {
+ super(dto);
+ TestCase.assertEquals(MY_BOB_PROP_VAL, dto.getAttr(MY_BOB_PROP));
+ }
+
+ public BobjStdDTO toDTO() throws Exception {
+ BobjStdDTO dto = super.toDTO();
+
+ dto.addAttr(MY_BOB_PROP, MY_BOB_PROP_VAL);
+
+ return dto;
+ }
+}
\ No newline at end of file
Modified: labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/internal/core/objectstore/AbstractBobjStore.java
===================================================================
--- labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/internal/core/objectstore/AbstractBobjStore.java 2006-07-31 08:56:43 UTC (rev 5356)
+++ labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/internal/core/objectstore/AbstractBobjStore.java 2006-07-31 10:42:18 UTC (rev 5357)
@@ -172,7 +172,7 @@
* @see BobjStore#getStore(String)
*/
public AbstractBobjStore getStore (BaseBusinessObject p_o)
- { return (null != p_o) ? getStore(p_o.classNm()) : null;
+ { return (null != p_o) ? getStore(p_o.getClass().getSimpleName()) : null;
} //__________________________________
/**
More information about the jboss-svn-commits
mailing list