jruby-activemq 5.5.1-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (302) hide show
  1. data/History.md +6 -0
  2. data/LICENSE +619 -0
  3. data/README.md +15 -0
  4. data/Rakefile +34 -0
  5. data/apache-activemq-5.5.1/LICENSE +619 -0
  6. data/apache-activemq-5.5.1/NOTICE +85 -0
  7. data/apache-activemq-5.5.1/README.txt +63 -0
  8. data/apache-activemq-5.5.1/WebConsole-README.txt +42 -0
  9. data/apache-activemq-5.5.1/activemq-all-5.5.1.jar +0 -0
  10. data/apache-activemq-5.5.1/bin/activemq +653 -0
  11. data/apache-activemq-5.5.1/bin/activemq-admin +155 -0
  12. data/apache-activemq-5.5.1/bin/linux-x86-32/activemq +543 -0
  13. data/apache-activemq-5.5.1/bin/linux-x86-32/libwrapper.so +0 -0
  14. data/apache-activemq-5.5.1/bin/linux-x86-32/wrapper +0 -0
  15. data/apache-activemq-5.5.1/bin/linux-x86-32/wrapper.conf +139 -0
  16. data/apache-activemq-5.5.1/bin/linux-x86-64/activemq +543 -0
  17. data/apache-activemq-5.5.1/bin/linux-x86-64/libwrapper.so +0 -0
  18. data/apache-activemq-5.5.1/bin/linux-x86-64/wrapper +0 -0
  19. data/apache-activemq-5.5.1/bin/linux-x86-64/wrapper.conf +139 -0
  20. data/apache-activemq-5.5.1/bin/macosx/activemq +537 -0
  21. data/apache-activemq-5.5.1/bin/macosx/libwrapper.jnilib +0 -0
  22. data/apache-activemq-5.5.1/bin/macosx/wrapper +0 -0
  23. data/apache-activemq-5.5.1/bin/macosx/wrapper.conf +139 -0
  24. data/apache-activemq-5.5.1/bin/run.jar +0 -0
  25. data/apache-activemq-5.5.1/bin/wrapper.jar +0 -0
  26. data/apache-activemq-5.5.1/conf/activemq-command.xml +52 -0
  27. data/apache-activemq-5.5.1/conf/activemq-demo.xml +289 -0
  28. data/apache-activemq-5.5.1/conf/activemq-dynamic-network-broker1.xml +108 -0
  29. data/apache-activemq-5.5.1/conf/activemq-dynamic-network-broker2.xml +109 -0
  30. data/apache-activemq-5.5.1/conf/activemq-jdbc.xml +98 -0
  31. data/apache-activemq-5.5.1/conf/activemq-scalability.xml +77 -0
  32. data/apache-activemq-5.5.1/conf/activemq-security.xml +132 -0
  33. data/apache-activemq-5.5.1/conf/activemq-specjms.xml +118 -0
  34. data/apache-activemq-5.5.1/conf/activemq-static-network-broker1.xml +100 -0
  35. data/apache-activemq-5.5.1/conf/activemq-static-network-broker2.xml +100 -0
  36. data/apache-activemq-5.5.1/conf/activemq-stomp.xml +133 -0
  37. data/apache-activemq-5.5.1/conf/activemq-throughput.xml +82 -0
  38. data/apache-activemq-5.5.1/conf/activemq.xml +136 -0
  39. data/apache-activemq-5.5.1/conf/broker-localhost.cert +0 -0
  40. data/apache-activemq-5.5.1/conf/broker.ks +0 -0
  41. data/apache-activemq-5.5.1/conf/broker.ts +0 -0
  42. data/apache-activemq-5.5.1/conf/camel.xml +66 -0
  43. data/apache-activemq-5.5.1/conf/client.ks +0 -0
  44. data/apache-activemq-5.5.1/conf/client.ts +0 -0
  45. data/apache-activemq-5.5.1/conf/credentials-enc.properties +22 -0
  46. data/apache-activemq-5.5.1/conf/credentials.properties +22 -0
  47. data/apache-activemq-5.5.1/conf/jetty-realm.properties +20 -0
  48. data/apache-activemq-5.5.1/conf/jetty.xml +112 -0
  49. data/apache-activemq-5.5.1/conf/jmx.access +18 -0
  50. data/apache-activemq-5.5.1/conf/jmx.password +18 -0
  51. data/apache-activemq-5.5.1/conf/log4j.properties +75 -0
  52. data/apache-activemq-5.5.1/conf/logging.properties +25 -0
  53. data/apache-activemq-5.5.1/data/activemq.log +0 -0
  54. data/apache-activemq-5.5.1/docs/index.html +22 -0
  55. data/apache-activemq-5.5.1/example/build.xml +317 -0
  56. data/apache-activemq-5.5.1/example/conf/activemq.xml +41 -0
  57. data/apache-activemq-5.5.1/example/conf/log4j.properties +39 -0
  58. data/apache-activemq-5.5.1/example/conf/resin-web.xml +35 -0
  59. data/apache-activemq-5.5.1/example/conf/web.xml +40 -0
  60. data/apache-activemq-5.5.1/example/perfharness/perfharness-activemq.sh +49 -0
  61. data/apache-activemq-5.5.1/example/ruby/README.txt +27 -0
  62. data/apache-activemq-5.5.1/example/ruby/catstomp.rb +49 -0
  63. data/apache-activemq-5.5.1/example/ruby/listener.rb +51 -0
  64. data/apache-activemq-5.5.1/example/ruby/publisher.rb +67 -0
  65. data/apache-activemq-5.5.1/example/ruby/stompcat.rb +50 -0
  66. data/apache-activemq-5.5.1/example/src/CommandLineSupport.java +120 -0
  67. data/apache-activemq-5.5.1/example/src/ConsumerTool.java +353 -0
  68. data/apache-activemq-5.5.1/example/src/EmbeddedBroker.java +41 -0
  69. data/apache-activemq-5.5.1/example/src/Log4jJMSAppenderExample.java +70 -0
  70. data/apache-activemq-5.5.1/example/src/ProducerAndConsumerTool.java +51 -0
  71. data/apache-activemq-5.5.1/example/src/ProducerTool.java +247 -0
  72. data/apache-activemq-5.5.1/example/src/RequesterTool.java +257 -0
  73. data/apache-activemq-5.5.1/example/src/StompExample.java +59 -0
  74. data/apache-activemq-5.5.1/example/src/TopicListener.java +118 -0
  75. data/apache-activemq-5.5.1/example/src/TopicPublisher.java +205 -0
  76. data/apache-activemq-5.5.1/example/src/jndi.properties +17 -0
  77. data/apache-activemq-5.5.1/example/src/log4j-jms.properties +31 -0
  78. data/apache-activemq-5.5.1/example/transactions/README.txt +40 -0
  79. data/apache-activemq-5.5.1/example/transactions/build.xml +113 -0
  80. data/apache-activemq-5.5.1/example/transactions/src/Retailer.java +107 -0
  81. data/apache-activemq-5.5.1/example/transactions/src/Supplier.java +135 -0
  82. data/apache-activemq-5.5.1/example/transactions/src/TransactionsDemo.java +47 -0
  83. data/apache-activemq-5.5.1/example/transactions/src/Vendor.java +302 -0
  84. data/apache-activemq-5.5.1/lib/a.sh +3 -0
  85. data/apache-activemq-5.5.1/lib/activation-1.1.jar +0 -0
  86. data/apache-activemq-5.5.1/lib/activemq-camel-5.5.1.jar +0 -0
  87. data/apache-activemq-5.5.1/lib/activemq-console-5.5.1.jar +0 -0
  88. data/apache-activemq-5.5.1/lib/activemq-core-5.5.1.jar +0 -0
  89. data/apache-activemq-5.5.1/lib/activemq-jaas-5.5.1.jar +0 -0
  90. data/apache-activemq-5.5.1/lib/activemq-protobuf-1.1.jar +0 -0
  91. data/apache-activemq-5.5.1/lib/activemq-rar.txt +20 -0
  92. data/apache-activemq-5.5.1/lib/activemq-web-5.5.1.jar +0 -0
  93. data/apache-activemq-5.5.1/lib/camel-core-2.7.0.jar +0 -0
  94. data/apache-activemq-5.5.1/lib/camel-jetty-2.7.0.jar +0 -0
  95. data/apache-activemq-5.5.1/lib/camel-jms-2.7.0.jar +0 -0
  96. data/apache-activemq-5.5.1/lib/camel-spring-2.7.0.jar +0 -0
  97. data/apache-activemq-5.5.1/lib/geronimo-j2ee-management_1.1_spec-1.0.1.jar +0 -0
  98. data/apache-activemq-5.5.1/lib/geronimo-jms_1.1_spec-1.1.1.jar +0 -0
  99. data/apache-activemq-5.5.1/lib/geronimo-jta_1.0.1B_spec-1.0.1.jar +0 -0
  100. data/apache-activemq-5.5.1/lib/jaxb-api-2.1.jar +0 -0
  101. data/apache-activemq-5.5.1/lib/jaxb-impl-2.1.6.jar +0 -0
  102. data/apache-activemq-5.5.1/lib/jcl-over-slf4j-1.5.11.jar +0 -0
  103. data/apache-activemq-5.5.1/lib/kahadb-5.5.1.jar +0 -0
  104. data/apache-activemq-5.5.1/lib/optional/activeio-core-3.1.2.jar +0 -0
  105. data/apache-activemq-5.5.1/lib/optional/activemq-jmdns_1.0-5.5.1.jar +0 -0
  106. data/apache-activemq-5.5.1/lib/optional/activemq-optional-5.5.1.jar +0 -0
  107. data/apache-activemq-5.5.1/lib/optional/activemq-pool-5.5.1.jar +0 -0
  108. data/apache-activemq-5.5.1/lib/optional/activemq-spring-5.5.1.jar +0 -0
  109. data/apache-activemq-5.5.1/lib/optional/activemq-xmpp-5.5.1.jar +0 -0
  110. data/apache-activemq-5.5.1/lib/optional/commons-beanutils-1.6.1.jar +0 -0
  111. data/apache-activemq-5.5.1/lib/optional/commons-codec-1.2.jar +0 -0
  112. data/apache-activemq-5.5.1/lib/optional/commons-collections-3.2.1.jar +0 -0
  113. data/apache-activemq-5.5.1/lib/optional/commons-dbcp-1.2.2.jar +0 -0
  114. data/apache-activemq-5.5.1/lib/optional/commons-httpclient-3.1.jar +0 -0
  115. data/apache-activemq-5.5.1/lib/optional/commons-lang-2.4.jar +0 -0
  116. data/apache-activemq-5.5.1/lib/optional/commons-net-2.0.jar +0 -0
  117. data/apache-activemq-5.5.1/lib/optional/commons-pool-1.5.4.jar +0 -0
  118. data/apache-activemq-5.5.1/lib/optional/geronimo-j2ee-connector_1.5_spec-2.0.0.jar +0 -0
  119. data/apache-activemq-5.5.1/lib/optional/jasypt-1.7.jar +0 -0
  120. data/apache-activemq-5.5.1/lib/optional/jettison-1.2.jar +0 -0
  121. data/apache-activemq-5.5.1/lib/optional/josql-1.5.jar +0 -0
  122. data/apache-activemq-5.5.1/lib/optional/log4j-1.2.14.jar +0 -0
  123. data/apache-activemq-5.5.1/lib/optional/slf4j-log4j12-1.5.11.jar +0 -0
  124. data/apache-activemq-5.5.1/lib/optional/spring-aop-3.0.3.RELEASE.jar +0 -0
  125. data/apache-activemq-5.5.1/lib/optional/spring-asm-3.0.3.RELEASE.jar +0 -0
  126. data/apache-activemq-5.5.1/lib/optional/spring-beans-3.0.3.RELEASE.jar +0 -0
  127. data/apache-activemq-5.5.1/lib/optional/spring-context-3.0.3.RELEASE.jar +0 -0
  128. data/apache-activemq-5.5.1/lib/optional/spring-core-3.0.3.RELEASE.jar +0 -0
  129. data/apache-activemq-5.5.1/lib/optional/spring-expression-3.0.3.RELEASE.jar +0 -0
  130. data/apache-activemq-5.5.1/lib/optional/spring-jms-3.0.3.RELEASE.jar +0 -0
  131. data/apache-activemq-5.5.1/lib/optional/spring-oxm-tiger-1.5.8.jar +0 -0
  132. data/apache-activemq-5.5.1/lib/optional/spring-tx-3.0.3.RELEASE.jar +0 -0
  133. data/apache-activemq-5.5.1/lib/optional/stax2-api-3.0.1.jar +0 -0
  134. data/apache-activemq-5.5.1/lib/optional/velocity-1.6.2.jar +0 -0
  135. data/apache-activemq-5.5.1/lib/optional/woodstox-core-asl-4.0.7.jar +0 -0
  136. data/apache-activemq-5.5.1/lib/optional/xbean-spring-3.7.jar +0 -0
  137. data/apache-activemq-5.5.1/lib/optional/xpp3-1.1.4c.jar +0 -0
  138. data/apache-activemq-5.5.1/lib/optional/xstream-1.3.1.jar +0 -0
  139. data/apache-activemq-5.5.1/lib/slf4j-api-1.5.11.jar +0 -0
  140. data/apache-activemq-5.5.1/lib/stax-1.2.0.jar +0 -0
  141. data/apache-activemq-5.5.1/lib/stax-api-1.0.1.jar +0 -0
  142. data/apache-activemq-5.5.1/lib/web/commons-management-1.0.jar +0 -0
  143. data/apache-activemq-5.5.1/lib/web/core-3.1.1.jar +0 -0
  144. data/apache-activemq-5.5.1/lib/web/geronimo-servlet_2.5_spec-1.2.jar +0 -0
  145. data/apache-activemq-5.5.1/lib/web/jdom-1.0.jar +0 -0
  146. data/apache-activemq-5.5.1/lib/web/jetty-all-server-7.1.6.v20100715.jar +0 -0
  147. data/apache-activemq-5.5.1/lib/web/jetty-websocket-7.1.6.v20100715.jar +0 -0
  148. data/apache-activemq-5.5.1/lib/web/jsp-2.1-glassfish-2.1.v20100127.jar +0 -0
  149. data/apache-activemq-5.5.1/lib/web/jsp-api-2.1-glassfish-2.1.v20100127.jar +0 -0
  150. data/apache-activemq-5.5.1/lib/web/rome-0.8.jar +0 -0
  151. data/apache-activemq-5.5.1/lib/web/sitemesh-2.2.1.jar +0 -0
  152. data/apache-activemq-5.5.1/lib/web/spring-web-3.0.3.RELEASE.jar +0 -0
  153. data/apache-activemq-5.5.1/lib/web/spring-webmvc-3.0.3.RELEASE.jar +0 -0
  154. data/apache-activemq-5.5.1/user-guide.html +119 -0
  155. data/apache-activemq-5.5.1/webapps/admin/404.html +137 -0
  156. data/apache-activemq-5.5.1/webapps/admin/500.html +138 -0
  157. data/apache-activemq-5.5.1/webapps/admin/META-INF/LICENSE +1026 -0
  158. data/apache-activemq-5.5.1/webapps/admin/META-INF/NOTICE +107 -0
  159. data/apache-activemq-5.5.1/webapps/admin/WEB-INF/classes/org/apache/activemq/web/WebConsoleStarter.class +0 -0
  160. data/apache-activemq-5.5.1/webapps/admin/WEB-INF/classes/org/apache/activemq/web/controller/CopyMessage.class +0 -0
  161. data/apache-activemq-5.5.1/webapps/admin/WEB-INF/classes/org/apache/activemq/web/controller/CreateDestination.class +0 -0
  162. data/apache-activemq-5.5.1/webapps/admin/WEB-INF/classes/org/apache/activemq/web/controller/CreateSubscriber.class +0 -0
  163. data/apache-activemq-5.5.1/webapps/admin/WEB-INF/classes/org/apache/activemq/web/controller/DeleteDestination.class +0 -0
  164. data/apache-activemq-5.5.1/webapps/admin/WEB-INF/classes/org/apache/activemq/web/controller/DeleteJob.class +0 -0
  165. data/apache-activemq-5.5.1/webapps/admin/WEB-INF/classes/org/apache/activemq/web/controller/DeleteMessage.class +0 -0
  166. data/apache-activemq-5.5.1/webapps/admin/WEB-INF/classes/org/apache/activemq/web/controller/DeleteSubscriber.class +0 -0
  167. data/apache-activemq-5.5.1/webapps/admin/WEB-INF/classes/org/apache/activemq/web/controller/MoveMessage.class +0 -0
  168. data/apache-activemq-5.5.1/webapps/admin/WEB-INF/classes/org/apache/activemq/web/controller/PurgeDestination.class +0 -0
  169. data/apache-activemq-5.5.1/webapps/admin/WEB-INF/classes/org/apache/activemq/web/controller/SendMessage.class +0 -0
  170. data/apache-activemq-5.5.1/webapps/admin/WEB-INF/classes/org/apache/activemq/web/filter/ApplicationContextFilter$1.class +0 -0
  171. data/apache-activemq-5.5.1/webapps/admin/WEB-INF/classes/org/apache/activemq/web/filter/ApplicationContextFilter$2.class +0 -0
  172. data/apache-activemq-5.5.1/webapps/admin/WEB-INF/classes/org/apache/activemq/web/filter/ApplicationContextFilter.class +0 -0
  173. data/apache-activemq-5.5.1/webapps/admin/WEB-INF/classes/org/apache/activemq/web/handler/BindingBeanNameUrlHandlerMapping.class +0 -0
  174. data/apache-activemq-5.5.1/webapps/admin/WEB-INF/decorators.xml +30 -0
  175. data/apache-activemq-5.5.1/webapps/admin/WEB-INF/dispatcher-servlet.xml +62 -0
  176. data/apache-activemq-5.5.1/webapps/admin/WEB-INF/jspf/headertags.jspf +21 -0
  177. data/apache-activemq-5.5.1/webapps/admin/WEB-INF/jspf/old.jspf +21 -0
  178. data/apache-activemq-5.5.1/webapps/admin/WEB-INF/tags/form/checkbox.tag +18 -0
  179. data/apache-activemq-5.5.1/webapps/admin/WEB-INF/tags/form/forEachMapEntry.tag +29 -0
  180. data/apache-activemq-5.5.1/webapps/admin/WEB-INF/tags/form/option.tag +20 -0
  181. data/apache-activemq-5.5.1/webapps/admin/WEB-INF/tags/form/short.tag +29 -0
  182. data/apache-activemq-5.5.1/webapps/admin/WEB-INF/tags/form/text.tag +30 -0
  183. data/apache-activemq-5.5.1/webapps/admin/WEB-INF/tags/form/tooltip.tag +29 -0
  184. data/apache-activemq-5.5.1/webapps/admin/WEB-INF/tags/form/uri.tag +18 -0
  185. data/apache-activemq-5.5.1/webapps/admin/WEB-INF/tags/jms/forEachConnection.tag +35 -0
  186. data/apache-activemq-5.5.1/webapps/admin/WEB-INF/tags/jms/forEachMessage.tag +34 -0
  187. data/apache-activemq-5.5.1/webapps/admin/WEB-INF/tags/jms/formatTimestamp.tag +29 -0
  188. data/apache-activemq-5.5.1/webapps/admin/WEB-INF/tags/jms/persistent.tag +27 -0
  189. data/apache-activemq-5.5.1/webapps/admin/WEB-INF/web.xml +187 -0
  190. data/apache-activemq-5.5.1/webapps/admin/WEB-INF/webconsole-default.xml +26 -0
  191. data/apache-activemq-5.5.1/webapps/admin/WEB-INF/webconsole-embedded.xml +45 -0
  192. data/apache-activemq-5.5.1/webapps/admin/WEB-INF/webconsole-invm.xml +41 -0
  193. data/apache-activemq-5.5.1/webapps/admin/WEB-INF/webconsole-jndi.xml +39 -0
  194. data/apache-activemq-5.5.1/webapps/admin/WEB-INF/webconsole-properties.xml +39 -0
  195. data/apache-activemq-5.5.1/webapps/admin/WEB-INF/webconsole-query.xml +25 -0
  196. data/apache-activemq-5.5.1/webapps/admin/browse.jsp +64 -0
  197. data/apache-activemq-5.5.1/webapps/admin/connection.jsp +138 -0
  198. data/apache-activemq-5.5.1/webapps/admin/connections.jsp +85 -0
  199. data/apache-activemq-5.5.1/webapps/admin/decorators/main.jsp +165 -0
  200. data/apache-activemq-5.5.1/webapps/admin/decorators/panel.jsp +31 -0
  201. data/apache-activemq-5.5.1/webapps/admin/decorators/printable.jsp +31 -0
  202. data/apache-activemq-5.5.1/webapps/admin/graph.jsp +67 -0
  203. data/apache-activemq-5.5.1/webapps/admin/images/activemq-logo.png +0 -0
  204. data/apache-activemq-5.5.1/webapps/admin/images/asf-logo.png +0 -0
  205. data/apache-activemq-5.5.1/webapps/admin/images/big-bullet.png +0 -0
  206. data/apache-activemq-5.5.1/webapps/admin/images/black-footer-bottom.png +0 -0
  207. data/apache-activemq-5.5.1/webapps/admin/images/black-footer-left.png +0 -0
  208. data/apache-activemq-5.5.1/webapps/admin/images/black-footer-right.png +0 -0
  209. data/apache-activemq-5.5.1/webapps/admin/images/bottom-red-bar.png +0 -0
  210. data/apache-activemq-5.5.1/webapps/admin/images/checker-bg.png +0 -0
  211. data/apache-activemq-5.5.1/webapps/admin/images/content-left.png +0 -0
  212. data/apache-activemq-5.5.1/webapps/admin/images/content-right.png +0 -0
  213. data/apache-activemq-5.5.1/webapps/admin/images/feed_atom.png +0 -0
  214. data/apache-activemq-5.5.1/webapps/admin/images/feed_rss.png +0 -0
  215. data/apache-activemq-5.5.1/webapps/admin/images/left-box-bottom.png +0 -0
  216. data/apache-activemq-5.5.1/webapps/admin/images/left-box-right.png +0 -0
  217. data/apache-activemq-5.5.1/webapps/admin/images/left-box-top.png +0 -0
  218. data/apache-activemq-5.5.1/webapps/admin/images/oval-arrow.png +0 -0
  219. data/apache-activemq-5.5.1/webapps/admin/images/right-box-bottom.png +0 -0
  220. data/apache-activemq-5.5.1/webapps/admin/images/right-box-left.png +0 -0
  221. data/apache-activemq-5.5.1/webapps/admin/images/right-box-top.png +0 -0
  222. data/apache-activemq-5.5.1/webapps/admin/images/small-bullet-gray.png +0 -0
  223. data/apache-activemq-5.5.1/webapps/admin/images/small-bullet-red.png +0 -0
  224. data/apache-activemq-5.5.1/webapps/admin/images/spacer.gif +0 -0
  225. data/apache-activemq-5.5.1/webapps/admin/images/top-red-bar.png +0 -0
  226. data/apache-activemq-5.5.1/webapps/admin/images/white-header-left.png +0 -0
  227. data/apache-activemq-5.5.1/webapps/admin/images/white-header-right.png +0 -0
  228. data/apache-activemq-5.5.1/webapps/admin/images/white-header-top.png +0 -0
  229. data/apache-activemq-5.5.1/webapps/admin/index.jsp +65 -0
  230. data/apache-activemq-5.5.1/webapps/admin/js/common.js +121 -0
  231. data/apache-activemq-5.5.1/webapps/admin/js/css.js +145 -0
  232. data/apache-activemq-5.5.1/webapps/admin/js/mochi/MochiKit.js +4804 -0
  233. data/apache-activemq-5.5.1/webapps/admin/js/mochi/__package__.js +14 -0
  234. data/apache-activemq-5.5.1/webapps/admin/js/plotkit/Base.js +332 -0
  235. data/apache-activemq-5.5.1/webapps/admin/js/plotkit/Canvas.js +707 -0
  236. data/apache-activemq-5.5.1/webapps/admin/js/plotkit/Layout.js +588 -0
  237. data/apache-activemq-5.5.1/webapps/admin/js/plotkit/SVG.js +677 -0
  238. data/apache-activemq-5.5.1/webapps/admin/js/plotkit/SweetCanvas.js +281 -0
  239. data/apache-activemq-5.5.1/webapps/admin/js/plotkit/SweetSVG.js +196 -0
  240. data/apache-activemq-5.5.1/webapps/admin/js/plotkit/dummy.svg +15 -0
  241. data/apache-activemq-5.5.1/webapps/admin/js/plotkit/iecanvas.htc +389 -0
  242. data/apache-activemq-5.5.1/webapps/admin/js/prettify.js +1424 -0
  243. data/apache-activemq-5.5.1/webapps/admin/js/standardista-table-sorting.js +434 -0
  244. data/apache-activemq-5.5.1/webapps/admin/message.jsp +185 -0
  245. data/apache-activemq-5.5.1/webapps/admin/network.jsp +52 -0
  246. data/apache-activemq-5.5.1/webapps/admin/queueConsumers.jsp +79 -0
  247. data/apache-activemq-5.5.1/webapps/admin/queueGraph.jsp +68 -0
  248. data/apache-activemq-5.5.1/webapps/admin/queues.jsp +78 -0
  249. data/apache-activemq-5.5.1/webapps/admin/scheduled.jsp +67 -0
  250. data/apache-activemq-5.5.1/webapps/admin/send.jsp +173 -0
  251. data/apache-activemq-5.5.1/webapps/admin/styles/prettify.css +44 -0
  252. data/apache-activemq-5.5.1/webapps/admin/styles/site.css +206 -0
  253. data/apache-activemq-5.5.1/webapps/admin/styles/sorttable.css +70 -0
  254. data/apache-activemq-5.5.1/webapps/admin/styles/type-settings.css +177 -0
  255. data/apache-activemq-5.5.1/webapps/admin/subscribers.jsp +158 -0
  256. data/apache-activemq-5.5.1/webapps/admin/test/dummy.jsp +52 -0
  257. data/apache-activemq-5.5.1/webapps/admin/test/index.jsp +84 -0
  258. data/apache-activemq-5.5.1/webapps/admin/test/systemProperties.jsp +53 -0
  259. data/apache-activemq-5.5.1/webapps/admin/topics.jsp +66 -0
  260. data/apache-activemq-5.5.1/webapps/admin/xml/queues.jsp +34 -0
  261. data/apache-activemq-5.5.1/webapps/admin/xml/topics.jsp +29 -0
  262. data/apache-activemq-5.5.1/webapps/demo/META-INF/LICENSE +494 -0
  263. data/apache-activemq-5.5.1/webapps/demo/META-INF/NOTICE +82 -0
  264. data/apache-activemq-5.5.1/webapps/demo/WEB-INF/web.xml +111 -0
  265. data/apache-activemq-5.5.1/webapps/demo/chat.css +76 -0
  266. data/apache-activemq-5.5.1/webapps/demo/chat.html +219 -0
  267. data/apache-activemq-5.5.1/webapps/demo/index.html +181 -0
  268. data/apache-activemq-5.5.1/webapps/demo/js/amq.js +307 -0
  269. data/apache-activemq-5.5.1/webapps/demo/js/amq_dojo_adapter.js +84 -0
  270. data/apache-activemq-5.5.1/webapps/demo/js/amq_jquery_adapter.js +88 -0
  271. data/apache-activemq-5.5.1/webapps/demo/js/amq_prototype_adapter.js +84 -0
  272. data/apache-activemq-5.5.1/webapps/demo/js/chat.js +209 -0
  273. data/apache-activemq-5.5.1/webapps/demo/js/dojo.js +16 -0
  274. data/apache-activemq-5.5.1/webapps/demo/js/jquery-1.4.2.min.js +154 -0
  275. data/apache-activemq-5.5.1/webapps/demo/js/prototype.js +4874 -0
  276. data/apache-activemq-5.5.1/webapps/demo/portfolio/portfolio.html +87 -0
  277. data/apache-activemq-5.5.1/webapps/demo/portfolio/portfolio.js +91 -0
  278. data/apache-activemq-5.5.1/webapps/demo/sandbox/index.html +31 -0
  279. data/apache-activemq-5.5.1/webapps/demo/sandbox/portfolio.html +93 -0
  280. data/apache-activemq-5.5.1/webapps/demo/sandbox/portfolio.js +49 -0
  281. data/apache-activemq-5.5.1/webapps/demo/sandbox/util.js +52 -0
  282. data/apache-activemq-5.5.1/webapps/demo/sandbox/webmq.js +149 -0
  283. data/apache-activemq-5.5.1/webapps/demo/send.html +51 -0
  284. data/apache-activemq-5.5.1/webapps/demo/style.css +440 -0
  285. data/apache-activemq-5.5.1/webapps/demo/test/amq_test.html +311 -0
  286. data/apache-activemq-5.5.1/webapps/demo/test/assets/README +4 -0
  287. data/apache-activemq-5.5.1/webapps/demo/test/assets/jsunittest.js +1017 -0
  288. data/apache-activemq-5.5.1/webapps/demo/test/assets/unittest.css +54 -0
  289. data/apache-activemq-5.5.1/webapps/favicon.ico +0 -0
  290. data/apache-activemq-5.5.1/webapps/fileserver/META-INF/LICENSE +203 -0
  291. data/apache-activemq-5.5.1/webapps/fileserver/META-INF/NOTICE +5 -0
  292. data/apache-activemq-5.5.1/webapps/fileserver/WEB-INF/classes/org/apache/activemq/util/FilenameGuardFilter$GuardedHttpServletRequest.class +0 -0
  293. data/apache-activemq-5.5.1/webapps/fileserver/WEB-INF/classes/org/apache/activemq/util/FilenameGuardFilter.class +0 -0
  294. data/apache-activemq-5.5.1/webapps/fileserver/WEB-INF/classes/org/apache/activemq/util/IOHelper.class +0 -0
  295. data/apache-activemq-5.5.1/webapps/fileserver/WEB-INF/classes/org/apache/activemq/util/RestFilter.class +0 -0
  296. data/apache-activemq-5.5.1/webapps/fileserver/WEB-INF/web.xml +56 -0
  297. data/apache-activemq-5.5.1/webapps/fileserver/index.html +30 -0
  298. data/apache-activemq-5.5.1/webapps/index.html +145 -0
  299. data/apache-activemq-5.5.1/webapps/styles/site.css +206 -0
  300. data/apache-activemq-5.5.1/webapps/styles/type-settings.css +177 -0
  301. data/lib/activemq.rb +11 -0
  302. metadata +382 -0
