XUnit - Logging & Debugging

Poster Content
nk4um Moderator
Posts: 901
October 9, 2007 17:47Ambiguous
Sorry I realise I shouldn''t have used copy as the example there - it is a bit confusing. The main point is that target is always a SINK request with the representation from the <instr> source request.

Try this...


<idoc>
   <seq>
      <instr>
         <type>source</type>
         <uri>active:beanshell+operator@ffcpl:/test/bc/sinkTest.bsh</uri>
         <target>active:beanshell+operator@ffcpl:/test/bc/sinkTest.bsh</target>
      </instr>
   </seq>
</idoc>


Where the sinkTest.bsh is the same as above.  You''ll see two requests made to the script one a SOURCE (!) and the other a SINK (2).
Like · Post Reply
nk4um Moderator
Posts: 901
October 9, 2007 17:23target is a SINK request
Hi Jeremy/Tom,

Tom is pretty close.  DPML is old and its instructions are actually a matched SOURCE/SINK pair.  The Source request is constructed from the type and any arguments, while the target specifeis a resource to issue a SINK request (with the result of the source).

Here''s an example:


<idoc>
   <seq>
      <instr>
         <type>copy</type>
         <operand><test/></operand>
         <target>active:beanshell+operator@ffcpl:/test/bc/sinkTest.bsh</target>
      </instr>
   </seq>
</idoc>


Where the script ffcpl/test/bc/sinkTest.bsh is..


void main()
{   System.out.println(context.getThisRequest().getRequestType());

}


Type is a static on the INKFRequestReadOnly - should see 2 in stdout = SINK.

So you can sink any DPML statement by stating the target URI to sink to.

Cheers,

P.

PS If your interested copy (built-in) just makes a source for the operand and sinks to target.  It detects var: and literal args and realises these are local so it doesn''t need to make a source request for them.

Like · Post Reply
nk4um User
Posts: 79
October 9, 2007 17:10sink resource from dpml
Tom,
I appreciate the reply but it is not relevant to what I am trying to accomplish.

I am attempting to execute a sink against a resource that is handled by a Java accessor (from DPML). I copied what was posted by Peter R. and then attempted to extend it.

What I want to avoid is having to export different URI schemes in my modules. I only want to export ffcpl. But I still would like to use DPML within the context of XUnit tests.
Like · Post Reply
nk4um User
Posts: 47
October 9, 2007 17:01Try copy instead
It''s not clear to me what you are trying to accomplish but
try the ''copy'' accessor instead. The docs for Copy say:

The copy accessor assigns the value of one resource to another. If the resource that is being assigned-to supports SINKing of data then the data will be sunk. This primitive service is built into the DPML language.


I assume that you might be trying to write to an output file. In which case,
your target should use the ''file:'' URI. See the following example which copies a
literal to the response variable and then copies the contents of the variable
to the output.txt file in /tmp:

<idoc>
  <seq>
  <instr>
    <type>copy</type>
    <operand><message>Hello World 2</message></operand>
    <target>this:response</target>
  </instr>
  <instr>
    <type>copy</type>
    <operand>this:response</operand>
    <target>file:/tmp/output.txt</target>
  </instr>
  </seq>
</idoc>


Hope this helps,
   -tom
Like · Post Reply
nk4um User
Posts: 79
October 9, 2007 15:28sink ffcpl uri from dpml
Sourcing a ffcpl uri from dpml works


<idoc>
   <seq>
      <instr>
         <type>source</type>
         <uri>ffcpl:/infrastructure/testing/mock</uri>
         <target>this:response</target>
      </instr>
   </seq>
</idoc>


BUT sinking does not work. URI does not resolve


<idoc>
   <seq>
      <instr>
         <type>sink</type>
         <uri>ffcpl:/infrastructure/testing/mock</uri>
         <target>this:response</target>
      </instr>
   </seq>
</idoc>

URI Resolution Failure
The request active:sink+uri@ffcpl%3A/infrastructure/testing/mock+param@ffcpl%3A/tests/update.idoc%23xpointer(/idoc/seq/instr/param/request) in module urn:org:ten60:netkernel:ext:dpml failed because no module could be located to handle it. See Exception trace for details of resolution process.
active:sink+uri@ffcpl%3A/infrastructure/testing/mock+param@ffcpl%3A/tests/update.idoc%23xpointer(/idoc/seq/instr/param/request)

executing instruction
INSTR: sink uri=ffcpl:/infrastructure/testing/mock param=literal
in idoc
ffcpl:/tests/update.idoc



