@@ -479,6 +479,11 @@ class UtplsqlDao {
479
479
return nodes
480
480
}
481
481
482
+ /**
483
+ * enable DBMS_OUTPUT
484
+ *
485
+ * @throws DataAccessException if there is a problem
486
+ */
482
487
def void enableDbmsOutput () {
483
488
// equivalent to "set serveroutput on size unlimited"
484
489
jdbcTemplate. update(' ' '
@@ -487,7 +492,12 @@ class UtplsqlDao {
487
492
END;
488
493
' ' ' )
489
494
}
490
-
495
+
496
+ /**
497
+ * disable DBMS_OUTPUT
498
+ *
499
+ * @throws DataAccessException if there is a problem
500
+ */
491
501
def void disableDbmsOutput () {
492
502
jdbcTemplate. update(' ' '
493
503
BEGIN
@@ -496,10 +506,22 @@ class UtplsqlDao {
496
506
' ' ' )
497
507
}
498
508
509
+ /**
510
+ * return the content of DBMS_OUTPUT as String
511
+ *
512
+ * @throws DataAccessException if there is a problem
513
+ */
499
514
def String getDbmsOutput () {
500
515
return getDbmsOutput(1000 )
501
516
}
502
517
518
+ /**
519
+ * return the content of DBMS_OUTPUT as String
520
+
521
+ * @param bufferSize maximum number of rows to be read from the DBMS_OUTPUT buffer in one network round trip
522
+ * @return content of DBMS_OUTPUT as String
523
+ * @throws DataAccessException if there is a problem
524
+ */
503
525
def String getDbmsOutput (int bufferSize ) {
504
526
val sb = new StringBuffer
505
527
val sql = ' ' '
@@ -531,18 +553,49 @@ class UtplsqlDao {
531
553
} while (ret. numlines > 0 )
532
554
return sb. toString
533
555
}
534
-
535
- def String htmlCodeCoverage (List<String > pathList ) {
556
+
557
+ /**
558
+ * gets the HTML code coverage report as String
559
+ *
560
+ * @param pathList utPLSQL path list
561
+ * @param schemaList list of schemas under tests. Current schema, if empty
562
+ * @param includeObjectList list of objects to be included for coverage analysis. All, if empty
563
+ * @param excludeObjectList list of objects to be excluded from coverage analysis. None, if empty
564
+ * @return HTML code coverage report in HTML format
565
+ * @throws DataAccessException if there is a problem
566
+ */
567
+ def String htmlCodeCoverage (List<String > pathList , List<String > schemaList , List<String > includeObjectList , List<String > excludeObjectList ) {
536
568
enableDbmsOutput
537
569
val sql = ' ' '
538
570
BEGIN
539
571
ut.run(
540
- ut_varchar2_list(
541
- «FOR path : pathList SEPARATOR ","»
572
+ a_paths => ut_varchar2_list(
573
+ «FOR path : pathList SEPARATOR ", "»
542
574
' «path»'
543
575
«ENDFOR»
544
576
),
545
- ut_coverage_html_reporter()
577
+ «IF schemaList.size > 0»
578
+ a_coverage_schemes => ut_varchar2_list(
579
+ «FOR schema : schemaList SEPARATOR ", "»
580
+ ' «schema»'
581
+ «ENDFOR»
582
+ ),
583
+ «ENDIF»
584
+ «IF includeObjectList.size > 0»
585
+ a_include_objects => ut_varchar2_list(
586
+ «FOR includeObject : includeObjectList SEPARATOR ", "»
587
+ ' «includeObject»'
588
+ «ENDFOR»
589
+ ),
590
+ «ENDIF»
591
+ «IF excludeObjectList.size > 0»
592
+ a_exclude_objects => ut_varchar2_list(
593
+ «FOR excludeObject : excludeObjectList SEPARATOR ", "»
594
+ ' «excludeObject»'
595
+ «ENDFOR»
596
+ ),
597
+ «ENDIF»
598
+ a_reporter => ut_coverage_html_reporter()
546
599
);
547
600
END;
548
601
' ' '
@@ -552,4 +605,29 @@ class UtplsqlDao {
552
605
return ret
553
606
}
554
607
608
+ /**
609
+ * gets dependencies of a given object.
610
+ *
611
+ * The result can be used as input for the includeObjectList in htmlCodeCoverage
612
+ * The scope is reduced to the current schema.
613
+ * This is useful when test packages are installed in the code schema.
614
+ * The result may include test packages
615
+ *
616
+ * @param name test package name
617
+ * @return list of dependencies in the current schema
618
+ */
619
+ def List<String > includes (String name ) {
620
+ val sql = ' ' '
621
+ select referenced_name
622
+ from «IF dbaViewAccessible»dba«ELSE»all«ENDIF»_dependencies
623
+ WHERE owner = user
624
+ AND name = upper(?)
625
+ AND referenced_owner = user
626
+ AND referenced_type IN (' PACKAGE ' , ' TYPE ' , ' PROCEDURE ' , ' FUNCTION ' , ' TRIGGER ' )
627
+ ' ' '
628
+ val jdbcTemplate = new JdbcTemplate (new SingleConnectionDataSource (conn, true ))
629
+ val deps = jdbcTemplate. queryForList(sql, String , #[name])
630
+ return deps
631
+ }
632
+
555
633
}
0 commit comments