Hi,

Is there another way this can be done so I can test the functionality for
replaceSuffix . :)

Janandith.

On Mon, Aug 11, 2008 at 1:06 AM, Felix Meschberger <[EMAIL PROTECTED]>wrote:

> Hi,
>
> I would assume that the problem is, that the replacement suffix is only
> available in the included request and not in the including request. Thus,
> the suffix.jsp script is not expected to see the new suffix.
>
> Regards
> Felix
>
>
> janandith jayawardena schrieb:
>
>> Hi,
>> Thanks Felix. I wrote the test for replaceSelector :).
>>
>> The problem now is with replace suffix.
>>
>> can you suggest a way for this.
>>
>> currently in my test file I have this,
>>
>>
>>       Map<String,String> props = new HashMap<String,String>();
>>       string resourceTypeX =  "/x";
>>       props.put("sling:resourceType", resourceTypeX);
>>       string  contentUrlX = testClient.createNode(HTTP_BASE_URL
>> +resourceTypeX , props);
>>
>>        string resourceTypeXQ = resourceTypeX + "/q";
>>        props.clear();
>>        props.put("sling:resourceType", resourceTypeXQ);
>>        string contentUrlQ = testClient.createNode(HTTP_BASE_URL
>> +resourceTypeXQ, props);
>>        uploadTestScript(resourceTypeXQ,"suffix.jsp","html.jsp");
>>
>>
>> public void testReplaceSuffix() throws Exception {
>>
>>
>>        final String content = getContent(contentUrlQ + ".html/a.c",
>> CONTENT_TYPE_HTML);
>>          System.out.println(content);
>>       // assertTrue("result of flush",content.contains("Flush Successful
>> becasue commit is true"));
>>    }
>>
>>
>> The "suffix.jsp" file contains the following,
>>
>> <[EMAIL PROTECTED] session="false"%>
>> <[EMAIL PROTECTED] import="org.apache.sling.api.SlingHttpServletRequest"%>
>> <[EMAIL PROTECTED] import="org.apache.sling.api.resource.Resource"%>
>> <[EMAIL PROTECTED] prefix="sling" 
>> uri="http://sling.apache.org/taglibs/sling/1.0
>> "%>
>>
>> <sling:defineObjects/>
>>
>> <sling:include replaceSuffix="a.b" />
>>
>> <%
>>    SlingHttpServletRequest req = (SlingHttpServletRequest) request;
>>    String suffixTest = "" ;
>>    suffixTest = req.getRequestPathInfo().getSuffix() ;
>>
>>    if(suffixTest==null){
>>        suffixTest = "Suffix Not Successful";
>>    }
>>    else{
>>        suffixTest = "Suffix Successful";
>>
>>    }
>>
>> %>
>>
>> This test fails.
>>
>>
>> Also you can have a look at the current test at,
>>
>> http://code.google.com/p/sling-scala/source/browse/trunk/sling475/?r=85
>>
>> regards,
>>
>> Janandith.
>>
>>
>>
>> On Wed, Aug 6, 2008 at 3:34 AM, Felix Meschberger <[EMAIL PROTECTED]
>> >wrote:
>>
>>  Hi Janandith,
>>>
>>> janandith jayawardena schrieb:
>>>
>>>  Hi Felix,
>>>>
>>>>
>>>>  I do not exactly understand what you are trying to achieve. Do you have
>>>> three scripts -- html.jsp, selector.jsp and replace.jsp ? And you >
>>>> request
>>>> http://host/something.html and have the html.jsp being called.
>>>>
>>>>  Now what is next ?
>>>>
>>>> Thats what I want to do :).
>>>>
>>>> Basically I want a way to write a test for SLING-475 which can test the
>>>> functionality of flush , replaceSelectors and replaceSuffix in
>>>> <sling:include /> tag. I'm still confused in  finding a way to use these
>>>> options in sling:include tag.
>>>>
>>>>  Well, I would assume, that testing the flush would not be that easy ...
>>>
>>> Testing the replaceSelectors would mean being able to tell that the
>>> correct
>>> script has been included and for replaceSuffix you would check whether in
>>> the included script the new suffix is visible.
>>>
>>> So in html.jsp you would do:
>>>
>>>  <sling:include replaceSelectors="selector">
>>>
>>> in selector.jsp you could do something like
>>>
>>>  Hello this is selector.jsp
>>>
>>> In the response check you would then see whether selector.jsp is
>>> contained
>>> in the response. If replaceSelectors would not work, the response would
>>> not
>>> contain the checker string.
>>>
>>> Similar tests could be done for the replaceSuffix.
>>>
>>> Actually, you probably only need two scripts - html.jsp and selector.jsp.
>>>
>>> Hope this helps.
>>>
>>> Regards
>>> Felix
>>>
>>>
>>>  Janandith.
>>>>
>>>>
>>>>
>>>> On Mon, Aug 4, 2008 at 3:05 PM, Felix Meschberger <[EMAIL PROTECTED]
>>>>
>>>>> wrote:
>>>>>
>>>>  Hi,
>>>>
>>>>> janandith jayawardena schrieb:
>>>>>
>>>>>  Hi,
>>>>>
>>>>>> Thanks Bertrand.
>>>>>>
>>>>>> When I use ,
>>>>>>
>>>>>> <sling:include addSelectors="selector"  replaceSelectors="replace" />
>>>>>>
>>>>>> I get the content of replace.jsp
>>>>>>
>>>>>>  Point is, that the addSelectors and replaceSelectors are also in fact
>>>>>>
>>>>> mutually exclusive in the sense that addSelectors is ignored if
>>>>> replaceSelectors is set.
>>>>>
>>>>> Hence the inclusion of replace.jsp is expected.
>>>>>
>>>>>
>>>>>  and
>>>>>
>>>>>> when I use ,
>>>>>>
>>>>>> <sling:include addSelectors="selector"/>
>>>>>> <sling:include addSelectors="selector"  replaceSelectors="replace" />
>>>>>>
>>>>>> I get both selector.jsp and replace.jsp content.
>>>>>>
>>>>>>  Similar here: The first include includes the selector.jsp, while the
>>>>>>
>>>>> second
>>>>> includes replace.jsp for the reasons explained above.
>>>>>
>>>>>
>>>>>  I tried this,
>>>>>
>>>>>> <sling:include addSelectors="selector"/>
>>>>>> <sling:include flush=true />
>>>>>> <sling:include addSelectors="selector"  replaceSelectors="replace" />
>>>>>>
>>>>>> hoping flush will erase initial selector.jsp content but there is no
>>>>>> content
>>>>>> and the program fails.
>>>>>>
>>>>>>  This is a dangerouse one because of the second line with the "flush"
>>>>>>
>>>>> attribute: The flush attribute says to write the current contents of
>>>>> the
>>>>> output buffer out to the response (and not erase the buffer as you
>>>>> might
>>>>> expect). In addition this tag will recursively include the same script
>>>>> again, which should result in an exception being thrown.
>>>>>
>>>>>
>>>>>  I want to test with all these tags in one html.jsp file. how can I use
>>>>>
>>>>>> the
>>>>>> replaceSelector to replace selector.jsp with replace.jsp.
>>>>>>
>>>>>>  I do not exactly understand what you are trying to achieve. Do you
>>>>>> have
>>>>>>
>>>>> three scripts -- html.jsp, selector.jsp and replace.jsp ? And you
>>>>> request
>>>>> http://host/something.html and have the html.jsp being called.
>>>>>
>>>>> Now what is next ?
>>>>>
>>>>>
>>>>>
>>>>>  Also why does the whole script fail when using flush. What is the
>>>>>
>>>>>> correct
>>>>>> way to use it.
>>>>>>
>>>>>>  Due to a recursive inclusion of itself and the exception bein thrown.
>>>>>>
>>>>> This
>>>>> has nothing to do with the flush attribute but with the include itself,
>>>>> which just includes the current resource with the same selectors and
>>>>> extension and therefore resolves to the same script over and over again
>>>>> until too many scripts are included and an exception is thrown.
>>>>>
>>>>> Regards
>>>>> Felix
>>>>>
>>>>>
>>>>>
>>

Reply via email to