Is this a limitation of DPML?
Like · Post Reply
nk4um Moderator
Posts: 901
October 8, 2007 15:10source in DPML
3. Finally, is there anyway to get DPML to make ffcpl requests rather than always tranlating into active? If you have a modules that exports resources using the ffcpl scheme, you cannot use DPML as a test harness.


Yes you can do this:
<instr>
  <type>source</type>
  <uri>ffcpl:/some/uri</uri>
  <target>var:result</target>
</instr>


P.
Like · Post Reply
nk4um Moderator
Posts: 901
October 7, 2007 13:29Brief Triage
Hi Jeremy,

Just time for a very quick response.  Your "No Match Found for ffcpl:/xunit/mock-service" is because you are not importing the xunit module into your urn:edu:bc:sg:infrastructure:MockService module.

The resolution trace shows exactly what is happening.  The request is hitting the module and getting rewritten to active:xunit - but then does not find active:xunit in the imports section.

Hope this is a quick fix.  I''ll think about the other points when I have some more time.

P.
Like · Post Reply
nk4um User
Posts: 79
October 6, 2007 19:03XUnit - Logging & Debugging
1. How do you turn on debugging for a set of XUnit tests. I noticed that if I run the self tests a log file is created. But if I run my tests, nothing is created.

2. I need the log file because I cannot get XUnit to execute a simple URL request.


<match>ffcpl:/infrastructure/testing/+.*</match>


The above URI is exported and matches against an Accessor. If I call it from the front-end fulcrum everything works great.

However, if I call it from an xunit test definition, it does not work


<testlist output="xml" title="Mock Service Tests">
   <!-- An optional XHTML description -->
   <desc>
      <div>
         <h1>XUnit Tests</h1>
         <p>Mock Service XUnit Definitions</p>
      </div>
   </desc>
   <test>
      <uri>http://localhost:8080/infrastructure/testing/mock</uri>
   </test>
</testlist>

OR

<testlist output="xml" title="Mock Service Tests">
   <!-- An optional XHTML description -->
   <desc>
      <div>
         <h1>XUnit Tests</h1>
         <p>Mock Service XUnit Definitions</p>
      </div>
   </desc>
   <test>
      <uri>ffcpl:/infrastructure/testing/mock</uri>
   </test>
</testlist>



I verified that my XUnit entrypoint was resolving all the way to my test definition.



entrypoint = ffcpl:/xunit/mock-service

Request:ffcpl:/xunit/mock-service
Trace:Searching for ffcpl:/xunit/mock-service
Starting Module urn:edu:bc:sg:infrastructure:MockService
Rewriting Request to active:xunit+testlist@ffcpl:/xml/xunit-definitions.xml



So the request does get sent onto my test definition file. But then I get back the following message


Message:   The request ffcpl:/xunit/mock-service in module urn:edu:bc:sg:infrastructure:MockService failed because no module could be located to handle it. See Exception trace for details of resolution process.
Request:   ffcpl:/xunit/mock-service
Trace:      Searching for ffcpl:/xunit/mock-service
Starting Module urn:edu:bc:sg:infrastructure:MockService
Rewriting Request to active:xunit+testlist@ffcpl:/xml/xunit-definitions.xml
Checked Unmatched Mapping ffcpl:/etc/LogConfig.xml THIS
Checked Unmatched Mapping ffcpl:/xml/.* THIS
Checked Unmatched Mapping ffcpl:/tests/.* THIS
Checked Unmatched Mapping ffcpl:/pub/.* THIS
Checked Unmatched Mapping ffcpl:/entrypoints.xml THIS
Checked Unmatched Mapping ffcpl:/infrastructure/testing/mock.* to accessor edu.bc.sg.infrastructure.testing.impl.MockServiceAccessor
Checked Unmatched Mapping (many) to import urn:org:ten60:netkernel:ext:layer1
Checked Unmatched Mapping (many) to import urn:org:ten60:netkernel:ext:xml:core
Checked Unmatched Mapping (many) to import urn:org:ten60:netkernel:ext:xml:ura
Checked Unmatched Mapping (many) to import urn:org:ten60:netkernel:ext:sys
Checked Unmatched Mapping (many) to import urn:org:ten60:netkernel:ext:dpml
Checked Unmatched Mapping (many) to import urn:org:ten60:netkernel:ext:script
Checked Unmatched Mapping (many) to import urn:edu:bc:sg:infrastructure:BCCommon
Matched on Mapping .* SUPER
No Match Found for ffcpl:/xunit/mock-service


So at this point I have no idea if the test failed or if I do not have XUnit configured correctly.

3. Finally, is there anyway to get DPML to make ffcpl requests rather than always tranlating into active? If you have a modules that exports resources using the ffcpl scheme, you cannot use DPML as a test harness.
Like · Post Reply