@@ -0,0 +1,311 @@
1
+ <!--
2
+ Licensed to the Apache Software Foundation (ASF) under one or more
3
+ contributor license agreements. See the NOTICE file distributed with
4
+ this work for additional information regarding copyright ownership.
5
+ The ASF licenses this file to You under the Apache License, Version 2.0
6
+ (the "License"); you may not use this file except in compliance with
7
+ the License. You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ -->
17
+
18
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
19
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
20
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
21
+ <head>
22
+ <title>AMQ test</title>
23
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
24
+ <script src="assets/jsunittest.js" type="text/javascript"></script>
25
+
26
+ <script>
27
+ var org = org || {};
28
+ org.activemq = org.activemq || {};
29
+
30
+ org.activemq.AmqAdapter = {
31
+ // implement org.activemq.AmqAdapter API
32
+ init: function(options) {},
33
+ ajax: function(uri, options) {
34
+ ajaxRequests[ajaxRequests.length] = { uri:uri, options:options };
35
+ },
36
+
37
+ // add additional functionality for testing.
38
+ ajaxRequests: [],
39
+ getRequests: function() {
40
+ return ajaxRequests;
41
+ },
42
+ reset: function() {
43
+ ajaxRequests=[];
44
+ }
45
+ };
46
+ </script>
47
+ <script src="../js/amq.js" type="text/javascript"></script>
48
+
49
+ <link rel="stylesheet" href="assets/unittest.css" type="text/css" />
50
+ </head>
51
+ <body>
52
+
53
+ <div id="content">
54
+
55
+ <div id="header">
56
+ <h1>AMQ tests</h1>
57
+ <p>
58
+ This file tests amq.js.
59
+ </p>
60
+ </div>
61
+
62
+ <!-- Log output (one per Runner, via {testLog: "testlog"} option)-->
63
+ <div id="testlog"></div>
64
+
65
+ <!-- Put sample/test html here -->
66
+ <div id="sample">
67
+ </div>
68
+ </div>
69
+
70
+ <script type="text/javascript">
71
+ function createXmlFromString( xmlString ) {
72
+ // http://developer.taboca.com/cases/en/client-javascript-dom-parser/
73
+ // Mozilla and Netscape browsers
74
+ if (document.implementation.createDocument) {
75
+ var parser = new DOMParser()
76
+ response = parser.parseFromString( xmlString, "text/xml")
77
+ // MSIE
78
+ } else if (window.ActiveXObject) {
79
+ response = new ActiveXObject("Microsoft.XMLDOM")
80
+ response.async="false"
81
+ response.loadXML( xmlString )
82
+ }
83
+ return response;
84
+ }
85
+
86
+ // <![CDATA[
87
+ new Test.Unit.Runner({
88
+ setup: function() {
89
+ org.activemq.AmqAdapter.reset();
90
+ org.activemq.Amq.init({ uri: '../amq', timeout: 30 });
91
+ },
92
+
93
+ teardown: function() {
94
+ org.activemq.Amq.endBatch();
95
+ },
96
+
97
+ testMessagesAreSentToUrlDefinedInInit: function() { with( this ) {
98
+ org.activemq.Amq.sendMessage( 'queue://test', '<message>test</message>' );
99
+ var requests = org.activemq.AmqAdapter.getRequests();
100
+ assertEqual( 2, requests.length );
101
+ assertEqual( '../amq', requests[ 0 ].uri );
102
+ assertEqual( '../amq', requests[ 1 ].uri );
103
+ }},
104
+
105
+ testFirstMessageIsAPoll: function() { with( this ) {
106
+ org.activemq.Amq.sendMessage( 'queue://test', '<message>test</message>' );
107
+ var requests = org.activemq.AmqAdapter.getRequests();
108
+
109
+ assertEqual( 'get', requests[ 0 ].options.method );
110
+ assert( requests[ 0 ].options.data.match( /timeout=1&d=\d+&r=[\d.]+/ ) );
111
+ }},
112
+
113
+ testPostIsSentIfNoBatchIsInProgress: function() { with( this ) {
114
+ org.activemq.Amq.sendMessage( 'queue://test', '<message>test</message>' );
115
+ var requests = org.activemq.AmqAdapter.getRequests();
116
+
117
+ assertEqual( 2, requests.length );
118
+ assertEqual( 'post', requests[ 1 ].options.method );
119
+ assertEqual( 'destination=queue://test&message=<message>test</message>&type=send', requests[ 1 ].options.data );
120
+ }},
121
+
122
+ testMessagesAreDeliveredInABatchIfAjaxRequestIsInProgressWhenSendMessageIsCalled: function() { with( this ) {
123
+ // use startBatch to indicate a previous message POST is currently in progress.
124
+ org.activemq.Amq.startBatch();
125
+ org.activemq.Amq.sendMessage( 'queue://test', '<message>test</message>' );
126
+ org.activemq.Amq.sendMessage( 'queue://test2', '<message>test2</message>' );
127
+ // endBatch is the callback once the previous POST finishes. Triggers delivery of queued messages.
128
+ org.activemq.Amq.endBatch();
129
+
130
+ var requests = org.activemq.AmqAdapter.getRequests();
131
+ assertEqual( 2, requests.length );
132
+ assertEqual( 'post', requests[1].options.method );
133
+ assertEqual( "destination=queue://test&message=<message>test</message>&type=send&d1=queue://test2&m1=<message>test2</message>&t1=send", requests[1].options.data );
134
+ }},
135
+
136
+ testAddListenerSendsListenMessage: function() { with( this ) {
137
+ org.activemq.Amq.addListener( 'client_id', 'topic://test', function(){} );
138
+ var requests = org.activemq.AmqAdapter.getRequests();
139
+
140
+ assertEqual( 2, requests.length );
141
+ assertEqual( 'post', requests[1].options.method );
142
+ assertEqual( "destination=topic://test&message=client_id&type=listen", requests[1].options.data );
143
+ }},
144
+
145
+ testAddListenerMayIncludeASelector: function() { with( this ) {
146
+ org.activemq.Amq.addListener( 'client_id', 'topic://test', function(){}, {selector:"identifier='ALPHA'"} );
147
+
148
+ var requests = org.activemq.AmqAdapter.getRequests();
149
+ assertEqual( 2, requests.length );
150
+ assertEqual( 'post', requests[1].options.method );
151
+ assertEqual( "destination=topic://test&message=client_id&type=listen", requests[1].options.data );
152
+ assertHashEqual( { selector: "identifier='ALPHA'" }, requests[1].options.headers );
153
+ }},
154
+
155
+ testAllQueuedMessagesContainingHeadersAreDeliveredIndividuallyToPreventHeaderConflicts: function() { with( this ) {
156
+ org.activemq.Amq.startBatch();
157
+ org.activemq.Amq.addListener( 'client_id_1', 'topic://test1', function(){}, {selector:"identifier='ALPHA'"} );
158
+ org.activemq.Amq.addListener( 'client_id_2', 'topic://test2', function(){}, {selector:"identifier='BRAVO'"} );
159
+
160
+ // simulate 1st post returning, which triggers 2nd post.
161
+ org.activemq.Amq.endBatch();
162
+
163
+ // poll & first listen have been sent.
164
+ assertEqual( 2, org.activemq.AmqAdapter.getRequests().length );
165
+
166
+ // second listen is still in the queue.
167
+ var queued = org.activemq.Amq.getMessageQueue();
168
+ assertEqual( 1, queued.length );
169
+ assertHashEqual( { selector: "identifier='BRAVO'" }, queued[ 0 ].headers );
170
+ assertHashEqual( { destination: 'topic://test2', message: 'client_id_2', messageType: 'listen' }, queued[ 0 ].message );
171
+
172
+ // when first post returns, the second listen gets sent.
173
+ // this endBatch simulates that second post returning.
174
+ org.activemq.Amq.endBatch();
175
+
176
+ var requests = org.activemq.AmqAdapter.getRequests();
177
+ var queued = org.activemq.Amq.getMessageQueue();
178
+
179
+ assertEqual( 3, requests.length );
180
+ assertEqual( 'post', requests[1].options.method );
181
+ assertEqual( "destination=topic://test1&message=client_id_1&type=listen", requests[1].options.data );
182
+ assertHashEqual( { selector: "identifier='ALPHA'" }, requests[1].options.headers );
183
+
184
+ assertEqual( 'post', requests[2].options.method );
185
+ assertEqual( "destination=topic://test2&message=client_id_2&type=listen", requests[2].options.data );
186
+ assertHashEqual( { selector: "identifier='BRAVO'" }, requests[2].options.headers );
187
+
188
+ assertEqual( 0, queued.length );
189
+ }},
190
+
191
+ // Is this desired behavior? Message order changes from that specified by the client.
192
+ testQueuedMessagesWithoutHeadersAreDeliveredInASinglePost: function() { with( this ) {
193
+ org.activemq.Amq.startBatch();
194
+ org.activemq.Amq.sendMessage( 'queue://test', '<message>test</message>' );
195
+ org.activemq.Amq.addListener( 'client_id_1', 'topic://test1', function(){}, {selector:"identifier='ALPHA'"} );
196
+ org.activemq.Amq.sendMessage( 'queue://test', '<message>test</message>' );
197
+ org.activemq.Amq.addListener( 'client_id_2', 'topic://test2', function(){}, {selector:"identifier='BRAVO'"} );
198
+ org.activemq.Amq.sendMessage( 'queue://test', '<message>test</message>' );
199
+
200
+ // poll & all sendMessage calls go out first.
201
+ org.activemq.Amq.endBatch();
202
+ assertEqual( 2, org.activemq.AmqAdapter.getRequests().length );
203
+ assertEqual( 2, org.activemq.Amq.getMessageQueue().length );
204
+
205
+ // first listen goes next.
206
+ org.activemq.Amq.endBatch();
207
+ assertEqual( 3, org.activemq.AmqAdapter.getRequests().length );
208
+ assertEqual( 1, org.activemq.Amq.getMessageQueue().length );
209
+
210
+ // final listen goes out.
211
+ org.activemq.Amq.endBatch();
212
+
213
+ var requests = org.activemq.AmqAdapter.getRequests();
214
+ assertEqual( 4, requests.length );
215
+ assertEqual( 0, org.activemq.Amq.getMessageQueue().length );
216
+
217
+ assertEqual( "destination=queue://test&message=<message>test</message>&type=send&d1=queue://test&m1=<message>test</message>&t1=send&d2=queue://test&m2=<message>test</message>&t2=send", requests[ 1 ].options.data );
218
+ assertHashEqual( {}, requests[ 1 ].options.headers );
219
+
220
+ assertEqual( "destination=topic://test1&message=client_id_1&type=listen", requests[ 2 ].options.data );
221
+ assertEqual( "destination=topic://test2&message=client_id_2&type=listen", requests[ 3 ].options.data );
222
+
223
+ }},
224
+
225
+ testSelectorFromQueuedListenerIsNotAddedToLaterMessages: function() { with( this ) {
226
+ org.activemq.Amq.startBatch();
227
+ org.activemq.Amq.addListener( 'client_id_1', 'topic://test1', function(){}, {selector:"identifier='ALPHA'"} );
228
+ org.activemq.Amq.sendMessage( 'queue://test', '<message>test</message>' );
229
+ org.activemq.Amq.sendMessage( 'queue://test', '<message>test</message>' );
230
+
231
+ // poll & listener go out first.
232
+ org.activemq.Amq.endBatch();
233
+ assertEqual( 2, org.activemq.AmqAdapter.getRequests().length );
234
+ assertEqual( 2, org.activemq.Amq.getMessageQueue().length );
235
+
236
+ // 2 sendMessages go next.
237
+ org.activemq.Amq.endBatch();
238
+
239
+ var requests = org.activemq.AmqAdapter.getRequests();
240
+ assertEqual( 3, requests.length );
241
+ assertEqual( 0, org.activemq.Amq.getMessageQueue().length );
242
+
243
+ assertEqual( "destination=topic://test1&message=client_id_1&type=listen", requests[ 1 ].options.data );
244
+ assertHashEqual( { selector: "identifier='ALPHA'" }, requests[ 1 ].options.headers );
245
+ assertEqual( "destination=queue://test&message=<message>test</message>&type=send&d1=queue://test&m1=<message>test</message>&t1=send", requests[ 2 ].options.data );
246
+ assertHashEqual( {}, requests[ 2 ].options.headers );
247
+ }},
248
+
249
+ testAddListenerWithoutSelectorWillBeBatchedWithOtherMessages: function() { with( this ) {
250
+ org.activemq.Amq.startBatch();
251
+ org.activemq.Amq.sendMessage( 'queue://test', '<message>test</message>' );
252
+ org.activemq.Amq.addListener( 'client_id_1', 'topic://test1', function(){} );
253
+ org.activemq.Amq.sendMessage( 'queue://test', '<message>test</message>' );
254
+ org.activemq.Amq.addListener( 'client_id_2', 'topic://test2', function(){} );
255
+ org.activemq.Amq.sendMessage( 'queue://test', '<message>test</message>' );
256
+
257
+ org.activemq.Amq.endBatch();
258
+
259
+ var requests = org.activemq.AmqAdapter.getRequests();
260
+ assertEqual( 2, requests.length );
261
+ assertEqual( 0, org.activemq.Amq.getMessageQueue().length );
262
+ assertEqual( "destination=queue://test&message=<message>test</message>&type=send&d1=topic://test1&m1=client_id_1&t1=listen&d2=queue://test&m2=<message>test</message>&t2=send&d3=topic://test2&m3=client_id_2&t3=listen&d4=queue://test&m4=<message>test</message>&t4=send", requests[ 1 ].options.data );
263
+ }},
264
+
265
+ testRemoveListenerSendsUnlistenMessage: function() { with( this ) {
266
+ org.activemq.Amq.removeListener( 'client_id', 'topic://test' );
267
+
268
+ var requests = org.activemq.AmqAdapter.getRequests();
269
+ assertEqual( 2, requests.length );
270
+ assertEqual( 'post', requests[1].options.method );
271
+ assertEqual( "destination=topic://test&message=client_id&type=unlisten", requests[1].options.data );
272
+ }},
273
+
274
+ testAddListenerCallbackIsCalledForReceivedMessages: function() { with( this ) {
275
+ // build an XML document like the one which the ajax implementers would pass to pollHandler
276
+ response = createXmlFromString( '<ajax-response><response id="client_id" destination="queue://test" >test message</response></ajax-response>' );
277
+
278
+ // we'll expect the callback to set this value
279
+ var callbackValue;
280
+
281
+ org.activemq.Amq.addListener( 'client_id', 'queue://test', function( msg ) { callbackValue = msg; } );
282
+ org.activemq.Amq.testPollHandler( response );
283
+
284
+ assertEqual( 'test message', callbackValue.textContent );
285
+ }},
286
+
287
+ testClientIdSpecifiedInInitIsAddedToAllAjaxRequests: function() { with( this ) {
288
+ // need to reset to remove the poll message sent when init() is called in setup().
289
+ org.activemq.AmqAdapter.reset();
290
+ org.activemq.Amq.init({ uri: '../amq', timeout: 30, clientId:'uniqueClientName' });
291
+
292
+ org.activemq.Amq.addListener( 'id', 'queue://test', function(){} );
293
+ org.activemq.Amq.sendMessage( 'queue://test', '<message>test</message>' );
294
+ org.activemq.Amq.removeListener( 'id', 'topic://test' );
295
+ org.activemq.Amq.endBatch();
296
+
297
+ var requests = org.activemq.AmqAdapter.getRequests();
298
+ var clientNameRegex = /clientId=uniqueClientName/;
299
+
300
+ assertEqual( 3, requests.length );
301
+ assertMatch( clientNameRegex, requests[0].options.data );
302
+ assertMatch( clientNameRegex, requests[1].options.data );
303
+ assertMatch( clientNameRegex, requests[2].options.data );
304
+
305
+ }}
306
+
307
+ });
308
+ // ]]>
309
+ </script>
310
+ </body>
311
+ </html>
@@ -0,0 +1,4 @@
1
+ jsunittest.js from http://jsunittest.com/
2
+
3
+ This directory is for core jsunittest files only! Put your unit test .html files up one level.
4
+ You should be referencing files in public/javascripts/ in your test files.
@@ -0,0 +1,1017 @@
1
+ /* Jsunittest, version 0.7.3
2
+ * (c) 2008 Dr Nic Williams
3
+ *
4
+ * Jsunittest is freely distributable under
5
+ * the terms of an MIT-style license.
6
+ * For details, see the web site: http://jsunittest.rubyforge.org
7
+ *
8
+ *--------------------------------------------------------------------------*/
9
+
10
+ var JsUnitTest = {
11
+ Unit: {},
12
+ inspect: function(object) {
13
+ try {
14
+ if (typeof object == "undefined") return 'undefined';
15
+ if (object === null) return 'null';
16
+ if (typeof object == "string") {
17
+ var useDoubleQuotes = arguments[1];
18
+ var escapedString = this.gsub(object, /[\x00-\x1f\\]/, function(match) {
19
+ var character = String.specialChar[match[0]];
20
+ return character ? character : '\\u00' + match[0].charCodeAt().toPaddedString(2, 16);
21
+ });
22
+ if (useDoubleQuotes) return '"' + escapedString.replace(/"/g, '\\"') + '"';
23
+ return "'" + escapedString.replace(/'/g, '\\\'') + "'";
24
+ };
25
+ return String(object);
26
+ } catch (e) {
27
+ if (e instanceof RangeError) return '...';
28
+ throw e;
29
+ }
30
+ },
31
+ $: function(element) {
32
+ if (arguments.length > 1) {
33
+ for (var i = 0, elements = [], length = arguments.length; i < length; i++)
34
+ elements.push(this.$(arguments[i]));
35
+ return elements;
36
+ }
37
+ if (typeof element == "string")
38
+ element = document.getElementById(element);
39
+ return element;
40
+ },
41
+ gsub: function(source, pattern, replacement) {
42
+ var result = '', match;
43
+ replacement = arguments.callee.prepareReplacement(replacement);
44
+
45
+ while (source.length > 0) {
46
+ if (match = source.match(pattern)) {
47
+ result += source.slice(0, match.index);
48
+ result += JsUnitTest.String.interpret(replacement(match));
49
+ source = source.slice(match.index + match[0].length);
50
+ } else {
51
+ result += source, source = '';
52
+ }
53
+ }
54
+ return result;
55
+ },
56
+ scan: function(source, pattern, iterator) {
57
+ this.gsub(source, pattern, iterator);
58
+ return String(source);
59
+ },
60
+ escapeHTML: function(data) {
61
+ return data.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;');
62
+ },
63
+ arrayfromargs: function(args) {
64
+ var myarray = new Array();
65
+ var i;
66
+
67
+ for (i=0;i<args.length;i++)
68
+ myarray[i] = args[i];
69
+
70
+ return myarray;
71
+ },
72
+ hashToSortedArray: function(hash) {
73
+ var results = [];
74
+ for (key in hash) {
75
+ results.push([key, hash[key]]);
76
+ }
77
+ return results.sort();
78
+ },
79
+ flattenArray: function(array) {
80
+ var results = arguments[1] || [];
81
+ for (var i=0; i < array.length; i++) {
82
+ var object = array[i];
83
+ if (object != null && typeof object == "object" &&
84
+ 'splice' in object && 'join' in object) {
85
+ this.flattenArray(object, results);
86
+ } else {
87
+ results.push(object);
88
+ }
89
+ };
90
+ return results;
91
+ },
92
+ selectorMatch: function(expression, element) {
93
+ var tokens = [];
94
+ var patterns = {
95
+ // combinators must be listed first
96
+ // (and descendant needs to be last combinator)
97
+ laterSibling: /^\s*~\s*/,
98
+ child: /^\s*>\s*/,
99
+ adjacent: /^\s*\+\s*/,
100
+ descendant: /^\s/,
101
+
102
+ // selectors follow
103
+ tagName: /^\s*(\*|[\w\-]+)(\b|$)?/,
104
+ id: /^#([\w\-\*]+)(\b|$)/,
105
+ className: /^\.([\w\-\*]+)(\b|$)/,
106
+ pseudo:
107
+ /^:((first|last|nth|nth-last|only)(-child|-of-type)|empty|checked|(en|dis)abled|not)(\((.*?)\))?(\b|$|(?=\s|[:+~>]))/,
108
+ attrPresence: /^\[((?:[\w]+:)?[\w]+)\]/,
109
+ attr: /\[((?:[\w-]*:)?[\w-]+)\s*(?:([!^$*~|]?=)\s*((['"])([^\4]*?)\4|([^'"][^\]]*?)))?\]/
110
+ };
111
+
112
+ var assertions = {
113
+ tagName: function(element, matches) {
114
+ return matches[1].toUpperCase() == element.tagName.toUpperCase();
115
+ },
116
+
117
+ className: function(element, matches) {
118
+ return Element.hasClassName(element, matches[1]);
119
+ },
120
+
121
+ id: function(element, matches) {
122
+ return element.id === matches[1];
123
+ },
124
+
125
+ attrPresence: function(element, matches) {
126
+ return Element.hasAttribute(element, matches[1]);
127
+ },
128
+
129
+ attr: function(element, matches) {
130
+ var nodeValue = Element.readAttribute(element, matches[1]);
131
+ return nodeValue && operators[matches[2]](nodeValue, matches[5] || matches[6]);
132
+ }
133
+ };
134
+ var e = this.expression, ps = patterns, as = assertions;
135
+ var le, p, m;
136
+
137
+ while (e && le !== e && (/\S/).test(e)) {
138
+ le = e;
139
+ for (var i in ps) {
140
+ p = ps[i];
141
+ if (m = e.match(p)) {
142
+ // use the Selector.assertions methods unless the selector
143
+ // is too complex.
144
+ if (as[i]) {
145
+ tokens.push([i, Object.clone(m)]);
146
+ e = e.replace(m[0], '');
147
+ }
148
+ }
149
+ }
150
+ }
151
+
152
+ var match = true, name, matches;
153
+ for (var i = 0, token; token = tokens[i]; i++) {
154
+ name = token[0], matches = token[1];
155
+ if (!assertions[name](element, matches)) {
156
+ match = false; break;
157
+ }
158
+ }
159
+
160
+ return match;
161
+ },
162
+ toQueryParams: function(query, separator) {
163
+ var query = query || window.location.search;
164
+ var match = query.replace(/^\s+/, '').replace(/\s+$/, '').match(/([^?#]*)(#.*)?$/);
165
+ if (!match) return { };
166
+
167
+ var hash = {};
168
+ var parts = match[1].split(separator || '&');
169
+ for (var i=0; i < parts.length; i++) {
170
+ var pair = parts[i].split('=');
171
+ if (pair[0]) {
172
+ var key = decodeURIComponent(pair.shift());
173
+ var value = pair.length > 1 ? pair.join('=') : pair[0];
174
+ if (value != undefined) value = decodeURIComponent(value);
175
+
176
+ if (key in hash) {
177
+ var object = hash[key];
178
+ var isArray = object != null && typeof object == "object" &&
179
+ 'splice' in object && 'join' in object
180
+ if (!isArray) hash[key] = [hash[key]];
181
+ hash[key].push(value);
182
+ }
183
+ else hash[key] = value;
184
+ }
185
+ };
186
+ return hash;
187
+ },
188
+
189
+ String: {
190
+ interpret: function(value) {
191
+ return value == null ? '' : String(value);
192
+ }
193
+ }
194
+ };
195
+
196
+ JsUnitTest.gsub.prepareReplacement = function(replacement) {
197
+ if (typeof replacement == "function") return replacement;
198
+ var template = new Template(replacement);
199
+ return function(match) { return template.evaluate(match) };
200
+ };
201
+
202
+ JsUnitTest.Version = '0.7.3';
203
+
204
+ JsUnitTest.Template = function(template, pattern) {
205
+ this.template = template; //template.toString();
206
+ this.pattern = pattern || JsUnitTest.Template.Pattern;
207
+ };
208
+
209
+ JsUnitTest.Template.prototype.evaluate = function(object) {
210
+ if (typeof object.toTemplateReplacements == "function")
211
+ object = object.toTemplateReplacements();
212
+
213
+ return JsUnitTest.gsub(this.template, this.pattern, function(match) {
214
+ if (object == null) return '';
215
+
216
+ var before = match[1] || '';
217
+ if (before == '\\') return match[2];
218
+
219
+ var ctx = object, expr = match[3];
220
+ var pattern = /^([^.[]+|\[((?:.*?[^\\])?)\])(\.|\[|$)/;
221
+ match = pattern.exec(expr);
222
+ if (match == null) return before;
223
+
224
+ while (match != null) {
225
+ var comp = (match[1].indexOf('[]') === 0) ? match[2].gsub('\\\\]', ']') : match[1];
226
+ ctx = ctx[comp];
227
+ if (null == ctx || '' == match[3]) break;
228
+ expr = expr.substring('[' == match[3] ? match[1].length : match[0].length);
229
+ match = pattern.exec(expr);
230
+ }
231
+
232
+ return before + JsUnitTest.String.interpret(ctx);
233
+ });
234
+ }
235
+
236
+ JsUnitTest.Template.Pattern = /(^|.|\r|\n)(#\{(.*?)\})/;
237
+ JsUnitTest.Event = {};
238
+ // written by Dean Edwards, 2005
239
+ // with input from Tino Zijdel, Matthias Miller, Diego Perini
240
+ // namespaced by Dr Nic Williams 2008
241
+
242
+ // http://dean.edwards.name/weblog/2005/10/add-event/
243
+ // http://dean.edwards.name/weblog/2005/10/add-event2/
244
+ JsUnitTest.Event.addEvent = function(element, type, handler) {
245
+ if (element.addEventListener) {
246
+ element.addEventListener(type, handler, false);
247
+ } else {
248
+ // assign each event handler a unique ID
249
+ if (!handler.$$guid) handler.$$guid = JsUnitTest.Event.addEvent.guid++;
250
+ // create a hash table of event types for the element
251
+ if (!element.events) element.events = {};
252
+ // create a hash table of event handlers for each element/event pair
253
+ var handlers = element.events[type];
254
+ if (!handlers) {
255
+ handlers = element.events[type] = {};
256
+ // store the existing event handler (if there is one)
257
+ if (element["on" + type]) {
258
+ handlers[0] = element["on" + type];
259
+ }
260
+ }
261
+ // store the event handler in the hash table
262
+ handlers[handler.$$guid] = handler;
263
+ // assign a global event handler to do all the work
264
+ element["on" + type] = this.handleEvent;
265
+ }
266
+ };
267
+ // a counter used to create unique IDs
268
+ JsUnitTest.Event.addEvent.guid = 1;
269
+
270
+ JsUnitTest.Event.removeEvent = function(element, type, handler) {
271
+ if (element.removeEventListener) {
272
+ element.removeEventListener(type, handler, false);
273
+ } else {
274
+ // delete the event handler from the hash table
275
+ if (element.events && element.events[type]) {
276
+ delete element.events[type][handler.$$guid];
277
+ }
278
+ }
279
+ };
280
+
281
+ JsUnitTest.Event.handleEvent = function(event) {
282
+ var returnValue = true;
283
+ // grab the event object (IE uses a global event object)
284
+ event = event || JsUnitTest.Event.fixEvent(((this.ownerDocument || this.document || this).parentWindow || window).event);
285
+ // get a reference to the hash table of event handlers
286
+ var handlers = this.events[event.type];
287
+ // execute each event handler
288
+ for (var i in handlers) {
289
+ this.$$handleEvent = handlers[i];
290
+ if (this.$$handleEvent(event) === false) {
291
+ returnValue = false;
292
+ }
293
+ }
294
+ return returnValue;
295
+ };
296
+
297
+ JsUnitTest.Event.fixEvent = function(event) {
298
+ // add W3C standard event methods
299
+ event.preventDefault = this.fixEvent.preventDefault;
300
+ event.stopPropagation = this.fixEvent.stopPropagation;
301
+ return event;
302
+ };
303
+ JsUnitTest.Event.fixEvent.preventDefault = function() {
304
+ this.returnValue = false;
305
+ };
306
+ JsUnitTest.Event.fixEvent.stopPropagation = function() {
307
+ this.cancelBubble = true;
308
+ };
309
+
310
+ JsUnitTest.Unit.Logger = function(element) {
311
+ this.element = JsUnitTest.$(element);
312
+ if (this.element) this._createLogTable();
313
+ };
314
+
315
+ JsUnitTest.Unit.Logger.prototype.start = function(testName) {
316
+ if (!this.element) return;
317
+ var tbody = this.element.getElementsByTagName('tbody')[0];
318
+
319
+ var tr = document.createElement('tr');
320
+ var td;
321
+
322
+ //testname
323
+ td = document.createElement('td');
324
+ td.appendChild(document.createTextNode(testName));
325
+ tr.appendChild(td)
326
+
327
+ tr.appendChild(document.createElement('td'));//status
328
+ tr.appendChild(document.createElement('td'));//message
329
+
330
+ tbody.appendChild(tr);
331
+ };
332
+
333
+ JsUnitTest.Unit.Logger.prototype.setStatus = function(status) {
334
+ var logline = this.getLastLogLine();
335
+ logline.className = status;
336
+ var statusCell = logline.getElementsByTagName('td')[1];
337
+ statusCell.appendChild(document.createTextNode(status));
338
+ };
339
+
340
+ JsUnitTest.Unit.Logger.prototype.finish = function(status, summary) {
341
+ if (!this.element) return;
342
+ this.setStatus(status);
343
+ this.message(summary);
344
+ };
345
+
346
+ JsUnitTest.Unit.Logger.prototype.message = function(message) {
347
+ if (!this.element) return;
348
+ var cell = this.getMessageCell();
349
+
350
+ // cell.appendChild(document.createTextNode(this._toHTML(message)));
351
+ cell.innerHTML = this._toHTML(message);
352
+ };
353
+
354
+ JsUnitTest.Unit.Logger.prototype.summary = function(summary) {
355
+ if (!this.element) return;
356
+ var div = this.element.getElementsByTagName('div')[0];
357
+ div.innerHTML = this._toHTML(summary);
358
+ };
359
+
360
+ JsUnitTest.Unit.Logger.prototype.getLastLogLine = function() {
361
+ var tbody = this.element.getElementsByTagName('tbody')[0];
362
+ var loglines = tbody.getElementsByTagName('tr');
363
+ return loglines[loglines.length - 1];
364
+ };
365
+
366
+ JsUnitTest.Unit.Logger.prototype.getMessageCell = function() {
367
+ var logline = this.getLastLogLine();
368
+ return logline.getElementsByTagName('td')[2];
369
+ };
370
+
371
+ JsUnitTest.Unit.Logger.prototype._createLogTable = function() {
372
+ var html = '<div class="logsummary">running...</div>' +
373
+ '<table class="logtable">' +
374
+ '<thead><tr><th>Status</th><th>Test</th><th>Message</th></tr></thead>' +
375
+ '<tbody class="loglines"></tbody>' +
376
+ '</table>';
377
+ this.element.innerHTML = html;
378
+ };
379
+
380
+ JsUnitTest.Unit.Logger.prototype.appendActionButtons = function(actions) {
381
+ // actions = $H(actions);
382
+ // if (!actions.any()) return;
383
+ // var div = new Element("div", {className: 'action_buttons'});
384
+ // actions.inject(div, function(container, action) {
385
+ // var button = new Element("input").setValue(action.key).observe("click", action.value);
386
+ // button.type = "button";
387
+ // return container.insert(button);
388
+ // });
389
+ // this.getMessageCell().insert(div);
390
+ };
391
+
392
+ JsUnitTest.Unit.Logger.prototype._toHTML = function(txt) {
393
+ return JsUnitTest.escapeHTML(txt).replace(/\n/g,"<br/>");
394
+ };
395
+ JsUnitTest.Unit.MessageTemplate = function(string) {
396
+ var parts = [];
397
+ var str = JsUnitTest.scan((string || ''), /(?=[^\\])\?|(?:\\\?|[^\?])+/, function(part) {
398
+ parts.push(part[0]);
399
+ });
400
+ this.parts = parts;
401
+ };
402
+
403
+ JsUnitTest.Unit.MessageTemplate.prototype.evaluate = function(params) {
404
+ var results = [];
405
+ for (var i=0; i < this.parts.length; i++) {
406
+ var part = this.parts[i];
407
+ var result = (part == '?') ? JsUnitTest.inspect(params.shift()) : part.replace(/\\\?/, '?');
408
+ results.push(result);
409
+ };
410
+ return results.join('');
411
+ };
412
+ // A generic function for performming AJAX requests
413
+ // It takes one argument, which is an object that contains a set of options
414
+ // All of which are outline in the comments, below
415
+ // From John Resig's book Pro JavaScript Techniques
416
+ // published by Apress, 2006-8
417
+ JsUnitTest.ajax = function( options ) {
418
+
419
+ // Load the options object with defaults, if no
420
+ // values were provided by the user
421
+ options = {
422
+ // The type of HTTP Request
423
+ type: options.type || "POST",
424
+
425
+ // The URL the request will be made to
426
+ url: options.url || "",
427
+
428
+ // How long to wait before considering the request to be a timeout
429
+ timeout: options.timeout || 5000,
430
+
431
+ // Functions to call when the request fails, succeeds,
432
+ // or completes (either fail or succeed)
433
+ onComplete: options.onComplete || function(){},
434
+ onError: options.onError || function(){},
435
+ onSuccess: options.onSuccess || function(){},
436
+
437
+ // The data type that'll be returned from the server
438
+ // the default is simply to determine what data was returned from the
439
+ // and act accordingly.
440
+ data: options.data || ""
441
+ };
442
+
443
+ // Create the request object
444
+ var xml = window.ActiveXObject ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest();
445
+
446
+ // Open the asynchronous POST request
447
+ xml.open(options.type, options.url, true);
448
+
449
+ // We're going to wait for a request for 5 seconds, before giving up
450
+ var timeoutLength = 5000;
451
+
452
+ // Keep track of when the request has been succesfully completed
453
+ var requestDone = false;
454
+
455
+ // Initalize a callback which will fire 5 seconds from now, cancelling
456
+ // the request (if it has not already occurred).
457
+ setTimeout(function(){
458
+ requestDone = true;
459
+ }, timeoutLength);
460
+
461
+ // Watch for when the state of the document gets updated
462
+ xml.onreadystatechange = function(){
463
+ // Wait until the data is fully loaded,
464
+ // and make sure that the request hasn't already timed out
465
+ if ( xml.readyState == 4 && !requestDone ) {
466
+
467
+ // Check to see if the request was successful
468
+ if ( httpSuccess( xml ) ) {
469
+
470
+ // Execute the success callback with the data returned from the server
471
+ options.onSuccess( httpData( xml, options.type ) );
472
+
473
+ // Otherwise, an error occurred, so execute the error callback
474
+ } else {
475
+ options.onError();
476
+ }
477
+
478
+ // Call the completion callback
479
+ options.onComplete();
480
+
481
+ // Clean up after ourselves, to avoid memory leaks
482
+ xml = null;
483
+ }
484
+ };
485
+
486
+ // Establish the connection to the server
487
+ xml.send(null);
488
+
489
+ // Determine the success of the HTTP response
490
+ function httpSuccess(r) {
491
+ try {
492
+ // If no server status is provided, and we're actually
493
+ // requesting a local file, then it was successful
494
+ return !r.status && location.protocol == "file:" ||
495
+
496
+ // Any status in the 200 range is good
497
+ ( r.status >= 200 && r.status < 300 ) ||
498
+
499
+ // Successful if the document has not been modified
500
+ r.status == 304 ||
501
+
502
+ // Safari returns an empty status if the file has not been modified
503
+ navigator.userAgent.indexOf("Safari") >= 0 && typeof r.status == "undefined";
504
+ } catch(e){}
505
+
506
+ // If checking the status failed, then assume that the request failed too
507
+ return false;
508
+ }
509
+
510
+ // Extract the correct data from the HTTP response
511
+ function httpData(r,type) {
512
+ // Get the content-type header
513
+ var ct = r.getResponseHeader("content-type");
514
+
515
+ // If no default type was provided, determine if some
516
+ // form of XML was returned from the server
517
+ var data = !type && ct && ct.indexOf("xml") >= 0;
518
+
519
+ // Get the XML Document object if XML was returned from
520
+ // the server, otherwise return the text contents returned by the server
521
+ data = type == "xml" || data ? r.responseXML : r.responseText;
522
+
523
+ // If the specified type is "script", execute the returned text
524
+ // response as if it was JavaScript
525
+ if ( type == "script" )
526
+ eval.call( window, data );
527
+
528
+ // Return the response data (either an XML Document or a text string)
529
+ return data;
530
+ }
531
+
532
+ };
533
+ JsUnitTest.Unit.Assertions = {
534
+ buildMessage: function(message, template) {
535
+ var args = JsUnitTest.arrayfromargs(arguments).slice(2);
536
+ return (message ? message + '\n' : '') +
537
+ new JsUnitTest.Unit.MessageTemplate(template).evaluate(args);
538
+ },
539
+
540
+ flunk: function(message) {
541
+ this.assertBlock(message || 'Flunked', function() { return false });
542
+ },
543
+
544
+ assertBlock: function(message, block) {
545
+ try {
546
+ block.call(this) ? this.pass() : this.fail(message);
547
+ } catch(e) { this.error(e) }
548
+ },
549
+
550
+ assert: function(expression, message) {
551
+ message = this.buildMessage(message || 'assert', 'got <?>', expression);
552
+ this.assertBlock(message, function() { return expression });
553
+ },
554
+
555
+ assertEqual: function(expected, actual, message) {
556
+ message = this.buildMessage(message || 'assertEqual', 'expected <?>, actual: <?>', expected, actual);
557
+ this.assertBlock(message, function() { return expected == actual });
558
+ },
559
+
560
+ assertNotEqual: function(expected, actual, message) {
561
+ message = this.buildMessage(message || 'assertNotEqual', 'expected <?>, actual: <?>', expected, actual);
562
+ this.assertBlock(message, function() { return expected != actual });
563
+ },
564
+
565
+ assertEnumEqual: function(expected, actual, message) {
566
+ message = this.buildMessage(message || 'assertEnumEqual', 'expected <?>, actual: <?>', expected, actual);
567
+ var expected_array = JsUnitTest.flattenArray(expected);
568
+ var actual_array = JsUnitTest.flattenArray(actual);
569
+ this.assertBlock(message, function() {
570
+ if (expected_array.length == actual_array.length) {
571
+ for (var i=0; i < expected_array.length; i++) {
572
+ if (expected_array[i] != actual_array[i]) return false;
573
+ };
574
+ return true;
575
+ }
576
+ return false;
577
+ });
578
+ },
579
+
580
+ assertEnumNotEqual: function(expected, actual, message) {
581
+ message = this.buildMessage(message || 'assertEnumNotEqual', '<?> was the same as <?>', expected, actual);
582
+ var expected_array = JsUnitTest.flattenArray(expected);
583
+ var actual_array = JsUnitTest.flattenArray(actual);
584
+ this.assertBlock(message, function() {
585
+ if (expected_array.length == actual_array.length) {
586
+ for (var i=0; i < expected_array.length; i++) {
587
+ if (expected_array[i] != actual_array[i]) return true;
588
+ };
589
+ return false;
590
+ }
591
+ return true;
592
+ });
593
+ },
594
+
595
+ assertHashEqual: function(expected, actual, message) {
596
+ message = this.buildMessage(message || 'assertHashEqual', 'expected <?>, actual: <?>', expected, actual);
597
+ var expected_array = JsUnitTest.flattenArray(JsUnitTest.hashToSortedArray(expected));
598
+ var actual_array = JsUnitTest.flattenArray(JsUnitTest.hashToSortedArray(actual));
599
+ var block = function() {
600
+ if (expected_array.length == actual_array.length) {
601
+ for (var i=0; i < expected_array.length; i++) {
602
+ if (expected_array[i] != actual_array[i]) return false;
603
+ };
604
+ return true;
605
+ }
606
+ return false;
607
+ };
608
+ this.assertBlock(message, block);
609
+ },
610
+
611
+ assertHashNotEqual: function(expected, actual, message) {
612
+ message = this.buildMessage(message || 'assertHashNotEqual', '<?> was the same as <?>', expected, actual);
613
+ var expected_array = JsUnitTest.flattenArray(JsUnitTest.hashToSortedArray(expected));
614
+ var actual_array = JsUnitTest.flattenArray(JsUnitTest.hashToSortedArray(actual));
615
+ // from now we recursively zip & compare nested arrays
616
+ var block = function() {
617
+ if (expected_array.length == actual_array.length) {
618
+ for (var i=0; i < expected_array.length; i++) {
619
+ if (expected_array[i] != actual_array[i]) return true;
620
+ };
621
+ return false;
622
+ }
623
+ return true;
624
+ };
625
+ this.assertBlock(message, block);
626
+ },
627
+
628
+ assertIdentical: function(expected, actual, message) {
629
+ message = this.buildMessage(message || 'assertIdentical', 'expected <?>, actual: <?>', expected, actual);
630
+ this.assertBlock(message, function() { return expected === actual });
631
+ },
632
+
633
+ assertNotIdentical: function(expected, actual, message) {
634
+ message = this.buildMessage(message || 'assertNotIdentical', 'expected <?>, actual: <?>', expected, actual);
635
+ this.assertBlock(message, function() { return expected !== actual });
636
+ },
637
+
638
+ assertNull: function(obj, message) {
639
+ message = this.buildMessage(message || 'assertNull', 'got <?>', obj);
640
+ this.assertBlock(message, function() { return obj === null });
641
+ },
642
+
643
+ assertNotNull: function(obj, message) {
644
+ message = this.buildMessage(message || 'assertNotNull', 'got <?>', obj);
645
+ this.assertBlock(message, function() { return obj !== null });
646
+ },
647
+
648
+ assertUndefined: function(obj, message) {
649
+ message = this.buildMessage(message || 'assertUndefined', 'got <?>', obj);
650
+ this.assertBlock(message, function() { return typeof obj == "undefined" });
651
+ },
652
+
653
+ assertNotUndefined: function(obj, message) {
654
+ message = this.buildMessage(message || 'assertNotUndefined', 'got <?>', obj);
655
+ this.assertBlock(message, function() { return typeof obj != "undefined" });
656
+ },
657
+
658
+ assertNullOrUndefined: function(obj, message) {
659
+ message = this.buildMessage(message || 'assertNullOrUndefined', 'got <?>', obj);
660
+ this.assertBlock(message, function() { return obj == null });
661
+ },
662
+
663
+ assertNotNullOrUndefined: function(obj, message) {
664
+ message = this.buildMessage(message || 'assertNotNullOrUndefined', 'got <?>', obj);
665
+ this.assertBlock(message, function() { return obj != null });
666
+ },
667
+
668
+ assertMatch: function(expected, actual, message) {
669
+ message = this.buildMessage(message || 'assertMatch', 'regex <?> did not match <?>', expected, actual);
670
+ this.assertBlock(message, function() { return new RegExp(expected).exec(actual) });
671
+ },
672
+
673
+ assertNoMatch: function(expected, actual, message) {
674
+ message = this.buildMessage(message || 'assertNoMatch', 'regex <?> matched <?>', expected, actual);
675
+ this.assertBlock(message, function() { return !(new RegExp(expected).exec(actual)) });
676
+ },
677
+
678
+ assertHasClass: function(element, klass, message) {
679
+ element = JsUnitTest.$(element);
680
+ message = this.buildMessage(message || 'assertHasClass', '? doesn\'t have class <?>.', element, klass);
681
+ this.assertBlock(message, function() {
682
+ var elementClassName = element.className;
683
+ return (elementClassName.length > 0 && (elementClassName == klass ||
684
+ new RegExp("(^|\\s)" + klass + "(\\s|$)").test(elementClassName)));
685
+ // return !!element.className.match(new RegExp(klass))
686
+ });
687
+ },
688
+
689
+ assertNotHasClass: function(element, klass, message) {
690
+ element = JsUnitTest.$(element);
691
+ message = this.buildMessage(message || 'assertNotHasClass', '? does have class <?>.', element, klass);
692
+ this.assertBlock(message, function() {
693
+ var elementClassName = element.className;
694
+ return !(elementClassName.length > 0 && (elementClassName == klass ||
695
+ new RegExp("(^|\\s)" + klass + "(\\s|$)").test(elementClassName)));
696
+ });
697
+ },
698
+
699
+ assertHidden: function(element, message) {
700
+ element = JsUnitTest.$(element);
701
+ message = this.buildMessage(message || 'assertHidden', '? isn\'t hidden.', element);
702
+ this.assertBlock(message, function() { return !element.style.display || element.style.display == 'none' });
703
+ },
704
+
705
+ assertInstanceOf: function(expected, actual, message) {
706
+ message = this.buildMessage(message || 'assertInstanceOf', '<?> was not an instance of the expected type', actual);
707
+ this.assertBlock(message, function() { return actual instanceof expected });
708
+ },
709
+
710
+ assertNotInstanceOf: function(expected, actual, message) {
711
+ message = this.buildMessage(message || 'assertNotInstanceOf', '<?> was an instance of the expected type', actual);
712
+ this.assertBlock(message, function() { return !(actual instanceof expected) });
713
+ },
714
+
715
+ assertRespondsTo: function(method, obj, message) {
716
+ message = this.buildMessage(message || 'assertRespondsTo', 'object doesn\'t respond to <?>', method);
717
+ this.assertBlock(message, function() { return (method in obj && typeof obj[method] == 'function') });
718
+ },
719
+
720
+ assertRaise: function(exceptionName, method, message) {
721
+ message = this.buildMessage(message || 'assertRaise', '<?> exception expected but none was raised', exceptionName);
722
+ var block = function() {
723
+ try {
724
+ method();
725
+ return false;
726
+ } catch(e) {
727
+ if (e.name == exceptionName) return true;
728
+ else throw e;
729
+ }
730
+ };
731
+ this.assertBlock(message, block);
732
+ },
733
+
734
+ assertNothingRaised: function(method, message) {
735
+ try {
736
+ method();
737
+ this.assert(true, "Expected nothing to be thrown");
738
+ } catch(e) {
739
+ message = this.buildMessage(message || 'assertNothingRaised', '<?> was thrown when nothing was expected.', e);
740
+ this.flunk(message);
741
+ }
742
+ },
743
+
744
+ _isVisible: function(element) {
745
+ element = JsUnitTest.$(element);
746
+ if(!element.parentNode) return true;
747
+ this.assertNotNull(element);
748
+ if(element.style && (element.style.display == 'none'))
749
+ return false;
750
+
751
+ return arguments.callee.call(this, element.parentNode);
752
+ },
753
+
754
+ assertVisible: function(element, message) {
755
+ message = this.buildMessage(message, '? was not visible.', element);
756
+ this.assertBlock(message, function() { return this._isVisible(element) });
757
+ },
758
+
759
+ assertNotVisible: function(element, message) {
760
+ message = this.buildMessage(message, '? was not hidden and didn\'t have a hidden parent either.', element);
761
+ this.assertBlock(message, function() { return !this._isVisible(element) });
762
+ },
763
+
764
+ assertElementsMatch: function() {
765
+ var pass = true, expressions = JsUnitTest.arrayfromargs(arguments);
766
+ var elements = expressions.shift();
767
+ if (elements.length != expressions.length) {
768
+ message = this.buildMessage('assertElementsMatch', 'size mismatch: ? elements, ? expressions (?).', elements.length, expressions.length, expressions);
769
+ this.flunk(message);
770
+ pass = false;
771
+ }
772
+ for (var i=0; i < expressions.length; i++) {
773
+ var expression = expressions[i];
774
+ var element = JsUnitTest.$(elements[i]);
775
+ if (JsUnitTest.selectorMatch(expression, element)) {
776
+ pass = true;
777
+ break;
778
+ }
779
+ message = this.buildMessage('assertElementsMatch', 'In index <?>: expected <?> but got ?', index, expression, element);
780
+ this.flunk(message);
781
+ pass = false;
782
+ };
783
+ this.assert(pass, "Expected all elements to match.");
784
+ },
785
+
786
+ assertElementMatches: function(element, expression, message) {
787
+ this.assertElementsMatch([element], expression);
788
+ }
789
+ };
790
+ JsUnitTest.Unit.Runner = function(testcases) {
791
+ var argumentOptions = arguments[1] || {};
792
+ var options = this.options = {};
793
+ options.testLog = ('testLog' in argumentOptions) ? argumentOptions.testLog : 'testlog';
794
+ options.resultsURL = this.queryParams.resultsURL;
795
+ options.testLog = JsUnitTest.$(options.testLog);
796
+
797
+ this.tests = this.getTests(testcases);
798
+ this.currentTest = 0;
799
+ this.logger = new JsUnitTest.Unit.Logger(options.testLog);
800
+
801
+ var self = this;
802
+ JsUnitTest.Event.addEvent(window, "load", function() {
803
+ setTimeout(function() {
804
+ self.runTests();
805
+ }, 0.1);
806
+ });
807
+ };
808
+
809
+ JsUnitTest.Unit.Runner.prototype.queryParams = JsUnitTest.toQueryParams();
810
+
811
+ JsUnitTest.Unit.Runner.prototype.portNumber = function() {
812
+ if (window.location.search.length > 0) {
813
+ var matches = window.location.search.match(/\:(\d{3,5})\//);
814
+ if (matches) {
815
+ return parseInt(matches[1]);
816
+ }
817
+ }
818
+ return null;
819
+ };
820
+
821
+ JsUnitTest.Unit.Runner.prototype.getTests = function(testcases) {
822
+ var tests = [], options = this.options;
823
+ if (this.queryParams.tests) tests = this.queryParams.tests.split(',');
824
+ else if (options.tests) tests = options.tests;
825
+ else if (options.test) tests = [option.test];
826
+ else {
827
+ for (testname in testcases) {
828
+ if (testname.match(/^test/)) tests.push(testname);
829
+ }
830
+ }
831
+ var results = [];
832
+ for (var i=0; i < tests.length; i++) {
833
+ var test = tests[i];
834
+ if (testcases[test])
835
+ results.push(
836
+ new JsUnitTest.Unit.Testcase(test, testcases[test], testcases.setup, testcases.teardown)
837
+ );
838
+ };
839
+ return results;
840
+ };
841
+
842
+ JsUnitTest.Unit.Runner.prototype.getResult = function() {
843
+ var results = {
844
+ tests: this.tests.length,
845
+ assertions: 0,
846
+ failures: 0,
847
+ errors: 0,
848
+ warnings: 0
849
+ };
850
+
851
+ for (var i=0; i < this.tests.length; i++) {
852
+ var test = this.tests[i];
853
+ results.assertions += test.assertions;
854
+ results.failures += test.failures;
855
+ results.errors += test.errors;
856
+ results.warnings += test.warnings;
857
+ };
858
+ return results;
859
+ };
860
+
861
+ JsUnitTest.Unit.Runner.prototype.postResults = function() {
862
+ if (this.options.resultsURL) {
863
+ // new Ajax.Request(this.options.resultsURL,
864
+ // { method: 'get', parameters: this.getResult(), asynchronous: false });
865
+ var results = this.getResult();
866
+ var url = this.options.resultsURL + "?";
867
+ url += "tests="+ this.tests.length + "&";
868
+ url += "assertions="+ results.assertions + "&";
869
+ url += "warnings=" + results.warnings + "&";
870
+ url += "failures=" + results.failures + "&";
871
+ url += "errors=" + results.errors;
872
+ JsUnitTest.ajax({
873
+ url: url,
874
+ type: 'GET'
875
+ })
876
+ }
877
+ };
878
+
879
+ JsUnitTest.Unit.Runner.prototype.runTests = function() {
880
+ var test = this.tests[this.currentTest], actions;
881
+
882
+ if (!test) return this.finish();
883
+ if (!test.isWaiting) this.logger.start(test.name);
884
+ test.run();
885
+ var self = this;
886
+ if(test.isWaiting) {
887
+ this.logger.message("Waiting for " + test.timeToWait + "ms");
888
+ // setTimeout(this.runTests.bind(this), test.timeToWait || 1000);
889
+ setTimeout(function() {
890
+ self.runTests();
891
+ }, test.timeToWait || 1000);
892
+ return;
893
+ }
894
+
895
+ this.logger.finish(test.status(), test.summary());
896
+ if (actions = test.actions) this.logger.appendActionButtons(actions);
897
+ this.currentTest++;
898
+ // tail recursive, hopefully the browser will skip the stackframe
899
+ this.runTests();
900
+ };
901
+
902
+ JsUnitTest.Unit.Runner.prototype.finish = function() {
903
+ this.postResults();
904
+ this.logger.summary(this.summary());
905
+ };
906
+
907
+ JsUnitTest.Unit.Runner.prototype.summary = function() {
908
+ return new JsUnitTest.Template('#{tests} tests, #{assertions} assertions, #{failures} failures, #{errors} errors, #{warnings} warnings').evaluate(this.getResult());
909
+ };
910
+ JsUnitTest.Unit.Testcase = function(name, test, setup, teardown) {
911
+ this.name = name;
912
+ this.test = test || function() {};
913
+ this.setup = setup || function() {};
914
+ this.teardown = teardown || function() {};
915
+ this.messages = [];
916
+ this.actions = {};
917
+ };
918
+ // import JsUnitTest.Unit.Assertions
919
+
920
+ for (method in JsUnitTest.Unit.Assertions) {
921
+ JsUnitTest.Unit.Testcase.prototype[method] = JsUnitTest.Unit.Assertions[method];
922
+ }
923
+
924
+ JsUnitTest.Unit.Testcase.prototype.isWaiting = false;
925
+ JsUnitTest.Unit.Testcase.prototype.timeToWait = 1000;
926
+ JsUnitTest.Unit.Testcase.prototype.assertions = 0;
927
+ JsUnitTest.Unit.Testcase.prototype.failures = 0;
928
+ JsUnitTest.Unit.Testcase.prototype.errors = 0;
929
+ JsUnitTest.Unit.Testcase.prototype.warnings = 0;
930
+ JsUnitTest.Unit.Testcase.prototype.isRunningFromRake = window.location.port;
931
+
932
+ // JsUnitTest.Unit.Testcase.prototype.isRunningFromRake = window.location.port == 4711;
933
+
934
+ JsUnitTest.Unit.Testcase.prototype.wait = function(time, nextPart) {
935
+ this.isWaiting = true;
936
+ this.test = nextPart;
937
+ this.timeToWait = time;
938
+ };
939
+
940
+ JsUnitTest.Unit.Testcase.prototype.run = function(rethrow) {
941
+ try {
942
+ try {
943
+ if (!this.isWaiting) this.setup();
944
+ this.isWaiting = false;
945
+ this.test();
946
+ } finally {
947
+ if(!this.isWaiting) {
948
+ this.teardown();
949
+ }
950
+ }
951
+ }
952
+ catch(e) {
953
+ if (rethrow) throw e;
954
+ this.error(e, this);
955
+ }
956
+ };
957
+
958
+ JsUnitTest.Unit.Testcase.prototype.summary = function() {
959
+ var msg = '#{assertions} assertions, #{failures} failures, #{errors} errors, #{warnings} warnings\n';
960
+ return new JsUnitTest.Template(msg).evaluate(this) +
961
+ this.messages.join("\n");
962
+ };
963
+
964
+ JsUnitTest.Unit.Testcase.prototype.pass = function() {
965
+ this.assertions++;
966
+ };
967
+
968
+ JsUnitTest.Unit.Testcase.prototype.fail = function(message) {
969
+ this.failures++;
970
+ var line = "";
971
+ try {
972
+ throw new Error("stack");
973
+ } catch(e){
974
+ line = (/\.html:(\d+)/.exec(e.stack || '') || ['',''])[1];
975
+ }
976
+ this.messages.push("Failure: " + message + (line ? " Line #" + line : ""));
977
+ };
978
+
979
+ JsUnitTest.Unit.Testcase.prototype.warning = function(message) {
980
+ this.warnings++;
981
+ var line = "";
982
+ try {
983
+ throw new Error("stack");
984
+ } catch(e){
985
+ line = (/\.html:(\d+)/.exec(e.stack || '') || ['',''])[1];
986
+ }
987
+ this.messages.push("Warning: " + message + (line ? " Line #" + line : ""));
988
+ };
989
+ JsUnitTest.Unit.Testcase.prototype.warn = JsUnitTest.Unit.Testcase.prototype.warning;
990
+
991
+ JsUnitTest.Unit.Testcase.prototype.info = function(message) {
992
+ this.messages.push("Info: " + message);
993
+ };
994
+
995
+ JsUnitTest.Unit.Testcase.prototype.error = function(error, test) {
996
+ this.errors++;
997
+ this.actions['retry with throw'] = function() { test.run(true) };
998
+ this.messages.push(error.name + ": "+ error.message + "(" + JsUnitTest.inspect(error) + ")");
999
+ };
1000
+
1001
+ JsUnitTest.Unit.Testcase.prototype.status = function() {
1002
+ if (this.failures > 0) return 'failed';
1003
+ if (this.errors > 0) return 'error';
1004
+ if (this.warnings > 0) return 'warning';
1005
+ return 'passed';
1006
+ };
1007
+
1008
+ JsUnitTest.Unit.Testcase.prototype.benchmark = function(operation, iterations) {
1009
+ var startAt = new Date();
1010
+ (iterations || 1).times(operation);
1011
+ var timeTaken = ((new Date())-startAt);
1012
+ this.info((arguments[2] || 'Operation') + ' finished ' +
1013
+ iterations + ' iterations in ' + (timeTaken/1000)+'s' );
1014
+ return timeTaken;
1015
+ };
1016
+
1017
+ Test = JsUnitTest