ATGDustCase for a Droplet - Sample Code

The code given is pretty much focussed on basics,it
certainly helps to execute/pass your first ATG Dust
Case.Customise this class as you wish to suit your requirements,
dont forget to add your own package  name,service method etc here.

Below is the AtgDustCase for a Droplet named AcessServlet.
I am not providing the code for AccessServlet but for the test class.

package *.*.*.*;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.ServletException;
import atg.servlet.DynamoHttpServletRequest;
import atg.servlet.DynamoHttpServletResponse;
import atg.servlet.ServletTestUtils;
import atg.test.AtgDustCase;
public class AcessServletTest extends AtgDustCase {
        private ServletTestUtils mServletTestUtils = null;
        private AcessServlet obj;
        protected void setUp() throws Exception {
        super.setUp();
        if (mServletTestUtils == null)
            mServletTestUtils = new ServletTestUtils();
                assertNotNull(mServletTestUtils);
        File configpath = new File
         ("C:\\workspace\\myModule\\config");
        assertNotNull(configpath);
        setConfigurationLocation(configpath.getAbsolutePath());
        obj = (AcessServlet) resolveNucleusComponent
        (("/atg/userprofiling/AcessServlet "));
        assertNotNull(obj);
       
    }
    protected void tearDown() throws Exception {
        assertNotNull("tearDown");
        super.tearDown();
    }
    public void testAgent() throws ServletException, IOException {
        int bufferSize = 128 * 1024;
        Map<String, String> params = new HashMap<String, String>();
        DynamoHttpServletRequest request = mServletTestUtils.
        createDynamoHttpServletRequest(params,  
        bufferSize, "GET");
        DynamoHttpServletResponse response = mServletTestUtils.
        createDynamoHttpServletResponse();
        //obj.service(request, response); //
         ............  //Here you can add Oparams and Response
         related validations
         ..............
    }
}
Add Assert statements appropriately to justify your test cases.
From the IDE(Eclipse)Right Click the file Run As Junit Test !!!

See basic steps to execute ATGDustCase for a FormHandler

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...