Note that there are some explanatory texts on larger screens.

plurals
  1. POPutting array of arrays into a spring context
    text
    copied!<p>I just found a TestNG test case that uses Spring to provide its data source. As a result the code is quite clean and concise.</p> <p>However, I need to expand the test cases so they can take a variable list of inputs.</p> <p>Am I stuck using bean references for the list of lists as I've attempted below? Is there a way to do that and still be pretty (i.e. not breaking up the logical flow of input followed by output)? Is there a better way?</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"&gt; &lt;bean id="stringPatternRegexMap" class="java.util.HashMap"&gt; &lt;constructor-arg&gt; &lt;map&gt; &lt;entry key="some input #1" value="expected output #1"/&gt; &lt;entry key="some input #2" value="expected output #2"/&gt; &lt;entry key="some input #3" value="expected output #3"/&gt; &lt;entry key-ref="multi-list-1" value="expected output #3"/&gt; &lt;entry key-ref="null-reference" value="null-reference"/&gt; &lt;/map&gt; &lt;/constructor-arg&gt; &lt;/bean&gt; &lt;bean id="multi-list-1"&gt; &lt;list&gt; &lt;value&gt;apple&lt;/value&gt; &lt;value&gt;banana&lt;/value&gt; &lt;value&gt;orange&lt;/value&gt; &lt;/list&gt; &lt;/bean&gt; &lt;bean id="null-reference"&gt; &lt;value&gt; &lt;null/&gt; &lt;/value&gt; &lt;/bean&gt; &lt;/beans&gt; </code></pre> <p>Note that the original code appears to be using a map instead of a list because it seems an easier way to provide a list of String[2].</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload