<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Documentation to write test cases for the functionalities in alfresco community edition in Alfresco Forum</title>
    <link>https://connect.hyland.com/t5/alfresco-forum/documentation-to-write-test-cases-for-the-functionalities-in/m-p/80629#M24926</link>
    <description>&lt;P&gt;Is there a documentation to write test cases for the functionalities which are supported by alfresco.&lt;/P&gt;</description>
    <pubDate>Fri, 18 Sep 2020 17:03:05 GMT</pubDate>
    <dc:creator>arjunm1989</dc:creator>
    <dc:date>2020-09-18T17:03:05Z</dc:date>
    <item>
      <title>Documentation to write test cases for the functionalities in alfresco community edition</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/documentation-to-write-test-cases-for-the-functionalities-in/m-p/80629#M24926</link>
      <description>&lt;P&gt;Is there a documentation to write test cases for the functionalities which are supported by alfresco.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Sep 2020 17:03:05 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/documentation-to-write-test-cases-for-the-functionalities-in/m-p/80629#M24926</guid>
      <dc:creator>arjunm1989</dc:creator>
      <dc:date>2020-09-18T17:03:05Z</dc:date>
    </item>
    <item>
      <title>Re: Documentation to write test cases for the functionalities in alfresco community edition</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/documentation-to-write-test-cases-for-the-functionalities-in/m-p/80630#M24927</link>
      <description>&lt;P&gt;I am not sure if there is any specific documentation available in docs.alfresco.com for writing test cases. You should take reference from alfresco sdk sample and follow the same approach while writing test cases. You can write simple junit test cases as well as Integration test cases.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;Refer this sdk doc for details on integration test:&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://github.com/Alfresco/alfresco-sdk/blob/master/docs/advanced-topics/integration-testing/it-working.md" target="_blank" rel="nofollow noopener noreferrer"&gt;https://github.com/Alfresco/alfresco-sdk/blob/master/docs/advanced-topics/integration-testing/it-working.md&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;Sample webscript test case, you can find this in sample artifacts generated via sdk:&lt;/U&gt;&lt;/P&gt;
&lt;PRE&gt;import org.junit.Test;
import org.mockito.Mockito;
import org.springframework.extensions.webscripts.*;
import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

public class HelloWorldWebScriptControllerTest {
    @Test
    public void testController() {
        WebScriptRequest req = Mockito.mock(WebScriptRequest.class);
        Status status = Mockito.mock(Status.class);
        Cache cache = Mockito.mock(Cache.class);
        String helloPropName = "fromJava";
        String helloPropExpectedValue = "HelloFromJava";
        HelloWorldWebScript ws = new HelloWorldWebScript();
        Map&amp;lt;String, Object&amp;gt; model = ws.executeImpl(req, status, cache);
        assertNotNull("Response from Web Script Java Controller is null", model);
        assertEquals("Incorrect Web Script Java Controller Response",
                helloPropExpectedValue, model.get(helloPropName));
    }
}&lt;/PRE&gt;
&lt;P&gt;&lt;U&gt;Sample of IT:&lt;/U&gt;&lt;/P&gt;
&lt;PRE&gt;import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

public class HelloWorldWebScriptIT {
    private static final String ACS_ENDPOINT_PROP = "acs.endpoint.path";
    private static final String ACS_DEFAULT_ENDPOINT = "http://localhost:8080/alfresco";
    @Test
    public void testWebScriptCall() throws Exception {
        String webscriptURL = getPlatformEndpoint() + "/service/sample/helloworld";
        String expectedResponse = "Message: 'Hello from JS!' 'HelloFromJava'";
        // Login credentials for Alfresco Repo
        CredentialsProvider provider = new BasicCredentialsProvider();
        UsernamePasswordCredentials credentials = new UsernamePasswordCredentials("admin", "admin");
        provider.setCredentials(AuthScope.ANY, credentials);

        // Create HTTP Client with credentials
        CloseableHttpClient httpclient = HttpClientBuilder.create()
                .setDefaultCredentialsProvider(provider)
                .build();
        // Execute Web Script call
        try {
            HttpGet httpget = new HttpGet(webscriptURL);
            HttpResponse httpResponse = httpclient.execute(httpget);
            assertEquals("Incorrect HTTP Response Status",
                    HttpStatus.SC_OK, httpResponse.getStatusLine().getStatusCode());
            HttpEntity entity = httpResponse.getEntity();
            assertNotNull("Response from Web Script is null", entity);
            assertEquals("Incorrect Web Script Response", expectedResponse, EntityUtils.toString(entity));
        } finally {
            httpclient.close();
        }
    }
    private String getPlatformEndpoint() {
        final String platformEndpoint = System.getProperty(ACS_ENDPOINT_PROP);
        return StringUtils.isNotBlank(platformEndpoint) ? platformEndpoint : ACS_DEFAULT_ENDPOINT;
    }
}&lt;/PRE&gt;</description>
      <pubDate>Sun, 20 Sep 2020 03:02:08 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/documentation-to-write-test-cases-for-the-functionalities-in/m-p/80630#M24927</guid>
      <dc:creator>abhinavmishra14</dc:creator>
      <dc:date>2020-09-20T03:02:08Z</dc:date>
    </item>
    <item>
      <title>Re: Documentation to write test cases for the functionalities in alfresco community edition</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/documentation-to-write-test-cases-for-the-functionalities-in/m-p/80631#M24928</link>
      <description>&lt;P&gt;Thank you Abhinav. Also is there any doc that covering all the tasks or actions list in alfresco share kind of default alfresco scenarios or functionalities.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Sep 2020 13:45:31 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/documentation-to-write-test-cases-for-the-functionalities-in/m-p/80631#M24928</guid>
      <dc:creator>arjunm1989</dc:creator>
      <dc:date>2020-09-21T13:45:31Z</dc:date>
    </item>
    <item>
      <title>Re: Documentation to write test cases for the functionalities in alfresco community edition</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/documentation-to-write-test-cases-for-the-functionalities-in/m-p/80632#M24929</link>
      <description>&lt;P&gt;No, or i am not aware of any such specific doc. However, you can go through this video tutorials to learn more:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://docs.alfresco.com/6.2/topics/alfresco-video-tutorials.html" target="_blank" rel="nofollow noopener noreferrer"&gt;https://docs.alfresco.com/6.2/topics/alfresco-video-tutorials.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Sep 2020 15:09:56 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/documentation-to-write-test-cases-for-the-functionalities-in/m-p/80632#M24929</guid>
      <dc:creator>abhinavmishra14</dc:creator>
      <dc:date>2020-09-21T15:09:56Z</dc:date>
    </item>
  </channel>
</rss>

