Changeset 3340


Ignore:
Timestamp:
08/09/13 09:57:57 (11 years ago)
Author:
sroth
Message:

Updated mock functionality and file contents.

Location:
DASISH/t5.6/client/trunk/chrome/markingcollection/content/markingcollection/annotator-service/test/mockjax
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • DASISH/t5.6/client/trunk/chrome/markingcollection/content/markingcollection/annotator-service/test/mockjax/mockjax-xml.html

    r3325 r3340  
    1616        <!-- Libraries -->
    1717        <!-- <script src="../lib/jquery-1.10.2.min.js"></script> -->
     18       
     19        <!-- Observe: jquery 1.8.3 version required in order to have proxy approach work with mockjax! -->
    1820        <script src="../../lib/jquery-1.8.3.min.js"></script>
    1921       
  • DASISH/t5.6/client/trunk/chrome/markingcollection/content/markingcollection/annotator-service/test/mockjax/mockjax-xml.js

    r3329 r3340  
    77var url = '/api/annotations?link="http://en.wikipedia.org/wiki/Sagrada_Fam%C3%ADlia"';
    88
     9// Mock for Responding GET api/annotations?link="URI"
    910$.mockjax({
    1011    /* url: A string or regular expression specifying the url of the request that the data should be mocked for. */
    1112    // url: '/api/annotations?link="http://en.wikipedia.org/wiki/Sagrada_Fam%C3%ADlia"&access=read',
    1213    url: url,
     14    // url: '/api/annotations?link="http://en.wikipedia.org/wiki/Sagrada_Fam%C3%ADlia"',
    1315    /* type: Specify what HTTP method to match, usually GET or POST. Case-insensitive, so get and post also work. */
    1416    type: 'GET',
     
    1820    responseTime: 750,
    1921    /* proxy: A string specifying a path to a file, from which the contents will be returned for the request. */
    20     proxy: 'mocks/annotations-sagrada-GET.xml'
     22    proxy: 'mocks/annotations-sagrada-GET.xml',
     23});
     24
     25// Mock for Responding GET api/annotations/AID20130808114716 (annot-0001-GET.xml)
     26$.mockjax({
     27    url: '/api/annotations/AID20130808114716',
     28    type: 'GET',
     29    dataType: 'xml',
     30    responseTime: 750,
     31    proxy: 'mocks/annot-0001-GET.xml',
     32});
     33
     34// Mock for Responding GET api/annotations/AID20130808124131 (annot-0002-GET.xml)
     35$.mockjax({
     36    url: '/api/annotations/AID20130808124131',
     37    type: 'GET',
     38    dataType: 'xml',
     39    responseTime: 750,
     40    proxy: 'mocks/annot-0002-GET.xml',
    2141});
    2242
     
    2949                type: 'GET',
    3050                success: function(xml, textStatus, jqXHR) {
    31                 // success: function(xml) {   
    32                 // can be used if parameters textStatus and jqXHR are not required within the following code block
    33                    
     51                    // success: function(xml) {   
     52                    // can be used if parameters textStatus and jqXHR are not required within the following code block
     53
    3454                    $xml = $(xml);
    3555                   
     
    4565                        aidArr.push($(this).attr('ref').substr(29)); // http://dasish.eu/annotations/ is erased
    4666                    });
    47  
     67
    4868                    console.log(aidArr);
    49                    
    50                     for(var i in aidArr) {
     69
     70                    for (var i in aidArr) {
    5171                        aid_string += '<br />' + aidArr[i];
    5272                        $('#xmlContents').html('<h4 style="margin-bottom: 0;">List of AIDs returned from REST service address<br />GET api/annotations?link="URI":</h4>' + aid_string);
     73                        url = "";
     74                        url = '/api/annotations/' + aidArr[i];
     75                       
     76                        $.ajax({
     77                            url: url,
     78                            dataType: 'xml',
     79                            type: 'GET',
     80                            success: function(xml) {
     81                               
     82                                $xml = $(xml);
     83   
     84                                var body = "";
     85                                $xml.find('annotation').each(function() {
     86                                    body = $(this).find('body').text();
     87 
     88                                    $('#xmlContents').append("<br /><br /><strong>Body content of " + aidArr[i] + ":</strong><br /><em>" + body + "</em>");
     89                                   
     90                                });   
     91                               
     92                            }
     93                        });
     94
    5395                    }
    54                    
     96
    5597                }
     98
    5699            });
    57100        }
  • DASISH/t5.6/client/trunk/chrome/markingcollection/content/markingcollection/annotator-service/test/mockjax/mocks/annotations-sagrada-GET.xml

    r3332 r3340  
    1818        </targetSources>
    1919    </annotation>
     20    <!--
    2021    <annotation ref="http://dasish.eu/annotations/AIDzyy">
    2122        <owner ref="http://dasish.eu/users/UIDefef"/>
     
    2526        </targetSources>
    2627    </annotation>
     28    -->
    2729</annotations>
Note: See TracChangeset for help on using the changeset viewer.