Skip to content
Permalink
Browse files

[core] Empty composite handler: `acolyte.CompositeHandler.empty()`

  • Loading branch information
cchantep
cchantep committed Nov 23, 2013
1 parent 66991a8 commit 6b1c7602b58f2952f22e18c3408e273924572d91
@@ -34,6 +34,14 @@ public CompositeHandler(final Pattern[] queryDetection,
super(queryDetection, queryHandler, updateHandler);
} // end of <init>

/**
* Returns 'empty' statement handler,
* without detection pattern, query handler or update handler.
*/
public static CompositeHandler empty() {
return new CompositeHandler();
} // end of empty

// ---

/**
@@ -26,6 +26,10 @@ object CompositeHandlerSpec extends Specification {
}

"not match" >> {
"with empty handler" in {
CompositeHandler.empty.isQuery("TEST") aka "detection" must beFalse
}

"with unmatching statement" in {
new CompositeHandler().withQueryDetection("^SELECT ").
isQuery("TEST") aka "detection" must beFalse
@@ -59,8 +63,16 @@ object CompositeHandlerSpec extends Specification {
}

"Update handling" should {
"not be inited" in {
new CompositeHandler().withUpdateHandler(null.asInstanceOf[UpdateHandler]).
"not be inited with sole constructor" in {
new CompositeHandler().
withUpdateHandler(null.asInstanceOf[UpdateHandler]).
aka("init") must throwA[IllegalArgumentException]

}

"not be inited with empty statement handler" in {
CompositeHandler.empty.
withUpdateHandler(null.asInstanceOf[UpdateHandler]).
aka("init") must throwA[IllegalArgumentException]

}
@@ -94,12 +106,18 @@ object CompositeHandlerSpec extends Specification {
}

"Query handling" should {
"not be inited" in {
"not be inited with sole constructor" in {
new CompositeHandler().withQueryHandler(null.asInstanceOf[QueryHandler]).
aka("init") must throwA[IllegalArgumentException]

}

"not be inited with empty statement handler" in {
CompositeHandler.empty.withQueryHandler(null.asInstanceOf[QueryHandler]).
aka("init") must throwA[IllegalArgumentException]

}

"be successful for empty resultset" in {
lazy val rows = RowLists.rowList1(classOf[String])
lazy val res =

0 comments on commit 6b1c760

Please sign in to comment.
You can’t perform that action at this time.