Skip to content

Commit

Permalink
[core] Empty composite handler: acolyte.CompositeHandler.empty()
Browse files Browse the repository at this point in the history
  • Loading branch information
cchantep committed Nov 25, 2013
1 parent 66991a8 commit 6b1c760
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
8 changes: 8 additions & 0 deletions core/src/main/java/acolyte/CompositeHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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

// ---

/**
Expand Down
24 changes: 21 additions & 3 deletions core/src/test/scala/acolyte/CompositeHandlerSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]

}
Expand Down Expand Up @@ -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 =
Expand Down

0 comments on commit 6b1c760

Please sign in to comment.