rhmessaging commits: r1337 - mgmt/cumin/python/cumin.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2007-11-19 12:13:30 -0500 (Mon, 19 Nov 2007)
New Revision: 1337
Modified:
mgmt/cumin/python/cumin/brokercluster.py
mgmt/cumin/python/cumin/brokercluster.strings
mgmt/cumin/python/cumin/brokergroup.py
mgmt/cumin/python/cumin/brokergroup.strings
mgmt/cumin/python/cumin/widgets.py
Log:
Finishes hooking up remove forms.
Modified: mgmt/cumin/python/cumin/brokercluster.py
===================================================================
--- mgmt/cumin/python/cumin/brokercluster.py 2007-11-19 16:29:18 UTC (rev 1336)
+++ mgmt/cumin/python/cumin/brokercluster.py 2007-11-19 17:13:30 UTC (rev 1337)
@@ -57,6 +57,10 @@
self.add_mode(self.edit)
self.set_edit_mode(self.edit)
+ self.remove = BrokerClusterRemove(app, "remove")
+ self.add_mode(self.remove)
+ self.set_remove_mode(self.remove)
+
self.broker = BrokerFrame(app, "broker")
self.add_mode(self.broker)
@@ -70,7 +74,7 @@
class BrokerClusterStatus(CuminStatus):
pass
-class BrokerClusterView(Widget):
+class BrokerClusterView(CuminView):
def __init__(self, app, name):
super(BrokerClusterView, self).__init__(app, name)
Modified: mgmt/cumin/python/cumin/brokercluster.strings
===================================================================
--- mgmt/cumin/python/cumin/brokercluster.strings 2007-11-19 16:29:18 UTC (rev 1336)
+++ mgmt/cumin/python/cumin/brokercluster.strings 2007-11-19 17:13:30 UTC (rev 1337)
@@ -47,16 +47,10 @@
<tr>
<th class="actions" colspan="2">
<h2>Act on This Cluster:</h2>
- <form class="inline" action="?" method="get">
- <select>
- <option>Choose Action...</option>
- <option>Edit...</option>
- <option>Remove</option>
- <option>Start</option>
- <option>Stop</option>
- </select>
- <button>Submit</button>
- </form>
+ <a class="nav" href="{edit_href}">Edit</a>
+ <a href="{remove_href}">Remove</a>
+ <a href="{href}">Start</a>
+ <a href="{href}">Stop</a>
</th>
</tr>
</table>
Modified: mgmt/cumin/python/cumin/brokergroup.py
===================================================================
--- mgmt/cumin/python/cumin/brokergroup.py 2007-11-19 16:29:18 UTC (rev 1336)
+++ mgmt/cumin/python/cumin/brokergroup.py 2007-11-19 17:13:30 UTC (rev 1337)
@@ -58,13 +58,17 @@
self.add_child(self.edit)
self.set_edit_mode(self.edit)
+ self.remove = BrokerGroupRemove(app, "remove")
+ self.add_child(self.remove)
+ self.set_remove_mode(self.remove)
+
def get_title(self, session, group):
return "Broker Group '%s'" % group.name
class BrokerGroupStatus(CuminStatus):
pass
-class BrokerGroupView(Widget):
+class BrokerGroupView(CuminView):
def __init__(self, app, name):
super(BrokerGroupView, self).__init__(app, name)
@@ -85,11 +89,6 @@
def render_category(self, session, group):
return group.get_type().name
- def render_edit_href(self, session, group):
- branch = session.branch()
- self.page().show_broker_group(branch, group).show_edit(branch)
- return branch.marshal()
-
class GroupBrokerTab(BrokerSetForm):
def get_title(self, session, group):
return "Brokers %s" % fmt_count(len(group.broker_items()))
Modified: mgmt/cumin/python/cumin/brokergroup.strings
===================================================================
--- mgmt/cumin/python/cumin/brokergroup.strings 2007-11-19 16:29:18 UTC (rev 1336)
+++ mgmt/cumin/python/cumin/brokergroup.strings 2007-11-19 17:13:30 UTC (rev 1337)
@@ -40,7 +40,7 @@
<th class="actions" colspan="2">
<h2>Act on This Group:</h2>
<a class="nav" href="{edit_href}">Edit</a>
- <a href="{href}">Remove</a>
+ <a href="{remove_href}">Remove</a>
</th>
</tr>
</table>
Modified: mgmt/cumin/python/cumin/widgets.py
===================================================================
--- mgmt/cumin/python/cumin/widgets.py 2007-11-19 16:29:18 UTC (rev 1336)
+++ mgmt/cumin/python/cumin/widgets.py 2007-11-19 17:13:30 UTC (rev 1337)
@@ -16,6 +16,7 @@
self.__param = None
self.__view_mode = None
self.__edit_mode = None
+ self.__remove_mode = None
def set_object_parameter(self, param):
self.__param = param
17 years, 3 months
rhmessaging commits: r1336 - in mgmt: mint/python/mint and 1 other directory.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2007-11-19 11:29:18 -0500 (Mon, 19 Nov 2007)
New Revision: 1336
Modified:
mgmt/cumin/python/cumin/broker.py
mgmt/cumin/python/cumin/broker.strings
mgmt/cumin/python/cumin/brokercluster.py
mgmt/cumin/python/cumin/brokergroup.py
mgmt/cumin/python/cumin/brokerprofile.py
mgmt/cumin/python/cumin/page.py
mgmt/cumin/python/cumin/queue.py
mgmt/cumin/python/cumin/widgets.py
mgmt/cumin/python/cumin/widgets.strings
mgmt/mint/python/mint/schema.py
Log:
Generally makes the UI work with the real data model. Before lots of places
would blow up because they were expecting dummy data. They are now fixed.
Updates the schema to the newest with association methods fixed up.
Modified: mgmt/cumin/python/cumin/broker.py
===================================================================
--- mgmt/cumin/python/cumin/broker.py 2007-11-19 16:06:28 UTC (rev 1335)
+++ mgmt/cumin/python/cumin/broker.py 2007-11-19 16:29:18 UTC (rev 1336)
@@ -78,6 +78,9 @@
self.submit = self.Submit(app, "submit", self)
self.add_child(self.submit)
+ self.paginator = self.BrokerPaginator(app, "page")
+ self.add_child(self.paginator)
+
def do_process(self, session, model):
if self.submit.get(session):
self.submit.set(session, False)
@@ -100,6 +103,10 @@
def render_content(self, session, model):
return "Submit"
+ class BrokerPaginator(Paginator):
+ def get_object(self, session, model):
+ return self.parent().get_items(session, model)
+
class BrokerFrame(CuminFrame):
def __init__(self, app, name):
super(BrokerFrame, self).__init__(app, name)
Modified: mgmt/cumin/python/cumin/broker.strings
===================================================================
--- mgmt/cumin/python/cumin/broker.strings 2007-11-19 16:06:28 UTC (rev 1335)
+++ mgmt/cumin/python/cumin/broker.strings 2007-11-19 16:29:18 UTC (rev 1336)
@@ -19,6 +19,7 @@
</tr>
[BrokerSetForm.html]
+{page}
<form id="{id}" method="post" action="?">
<!-- <select onchange="document.getElementById('{id}.submit').submit()"> -->
Modified: mgmt/cumin/python/cumin/brokercluster.py
===================================================================
--- mgmt/cumin/python/cumin/brokercluster.py 2007-11-19 16:06:28 UTC (rev 1335)
+++ mgmt/cumin/python/cumin/brokercluster.py 2007-11-19 16:29:18 UTC (rev 1336)
@@ -91,10 +91,11 @@
class ClusterBrokerTab(BrokerSetForm):
def get_title(self, session, cluster):
- return "Brokers %s" % fmt_count(len(cluster.broker_items()))
+ return "Brokers" #XXX %s" % fmt_count(len(cluster.broker_items()))
def get_items(self, session, cluster):
- return sorted_by(cluster.broker_items())
+ return sorted_by(self.app.model.sys.brokers, "id")
+ #XXX return sorted_by(cluster.broker_items())
class ClusterStatsTab(Widget):
def get_title(self, session, cluster):
Modified: mgmt/cumin/python/cumin/brokergroup.py
===================================================================
--- mgmt/cumin/python/cumin/brokergroup.py 2007-11-19 16:06:28 UTC (rev 1335)
+++ mgmt/cumin/python/cumin/brokergroup.py 2007-11-19 16:29:18 UTC (rev 1336)
@@ -95,7 +95,8 @@
return "Brokers %s" % fmt_count(len(group.broker_items()))
def get_items(self, session, group):
- return sorted_by(group.broker_items())
+ return sorted_by(self.app.model.sys.brokers, "port")
+ #XXX return sorted_by(group.broker_items())
class BrokerGroupForm(CuminForm):
def __init__(self, app, name):
Modified: mgmt/cumin/python/cumin/brokerprofile.py
===================================================================
--- mgmt/cumin/python/cumin/brokerprofile.py 2007-11-19 16:06:28 UTC (rev 1335)
+++ mgmt/cumin/python/cumin/brokerprofile.py 2007-11-19 16:29:18 UTC (rev 1336)
@@ -77,7 +77,8 @@
return "Brokers %s" % fmt_count(len(profile.broker_items()))
def get_items(self, session, profile):
- return sorted_by(profile.broker_items())
+ return sorted_by(self.app.model.sys.brokers, "id")
+ #XXX return sorted_by(profile.broker_items())
def render_item_config_href(self, session, broker):
branch = session.branch()
@@ -86,6 +87,8 @@
return branch.marshal()
def render_item_config_status(self, session, broker):
+ return "0 differences" #XXX
+
diffs = 0
for prop in broker.get_broker_profile().config_property_items():
Modified: mgmt/cumin/python/cumin/page.py
===================================================================
--- mgmt/cumin/python/cumin/page.py 2007-11-19 16:06:28 UTC (rev 1335)
+++ mgmt/cumin/python/cumin/page.py 2007-11-19 16:29:18 UTC (rev 1336)
@@ -118,20 +118,17 @@
return self.set_current_frame(session, frame)
def show_queue(self, session, queue):
- broker = queue.mintVhost.mintBroker
- frame = self.show_broker(session, broker)
+ frame = self.show_broker(session, queue.vhost.broker)
frame = frame.show_queue(session, queue)
return self.set_current_frame(session, frame)
def show_exchange(self, session, exchange):
- broker = exchange.get_virtual_host().get_broker()
- frame = self.show_broker(session, broker)
+ frame = self.show_broker(session, exchange.vhost.broker)
frame = frame.show_exchange(session, exchange)
return self.set_current_frame(session, frame)
def show_client(self, session, client):
- broker = client.get_virtual_host().get_broker()
- frame = self.show_broker(session, broker)
+ frame = self.show_broker(session, client.vhost.broker)
frame = frame.show_client(session, client)
return self.set_current_frame(session, frame)
@@ -183,7 +180,6 @@
class BrokerTab(BrokerBrowser):
def get_title(self, session, model):
- print dir(model.sys)
return "Brokers %s" % fmt_count(len(model.brokers()))
class BrokerProfileTab(BrokerProfileSet):
Modified: mgmt/cumin/python/cumin/queue.py
===================================================================
--- mgmt/cumin/python/cumin/queue.py 2007-11-19 16:06:28 UTC (rev 1335)
+++ mgmt/cumin/python/cumin/queue.py 2007-11-19 16:29:18 UTC (rev 1336)
@@ -57,23 +57,23 @@
def render_item_enqueued(self, session, queue):
unit = self.unit.get(session)
key = unit == "b" and "byteTotalEnqueues" or "msgTotalEnqueues"
- value = getattr(queue.mintQueueStats, key)
+ value = getattr(queue.stats, key)
return fmt_rate(value, unit == "b" and "byte" or "msg", "sec")
def render_item_dequeued(self, session, queue):
unit = self.unit.get(session)
key = unit == "b" and "byteTotalDequeues" or "msgTotalDequeues"
- value = getattr(queue.mintQueueStats, key)
+ value = getattr(queue.stats, key)
return fmt_rate(value, unit == "b" and "byte" or "msg", "sec")
def render_item_depth(self, session, queue):
key = self.unit.get(session) == "b" and "byteDepth" or "msgDepth"
- return getattr(queue.mintQueueStats, key)
+ return getattr(queue.stats, key)
def render_item_depth_accel(self, session, queue):
unit = self.unit.get(session)
key = unit == "b" and "byteDepth" or "msgDepth"
- value = getattr(queue.mintQueueStats, key)
+ value = getattr(queue.stats, key)
return fmt_rate(value, unit == "b" and "byte" or "msg", "sec")
def render_item_status(self, session, queue):
@@ -117,36 +117,36 @@
class QueueStatus(CuminStatus):
def render_consumers(self, session, queue):
- return queue.mintQueueStats.consumers
+ return queue.stats.consumers
def render_messages_enqueued(self, session, queue):
- value = queue.mintQueueStats.msgTotalEnqueues
+ value = queue.stats.msgTotalEnqueues
return fmt_rate(value, "msg", "sec")
def render_messages_dequeued(self, session, queue):
- value = queue.mintQueueStats.msgTotalDequeues
+ value = queue.stats.msgTotalDequeues
return fmt_rate(value, "msg", "sec")
def render_message_depth(self, session, queue):
- return queue.mintQueueStats.msgDepth
+ return queue.stats.msgDepth
def render_message_depth_accel(self, session, queue):
- value = queue.mintQueueStats.msgDepth
+ value = queue.stats.msgDepth
return fmt_rate(value, "msg", "sec")
def render_bytes_enqueued(self, session, queue):
- value = queue.mintQueueStats.byteTotalEnqueues
+ value = queue.stats.byteTotalEnqueues
return fmt_rate(value, "byte", "sec")
def render_bytes_dequeued(self, session, queue):
- value = queue.mintQueueStats.byteTotalDequeues
+ value = queue.stats.byteTotalDequeues
return fmt_rate(value, "byte", "sec")
def render_byte_depth(self, session, queue):
- return queue.mintQueueStats.byteDepth
+ return queue.stats.byteDepth
def render_byte_depth_accel(self, session, queue):
- value = queue.mintQueueStats.byteDepth
+ value = queue.stats.byteDepth
return fmt_rate(value, "byte", "sec")
class QueueView(Widget):
Modified: mgmt/cumin/python/cumin/widgets.py
===================================================================
--- mgmt/cumin/python/cumin/widgets.py 2007-11-19 16:06:28 UTC (rev 1335)
+++ mgmt/cumin/python/cumin/widgets.py 2007-11-19 16:29:18 UTC (rev 1336)
@@ -1,3 +1,4 @@
+from math import ceil
from wooly import *
from wooly.widgets import *
from wooly.forms import *
@@ -252,3 +253,28 @@
class_ = self.get(session) == "b" and "selected"
return fmt_link(branch.marshal(), "Bytes", class_)
+
+class Paginator(ItemSet):
+ def __init__(self, app, name):
+ super(Paginator, self).__init__(app, name)
+
+ self.param = IntegerParameter(app, "param")
+ self.param.set_default(0)
+ self.add_parameter(self.param)
+
+ def get(self, session):
+ return self.param.get(session)
+
+ def set(self, session, value):
+ return self.param.set(session, value)
+
+ def get_items(self, session, object):
+ return range(0, ceil(len(object) / 20) - 1)
+
+ def render_item_href(self, session, page):
+ branch = session.branch()
+ self.set(branch, page)
+ return branch.marshal()
+
+ def render_item_content(self, session, page):
+ return page + 1
Modified: mgmt/cumin/python/cumin/widgets.strings
===================================================================
--- mgmt/cumin/python/cumin/widgets.strings 2007-11-19 16:06:28 UTC (rev 1335)
+++ mgmt/cumin/python/cumin/widgets.strings 2007-11-19 16:29:18 UTC (rev 1336)
@@ -25,3 +25,11 @@
<li>{messages_link}</li>
<li>{bytes_link}</li>
</ul>
+
+[Paginator.html]
+<ul class="comma">
+ {items}
+</ul>
+
+[Paginator.item_html]
+<li><a href="{item_href}">{item_content}</a></li>
Modified: mgmt/mint/python/mint/schema.py
===================================================================
--- mgmt/mint/python/mint/schema.py 2007-11-19 16:06:28 UTC (rev 1335)
+++ mgmt/mint/python/mint/schema.py 2007-11-19 16:29:18 UTC (rev 1336)
@@ -1,9 +1,6 @@
from sqlobject import *
from datetime import datetime
-#conn = connectionForURI("postgresql://localhost/")
-#sqlhub.processConnection = conn
-
class System(SQLObject):
idOriginal = BigIntCol(default=None)
recTime = TimestampCol(default=None)
@@ -69,6 +66,9 @@
model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, \
classToSchemaNameMap[self.__class__.__name__], "crash", args=actualArgs, packageName="qpid")
+System.sqlmeta.addJoin(MultipleJoin('Broker', joinMethodName='brokers'))
+
+
class BrokerStats(SQLObject):
idOriginal = BigIntCol(default=None)
recTime = TimestampCol(default=None)
@@ -85,6 +85,9 @@
broker = ForeignKey('Broker', cascade='null', default=None)
name = StringCol(length=1000, default=None)
+Broker.sqlmeta.addJoin(MultipleJoin('Vhost', joinMethodName='vhosts'))
+
+
class VhostStats(SQLObject):
idOriginal = BigIntCol(default=None)
recTime = TimestampCol(default=None)
@@ -120,6 +123,9 @@
model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, \
classToSchemaNameMap[self.__class__.__name__], "increaseDiskSize", args=actualArgs, packageName="qpid")
+Vhost.sqlmeta.addJoin(MultipleJoin('Queue', joinMethodName='queues'))
+
+
class QueueStats(SQLObject):
idOriginal = BigIntCol(default=None)
recTime = TimestampCol(default=None)
@@ -179,6 +185,9 @@
name = StringCol(length=1000, default=None)
type = StringCol(length=1000, default=None)
+Vhost.sqlmeta.addJoin(MultipleJoin('Exchange', joinMethodName='exchanges'))
+
+
class ExchangeStats(SQLObject):
idOriginal = BigIntCol(default=None)
recTime = TimestampCol(default=None)
@@ -208,6 +217,11 @@
exchange = ForeignKey('Exchange', cascade='null', default=None)
bindingKey = StringCol(length=1000, default=None)
+Queue.sqlmeta.addJoin(MultipleJoin('Binding', joinMethodName='bindings'))
+
+Exchange.sqlmeta.addJoin(MultipleJoin('Binding', joinMethodName='bindings'))
+
+
class BindingStats(SQLObject):
idOriginal = BigIntCol(default=None)
recTime = TimestampCol(default=None)
@@ -238,6 +252,9 @@
model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, \
classToSchemaNameMap[self.__class__.__name__], "detach", args=actualArgs, packageName="qpid")
+Vhost.sqlmeta.addJoin(MultipleJoin('Client', joinMethodName='clients'))
+
+
class ClientStats(SQLObject):
idOriginal = BigIntCol(default=None)
recTime = TimestampCol(default=None)
@@ -285,6 +302,11 @@
model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, \
classToSchemaNameMap[self.__class__.__name__], "close", args=actualArgs, packageName="qpid")
+Vhost.sqlmeta.addJoin(MultipleJoin('Session', joinMethodName='sessions'))
+
+Client.sqlmeta.addJoin(MultipleJoin('Session', joinMethodName='sessions'))
+
+
class SessionStats(SQLObject):
idOriginal = BigIntCol(default=None)
recTime = TimestampCol(default=None)
@@ -324,6 +346,9 @@
model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, \
classToSchemaNameMap[self.__class__.__name__], "start", args=actualArgs, packageName="qpid")
+Session.sqlmeta.addJoin(MultipleJoin('Destination', joinMethodName='destinations'))
+
+
class DestinationStats(SQLObject):
idOriginal = BigIntCol(default=None)
recTime = TimestampCol(default=None)
@@ -345,6 +370,11 @@
destination = ForeignKey('Destination', cascade='null', default=None)
exchange = ForeignKey('Exchange', cascade='null', default=None)
+Destination.sqlmeta.addJoin(MultipleJoin('Producer', joinMethodName='producers'))
+
+Exchange.sqlmeta.addJoin(MultipleJoin('Producer', joinMethodName='producers'))
+
+
class ProducerStats(SQLObject):
idOriginal = BigIntCol(default=None)
recTime = TimestampCol(default=None)
@@ -369,6 +399,11 @@
model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, \
classToSchemaNameMap[self.__class__.__name__], "close", args=actualArgs, packageName="qpid")
+Destination.sqlmeta.addJoin(MultipleJoin('Consumer', joinMethodName='consumers'))
+
+Queue.sqlmeta.addJoin(MultipleJoin('Consumer', joinMethodName='consumers'))
+
+
class ConsumerStats(SQLObject):
idOriginal = BigIntCol(default=None)
recTime = TimestampCol(default=None)
17 years, 3 months
rhmessaging commits: r1335 - mgmt/mint.
by rhmessaging-commits@lists.jboss.org
Author: nunofsantos
Date: 2007-11-19 11:06:28 -0500 (Mon, 19 Nov 2007)
New Revision: 1335
Modified:
mgmt/mint/schemaparser.py
Log:
generate multiple joins for reverse associations
Modified: mgmt/mint/schemaparser.py
===================================================================
--- mgmt/mint/schemaparser.py 2007-11-19 15:10:13 UTC (rev 1334)
+++ mgmt/mint/schemaparser.py 2007-11-19 16:06:28 UTC (rev 1335)
@@ -13,6 +13,7 @@
self.pythonOutput += "conn = connectionForURI(\"%s\")\n" % (self.options["dsn"])
self.pythonOutput += "sqlhub.processConnection = conn\n\n"
self.additional = ""
+ self.currentClass = ""
self.final = "\nclassToSchemaNameMap = dict()\n"
self.final += "schemaNameToClassMap = dict()\n"
# mapping between xml schema types and database column types
@@ -49,12 +50,17 @@
self.generateAttrib(name + "Low", type)
self.generateAttrib(name + "High", type)
+ def generateMultipleJoin(self, tableFrom, tableTo):
+ attrib = tableTo.lower() + "s"
+ self.additional += "\n%s.sqlmeta.addJoin(MultipleJoin('%s', joinMethodName='%s'))\n" % (tableFrom, tableTo, attrib)
+
def generateClassAttribs(self, schemaName, elements):
for elem in elements:
if (elem["@name"].endswith("Ref")):
reference = self.style.dbTableToPythonClass(elem["@name"]).replace("Ref", "")
attrib = reference[0].lower() + reference[1:]
self.generateForeignKeyAttrib(attrib, reference)
+ self.generateMultipleJoin(reference, self.currentClass)
elif (elem["@type"].startswith("hilo")):
self.generateHiLoAttrib(self.attrNameFromDbColumn(elem["@name"]), self.dataTypesMap[elem["@type"]])
else:
@@ -73,6 +79,7 @@
else:
pythonName = self.style.dbTableToPythonClass(schemaName)
statsPythonName = self.style.dbTableToPythonClass(schemaName + "_stats")
+ self.currentClass = pythonName
self.pythonOutput += "\nclass %s(SQLObject):\n" % (pythonName)
self.generateAttrib("idOriginal", "BigIntCol")
self.generateTimestampAttrib("rec")
@@ -115,6 +122,7 @@
self.additional = ""
if (self.pythonOutput.endswith("(SQLObject):\n")):
self.pythonOutput += " pass\n"
+ self.currentClass = ""
def parseConfigFile(self):
config = mllib.xml_parse("config.xml")
17 years, 3 months
rhmessaging commits: r1334 - in mgmt: cumin/python/cumin and 1 other directories.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2007-11-19 10:10:13 -0500 (Mon, 19 Nov 2007)
New Revision: 1334
Modified:
mgmt/README
mgmt/cumin/python/cumin/__init__.py
mgmt/cumin/python/cumin/broker.py
mgmt/cumin/python/cumin/brokercluster.py
mgmt/cumin/python/cumin/brokergroup.py
mgmt/cumin/python/cumin/brokerprofile.py
mgmt/cumin/python/cumin/brokerprofile.strings
mgmt/cumin/python/cumin/widgets.py
mgmt/mint/python/mint/schema.py
Log:
Adds remove forms for broker groups, profiles, and clusters. Hooks up the profile remove form.
Modified: mgmt/README
===================================================================
--- mgmt/README 2007-11-19 05:46:53 UTC (rev 1333)
+++ mgmt/README 2007-11-19 15:10:13 UTC (rev 1334)
@@ -77,3 +77,12 @@
export DEVEL_HOME="${HOME}/mgmt"
exec "${DEVEL_HOME}/bin/devel"
+
+
+SOME GOTCHAS YOU MIGHT RUN INTO
+-------------------------------
+
+1. PostgreSQL "sameuser ident" authentication
+
+ If you get an error about failed ident authentication, make sure
+ you have an ident server installed and running.
Modified: mgmt/cumin/python/cumin/__init__.py
===================================================================
--- mgmt/cumin/python/cumin/__init__.py 2007-11-19 05:46:53 UTC (rev 1333)
+++ mgmt/cumin/python/cumin/__init__.py 2007-11-19 15:10:13 UTC (rev 1334)
@@ -37,7 +37,7 @@
sys = System.get(1)
except SQLObjectNotFound:
sys = System()
- sys.set(id=0, idOriginal=0)
+ sys.set(sysId=0, idOriginal=0)
self.model.sys = sys
Modified: mgmt/cumin/python/cumin/broker.py
===================================================================
--- mgmt/cumin/python/cumin/broker.py 2007-11-19 05:46:53 UTC (rev 1333)
+++ mgmt/cumin/python/cumin/broker.py 2007-11-19 15:10:13 UTC (rev 1334)
@@ -561,7 +561,29 @@
groups = self.groups.get(session)
for name, addr, group in zip(names, addrs, groups):
- broker = mint.Broker()
- broker.set(
+ pass
+ #broker = mint.Broker()
self.process_cancel(session, model)
+
+class BrokerRemove(CuminConfirmForm):
+ def get_title(self, session, broker):
+ return "Remove Broker '%s'" % broker.port
+
+ def process_cancel(self, session, broker):
+ branch = session.branch()
+ self.page().show_broker(branch, broker).show_view(branch)
+ self.page().set_redirect_url(session, branch.marshal())
+
+ def process_submit(self, session, broker):
+ broker.remove()
+
+ branch = session.branch()
+ self.page().show_view(branch)
+ self.page().set_redirect_url(session, branch.marshal())
+
+ def render_submit_content(self, session, broker):
+ return "Yes, Remove Broker '%s'" % broker.port
+
+ def render_cancel_content(self, session, broker):
+ return "No, Cancel"
Modified: mgmt/cumin/python/cumin/brokercluster.py
===================================================================
--- mgmt/cumin/python/cumin/brokercluster.py 2007-11-19 05:46:53 UTC (rev 1333)
+++ mgmt/cumin/python/cumin/brokercluster.py 2007-11-19 15:10:13 UTC (rev 1334)
@@ -145,3 +145,25 @@
def process_display(self, session, cluster):
self.cluster_name.set(session, cluster.name)
+
+class BrokerClusterRemove(CuminConfirmForm):
+ def get_title(self, session, cluster):
+ return "Remove Broker Cluster '%s'" % cluster.name
+
+ def process_cancel(self, session, cluster):
+ branch = session.branch()
+ self.page().show_broker_cluster(branch, cluster).show_view(branch)
+ self.page().set_redirect_url(session, branch.marshal())
+
+ def process_submit(self, session, cluster):
+ cluster.remove()
+
+ branch = session.branch()
+ self.page().show_view(branch)
+ self.page().set_redirect_url(session, branch.marshal())
+
+ def render_submit_content(self, session, cluster):
+ return "Yes, Remove Broker Cluster '%s'" % cluster.name
+
+ def render_cancel_content(self, session, cluster):
+ return "No, Cancel"
Modified: mgmt/cumin/python/cumin/brokergroup.py
===================================================================
--- mgmt/cumin/python/cumin/brokergroup.py 2007-11-19 05:46:53 UTC (rev 1333)
+++ mgmt/cumin/python/cumin/brokergroup.py 2007-11-19 15:10:13 UTC (rev 1334)
@@ -153,3 +153,25 @@
def render_item_selected_attr(self, session, group):
return None
+
+class BrokerGroupRemove(CuminConfirmForm):
+ def get_title(self, session, group):
+ return "Remove Broker Group '%s'" % group.name
+
+ def process_cancel(self, session, group):
+ branch = session.branch()
+ self.page().show_broker_group(branch, group).show_view(branch)
+ self.page().set_redirect_url(session, branch.marshal())
+
+ def process_submit(self, session, group):
+ group.remove()
+
+ branch = session.branch()
+ self.page().show_view(branch)
+ self.page().set_redirect_url(session, branch.marshal())
+
+ def render_submit_content(self, session, group):
+ return "Yes, Remove Broker Group '%s'" % group.name
+
+ def render_cancel_content(self, session, group):
+ return "No, Cancel"
Modified: mgmt/cumin/python/cumin/brokerprofile.py
===================================================================
--- mgmt/cumin/python/cumin/brokerprofile.py 2007-11-19 05:46:53 UTC (rev 1333)
+++ mgmt/cumin/python/cumin/brokerprofile.py 2007-11-19 15:10:13 UTC (rev 1334)
@@ -39,10 +39,14 @@
self.add_mode(self.edit)
self.set_edit_mode(self.edit)
+ self.remove = BrokerProfileRemove(app, "remove")
+ self.add_mode(self.remove)
+ self.set_remove_mode(self.remove)
+
def get_title(self, session, profile):
return "Broker Profile '%s'" % profile.name
-class BrokerProfileView(Widget):
+class BrokerProfileView(CuminView):
def __init__(self, app, name):
super(BrokerProfileView, self).__init__(app, name)
@@ -58,11 +62,6 @@
def render_name(self, session, profile):
return profile.name
- def render_edit_href(self, session, profile):
- branch = session.branch()
- self.page().show_broker_profile(branch, profile).show_edit(branch)
- return branch.marshal()
-
class ProfileConfigTab(ConfigPropertySet):
def get_items(self, session, profile):
return sorted_by(profile.config_property_items())
@@ -142,3 +141,25 @@
def process_display(self, session, profile):
self.profile_name.set(session, profile.name)
+
+class BrokerProfileRemove(CuminConfirmForm):
+ def get_title(self, session, profile):
+ return "Remove Broker Profile '%s'" % profile.name
+
+ def process_cancel(self, session, profile):
+ branch = session.branch()
+ self.page().show_broker_profile(branch, profile).show_view(branch)
+ self.page().set_redirect_url(session, branch.marshal())
+
+ def process_submit(self, session, profile):
+ profile.remove()
+
+ branch = session.branch()
+ self.page().show_view(branch)
+ self.page().set_redirect_url(session, branch.marshal())
+
+ def render_submit_content(self, session, profile):
+ return "Yes, Remove Broker Profile '%s'" % profile.name
+
+ def render_cancel_content(self, session, profile):
+ return "No, Cancel"
Modified: mgmt/cumin/python/cumin/brokerprofile.strings
===================================================================
--- mgmt/cumin/python/cumin/brokerprofile.strings 2007-11-19 05:46:53 UTC (rev 1333)
+++ mgmt/cumin/python/cumin/brokerprofile.strings 2007-11-19 15:10:13 UTC (rev 1334)
@@ -25,7 +25,7 @@
<th class="actions" colspan="2">
<h2>Act on This Profile:</h2>
<a class="nav" href="{edit_href}">Edit</a>
- <a href="{href}">Remove</a>
+ <a href="{remove_href}">Remove</a>
</th>
</tr>
</table>
Modified: mgmt/cumin/python/cumin/widgets.py
===================================================================
--- mgmt/cumin/python/cumin/widgets.py 2007-11-19 05:46:53 UTC (rev 1333)
+++ mgmt/cumin/python/cumin/widgets.py 2007-11-19 15:10:13 UTC (rev 1334)
@@ -37,6 +37,12 @@
def show_edit(self, session):
return self.show_mode(session, self.__edit_mode)
+ def set_remove_mode(self, mode):
+ self.__remove_mode = mode
+
+ def show_remove(self, session):
+ return self.show_mode(session, self.__remove_mode)
+
def do_process(self, session, object):
self.page().get_frames(session).append(self)
@@ -48,6 +54,17 @@
self.show_view(branch)
return branch.marshal()
+class CuminView(Widget):
+ def render_edit_href(self, session, object):
+ branch = session.branch()
+ self.parent().show_edit(branch)
+ return branch.marshal()
+
+ def render_remove_href(self, session, object):
+ branch = session.branch()
+ self.parent().show_remove(branch)
+ return branch.marshal()
+
class CuminForm(Form):
def __init__(self, app, name):
super(CuminForm, self).__init__(app, name)
Modified: mgmt/mint/python/mint/schema.py
===================================================================
--- mgmt/mint/python/mint/schema.py 2007-11-19 05:46:53 UTC (rev 1333)
+++ mgmt/mint/python/mint/schema.py 2007-11-19 15:10:13 UTC (rev 1334)
@@ -1,8 +1,8 @@
from sqlobject import *
from datetime import datetime
-conn = connectionForURI("postgresql://localhost/")
-sqlhub.processConnection = conn
+#conn = connectionForURI("postgresql://localhost/")
+#sqlhub.processConnection = conn
class System(SQLObject):
idOriginal = BigIntCol(default=None)
17 years, 3 months
rhmessaging commits: r1333 - in store/trunk/cpp: tests/jrnl and 1 other directory.
by rhmessaging-commits@lists.jboss.org
Author: kpvdr
Date: 2007-11-19 00:46:53 -0500 (Mon, 19 Nov 2007)
New Revision: 1333
Added:
store/trunk/cpp/tests/jrnl/unit_test_enq_map.cpp
store/trunk/cpp/tests/jrnl/unit_test_file_hdr.cpp
Modified:
store/trunk/cpp/lib/jrnl/file_hdr.cpp
store/trunk/cpp/lib/jrnl/file_hdr.hpp
store/trunk/cpp/tests/jrnl/Makefile.am
Log:
Additional unit tests for the journal
Modified: store/trunk/cpp/lib/jrnl/file_hdr.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/file_hdr.cpp 2007-11-17 14:31:19 UTC (rev 1332)
+++ store/trunk/cpp/lib/jrnl/file_hdr.cpp 2007-11-19 05:46:53 UTC (rev 1333)
@@ -88,7 +88,7 @@
// ***** struct rec_tail *****
rec_tail::rec_tail():
- _xmagic(0xffffff), // 1's complement of 0
+ _xmagic(0xffffffff), // 1's complement of 0
_rid(0)
{}
@@ -180,7 +180,7 @@
}
void
-file_hdr::set_time(timespec ts)
+file_hdr::set_time(timespec& ts)
{
_ts_sec = ts.tv_sec;
_ts_nsec = ts.tv_nsec;
Modified: store/trunk/cpp/lib/jrnl/file_hdr.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/file_hdr.hpp 2007-11-17 14:31:19 UTC (rev 1332)
+++ store/trunk/cpp/lib/jrnl/file_hdr.hpp 2007-11-19 05:46:53 UTC (rev 1333)
@@ -245,7 +245,7 @@
* \brief Sets the timestamp in the struct to the provided value (in seconds and
* nanoseconds).
*/
- void set_time(timespec ts);
+ void set_time(timespec& ts);
/**
* \brief Returns the size of the header in bytes.
Modified: store/trunk/cpp/tests/jrnl/Makefile.am
===================================================================
--- store/trunk/cpp/tests/jrnl/Makefile.am 2007-11-17 14:31:19 UTC (rev 1332)
+++ store/trunk/cpp/tests/jrnl/Makefile.am 2007-11-19 05:46:53 UTC (rev 1333)
@@ -30,6 +30,8 @@
unit_test_jerrno \
unit_test_jinf \
unit_test_jdir \
+ unit_test_file_hdr \
+ unit_test_enq_map \
run-journal-tests
check_LTLIBRARIES = \
@@ -40,7 +42,9 @@
unit_test_jexception \
unit_test_jerrno \
unit_test_jinf \
- unit_test_jdir
+ unit_test_jdir \
+ unit_test_enq_map \
+ unit_test_file_hdr
unit_test_jexception_SOURCES = unit_test_jexception.cpp
unit_test_jexception_LDFLAGS = -lboost_unit_test_framework -lbdbstore -L../../lib/.libs
@@ -54,6 +58,12 @@
unit_test_jdir_SOURCES = unit_test_jdir.cpp
unit_test_jdir_LDFLAGS = -lboost_unit_test_framework -lbdbstore -lrt -L../../lib/.libs
+unit_test_file_hdr_SOURCES = unit_test_file_hdr.cpp
+unit_test_file_hdr_LDFLAGS = -lboost_unit_test_framework -lbdbstore -lrt -L../../lib/.libs
+
+unit_test_enq_map_SOURCES = unit_test_enq_map.cpp
+unit_test_enq_map_LDFLAGS = -lboost_unit_test_framework -lbdbstore -lrt -L../../lib/.libs
+
JournalSystemTests_la_SOURCES = \
JournalSystemTests.cpp \
JournalSystemTests.hpp
Added: store/trunk/cpp/tests/jrnl/unit_test_enq_map.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/unit_test_enq_map.cpp (rev 0)
+++ store/trunk/cpp/tests/jrnl/unit_test_enq_map.cpp 2007-11-19 05:46:53 UTC (rev 1333)
@@ -0,0 +1,261 @@
+/**
+* \file unit_test_enq_map.cpp
+*
+* Red Hat Messaging - Message Journal
+*
+* This file contains the unit tests for the journal.
+*
+* \author Kim van der Riet
+*
+* Copyright 2007 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging 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 library 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 library; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+* USA
+*
+* The GNU Lesser General Public License is available in the file COPYING.
+*/
+
+#include <boost/test/results_reporter.hpp>
+#include <boost/test/unit_test.hpp>
+#include <boost/test/unit_test_log.hpp>
+#include <iostream>
+#include <jrnl/enq_map.hpp>
+#include <jrnl/jerrno.hpp>
+
+using namespace boost::unit_test;
+using namespace rhm::journal;
+
+// Test functions of the form
+// void fn() {...}
+
+void test_constructor()
+{
+ enq_map e1;
+ BOOST_CHECK(e1.empty());
+ BOOST_CHECK_EQUAL(e1.size(), 0);
+}
+
+void test_insert_get()
+{
+ u_int16_t fid;
+ u_int64_t rid;
+ u_int16_t fid_start = 0x2000U;
+ u_int64_t rid_begin = 0xffffffff00000000ULL;
+ u_int64_t rid_end = 0xffffffff00000200ULL;
+
+ // insert with no dups
+ u_int64_t rid_incr_1 = 4ULL;
+ enq_map e2;
+ for (rid = rid_begin, fid = fid_start; rid < rid_end; rid += rid_incr_1, fid++)
+ e2.insert_fid(rid, fid);
+ BOOST_CHECK(!e2.empty());
+ BOOST_CHECK_EQUAL(e2.size(), 128);
+
+ // get
+ u_int64_t rid_incr_2 = 6ULL;
+ for (u_int64_t rid = rid_begin; rid < rid_end; rid += rid_incr_2)
+ {
+ BOOST_CHECK_EQUAL(e2.is_enqueued(rid), (rid%rid_incr_1 ? false : true));
+ try
+ {
+ u_int16_t exp_fid = fid_start + (u_int16_t)((rid - rid_begin)/rid_incr_1);
+ u_int16_t ret_fid = e2.get_fid(rid);
+ BOOST_CHECK_EQUAL(ret_fid, exp_fid);
+ BOOST_CHECK(rid%rid_incr_1 == 0);
+ }
+ catch (const jexception& e)
+ {
+ BOOST_CHECK_EQUAL(e.err_code(), jerrno::JERR_MAP_NOTFOUND);
+ BOOST_CHECK(rid%rid_incr_1);
+ }
+ if ((rid + rid_incr_2)%(8 * rid_incr_2) == 0)
+ fid++;
+ }
+
+ // insert with dups
+ for (rid = rid_begin, fid = fid_start; rid < rid_end; rid += rid_incr_2, fid++)
+ {
+ try
+ {
+ e2.insert_fid(rid, fid);
+ BOOST_CHECK(rid%rid_incr_1);
+ }
+ catch (const jexception& e)
+ {
+ BOOST_CHECK_EQUAL(e.err_code(), jerrno::JERR_MAP_DUPLICATE);
+ BOOST_CHECK(rid%rid_incr_1 == 0);
+ }
+ }
+ BOOST_CHECK_EQUAL(e2.size(), 171ULL);
+ e2.clear();
+ BOOST_CHECK(e2.empty());
+ BOOST_CHECK_EQUAL(e2.size(), 0);
+}
+
+void test_get_remove()
+{
+ u_int16_t fid;
+ u_int64_t rid;
+ u_int16_t fid_start = 0x3000U;
+ u_int64_t rid_begin = 0xeeeeeeee00000000ULL;
+ u_int64_t rid_end = 0xeeeeeeee00000200ULL;
+
+ u_int64_t rid_incr_1 = 4ULL;
+ u_int64_t num_incr_1 = (rid_end - rid_begin)/rid_incr_1;
+ enq_map e3;
+ for (rid = rid_begin, fid = fid_start; rid < rid_end; rid += rid_incr_1, fid++)
+ e3.insert_fid(rid, fid);
+ BOOST_CHECK_EQUAL(e3.size(), num_incr_1);
+
+ u_int64_t rid_incr_2 = 6ULL;
+ for (rid = rid_begin, fid = fid_start; rid < rid_end; rid += rid_incr_2, fid++)
+ {
+ try
+ {
+ u_int16_t exp_fid = fid_start + (u_int16_t)((rid - rid_begin)/rid_incr_1);
+ u_int16_t ret_fid = e3.get_remove_fid(rid);
+ BOOST_CHECK_EQUAL(ret_fid, exp_fid);
+ BOOST_CHECK(rid%rid_incr_1 == 0);
+ }
+ catch (const jexception& e)
+ {
+ BOOST_CHECK_EQUAL(e.err_code(), jerrno::JERR_MAP_NOTFOUND);
+ BOOST_CHECK(rid%rid_incr_1);
+ }
+ }
+ BOOST_CHECK_EQUAL(e3.size(), 85ULL);
+}
+
+void test_lock()
+{
+ u_int16_t fid;
+ u_int64_t rid;
+ u_int16_t fid_start = 0x4000U;
+ u_int64_t rid_begin = 0xdddddddd00000000ULL;
+ u_int64_t rid_end = 0xdddddddd00000200ULL;
+
+ // insert, every second entry is locked
+ u_int64_t rid_incr_1 = 4ULL;
+ u_int64_t num_incr_1 = (rid_end - rid_begin)/rid_incr_1;
+ bool locked = false;
+ enq_map e4;
+ for (rid = rid_begin, fid = fid_start; rid < rid_end; rid += rid_incr_1, fid++)
+ {
+ e4.insert_fid(rid, fid, locked);
+ locked = !locked;
+ }
+ BOOST_CHECK_EQUAL(e4.size(), num_incr_1);
+
+ // unlock and lock non-existent rids
+ try
+ {
+ e4.lock(1ULL);
+ BOOST_ERROR("Failed to throw exception when locking non-existent rid.");
+ }
+ catch (const jexception& e) { BOOST_CHECK_EQUAL(e.err_code(), jerrno::JERR_MAP_NOTFOUND); }
+ try
+ {
+ e4.unlock(2ULL);
+ BOOST_ERROR("Failed to throw exception when locking non-existent rid.");
+ }
+ catch (const jexception& e) { BOOST_CHECK_EQUAL(e.err_code(), jerrno::JERR_MAP_NOTFOUND); }
+
+ // get / unlock
+ for (u_int64_t rid = rid_begin; rid < rid_end; rid += rid_incr_1)
+ {
+ try { e4.get_fid(rid); }
+ catch(const jexception& e)
+ {
+ BOOST_CHECK_EQUAL(e.err_code(), jerrno::JERR_MAP_LOCKED);
+ BOOST_CHECK(rid%(2*rid_incr_1));
+ // unlock, read, then relock
+ e4.unlock(rid);
+ e4.get_fid(rid);
+ e4.lock(rid);
+ try
+ {
+ e4.get_fid(rid);
+ BOOST_ERROR("Failed to throw exception when getting locked record");
+ }
+ catch(const jexception& e)
+ {
+ BOOST_CHECK_EQUAL(e.err_code(), jerrno::JERR_MAP_LOCKED);
+ }
+ }
+ }
+
+ // remove all; if locked, use with txn_flag true; should ignore all locked records
+ for (u_int64_t rid = rid_begin; rid < rid_end; rid += rid_incr_1)
+ e4.get_remove_fid(rid, true);
+ BOOST_CHECK(e4.empty());
+}
+
+void test_lists()
+{
+ u_int16_t fid;
+ u_int64_t rid;
+ u_int16_t fid_start = 0x5000UL;
+ u_int64_t rid_begin = 0xdddddddd00000000ULL;
+ u_int64_t rid_end = 0xdddddddd00000200ULL;
+
+ // insert, every second entry is locked
+ u_int64_t rid_incr_1 = 4ULL;
+ u_int64_t num_incr_1 = (rid_end - rid_begin)/rid_incr_1;
+ std::vector<u_int64_t> rid_list;
+ std::vector<u_int16_t> fid_list;
+ enq_map e5;
+ for (rid = rid_begin, fid = fid_start; rid < rid_end; rid += rid_incr_1, fid++)
+ {
+ e5.insert_fid(rid, fid);
+ rid_list.push_back(rid);
+ fid_list.push_back(fid);
+ }
+ BOOST_CHECK_EQUAL(e5.size(), num_incr_1);
+ BOOST_CHECK_EQUAL(rid_list.size(), num_incr_1);
+ BOOST_CHECK_EQUAL(fid_list.size(), num_incr_1);
+
+ std::vector<u_int64_t> ret_rid_list;
+ e5.rid_list(ret_rid_list);
+ BOOST_CHECK_EQUAL(ret_rid_list.size(), num_incr_1);
+ for (unsigned i=0; i<ret_rid_list.size(); i++)
+ BOOST_CHECK_EQUAL(rid_list[i], ret_rid_list[i]);
+
+ std::vector<u_int16_t> ret_fid_list;
+ e5.fid_list(ret_fid_list);
+ BOOST_CHECK_EQUAL(ret_fid_list.size(), num_incr_1);
+ for (unsigned i=0; i<ret_fid_list.size(); i++)
+ BOOST_CHECK_EQUAL(fid_list[i], ret_fid_list[i]);
+}
+
+// Initialize test suite and include test functions
+
+test_suite* init_unit_test_suite(int, char**)
+{
+ std::cout << "--------" << std::endl << "unit_test_enq_map: ";
+ test_suite* ts = BOOST_TEST_SUITE("unit_test_enq_map");
+
+ results_reporter::set_level(SHORT_REPORT);
+ unit_test_log_t::instance().set_threshold_level(log_messages);
+
+ ts->add(BOOST_TEST_CASE(&test_constructor));
+ ts->add(BOOST_TEST_CASE(&test_insert_get));
+ ts->add(BOOST_TEST_CASE(&test_get_remove));
+ ts->add(BOOST_TEST_CASE(&test_lock));
+ ts->add(BOOST_TEST_CASE(&test_lists));
+
+ return ts;
+}
Added: store/trunk/cpp/tests/jrnl/unit_test_file_hdr.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/unit_test_file_hdr.cpp (rev 0)
+++ store/trunk/cpp/tests/jrnl/unit_test_file_hdr.cpp 2007-11-19 05:46:53 UTC (rev 1333)
@@ -0,0 +1,382 @@
+/**
+* \file unit_test_file_hdr.cpp
+*
+* Red Hat Messaging - Message Journal
+*
+* This file contains the unit tests for the journal.
+*
+* \author Kim van der Riet
+*
+* Copyright 2007 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging 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 library 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 library; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+* USA
+*
+* The GNU Lesser General Public License is available in the file COPYING.
+*/
+
+#include <boost/test/results_reporter.hpp>
+#include <boost/test/unit_test.hpp>
+#include <boost/test/unit_test_log.hpp>
+#include <jrnl/file_hdr.hpp>
+#include <jrnl/jcfg.hpp>
+
+using namespace boost::unit_test;
+using namespace rhm::journal;
+
+// Test functions of the form
+// void fn() {...}
+
+void test_hdr()
+{
+ hdr h1;
+ BOOST_CHECK_EQUAL(h1._magic, 0UL);
+ BOOST_CHECK_EQUAL(h1._version, 0);
+ BOOST_CHECK_EQUAL(h1._eflag, 0);
+ BOOST_CHECK_EQUAL(h1._uflag, 0);
+ BOOST_CHECK_EQUAL(h1._rid, 0ULL);
+
+ const u_int32_t magic = 0x89abcdefUL;
+ const u_int8_t version = 0xef;
+ const u_int16_t uflag = 0xabcd;
+ const u_int64_t rid = 0x123456789abcdef0ULL;
+
+ hdr h2(magic, version, uflag, rid);
+ BOOST_CHECK_EQUAL(h2._magic, magic);
+ BOOST_CHECK_EQUAL(h2._version, version);
+#ifdef JRNL_LITTLE_ENDIAN
+ BOOST_CHECK_EQUAL(h2._eflag, RHM_LENDIAN_FLAG);
+#else
+ BOOST_CHECK_EQUAL(h2._eflag, RHM_BENDIAN_FLAG);
+#endif
+ BOOST_CHECK_EQUAL(h2._uflag, uflag);
+ BOOST_CHECK_EQUAL(h2._rid, rid);
+
+ h1.copy(h2);
+ BOOST_CHECK_EQUAL(h1._magic, magic);
+ BOOST_CHECK_EQUAL(h1._version, version);
+#ifdef JRNL_LITTLE_ENDIAN
+ BOOST_CHECK_EQUAL(h1._eflag, RHM_LENDIAN_FLAG);
+#else
+ BOOST_CHECK_EQUAL(h1._eflag, RHM_BENDIAN_FLAG);
+#endif
+ BOOST_CHECK_EQUAL(h1._uflag, uflag);
+ BOOST_CHECK_EQUAL(h1._rid, rid);
+
+ h1.reset();
+ BOOST_CHECK_EQUAL(h1._magic, 0UL);
+ BOOST_CHECK_EQUAL(h1._version, 0);
+ BOOST_CHECK_EQUAL(h1._eflag, 0);
+ BOOST_CHECK_EQUAL(h1._uflag, 0);
+ BOOST_CHECK_EQUAL(h1._rid, 0ULL);
+}
+
+void test_rec_tail()
+{
+ const u_int32_t magic = 0xfedcba98;
+ const u_int64_t rid = 0xfedcba9876543210ULL;
+ const u_int32_t xmagic = ~magic;
+
+ {
+ rec_tail rt1;
+ BOOST_CHECK_EQUAL(rt1._xmagic, 0xffffffffUL);
+ BOOST_CHECK_EQUAL(rt1._rid, 0ULL);
+ }
+
+ {
+ rec_tail rt2(magic, rid);
+ BOOST_CHECK_EQUAL(rt2._xmagic, magic);
+ BOOST_CHECK_EQUAL(rt2._rid, rid);
+ }
+
+ {
+ hdr h(magic, RHM_JDAT_VERSION, 0, rid);
+ rec_tail rt3(h);
+ BOOST_CHECK_EQUAL(rt3._xmagic, xmagic);
+ BOOST_CHECK_EQUAL(rt3._rid, rid);
+ }
+}
+
+void test_file_hdr()
+{
+ const u_int32_t magic = 0xfedcba98UL;
+ const u_int8_t version = 0xa5;
+ const u_int16_t uflag = 0x1234;
+ const u_int64_t rid = 0xfedcba9876543210ULL;
+ const u_int32_t fid = 0xfedcba98UL;
+#ifdef JRNL_32_BIT
+ const size_t fro = 0xfedcba98UL;
+#else
+ const size_t fro = 0xfedcba9876543210ULL;
+#endif
+ timespec ts;
+
+ {
+ file_hdr fh1;
+ BOOST_CHECK_EQUAL(fh1._hdr._magic, 0UL);
+ BOOST_CHECK_EQUAL(fh1._hdr._version, 0);
+ BOOST_CHECK_EQUAL(fh1._hdr._eflag, 0);
+ BOOST_CHECK_EQUAL(fh1._hdr._uflag, 0);
+ BOOST_CHECK_EQUAL(fh1._hdr._rid, 0ULL);
+ BOOST_CHECK_EQUAL(fh1._fid, 0UL);
+#ifdef JRNL_32_BIT
+ BOOST_CHECK_EQUAL(fh1._fro, 0UL);
+ BOOST_CHECK_EQUAL(fh1._ts_sec, 0L);
+ BOOST_CHECK_EQUAL(fh1._ts_nsec, 0UL);
+#else
+ BOOST_CHECK_EQUAL(fh1._fro, 0ULL);
+ BOOST_CHECK_EQUAL(fh1._ts_sec, 0ULL);
+ BOOST_CHECK_EQUAL(fh1._ts_nsec, 0ULL);
+#endif
+ }
+
+ {
+ file_hdr fh2(magic, version, uflag, rid, fid, fro);
+ BOOST_CHECK_EQUAL(fh2._hdr._magic, magic);
+ BOOST_CHECK_EQUAL(fh2._hdr._version, version);
+#ifdef JRNL_LITTLE_ENDIAN
+ BOOST_CHECK_EQUAL(fh2._hdr._eflag, RHM_LENDIAN_FLAG);
+#else
+ BOOST_CHECK_EQUAL(fh2._hdr._eflag, RHM_BENDIAN_FLAG);
+#endif
+ BOOST_CHECK_EQUAL(fh2._hdr._uflag, uflag);
+ BOOST_CHECK_EQUAL(fh2._hdr._rid, rid);
+ BOOST_CHECK_EQUAL(fh2._fid,fid );
+ BOOST_CHECK_EQUAL(fh2._fro, fro);
+#ifdef JRNL_32_BIT
+ BOOST_CHECK_EQUAL(fh2._ts_sec, 0L);
+ BOOST_CHECK_EQUAL(fh2._ts_nsec, 0UL);
+#else
+ BOOST_CHECK_EQUAL(fh2._ts_sec, 0ULL);
+ BOOST_CHECK_EQUAL(fh2._ts_nsec, 0ULL);
+#endif
+ ::clock_gettime(CLOCK_REALTIME, &ts);
+ fh2.set_time(ts);
+ BOOST_CHECK_EQUAL(fh2._ts_sec, ts.tv_sec);
+ BOOST_CHECK_EQUAL(fh2._ts_nsec, (u_int32_t)ts.tv_nsec);
+ }
+
+ {
+ file_hdr fh3(magic, version, uflag, rid, fid, fro, true);
+ BOOST_CHECK_EQUAL(fh3._hdr._magic, magic);
+ BOOST_CHECK_EQUAL(fh3._hdr._version, version);
+#ifdef JRNL_LITTLE_ENDIAN
+ BOOST_CHECK_EQUAL(fh3._hdr._eflag, RHM_LENDIAN_FLAG);
+#else
+ BOOST_CHECK_EQUAL(fh3._hdr._eflag, RHM_BENDIAN_FLAG);
+#endif
+ BOOST_CHECK_EQUAL(fh3._hdr._uflag, uflag);
+ BOOST_CHECK_EQUAL(fh3._hdr._rid, rid);
+ BOOST_CHECK_EQUAL(fh3._fid, fid);
+ BOOST_CHECK_EQUAL(fh3._fro, fro);
+ BOOST_CHECK(fh3._ts_sec - ts.tv_sec <= 1); // No more than 1 sec difference
+ }
+}
+
+void test_enq_hdr()
+{
+ const u_int32_t magic = 0xfedcba98UL;
+ const u_int8_t version = 0xa5;
+ const u_int64_t rid = 0xfedcba9876543210ULL;
+#ifdef JRNL_32_BIT
+ const size_t xidsize = 0xfedcba98UL;
+ const size_t dsize = 0x76543210UL;
+#else
+ const size_t xidsize = 0xfedcba9876543210ULL;
+ const size_t dsize = 0x76543210fedcba98ULL;
+#endif
+
+ {
+ enq_hdr eh1;
+ BOOST_CHECK_EQUAL(eh1._hdr._magic, 0UL);
+ BOOST_CHECK_EQUAL(eh1._hdr._version, 0);
+ BOOST_CHECK_EQUAL(eh1._hdr._eflag, 0);
+ BOOST_CHECK_EQUAL(eh1._hdr._uflag, 0);
+ BOOST_CHECK_EQUAL(eh1._hdr._rid, 0ULL);
+#ifdef JRNL_32_BIT
+ BOOST_CHECK_EQUAL(eh1._xidsize, 0UL);
+ BOOST_CHECK_EQUAL(eh1._dsize, 0UL);
+#else
+ BOOST_CHECK_EQUAL(eh1._xidsize, 0ULL);
+ BOOST_CHECK_EQUAL(eh1._dsize, 0ULL);
+#endif
+ }
+
+ {
+ enq_hdr eh2(magic, version, rid, xidsize, dsize);
+ BOOST_CHECK_EQUAL(eh2._hdr._magic, magic);
+ BOOST_CHECK_EQUAL(eh2._hdr._version, version);
+#ifdef JRNL_LITTLE_ENDIAN
+ BOOST_CHECK_EQUAL(eh2._hdr._eflag, RHM_LENDIAN_FLAG);
+#else
+ BOOST_CHECK_EQUAL(eh2._hdr._eflag, RHM_BENDIAN_FLAG);
+#endif
+ BOOST_CHECK_EQUAL(eh2._hdr._uflag, 0);
+ BOOST_CHECK_EQUAL(eh2._hdr._rid, rid);
+ BOOST_CHECK_EQUAL(eh2._xidsize, xidsize);
+ BOOST_CHECK_EQUAL(eh2._dsize, dsize);
+ BOOST_CHECK(!eh2.is_transient());
+ BOOST_CHECK(!eh2.is_external());
+
+ eh2.set_transient(true);
+ BOOST_CHECK_EQUAL(eh2._hdr._uflag, enq_hdr::ENQ_HDR_TRANSIENT_MASK);
+ BOOST_CHECK(eh2.is_transient());
+ BOOST_CHECK(!eh2.is_external());
+
+ eh2.set_transient(false);
+ BOOST_CHECK_EQUAL(eh2._hdr._uflag, 0);
+ BOOST_CHECK(!eh2.is_transient());
+ BOOST_CHECK(!eh2.is_external());
+
+ eh2.set_external(true);
+ BOOST_CHECK_EQUAL(eh2._hdr._uflag, enq_hdr::ENQ_HDR_EXTERNAL_MASK);
+ BOOST_CHECK(!eh2.is_transient());
+ BOOST_CHECK(eh2.is_external());
+
+ eh2.set_external(false);
+ BOOST_CHECK_EQUAL(eh2._hdr._uflag, 0);
+ BOOST_CHECK(!eh2.is_transient());
+ BOOST_CHECK(!eh2.is_external());
+
+ eh2.set_transient(true);
+ eh2.set_external(true);
+ BOOST_CHECK_EQUAL(eh2._hdr._uflag,
+ enq_hdr::ENQ_HDR_TRANSIENT_MASK | enq_hdr::ENQ_HDR_EXTERNAL_MASK);
+ }
+
+ {
+ enq_hdr eh3(magic, version, rid, xidsize, dsize, true);
+ BOOST_CHECK_EQUAL(eh3._hdr._magic, magic);
+ BOOST_CHECK_EQUAL(eh3._hdr._version, version);
+#ifdef JRNL_LITTLE_ENDIAN
+ BOOST_CHECK_EQUAL(eh3._hdr._eflag, RHM_LENDIAN_FLAG);
+#else
+ BOOST_CHECK_EQUAL(eh3._hdr._eflag, RHM_BENDIAN_FLAG);
+#endif
+ BOOST_CHECK_EQUAL(eh3._hdr._uflag, enq_hdr::ENQ_HDR_TRANSIENT_MASK);
+ BOOST_CHECK_EQUAL(eh3._hdr._rid, rid);
+ BOOST_CHECK_EQUAL(eh3._xidsize, xidsize);
+ BOOST_CHECK_EQUAL(eh3._dsize, dsize);
+ BOOST_CHECK(eh3.is_transient());
+ BOOST_CHECK(!eh3.is_external());
+ }
+}
+
+void test_deq_hdr()
+{
+ const u_int32_t magic = 0xfedcba98UL;
+ const u_int8_t version = 0xa5;
+ const u_int16_t uflag = 0x1234;
+ const u_int64_t rid = 0xfedcba9876543210ULL;
+ const u_int64_t drid = 0x76543210fedcba98ULL;
+#ifdef JRNL_32_BIT
+ const size_t xidsize = 0xfedcba98UL;
+#else
+ const size_t xidsize = 0xfedcba9876543210ULL;
+#endif
+
+ {
+ deq_hdr dh1;
+ BOOST_CHECK_EQUAL(dh1._hdr._magic, 0UL);
+ BOOST_CHECK_EQUAL(dh1._hdr._version, 0);
+ BOOST_CHECK_EQUAL(dh1._hdr._eflag, 0);
+ BOOST_CHECK_EQUAL(dh1._hdr._uflag, 0);
+ BOOST_CHECK_EQUAL(dh1._hdr._rid, 0ULL);
+ BOOST_CHECK_EQUAL(dh1._deq_rid, 0ULL);
+#ifdef JRNL_32_BIT
+ BOOST_CHECK_EQUAL(dh1._xidsize, 0UL);
+#else
+ BOOST_CHECK_EQUAL(dh1._xidsize, 0ULL);
+#endif
+ }
+
+ {
+ deq_hdr dh2(magic, version, uflag, rid, drid, xidsize);
+ BOOST_CHECK_EQUAL(dh2._hdr._magic, magic);
+ BOOST_CHECK_EQUAL(dh2._hdr._version, version);
+#ifdef JRNL_LITTLE_ENDIAN
+ BOOST_CHECK_EQUAL(dh2._hdr._eflag, RHM_LENDIAN_FLAG);
+#else
+ BOOST_CHECK_EQUAL(dh2._hdr._eflag, RHM_BENDIAN_FLAG);
+#endif
+ BOOST_CHECK_EQUAL(dh2._hdr._uflag, uflag);
+ BOOST_CHECK_EQUAL(dh2._hdr._rid, rid);
+ BOOST_CHECK_EQUAL(dh2._deq_rid, drid);
+ BOOST_CHECK_EQUAL(dh2._xidsize, xidsize);
+ }
+}
+
+void test_txn_hdr()
+{
+ const u_int32_t magic = 0xfedcba98UL;
+ const u_int8_t version = 0xa5;
+ const u_int16_t uflag = 0x1234;
+ const u_int64_t rid = 0xfedcba9876543210ULL;
+#ifdef JRNL_32_BIT
+ const size_t xidsize = 0xfedcba98UL;
+#else
+ const size_t xidsize = 0xfedcba9876543210ULL;
+#endif
+
+ {
+ txn_hdr th1;
+ BOOST_CHECK_EQUAL(th1._hdr._magic, 0UL);
+ BOOST_CHECK_EQUAL(th1._hdr._version, 0);
+ BOOST_CHECK_EQUAL(th1._hdr._eflag, 0);
+ BOOST_CHECK_EQUAL(th1._hdr._uflag, 0);
+ BOOST_CHECK_EQUAL(th1._hdr._rid, 0ULL);
+#ifdef JRNL_32_BIT
+ BOOST_CHECK_EQUAL(th1._xidsize, 0UL);
+#else
+ BOOST_CHECK_EQUAL(th1._xidsize, 0ULL);
+#endif
+ }
+
+ {
+ txn_hdr th2(magic, version, uflag, rid, xidsize);
+ BOOST_CHECK_EQUAL(th2._hdr._magic, magic);
+ BOOST_CHECK_EQUAL(th2._hdr._version, version);
+#ifdef JRNL_LITTLE_ENDIAN
+ BOOST_CHECK_EQUAL(th2._hdr._eflag, RHM_LENDIAN_FLAG);
+#else
+ BOOST_CHECK_EQUAL(th2._hdr._eflag, RHM_BENDIAN_FLAG);
+#endif
+ BOOST_CHECK_EQUAL(th2._hdr._uflag, uflag);
+ BOOST_CHECK_EQUAL(th2._hdr._rid, rid);
+ BOOST_CHECK_EQUAL(th2._xidsize, xidsize);
+ }
+}
+
+// Initialize test suite and include test functions
+
+test_suite* init_unit_test_suite(int, char**)
+{
+ std::cout << "--------" << std::endl << "unit_test_file_hdr: ";
+ test_suite* ts = BOOST_TEST_SUITE("unit_test_file_hdr");
+
+ results_reporter::set_level(SHORT_REPORT);
+ unit_test_log_t::instance().set_threshold_level(log_messages);
+
+ ts->add(BOOST_TEST_CASE(&test_hdr));
+ ts->add(BOOST_TEST_CASE(&test_rec_tail));
+ ts->add(BOOST_TEST_CASE(&test_file_hdr));
+ ts->add(BOOST_TEST_CASE(&test_enq_hdr));
+ ts->add(BOOST_TEST_CASE(&test_deq_hdr));
+ ts->add(BOOST_TEST_CASE(&test_txn_hdr));
+
+ return ts;
+}
17 years, 3 months
rhmessaging commits: r1332 - in mgmt: misc and 1 other directory.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2007-11-17 09:31:19 -0500 (Sat, 17 Nov 2007)
New Revision: 1332
Modified:
mgmt/cumin/python/cumin/__init__.py
mgmt/cumin/python/cumin/broker.py
mgmt/cumin/python/cumin/model.py
mgmt/cumin/python/cumin/page.py
mgmt/cumin/python/cumin/parameters.py
mgmt/misc/mint-test.py
Log:
Checkpoint commit of changes to work with newest model.
Modified: mgmt/cumin/python/cumin/__init__.py
===================================================================
--- mgmt/cumin/python/cumin/__init__.py 2007-11-16 22:53:35 UTC (rev 1331)
+++ mgmt/cumin/python/cumin/__init__.py 2007-11-17 14:31:19 UTC (rev 1332)
@@ -34,10 +34,10 @@
self.mint = MintModel()
try:
- sys = MintSystem.get(1)
+ sys = System.get(1)
except SQLObjectNotFound:
- sys = MintSystem()
- sys.set(sysIdent=0, idOriginal=0)
+ sys = System()
+ sys.set(id=0, idOriginal=0)
self.model.sys = sys
Modified: mgmt/cumin/python/cumin/broker.py
===================================================================
--- mgmt/cumin/python/cumin/broker.py 2007-11-16 22:53:35 UTC (rev 1331)
+++ mgmt/cumin/python/cumin/broker.py 2007-11-17 14:31:19 UTC (rev 1332)
@@ -1,3 +1,4 @@
+import mint.schema as mint
from wooly import *
from wooly.widgets import *
from random import random
@@ -19,7 +20,7 @@
return "Brokers %s" % fmt_count(len(model.get_brokers()))
def get_items(self, session, model):
- return sorted_by(model.sys.brokers, "id")
+ return sorted_by(model.brokers(), "id")
def render_item_link(self, session, broker):
branch = session.branch()
@@ -283,7 +284,7 @@
return "Queues %s" % fmt_count(len(vhost.queues))
def get_object(self, session, broker):
- return MintVhost.selectBy(mintBrokerID=broker.id, name="/")[0]
+ return Vhost.selectBy(broker=broker, name="/")[0]
class BrokerExchangeTab(ExchangeSet):
def get_title(self, session, broker):
@@ -291,7 +292,7 @@
return "Exchanges %s" % fmt_count(len(vhost.exchanges))
def get_object(self, session, broker):
- return MintVhost.selectBy(mintBrokerID=broker.id, name="/")[0]
+ return Vhost.selectBy(broker=broker, name="/")[0]
class BrokerClientTab(ClientSet):
def get_title(self, session, broker):
@@ -299,15 +300,15 @@
return "Clients %s" % fmt_count(len(vhost.clients))
def get_object(self, session, broker):
- return MintVhost.selectBy(mintBrokerID=broker.id, name="/")[0]
+ return Vhost.selectBy(broker=broker, name="/")[0]
class BrokerVirtualHostTab(VirtualHostSet):
def get_title(self, session, broker):
return "Functional Hosts %s" % \
- fmt_count(len(broker.virtual_host_items()))
+ fmt_count(len(broker.vhosts))
def get_items(self, session, broker):
- return sorted_by(broker.virtual_host_items())
+ return sorted_by(broker.vhosts)
class BrokerConfigTab(ConfigPropertySet):
def get_title(self, session, broker):
@@ -558,8 +559,9 @@
names = self.names.get(session)
addrs = self.addrs.get(session)
groups = self.groups.get(session)
-
+
for name, addr, group in zip(names, addrs, groups):
- print name, addr, group
+ broker = mint.Broker()
+ broker.set(
self.process_cancel(session, model)
Modified: mgmt/cumin/python/cumin/model.py
===================================================================
--- mgmt/cumin/python/cumin/model.py 2007-11-16 22:53:35 UTC (rev 1331)
+++ mgmt/cumin/python/cumin/model.py 2007-11-17 14:31:19 UTC (rev 1332)
@@ -1,4 +1,4 @@
-from mint.schema import *
+import mint.schema as mint
from wooly import *
from wooly.model import *
@@ -47,23 +47,11 @@
self.link_cb = None
self.highlow = False
- def stats(self, object):
- if isinstance(object, MintQueue):
- stats = object.mintQueueStats
- elif isinstance(object, MintExchange):
- stats = object.mintExchangeStats
- elif isinstance(object, MintClient):
- stats = object.mintClientStats
- else:
- raise Exception()
-
- return stats
-
def value(self, object):
- return getattr(self.stats(object), self.name)
+ return getattr(object.stats, self.name)
def rate(self, object):
- return getattr(self.stats(object), self.name)
+ return getattr(object.stats, self.name)
def write_xml(self, object, writer):
writer.write("<stat name=\"%s\" value=\"%i\" rate=\"%i\"/>" \
@@ -73,7 +61,7 @@
class CuminQueue(CuminClass):
def __init__(self):
- super(CuminQueue, self).__init__(MintQueue)
+ super(CuminQueue, self).__init__(mint.Queue)
stat = CuminStat("consumers", "int")
stat.title = "Consumers"
@@ -436,6 +424,9 @@
def get_realm(self, id):
return self.get_index(self.realm).get(id)
+ def brokers(self):
+ return list(mint.Broker.select())
+
class DummyModelObject(ModelObject):
def __init__(self, model, mclass):
super(DummyModelObject, self).__init__(model, mclass)
Modified: mgmt/cumin/python/cumin/page.py
===================================================================
--- mgmt/cumin/python/cumin/page.py 2007-11-16 22:53:35 UTC (rev 1331)
+++ mgmt/cumin/python/cumin/page.py 2007-11-17 14:31:19 UTC (rev 1332)
@@ -183,7 +183,8 @@
class BrokerTab(BrokerBrowser):
def get_title(self, session, model):
- return "Brokers %s" % fmt_count(len(model.sys.brokers))
+ print dir(model.sys)
+ return "Brokers %s" % fmt_count(len(model.brokers()))
class BrokerProfileTab(BrokerProfileSet):
def get_title(self, session, model):
Modified: mgmt/cumin/python/cumin/parameters.py
===================================================================
--- mgmt/cumin/python/cumin/parameters.py 2007-11-16 22:53:35 UTC (rev 1331)
+++ mgmt/cumin/python/cumin/parameters.py 2007-11-17 14:31:19 UTC (rev 1332)
@@ -17,7 +17,7 @@
class BrokerParameter(Parameter):
def do_unmarshal(self, string):
- return MintBroker.get(int(string))
+ return Broker.get(int(string))
def do_marshal(self, broker):
return str(broker.id)
@@ -31,7 +31,7 @@
class ClientParameter(Parameter):
def do_unmarshal(self, string):
- return MintClient.get(int(string))
+ return Client.get(int(string))
def do_marshal(self, client):
return str(client.id)
@@ -45,14 +45,14 @@
class ExchangeParameter(Parameter):
def do_unmarshal(self, string):
- return MintExchange.get(int(string))
+ return Exchange.get(int(string))
def do_marshal(self, exchange):
return str(exchange.id)
class QueueParameter(Parameter):
def do_unmarshal(self, string):
- return MintQueue.get(int(string))
+ return Queue.get(int(string))
def do_marshal(self, queue):
return str(queue.id)
Modified: mgmt/misc/mint-test.py
===================================================================
--- mgmt/misc/mint-test.py 2007-11-16 22:53:35 UTC (rev 1331)
+++ mgmt/misc/mint-test.py 2007-11-17 14:31:19 UTC (rev 1332)
@@ -13,10 +13,10 @@
def getQueueByName(name, create=False):
try:
- queues = MintQueue.selectBy(name=name)[:1]
+ queues = Queue.selectBy(name=name)[:1]
queue = queues[0]
except IndexError:
- if (create): queue = MintQueue()
+ if (create): queue = Queue()
return queue
def configCallback(broker, oid, list, timestamps):
17 years, 3 months
rhmessaging commits: r1331 - in store/trunk/cpp: tests and 1 other directory.
by rhmessaging-commits@lists.jboss.org
Author: kpvdr
Date: 2007-11-16 17:53:35 -0500 (Fri, 16 Nov 2007)
New Revision: 1331
Modified:
store/trunk/cpp/lib/BdbMessageStore.cpp
store/trunk/cpp/tests/system_test.sh
Log:
Re-enable valgrind failures causing test failure
Modified: store/trunk/cpp/lib/BdbMessageStore.cpp
===================================================================
--- store/trunk/cpp/lib/BdbMessageStore.cpp 2007-11-16 22:53:21 UTC (rev 1330)
+++ store/trunk/cpp/lib/BdbMessageStore.cpp 2007-11-16 22:53:35 UTC (rev 1331)
@@ -972,7 +972,7 @@
break;
case rhm::journal::RHM_IORES_FULL:
// Temporary error msg till exception handler core problem solved...
-std::cerr << "Error storing message -- Journal full for queue " << queue->getName() << std::endl << std::flush;
+std::cerr << "Error storing message -- Journal full on queue \"" << queue->getName() << "\"" << std::endl << std::flush;
THROW_STORE_FULL_EXCEPTION("Error storing message -- Journal full :" + queue->getName());
break;
default:
Modified: store/trunk/cpp/tests/system_test.sh
===================================================================
--- store/trunk/cpp/tests/system_test.sh 2007-11-16 22:53:21 UTC (rev 1330)
+++ store/trunk/cpp/tests/system_test.sh 2007-11-16 22:53:35 UTC (rev 1331)
@@ -77,7 +77,7 @@
python "$abs_srcdir/persistence.py" -s "$xml_spec" -p $p -r 3 || fail=1
sleep 1
kill -SIGINT $pid || { echo process already died; cat qpid.log ; fail=1; }
- wait $pid #temporarily disable failure until broker can shutdown cleanly|| fail=1
+ wait $pid || fail=1
vg_check $log || fail=1
done
17 years, 3 months
rhmessaging commits: r1330 - in mgmt/mint: python/mint and 1 other directory.
by rhmessaging-commits@lists.jboss.org
Author: nunofsantos
Date: 2007-11-16 17:53:21 -0500 (Fri, 16 Nov 2007)
New Revision: 1330
Modified:
mgmt/mint/python/mint/__init__.py
mgmt/mint/python/mint/schema.py
mgmt/mint/schemaparser.py
Log:
refactored callback handlers to make them type generic
Modified: mgmt/mint/python/mint/__init__.py
===================================================================
--- mgmt/mint/python/mint/__init__.py 2007-11-16 21:59:23 UTC (rev 1329)
+++ mgmt/mint/python/mint/__init__.py 2007-11-16 22:53:21 UTC (rev 1330)
@@ -48,11 +48,8 @@
self.connectedBrokers = dict()
def sanitizeDict(self, d):
- for k in d.iterkeys():
- if (k == "id"):
- d[self.convertIdKey(k)] = d.pop(k)
- elif (k.endswith("Ref")):
- d[self.convertRefKey(k)] = d.pop(k)
+ if ("id" in d):
+ d[self.convertIdKey("id")] = d.pop("id")
return d
def convertIdKey(self, k):
@@ -61,66 +58,58 @@
def convertRefKey(self, k):
return k.replace("Ref", "")
+ def findParentKey(self, d):
+ for key in d.keys():
+ if (key.endswith("Ref")):
+ return key
+ return ""
+
def configCallback(self, broker, objectName, list, timestamps):
print "\nCONFIG---------------------------------------------------"
print objectName
- result = None
d = self.sanitizeDict(dict(list))
connectedBroker = self.connectedBrokers[broker]
d["managedBroker"] = broker
d["recTime"] = datetime.fromtimestamp(timestamps[0]/1000000000)
d["creationTime"] = datetime.fromtimestamp(timestamps[1]/1000000000)
print d
-
- if (objectName == "queue"):
- d["vhost"] = connectedBroker.getByOriginalId(schema.Vhost, d.pop(self.convertRefKey("vhostRef")))
- queue = connectedBroker.getByOriginalId(schema.Queue, d["idOriginal"], create=True)
- queue.set(**d)
- result = queue
- elif (objectName == "vhost"):
- d["broker"] = connectedBroker.getByOriginalId(schema.Broker, d.pop(self.convertRefKey("brokerRef")))
- vhost = connectedBroker.getByOriginalId(schema.Vhost, d["idOriginal"], create=True)
- vhost.set(**d)
- result = vhost
- elif (objectName == "broker"):
-#FIX
- d.pop(self.convertRefKey("systemRef"))
-# d["system"] = connectedBroker.getByOriginalId(System, 0)
+ ###FIX
+ if (objectName == "broker"):
+ # needs special handling until schema is sendind info about systems
+ d.pop("systemRef")
+ # d["system"] = connectedBroker.getByOriginalId(System, 0)
d["system"] = schema.System.selectBy(idOriginal=0)[:1][0]
connectedBroker.objs.set(0, d["system"])
-#FIX
- broker = connectedBroker.getByOriginalId(schema.Broker, d["idOriginal"], create=True)
- broker.set(**d)
- result = broker
- print "END CONFIG---------------------------------------------------\n"
- return result
+ else:
+ parentKey = self.findParentKey(d)
+ d[self.convertRefKey(parentKey)] = connectedBroker.getByOriginalId(schema.Vhost, d.pop(parentKey))
+ ###FIX
+ obj = connectedBroker.getByOriginalId(schema.schemaNameToClassMap[objectName], d["idOriginal"], create=True)
+ obj.set(**d)
+ print "END CONFIG---------------------------------------------------\n"
+ return obj
def instCallback(self, broker, objectName, list, timestamps):
print "\nINST---------------------------------------------------"
print objectName
- result = None
d = self.sanitizeDict(dict(list))
connectedBroker = self.connectedBrokers[broker]
d["recTime"] = datetime.fromtimestamp(timestamps[0]/1000000000)
print d
- if (objectName == "queue"):
- queue = connectedBroker.getByOriginalId(schema.Queue, d[self.convertIdKey("id")])
- d["queue"] = queue
- queueStats = schema.QueueStats()
- queueStats.set(**d)
- d = dict()
- if (timestamps[2] != 0):
- d["deletionTime"] = datetime.fromtimestamp(timestamps[2]/1000000000)
- d["statsPrev"] = queue.stats
- d["stats"] = queueStats
- queue.set(**d)
- result = queueStats
- elif (objectName == "vhost"):
- pass
- elif (objectName == "broker"):
- pass
+ obj = connectedBroker.getByOriginalId(schema.schemaNameToClassMap[objectName], d[self.convertIdKey("id")])
+ d[objectName] = obj
+ objNameStats = eval("schema.%sStats" % (schema.schemaNameToClassMap[objectName].__name__))
+ objStats = objNameStats.__new__(objNameStats)
+ objStats.__init__()
+ objStats.set(**d)
+ d = dict()
+ if (timestamps[2] != 0):
+ d["deletionTime"] = datetime.fromtimestamp(timestamps[2]/1000000000)
+ d["statsPrev"] = obj.stats
+ d["stats"] = objStats
+ obj.set(**d)
print "END INST---------------------------------------------------\n"
- return result
+ return objStats
def methodCallback(self, broker, methodId, errorNo, errorText, args):
print "\nMETHOD---------------------------------------------------"
@@ -129,9 +118,10 @@
print "Args: "
print args
method = self.outstandingMethodCalls.pop(methodId)
- method(errorText, args)
+ result = method(errorText, args)
print "END METHOD---------------------------------------------------\n"
-
+ return result
+
def connectToBroker(self, host, port):
broker = ManagedBroker(host=host, port=port)
label = "%s:%d" % (host, port)
Modified: mgmt/mint/python/mint/schema.py
===================================================================
--- mgmt/mint/python/mint/schema.py 2007-11-16 21:59:23 UTC (rev 1329)
+++ mgmt/mint/python/mint/schema.py 2007-11-16 22:53:21 UTC (rev 1330)
@@ -45,25 +45,29 @@
actualArgs = dict()
actualArgs["clusterName"] = clusterName
methodId = model.registerCallback(callbackMethod)
- model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, classToSchemaNameMap[self.__class__.__name__], "joinCluster", args=actualArgs, packageName="qpid")
+ model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, \
+ classToSchemaNameMap[self.__class__.__name__], "joinCluster", args=actualArgs, packageName="qpid")
def leaveCluster(self, model, managedBrokerLabel, callbackMethod):
actualArgs = dict()
methodId = model.registerCallback(callbackMethod)
- model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, classToSchemaNameMap[self.__class__.__name__], "leaveCluster", args=actualArgs, packageName="qpid")
+ model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, \
+ classToSchemaNameMap[self.__class__.__name__], "leaveCluster", args=actualArgs, packageName="qpid")
def echo(self, model, managedBrokerLabel, callbackMethod, sequence, body):
actualArgs = dict()
actualArgs["sequence"] = sequence
actualArgs["body"] = body
methodId = model.registerCallback(callbackMethod)
- model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, classToSchemaNameMap[self.__class__.__name__], "echo", args=actualArgs, packageName="qpid")
+ model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, \
+ classToSchemaNameMap[self.__class__.__name__], "echo", args=actualArgs, packageName="qpid")
def crash(self, model, managedBrokerLabel, callbackMethod):
"""Temporary test method to crash the broker"""
actualArgs = dict()
methodId = model.registerCallback(callbackMethod)
- model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, classToSchemaNameMap[self.__class__.__name__], "crash", args=actualArgs, packageName="qpid")
+ model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, \
+ classToSchemaNameMap[self.__class__.__name__], "crash", args=actualArgs, packageName="qpid")
class BrokerStats(SQLObject):
idOriginal = BigIntCol(default=None)
@@ -105,14 +109,16 @@
"""Discard all messages on queue"""
actualArgs = dict()
methodId = model.registerCallback(callbackMethod)
- model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, classToSchemaNameMap[self.__class__.__name__], "purge", args=actualArgs, packageName="qpid")
+ model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, \
+ classToSchemaNameMap[self.__class__.__name__], "purge", args=actualArgs, packageName="qpid")
def increaseDiskSize(self, model, managedBrokerLabel, callbackMethod, pages):
"""Increase number of disk pages allocated for this queue"""
actualArgs = dict()
actualArgs["pages"] = pages
methodId = model.registerCallback(callbackMethod)
- model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, classToSchemaNameMap[self.__class__.__name__], "increaseDiskSize", args=actualArgs, packageName="qpid")
+ model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, \
+ classToSchemaNameMap[self.__class__.__name__], "increaseDiskSize", args=actualArgs, packageName="qpid")
class QueueStats(SQLObject):
idOriginal = BigIntCol(default=None)
@@ -223,12 +229,14 @@
def close(self, model, managedBrokerLabel, callbackMethod):
actualArgs = dict()
methodId = model.registerCallback(callbackMethod)
- model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, classToSchemaNameMap[self.__class__.__name__], "close", args=actualArgs, packageName="qpid")
+ model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, \
+ classToSchemaNameMap[self.__class__.__name__], "close", args=actualArgs, packageName="qpid")
def detach(self, model, managedBrokerLabel, callbackMethod):
actualArgs = dict()
methodId = model.registerCallback(callbackMethod)
- model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, classToSchemaNameMap[self.__class__.__name__], "detach", args=actualArgs, packageName="qpid")
+ model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, \
+ classToSchemaNameMap[self.__class__.__name__], "detach", args=actualArgs, packageName="qpid")
class ClientStats(SQLObject):
idOriginal = BigIntCol(default=None)
@@ -256,22 +264,26 @@
def solicitAck(self, model, managedBrokerLabel, callbackMethod):
actualArgs = dict()
methodId = model.registerCallback(callbackMethod)
- model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, classToSchemaNameMap[self.__class__.__name__], "solicitAck", args=actualArgs, packageName="qpid")
+ model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, \
+ classToSchemaNameMap[self.__class__.__name__], "solicitAck", args=actualArgs, packageName="qpid")
def detach(self, model, managedBrokerLabel, callbackMethod):
actualArgs = dict()
methodId = model.registerCallback(callbackMethod)
- model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, classToSchemaNameMap[self.__class__.__name__], "detach", args=actualArgs, packageName="qpid")
+ model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, \
+ classToSchemaNameMap[self.__class__.__name__], "detach", args=actualArgs, packageName="qpid")
def resetLifespan(self, model, managedBrokerLabel, callbackMethod):
actualArgs = dict()
methodId = model.registerCallback(callbackMethod)
- model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, classToSchemaNameMap[self.__class__.__name__], "resetLifespan", args=actualArgs, packageName="qpid")
+ model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, \
+ classToSchemaNameMap[self.__class__.__name__], "resetLifespan", args=actualArgs, packageName="qpid")
def close(self, model, managedBrokerLabel, callbackMethod):
actualArgs = dict()
methodId = model.registerCallback(callbackMethod)
- model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, classToSchemaNameMap[self.__class__.__name__], "close", args=actualArgs, packageName="qpid")
+ model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, \
+ classToSchemaNameMap[self.__class__.__name__], "close", args=actualArgs, packageName="qpid")
class SessionStats(SQLObject):
idOriginal = BigIntCol(default=None)
@@ -297,17 +309,20 @@
actualArgs = dict()
actualArgs["strength"] = strength
methodId = model.registerCallback(callbackMethod)
- model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, classToSchemaNameMap[self.__class__.__name__], "throttle", args=actualArgs, packageName="qpid")
+ model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, \
+ classToSchemaNameMap[self.__class__.__name__], "throttle", args=actualArgs, packageName="qpid")
def stop(self, model, managedBrokerLabel, callbackMethod):
actualArgs = dict()
methodId = model.registerCallback(callbackMethod)
- model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, classToSchemaNameMap[self.__class__.__name__], "stop", args=actualArgs, packageName="qpid")
+ model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, \
+ classToSchemaNameMap[self.__class__.__name__], "stop", args=actualArgs, packageName="qpid")
def start(self, model, managedBrokerLabel, callbackMethod):
actualArgs = dict()
methodId = model.registerCallback(callbackMethod)
- model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, classToSchemaNameMap[self.__class__.__name__], "start", args=actualArgs, packageName="qpid")
+ model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, \
+ classToSchemaNameMap[self.__class__.__name__], "start", args=actualArgs, packageName="qpid")
class DestinationStats(SQLObject):
idOriginal = BigIntCol(default=None)
@@ -351,7 +366,8 @@
def close(self, model, managedBrokerLabel, callbackMethod):
actualArgs = dict()
methodId = model.registerCallback(callbackMethod)
- model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, classToSchemaNameMap[self.__class__.__name__], "close", args=actualArgs, packageName="qpid")
+ model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, \
+ classToSchemaNameMap[self.__class__.__name__], "close", args=actualArgs, packageName="qpid")
class ConsumerStats(SQLObject):
idOriginal = BigIntCol(default=None)
@@ -364,14 +380,26 @@
unackedMessagesHigh = IntCol(default=None)
classToSchemaNameMap = dict()
+schemaNameToClassMap = dict()
classToSchemaNameMap['System'] = 'system'
+schemaNameToClassMap['system'] = System
classToSchemaNameMap['Broker'] = 'broker'
+schemaNameToClassMap['broker'] = Broker
classToSchemaNameMap['Vhost'] = 'vhost'
+schemaNameToClassMap['vhost'] = Vhost
classToSchemaNameMap['Queue'] = 'queue'
+schemaNameToClassMap['queue'] = Queue
classToSchemaNameMap['Exchange'] = 'exchange'
+schemaNameToClassMap['exchange'] = Exchange
classToSchemaNameMap['Binding'] = 'binding'
+schemaNameToClassMap['binding'] = Binding
classToSchemaNameMap['Client'] = 'client'
+schemaNameToClassMap['client'] = Client
classToSchemaNameMap['Session'] = 'session'
+schemaNameToClassMap['session'] = Session
classToSchemaNameMap['Destination'] = 'destination'
+schemaNameToClassMap['destination'] = Destination
classToSchemaNameMap['Producer'] = 'producer'
+schemaNameToClassMap['producer'] = Producer
classToSchemaNameMap['Consumer'] = 'consumer'
+schemaNameToClassMap['consumer'] = Consumer
Modified: mgmt/mint/schemaparser.py
===================================================================
--- mgmt/mint/schemaparser.py 2007-11-16 21:59:23 UTC (rev 1329)
+++ mgmt/mint/schemaparser.py 2007-11-16 22:53:21 UTC (rev 1330)
@@ -14,6 +14,7 @@
self.pythonOutput += "sqlhub.processConnection = conn\n\n"
self.additional = ""
self.final = "\nclassToSchemaNameMap = dict()\n"
+ self.final += "schemaNameToClassMap = dict()\n"
# mapping between xml schema types and database column types
# see xml/MintTypes.xml
self.dataTypesMap = dict()
@@ -84,6 +85,7 @@
self.generateForeignKeyAttrib("stats", statsPythonName)
self.generateForeignKeyAttrib("statsPrev", statsPythonName)
self.final += "classToSchemaNameMap['%s'] = '%s'\n" % (pythonName, schemaName)
+ self.final += "schemaNameToClassMap['%s'] = %s\n" % (schemaName, pythonName)
def generateMethod(self, elem):
if (elem["@desc"] != None):
@@ -103,7 +105,8 @@
self.pythonOutput += comment
self.pythonOutput += actualArgs
self.pythonOutput += " methodId = model.registerCallback(callbackMethod)\n"
- self.pythonOutput += " model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, classToSchemaNameMap[self.__class__.__name__], \"%s\", " % (elem["@name"])
+ self.pythonOutput += " model.getConnectedBroker(managedBrokerLabel).method(methodId, self.idOriginal, \\\n"
+ self.pythonOutput += " classToSchemaNameMap[self.__class__.__name__], \"%s\", " % (elem["@name"])
self.pythonOutput += "args=actualArgs, packageName=\"qpid\")\n"
def endClass(self):
17 years, 3 months
rhmessaging commits: r1329 - in mgmt/mint: python/mint and 1 other directory.
by rhmessaging-commits@lists.jboss.org
Author: nunofsantos
Date: 2007-11-16 16:59:23 -0500 (Fri, 16 Nov 2007)
New Revision: 1329
Modified:
mgmt/mint/python/mint/__init__.py
mgmt/mint/python/mint/schema.py
mgmt/mint/python/mint/schema.sql
mgmt/mint/schemaparser.py
Log:
add statsPrev (statistics from the previous time interval) to all entities
Modified: mgmt/mint/python/mint/__init__.py
===================================================================
--- mgmt/mint/python/mint/__init__.py 2007-11-16 20:07:46 UTC (rev 1328)
+++ mgmt/mint/python/mint/__init__.py 2007-11-16 21:59:23 UTC (rev 1329)
@@ -111,6 +111,7 @@
d = dict()
if (timestamps[2] != 0):
d["deletionTime"] = datetime.fromtimestamp(timestamps[2]/1000000000)
+ d["statsPrev"] = queue.stats
d["stats"] = queueStats
queue.set(**d)
result = queueStats
Modified: mgmt/mint/python/mint/schema.py
===================================================================
--- mgmt/mint/python/mint/schema.py 2007-11-16 20:07:46 UTC (rev 1328)
+++ mgmt/mint/python/mint/schema.py 2007-11-16 21:59:23 UTC (rev 1329)
@@ -11,6 +11,7 @@
deletionTime = TimestampCol(default=None)
managedBroker = StringCol(length=1000, default=None)
stats = ForeignKey('SystemStats', cascade='null', default=None)
+ statsPrev = ForeignKey('SystemStats', cascade='null', default=None)
sysId = StringCol(length=1000, default=None)
class SystemStats(SQLObject):
@@ -25,6 +26,7 @@
deletionTime = TimestampCol(default=None)
managedBroker = StringCol(length=1000, default=None)
stats = ForeignKey('BrokerStats', cascade='null', default=None)
+ statsPrev = ForeignKey('BrokerStats', cascade='null', default=None)
system = ForeignKey('System', cascade='null', default=None)
port = SmallIntCol(default=None)
workerThreads = SmallIntCol(default=None)
@@ -75,6 +77,7 @@
deletionTime = TimestampCol(default=None)
managedBroker = StringCol(length=1000, default=None)
stats = ForeignKey('VhostStats', cascade='null', default=None)
+ statsPrev = ForeignKey('VhostStats', cascade='null', default=None)
broker = ForeignKey('Broker', cascade='null', default=None)
name = StringCol(length=1000, default=None)
@@ -90,6 +93,7 @@
deletionTime = TimestampCol(default=None)
managedBroker = StringCol(length=1000, default=None)
stats = ForeignKey('QueueStats', cascade='null', default=None)
+ statsPrev = ForeignKey('QueueStats', cascade='null', default=None)
vhost = ForeignKey('Vhost', cascade='null', default=None)
name = StringCol(length=1000, default=None)
durable = BoolCol(default=None)
@@ -164,6 +168,7 @@
deletionTime = TimestampCol(default=None)
managedBroker = StringCol(length=1000, default=None)
stats = ForeignKey('ExchangeStats', cascade='null', default=None)
+ statsPrev = ForeignKey('ExchangeStats', cascade='null', default=None)
vhost = ForeignKey('Vhost', cascade='null', default=None)
name = StringCol(length=1000, default=None)
type = StringCol(length=1000, default=None)
@@ -192,6 +197,7 @@
deletionTime = TimestampCol(default=None)
managedBroker = StringCol(length=1000, default=None)
stats = ForeignKey('BindingStats', cascade='null', default=None)
+ statsPrev = ForeignKey('BindingStats', cascade='null', default=None)
queue = ForeignKey('Queue', cascade='null', default=None)
exchange = ForeignKey('Exchange', cascade='null', default=None)
bindingKey = StringCol(length=1000, default=None)
@@ -209,6 +215,7 @@
deletionTime = TimestampCol(default=None)
managedBroker = StringCol(length=1000, default=None)
stats = ForeignKey('ClientStats', cascade='null', default=None)
+ statsPrev = ForeignKey('ClientStats', cascade='null', default=None)
vhost = ForeignKey('Vhost', cascade='null', default=None)
ipAddr = IntCol(default=None)
port = SmallIntCol(default=None)
@@ -240,6 +247,7 @@
deletionTime = TimestampCol(default=None)
managedBroker = StringCol(length=1000, default=None)
stats = ForeignKey('SessionStats', cascade='null', default=None)
+ statsPrev = ForeignKey('SessionStats', cascade='null', default=None)
vhost = ForeignKey('Vhost', cascade='null', default=None)
name = StringCol(length=1000, default=None)
client = ForeignKey('Client', cascade='null', default=None)
@@ -280,6 +288,7 @@
deletionTime = TimestampCol(default=None)
managedBroker = StringCol(length=1000, default=None)
stats = ForeignKey('DestinationStats', cascade='null', default=None)
+ statsPrev = ForeignKey('DestinationStats', cascade='null', default=None)
session = ForeignKey('Session', cascade='null', default=None)
name = StringCol(length=1000, default=None)
@@ -317,6 +326,7 @@
deletionTime = TimestampCol(default=None)
managedBroker = StringCol(length=1000, default=None)
stats = ForeignKey('ProducerStats', cascade='null', default=None)
+ statsPrev = ForeignKey('ProducerStats', cascade='null', default=None)
destination = ForeignKey('Destination', cascade='null', default=None)
exchange = ForeignKey('Exchange', cascade='null', default=None)
@@ -334,6 +344,7 @@
deletionTime = TimestampCol(default=None)
managedBroker = StringCol(length=1000, default=None)
stats = ForeignKey('ConsumerStats', cascade='null', default=None)
+ statsPrev = ForeignKey('ConsumerStats', cascade='null', default=None)
destination = ForeignKey('Destination', cascade='null', default=None)
queue = ForeignKey('Queue', cascade='null', default=None)
Modified: mgmt/mint/python/mint/schema.sql
===================================================================
--- mgmt/mint/python/mint/schema.sql 2007-11-16 20:07:46 UTC (rev 1328)
+++ mgmt/mint/python/mint/schema.sql 2007-11-16 21:59:23 UTC (rev 1329)
@@ -6,6 +6,7 @@
deletion_time TIMESTAMP,
managed_broker VARCHAR(1000),
stats_id INT,
+ stats_prev_id INT,
queue_id INT,
exchange_id INT,
binding_key VARCHAR(1000)
@@ -27,6 +28,7 @@
deletion_time TIMESTAMP,
managed_broker VARCHAR(1000),
stats_id INT,
+ stats_prev_id INT,
system_id INT,
port SMALLINT,
worker_threads SMALLINT,
@@ -57,6 +59,7 @@
deletion_time TIMESTAMP,
managed_broker VARCHAR(1000),
stats_id INT,
+ stats_prev_id INT,
vhost_id INT,
ip_addr INT,
port SMALLINT
@@ -82,6 +85,7 @@
deletion_time TIMESTAMP,
managed_broker VARCHAR(1000),
stats_id INT,
+ stats_prev_id INT,
destination_id INT,
queue_id INT
);
@@ -106,6 +110,7 @@
deletion_time TIMESTAMP,
managed_broker VARCHAR(1000),
stats_id INT,
+ stats_prev_id INT,
session_id INT,
name VARCHAR(1000)
);
@@ -130,6 +135,7 @@
deletion_time TIMESTAMP,
managed_broker VARCHAR(1000),
stats_id INT,
+ stats_prev_id INT,
vhost_id INT,
name VARCHAR(1000),
type VARCHAR(1000)
@@ -162,6 +168,7 @@
deletion_time TIMESTAMP,
managed_broker VARCHAR(1000),
stats_id INT,
+ stats_prev_id INT,
destination_id INT,
exchange_id INT
);
@@ -183,6 +190,7 @@
deletion_time TIMESTAMP,
managed_broker VARCHAR(1000),
stats_id INT,
+ stats_prev_id INT,
vhost_id INT,
name VARCHAR(1000),
durable BOOL,
@@ -248,6 +256,7 @@
deletion_time TIMESTAMP,
managed_broker VARCHAR(1000),
stats_id INT,
+ stats_prev_id INT,
vhost_id INT,
name VARCHAR(1000),
client_id INT,
@@ -272,6 +281,7 @@
deletion_time TIMESTAMP,
managed_broker VARCHAR(1000),
stats_id INT,
+ stats_prev_id INT,
sys_id VARCHAR(1000)
);
@@ -290,6 +300,7 @@
deletion_time TIMESTAMP,
managed_broker VARCHAR(1000),
stats_id INT,
+ stats_prev_id INT,
broker_id INT,
name VARCHAR(1000)
);
@@ -303,6 +314,8 @@
ALTER TABLE binding ADD CONSTRAINT stats_id_exists FOREIGN KEY (stats_id) REFERENCES binding_stats (id) ON DELETE SET NULL;
+ALTER TABLE binding ADD CONSTRAINT stats_prev_id_exists FOREIGN KEY (stats_prev_id) REFERENCES binding_stats (id) ON DELETE SET NULL;
+
ALTER TABLE binding ADD CONSTRAINT queue_id_exists FOREIGN KEY (queue_id) REFERENCES queue (id) ON DELETE SET NULL;
ALTER TABLE binding ADD CONSTRAINT exchange_id_exists FOREIGN KEY (exchange_id) REFERENCES exchange (id) ON DELETE SET NULL;
@@ -311,18 +324,24 @@
ALTER TABLE broker ADD CONSTRAINT stats_id_exists FOREIGN KEY (stats_id) REFERENCES broker_stats (id) ON DELETE SET NULL;
+ALTER TABLE broker ADD CONSTRAINT stats_prev_id_exists FOREIGN KEY (stats_prev_id) REFERENCES broker_stats (id) ON DELETE SET NULL;
+
ALTER TABLE broker ADD CONSTRAINT system_id_exists FOREIGN KEY (system_id) REFERENCES system (id) ON DELETE SET NULL;
ALTER TABLE broker_stats ADD CONSTRAINT broker_id_exists FOREIGN KEY (broker_id) REFERENCES broker (id) ON DELETE SET NULL;
ALTER TABLE client ADD CONSTRAINT stats_id_exists FOREIGN KEY (stats_id) REFERENCES client_stats (id) ON DELETE SET NULL;
+ALTER TABLE client ADD CONSTRAINT stats_prev_id_exists FOREIGN KEY (stats_prev_id) REFERENCES client_stats (id) ON DELETE SET NULL;
+
ALTER TABLE client ADD CONSTRAINT vhost_id_exists FOREIGN KEY (vhost_id) REFERENCES vhost (id) ON DELETE SET NULL;
ALTER TABLE client_stats ADD CONSTRAINT client_id_exists FOREIGN KEY (client_id) REFERENCES client (id) ON DELETE SET NULL;
ALTER TABLE consumer ADD CONSTRAINT stats_id_exists FOREIGN KEY (stats_id) REFERENCES consumer_stats (id) ON DELETE SET NULL;
+ALTER TABLE consumer ADD CONSTRAINT stats_prev_id_exists FOREIGN KEY (stats_prev_id) REFERENCES consumer_stats (id) ON DELETE SET NULL;
+
ALTER TABLE consumer ADD CONSTRAINT destination_id_exists FOREIGN KEY (destination_id) REFERENCES destination (id) ON DELETE SET NULL;
ALTER TABLE consumer ADD CONSTRAINT queue_id_exists FOREIGN KEY (queue_id) REFERENCES queue (id) ON DELETE SET NULL;
@@ -331,18 +350,24 @@
ALTER TABLE destination ADD CONSTRAINT stats_id_exists FOREIGN KEY (stats_id) REFERENCES destination_stats (id) ON DELETE SET NULL;
+ALTER TABLE destination ADD CONSTRAINT stats_prev_id_exists FOREIGN KEY (stats_prev_id) REFERENCES destination_stats (id) ON DELETE SET NULL;
+
ALTER TABLE destination ADD CONSTRAINT session_id_exists FOREIGN KEY (session_id) REFERENCES session (id) ON DELETE SET NULL;
ALTER TABLE destination_stats ADD CONSTRAINT destination_id_exists FOREIGN KEY (destination_id) REFERENCES destination (id) ON DELETE SET NULL;
ALTER TABLE exchange ADD CONSTRAINT stats_id_exists FOREIGN KEY (stats_id) REFERENCES exchange_stats (id) ON DELETE SET NULL;
+ALTER TABLE exchange ADD CONSTRAINT stats_prev_id_exists FOREIGN KEY (stats_prev_id) REFERENCES exchange_stats (id) ON DELETE SET NULL;
+
ALTER TABLE exchange ADD CONSTRAINT vhost_id_exists FOREIGN KEY (vhost_id) REFERENCES vhost (id) ON DELETE SET NULL;
ALTER TABLE exchange_stats ADD CONSTRAINT exchange_id_exists FOREIGN KEY (exchange_id) REFERENCES exchange (id) ON DELETE SET NULL;
ALTER TABLE producer ADD CONSTRAINT stats_id_exists FOREIGN KEY (stats_id) REFERENCES producer_stats (id) ON DELETE SET NULL;
+ALTER TABLE producer ADD CONSTRAINT stats_prev_id_exists FOREIGN KEY (stats_prev_id) REFERENCES producer_stats (id) ON DELETE SET NULL;
+
ALTER TABLE producer ADD CONSTRAINT destination_id_exists FOREIGN KEY (destination_id) REFERENCES destination (id) ON DELETE SET NULL;
ALTER TABLE producer ADD CONSTRAINT exchange_id_exists FOREIGN KEY (exchange_id) REFERENCES exchange (id) ON DELETE SET NULL;
@@ -351,12 +376,16 @@
ALTER TABLE queue ADD CONSTRAINT stats_id_exists FOREIGN KEY (stats_id) REFERENCES queue_stats (id) ON DELETE SET NULL;
+ALTER TABLE queue ADD CONSTRAINT stats_prev_id_exists FOREIGN KEY (stats_prev_id) REFERENCES queue_stats (id) ON DELETE SET NULL;
+
ALTER TABLE queue ADD CONSTRAINT vhost_id_exists FOREIGN KEY (vhost_id) REFERENCES vhost (id) ON DELETE SET NULL;
ALTER TABLE queue_stats ADD CONSTRAINT queue_id_exists FOREIGN KEY (queue_id) REFERENCES queue (id) ON DELETE SET NULL;
ALTER TABLE session ADD CONSTRAINT stats_id_exists FOREIGN KEY (stats_id) REFERENCES session_stats (id) ON DELETE SET NULL;
+ALTER TABLE session ADD CONSTRAINT stats_prev_id_exists FOREIGN KEY (stats_prev_id) REFERENCES session_stats (id) ON DELETE SET NULL;
+
ALTER TABLE session ADD CONSTRAINT vhost_id_exists FOREIGN KEY (vhost_id) REFERENCES vhost (id) ON DELETE SET NULL;
ALTER TABLE session ADD CONSTRAINT client_id_exists FOREIGN KEY (client_id) REFERENCES client (id) ON DELETE SET NULL;
@@ -365,10 +394,14 @@
ALTER TABLE system ADD CONSTRAINT stats_id_exists FOREIGN KEY (stats_id) REFERENCES system_stats (id) ON DELETE SET NULL;
+ALTER TABLE system ADD CONSTRAINT stats_prev_id_exists FOREIGN KEY (stats_prev_id) REFERENCES system_stats (id) ON DELETE SET NULL;
+
ALTER TABLE system_stats ADD CONSTRAINT system_id_exists FOREIGN KEY (system_id) REFERENCES system (id) ON DELETE SET NULL;
ALTER TABLE vhost ADD CONSTRAINT stats_id_exists FOREIGN KEY (stats_id) REFERENCES vhost_stats (id) ON DELETE SET NULL;
+ALTER TABLE vhost ADD CONSTRAINT stats_prev_id_exists FOREIGN KEY (stats_prev_id) REFERENCES vhost_stats (id) ON DELETE SET NULL;
+
ALTER TABLE vhost ADD CONSTRAINT broker_id_exists FOREIGN KEY (broker_id) REFERENCES broker (id) ON DELETE SET NULL;
ALTER TABLE vhost_stats ADD CONSTRAINT vhost_id_exists FOREIGN KEY (vhost_id) REFERENCES vhost (id) ON DELETE SET NULL;
Modified: mgmt/mint/schemaparser.py
===================================================================
--- mgmt/mint/schemaparser.py 2007-11-16 20:07:46 UTC (rev 1328)
+++ mgmt/mint/schemaparser.py 2007-11-16 21:59:23 UTC (rev 1329)
@@ -82,6 +82,7 @@
self.generateTimestampAttrib("deletion")
self.generateAttrib("managedBroker", "StringCol", "length=1000")
self.generateForeignKeyAttrib("stats", statsPythonName)
+ self.generateForeignKeyAttrib("statsPrev", statsPythonName)
self.final += "classToSchemaNameMap['%s'] = '%s'\n" % (pythonName, schemaName)
def generateMethod(self, elem):
17 years, 3 months
rhmessaging commits: r1328 - in store/trunk/cpp: tests/jrnl and 1 other directory.
by rhmessaging-commits@lists.jboss.org
Author: kpvdr
Date: 2007-11-16 15:07:46 -0500 (Fri, 16 Nov 2007)
New Revision: 1328
Modified:
store/trunk/cpp/lib/jrnl/jexception.cpp
store/trunk/cpp/lib/jrnl/jexception.hpp
store/trunk/cpp/tests/jrnl/unit_test_jexception.cpp
Log:
Another fix to jexception and its unit test class. It now handles null strings and strings that exceed its internal buffer space.
Modified: store/trunk/cpp/lib/jrnl/jexception.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jexception.cpp 2007-11-16 19:55:33 UTC (rev 1327)
+++ store/trunk/cpp/lib/jrnl/jexception.cpp 2007-11-16 20:07:46 UTC (rev 1328)
@@ -33,9 +33,11 @@
#include <jrnl/jexception.hpp>
#include <iomanip>
+#include <iostream> // debug only
#include <sstream>
#include <jrnl/jerrno.hpp>
+#define CATLEN(p) MAX_MSG_SIZE - ::strlen(p) - 1
namespace rhm
{
@@ -46,6 +48,7 @@
std::exception(),
_err_code(0)
{
+ ::sprintf(_what_msg, "jexception 0x0000");
*_additional_info = '\0';
*_throwing_class = '\0';
*_throwing_fn = '\0';
@@ -55,6 +58,7 @@
std::exception(),
_err_code(err_code)
{
+ ::sprintf(_what_msg, "jexception 0x%04X", err_code);
*_additional_info = '\0';
*_throwing_class = '\0';
*_throwing_fn = '\0';
@@ -64,7 +68,15 @@
std::exception(),
_err_code(0)
{
- if (additional_info) ::strncpy(_additional_info, additional_info, MAX_MSG_SIZE);
+ ::sprintf(_what_msg, "jexception ");
+ if (additional_info)
+ {
+ ::strncpy(_additional_info, additional_info, MAX_MSG_SIZE - 1);
+ _additional_info[MAX_MSG_SIZE - 1] = '\0';
+ ::strncat(_what_msg, _additional_info, CATLEN(_what_msg));
+ }
+ else
+ *_additional_info = '\0';
*_throwing_class = '\0';
*_throwing_fn = '\0';
}
@@ -73,7 +85,15 @@
std::exception(),
_err_code(err_code)
{
- if (additional_info) ::strncpy(_additional_info, additional_info, MAX_MSG_SIZE);
+ ::sprintf(_what_msg, "jexception 0x%04X ", err_code);
+ if (additional_info)
+ {
+ ::strncpy(_additional_info, additional_info, MAX_MSG_SIZE - 1);
+ _additional_info[MAX_MSG_SIZE - 1] = '\0';
+ ::strncat(_what_msg, _additional_info, CATLEN(_what_msg));
+ }
+ else
+ *_additional_info = '\0';
*_throwing_class = '\0';
*_throwing_fn = '\0';
}
@@ -83,9 +103,26 @@
std::exception(),
_err_code(err_code)
{
+ ::sprintf(_what_msg, "jexception 0x%04X ", err_code);
*_additional_info = '\0';
- if (throwing_class) ::strncpy(_throwing_class, throwing_class, MAX_THROWING_SIZE);
- if (throwing_fn) ::strncpy(_throwing_fn, throwing_fn, MAX_THROWING_SIZE);
+ if (throwing_class)
+ {
+ ::strncpy(_throwing_class, throwing_class, MAX_THROWING_SIZE - 1);
+ _throwing_class[MAX_THROWING_SIZE - 1] = '\0';
+ ::strncat(_what_msg, _throwing_class, CATLEN(_what_msg));
+ if (throwing_fn)
+ ::strncat(_what_msg, "::", CATLEN(_what_msg));
+ }
+ else
+ *_throwing_class = '\0';
+ if (throwing_fn)
+ {
+ ::strncpy(_throwing_fn, throwing_fn, MAX_THROWING_SIZE - 1);
+ _throwing_fn[MAX_THROWING_SIZE - 1] = '\0';
+ ::strncat(_what_msg, _throwing_fn, CATLEN(_what_msg));
+ }
+ else
+ *_throwing_fn = '\0';
}
jexception::jexception(const u_int32_t err_code, const char* additional_info,
@@ -93,9 +130,37 @@
std::exception(),
_err_code(err_code)
{
- if (additional_info) ::strncpy(_additional_info, additional_info, MAX_MSG_SIZE);
- if (throwing_class) ::strncpy(_throwing_class, throwing_class, MAX_THROWING_SIZE);
- if (throwing_fn) ::strncpy(_throwing_fn, throwing_fn, MAX_THROWING_SIZE);
+ ::sprintf(_what_msg, "jexception 0x%04X ", err_code);
+ if (throwing_class)
+ {
+ ::strncpy(_throwing_class, throwing_class, MAX_THROWING_SIZE - 1);
+ _throwing_class[MAX_THROWING_SIZE - 1] = '\0';
+ ::strncat(_what_msg, _throwing_class, CATLEN(_what_msg));
+ if (throwing_fn)
+ ::strncat(_what_msg, "::", CATLEN(_what_msg));
+ else if (additional_info)
+ ::strncat(_what_msg, " ", CATLEN(_what_msg));
+ }
+ else
+ *_throwing_class = '\0';
+ if (throwing_fn)
+ {
+ ::strncpy(_throwing_fn, throwing_fn, MAX_THROWING_SIZE - 1);
+ _throwing_fn[MAX_THROWING_SIZE - 1] = '\0';
+ ::strncat(_what_msg, _throwing_fn, CATLEN(_what_msg));
+ if (additional_info)
+ ::strncat(_what_msg, " ", CATLEN(_what_msg));
+ }
+ else
+ *_throwing_fn = '\0';
+ if (additional_info)
+ {
+ ::strncpy(_additional_info, additional_info, MAX_MSG_SIZE - 1);
+ _additional_info[MAX_MSG_SIZE - 1] = '\0';
+ ::strncat(_what_msg, _additional_info, CATLEN(_what_msg));
+ }
+ else
+ *_additional_info = '\0';
}
jexception::~jexception() throw ()
@@ -104,14 +169,7 @@
const char*
jexception::what() const throw ()
{
- std::stringstream ss;
- if (::strlen(_throwing_class) &&::strlen( _throwing_fn))
- ss << _throwing_class << "::" << _throwing_fn << "() threw ";
- ss << "jexception: 0x" << std::hex << std::setw(4) << std::setfill('0') << _err_code;
- ss << " " << jerrno::err_msg(_err_code);
- if (::strlen(_additional_info))
- ss << " (" << _additional_info << ")";
- return ss.str().c_str();
+ return _what_msg;
}
std::ostream&
Modified: store/trunk/cpp/lib/jrnl/jexception.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jexception.hpp 2007-11-16 19:55:33 UTC (rev 1327)
+++ store/trunk/cpp/lib/jrnl/jexception.hpp 2007-11-16 20:07:46 UTC (rev 1328)
@@ -62,6 +62,7 @@
{
private:
u_int32_t _err_code;
+ char _what_msg[MAX_MSG_SIZE];
char _additional_info[MAX_MSG_SIZE];
char _throwing_class[MAX_THROWING_SIZE];
char _throwing_fn[MAX_THROWING_SIZE];
Modified: store/trunk/cpp/tests/jrnl/unit_test_jexception.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/unit_test_jexception.cpp 2007-11-16 19:55:33 UTC (rev 1327)
+++ store/trunk/cpp/tests/jrnl/unit_test_jexception.cpp 2007-11-16 20:07:46 UTC (rev 1328)
@@ -38,6 +38,12 @@
using namespace boost::unit_test;
using namespace rhm::journal;
+// Helper function declarations
+void throw_exception(const jexception& e, size_t what_len, size_t ai_len);
+void throw_exception(const jexception& e, size_t what_len, size_t tc_len, size_t tf_len);
+void throw_exception(const jexception& e, size_t what_len, size_t ai_len, size_t tc_len,
+ size_t tf_len);
+
// Test functions of the form
// void fn() {...}
@@ -201,6 +207,111 @@
BOOST_CHECK(ss.str().size() > 0);
}
}
+
+void test_long_null_strings()
+{
+ // msg 1500 chars long; every 50th char is a '*'
+ const char* long_msg =
+ "Long_message_456789012345678901234567890123456789*"
+ "1234567890123456789012345678901234567890123456789*"
+ "1234567890123456789012345678901234567890123456789*"
+ "1234567890123456789012345678901234567890123456789*"
+ "1234567890123456789012345678901234567890123456789*"
+ "1234567890123456789012345678901234567890123456789*"
+ "1234567890123456789012345678901234567890123456789*"
+ "1234567890123456789012345678901234567890123456789*"
+ "1234567890123456789012345678901234567890123456789*"
+ "1234567890123456789012345678901234567890123456789*"
+ "1234567890123456789012345678901234567890123456789*"
+ "1234567890123456789012345678901234567890123456789*"
+ "1234567890123456789012345678901234567890123456789*"
+ "1234567890123456789012345678901234567890123456789*"
+ "1234567890123456789012345678901234567890123456789*"
+ "1234567890123456789012345678901234567890123456789*"
+ "1234567890123456789012345678901234567890123456789*"
+ "1234567890123456789012345678901234567890123456789*"
+ "1234567890123456789012345678901234567890123456789*"
+ "1234567890123456789012345678901234567890123456789*"
+ "1234567890123456789012345678901234567890123456789*"
+ "1234567890123456789012345678901234567890123456789*"
+ "1234567890123456789012345678901234567890123456789*"
+ "1234567890123456789012345678901234567890123456789*"
+ "1234567890123456789012345678901234567890123456789*"
+ "1234567890123456789012345678901234567890123456789*"
+ "1234567890123456789012345678901234567890123456789*"
+ "1234567890123456789012345678901234567890123456789*"
+ "1234567890123456789012345678901234567890123456789*"
+ "1234567890123456789012345678901234567890123456789*";
+ // throwing class and function 250 chars long
+ const char* long_throwing_class =
+ "Long_throwing_class_12345678901234567890123456789*"
+ "1234567890123456789012345678901234567890123456789*"
+ "1234567890123456789012345678901234567890123456789*"
+ "1234567890123456789012345678901234567890123456789*"
+ "1234567890123456789012345678901234567890123456789*";
+ const char* long_throwing_fn =
+ "Long_throwing_function_45678901234567890123456789*"
+ "1234567890123456789012345678901234567890123456789*"
+ "1234567890123456789012345678901234567890123456789*"
+ "1234567890123456789012345678901234567890123456789*"
+ "1234567890123456789012345678901234567890123456789*";
+
+
+ throw_exception(jexception(long_msg), MAX_MSG_SIZE - 1, MAX_MSG_SIZE - 1);
+ throw_exception(jexception((const char*)NULL), 11, 0);
+
+ throw_exception(jexception(0x1234, long_msg), MAX_MSG_SIZE - 1, MAX_MSG_SIZE - 1);
+ throw_exception(jexception(0x1234, NULL), 18, 0);
+
+ throw_exception(jexception(0x1234, long_throwing_class, long_throwing_fn),
+ (2 * (MAX_THROWING_SIZE - 1)) + 20, MAX_THROWING_SIZE - 1, MAX_THROWING_SIZE - 1);
+ throw_exception(jexception(0x1234, long_throwing_class, NULL), MAX_THROWING_SIZE - 1 + 18,
+ MAX_THROWING_SIZE - 1, 0);
+ throw_exception(jexception(0x1234, NULL, long_throwing_fn), MAX_THROWING_SIZE - 1 + 18, 0,
+ MAX_THROWING_SIZE - 1);
+ throw_exception(jexception(0x1234, NULL, NULL), 18, 0, 0);
+
+ throw_exception(jexception(0x1234, long_msg, long_throwing_class, long_throwing_fn),
+ MAX_MSG_SIZE - 1, MAX_MSG_SIZE - 1, MAX_THROWING_SIZE - 1, MAX_THROWING_SIZE - 1);
+ throw_exception(jexception(0x1234, long_msg, long_throwing_class, NULL), MAX_MSG_SIZE - 1,
+ MAX_MSG_SIZE - 1, MAX_THROWING_SIZE - 1, 0);
+ throw_exception(jexception(0x1234, long_msg, NULL, long_throwing_fn), MAX_MSG_SIZE - 1,
+ MAX_MSG_SIZE - 1, 0, MAX_THROWING_SIZE - 1);
+ throw_exception(jexception(0x1234, long_msg, NULL, NULL), MAX_MSG_SIZE - 1, MAX_MSG_SIZE - 1, 0,
+ 0);
+ throw_exception(jexception(0x1234, NULL, long_throwing_class, long_throwing_fn),
+ (2 * (MAX_THROWING_SIZE - 1)) + 20, 0, MAX_THROWING_SIZE - 1, MAX_THROWING_SIZE - 1);
+ throw_exception(jexception(0x1234, NULL, long_throwing_class, NULL), MAX_THROWING_SIZE - 1 + 18,
+ 0, MAX_THROWING_SIZE - 1, 0);
+ throw_exception(jexception(0x1234, NULL, NULL, long_throwing_fn), MAX_THROWING_SIZE - 1 + 18, 0,
+ 0, MAX_THROWING_SIZE - 1);
+ throw_exception(jexception(0x1234, NULL, NULL, NULL), 18, 0, 0, 0);
+}
+
+// Helper functions
+
+void throw_exception(const jexception& e, size_t what_len, size_t ai_len)
+{
+ throw_exception(e, what_len, ai_len, 0, 0);
+}
+
+void throw_exception(const jexception& e, size_t what_len, size_t tc_len, size_t tf_len)
+{
+ throw_exception(e, what_len, 0, tc_len, tf_len);
+}
+
+void throw_exception(const jexception& e, size_t what_len, size_t ai_len, size_t tc_len,
+ size_t tf_len)
+{
+ try { throw e; }
+ catch (const jexception& e)
+ {
+ BOOST_CHECK_EQUAL(::strlen(e.what()), what_len);
+ BOOST_CHECK_EQUAL(::strlen(e.additional_info()), ai_len);
+ BOOST_CHECK_EQUAL(::strlen(e.throwing_class()), tc_len);
+ BOOST_CHECK_EQUAL(::strlen(e.throwing_fn()), tf_len);
+ }
+}
// Initialize test suite and include test functions
@@ -219,6 +330,7 @@
ts->add(BOOST_TEST_CASE(&test_constructor_5));
ts->add(BOOST_TEST_CASE(&test_constructor_6));
ts->add(BOOST_TEST_CASE(&test_msg_scope));
+ ts->add(BOOST_TEST_CASE(&test_long_null_strings));
return ts;
}
17 years, 3 months