Examples of Mockery


Examples of org.jmock.Mockery


    public void testJdbcLockConfigDefault() throws Exception {

        JDBCPersistenceAdapter adapter = new JDBCPersistenceAdapter();
        Mockery context = new Mockery();
        final DataSource dataSource = context.mock(DataSource.class);
        final Connection connection = context.mock(Connection.class);
        final DatabaseMetaData metadata = context.mock(DatabaseMetaData.class);
        final ResultSet result = context.mock(ResultSet.class);
        adapter.setDataSource(dataSource);
        adapter.setCreateTablesOnStartup(false);

        context.checking(new Expectations() {{
            allowing(dataSource).getConnection();
            will(returnValue(connection));
            allowing(connection).getMetaData();
            will(returnValue(metadata));
            allowing(connection);
View Full Code Here

Examples of org.jmock.Mockery

    }

    public void testJdbcLockConfigOverride() throws Exception {
     
        JDBCPersistenceAdapter adapter = new JDBCPersistenceAdapter();
        Mockery context = new Mockery();
        final DataSource dataSource = context.mock(DataSource.class);
        final Connection connection = context.mock(Connection.class);
        final DatabaseMetaData metadata = context.mock(DatabaseMetaData.class);
        final ResultSet result = context.mock(ResultSet.class);
        adapter.setDataSource(dataSource);
        adapter.setCreateTablesOnStartup(false);
       
        context.checking(new Expectations() {{
            allowing (dataSource).getConnection(); will (returnValue(connection));
            allowing (connection).getMetaData(); will (returnValue(metadata));
            allowing (connection);
            allowing (metadata).getDriverName(); will (returnValue("Microsoft_SQL_Server_2005_jdbc_driver"));
            allowing (result).next(); will (returnValue(true));
View Full Code Here

Examples of org.jmock.Mockery

   

    public void testJdbcLockConfigDefault() throws Exception {
     
        JDBCPersistenceAdapter adapter = new JDBCPersistenceAdapter();
        Mockery context = new Mockery();
        final DataSource dataSource = context.mock(DataSource.class);
        final Connection connection = context.mock(Connection.class);
        final DatabaseMetaData metadata = context.mock(DatabaseMetaData.class);
        final ResultSet result = context.mock(ResultSet.class);
        adapter.setDataSource(dataSource);
        adapter.setCreateTablesOnStartup(false);
       
        context.checking(new Expectations() {{
            allowing (dataSource).getConnection(); will (returnValue(connection));
            allowing (connection).getMetaData(); will (returnValue(metadata));
            allowing (connection);
            allowing (metadata).getDriverName(); will (returnValue("Some_Unknown_driver"));
            allowing (result).next(); will (returnValue(true));
View Full Code Here

Examples of org.jmock.Mockery

    public void handleDoGet(final String fromURL, final String fromURLName,
                final String fromRelValue, final String toURL,
                        final String toURLName, final String toRelValue, final String action,
                        final String applyToBoth, final String jsonResponse)
    {
      Mockery context = new Mockery();
      final HttpServletRequest httpRequest = context.mock(HttpServletRequest.class);
      final HttpServletResponse httpResponse = context.mock(HttpServletResponse.class);
      final HttpSession httpSession = context.mock(HttpSession.class);
      final ByteArrayOutputStream out = new ByteArrayOutputStream();
      final PrintWriter httpResponseWriter = new PrintWriter(out);
       
      try
      {
        context.checking(new Expectations()
        {{
            // Expectations for servlet.doGet invocation
          one(httpRequest).getParameter("fromURL");
          will(returnValue(fromURL));
          one(httpRequest).getParameter("fromName");
          will(returnValue(fromURLName));
          one(httpRequest).getParameter("fromRelValue");
          will(returnValue(fromRelValue));
          one(httpRequest).getParameter("toURL");
          will(returnValue(toURL));
          one(httpRequest).getParameter("toName");
          will(returnValue(toURLName));
          one(httpRequest).getParameter("toRelValue");
          will(returnValue(toRelValue));
          one(httpRequest).getParameter("action");
          will(returnValue(action));
          one(httpRequest).getAttribute(SSOSubject.SSOSUBJECT_KEY);
          will(returnValue(new SSOSubject("r0wKz8K8U7En3pvets6KCJ4wT8Q=  ~  10129  ~  test  ~  Test  ~  Test  ~  "+new Date().getTime()+"  ~  1800000")));
          one(httpRequest).getParameter("applyToBoth");
          will(returnValue(applyToBoth));
         
          if(jsonResponse == null)
          {
            if("generateGig".equals(action))
            {
                one(httpRequest).getAttribute("X-Downloading-GEDCOM");
                will(returnValue(null));
                /*one(httpRequest).getSession(true);
                will(returnValue(httpSession));
                one(httpSession).getId();
                will(returnValue("http_session_"+Thread.currentThread().getId()));
                one(httpRequest).getAttribute("X-Downloading-GEDCOM");
                will(returnValue(null));
                one(httpRequest).getSession(true);
                will(returnValue(httpSession));
                one(httpSession).getId();
                will(returnValue("http_session_"+Thread.currentThread().getId()));
                one(httpRequest).getSession(true);
                will(returnValue(httpSession));
                one(httpSession).getId();
                will(returnValue("http_session_"+Thread.currentThread().getId()));*/
               
                // TODO: figure out how to use the jMock framework to ignore the
                // following setAttribute method call rather than matching it
                //File[] files = new File[2];
                //files[0] = new File(Environment.getProperty("CentralSiteRoot")+"/http~~~_3~~~1localhost~~~_38081/gedapi/export.ged.generated.http_session_"+Thread.currentThread().getId());
                //files[1] = new File(Environment.getProperty("CentralSiteRoot")+"/http~~~_3~~~1localhost~~~_38081/gedapi/export.ged.generated.http_session_"+Thread.currentThread().getId()+".generated.http_session_"+Thread.currentThread().getId());
                //one(httpRequest).setAttribute("generatedFiles", files);
                one(httpRequest).setAttribute("fromGedcomURL", fromURL.substring(0, fromURL.lastIndexOf('/')));
                one(httpRequest).getSession(true);
                will(returnValue(httpSession));
                one(httpSession).getId();
                will(returnValue("http_session_"+Thread.currentThread().getId()));
                one(httpRequest).setAttribute("fromGeneratedGigFile", new File(Environment.getProperty("CentralSiteRoot")+"/http~~~_3~~~1localhost~~~_38081/gedapi/"+GLinkURL.hashFilename("export.ged.generated.http_session_"+Thread.currentThread().getId())));
                one(httpRequest).getAttribute("X-Downloading-GEDCOM");
                will(returnValue(null));
                one(httpRequest).setAttribute("toGedcomURL", toURL.substring(0, toURL.lastIndexOf('/')));
                one(httpRequest).getSession(true);
                will(returnValue(httpSession));
                one(httpSession).getId();
                will(returnValue("http_session_"+Thread.currentThread().getId()));
                one(httpRequest).setAttribute("toGeneratedGigFile", new File(Environment.getProperty("CentralSiteRoot")+"/http~~~_3~~~1localhost~~~_38081/gedapi/"+GLinkURL.hashFilename("export.ged.generated.http_session_"+Thread.currentThread().getId()+"_toURL")));

                //ignoring(httpRequest).setAttribute("generatedFiles", anything());
               
              one(httpRequest).getRequestDispatcher("generateGig.jsp");
              //files[0].deleteOnExit();
              //files[1].deleteOnExit();
            }
            else if("generateGeg".equals(action))
            {
                one(httpRequest).setAttribute("fromGLinkURL", "http://localhost:8081/gedapi/export.ged.I1.glink.xml");
                one(httpRequest).getSession(true);
                will(returnValue(httpSession));
                one(httpSession).getId();
                will(returnValue("http_session_"+Thread.currentThread().getId()));
                one(httpRequest).setAttribute("fromGeneratedGegFile", new File(Environment.getProperty("CentralSiteRoot")+"/http~~~_3~~~1localhost~~~_38081/gedapi/"+GLinkURL.hashFilename("export.ged.I1.glink.xml.generated.http_session_"+Thread.currentThread().getId())));
                one(httpRequest).setAttribute("toGLinkURL", "http://localhost:8081/gedapi/export.ged.I2.glink.xml");
                one(httpRequest).getSession(true);
                will(returnValue(httpSession));
                one(httpSession).getId();
                will(returnValue("http_session_"+Thread.currentThread().getId()));
                one(httpRequest).setAttribute("toGeneratedGegFile", new File(Environment.getProperty("CentralSiteRoot")+"/http~~~_3~~~1localhost~~~_38081/gedapi/"+GLinkURL.hashFilename("export.ged.I2.glink.xml.generated.http_session_"+Thread.currentThread().getId())));
               
                // TODO: figure out how to use the jMock framework to ignore the
                // following setAttribute method call rather than matching it
                //File[] files = new File[2];
                //files[0] = null;
                //files[1] = null;
                //one(httpRequest).setAttribute("generatedFiles", files);
               
                //ignoring(httpRequest).setAttribute("generatedFiles", anything());
               
              one(httpRequest).getRequestDispatcher("generateGeg.jsp");
            }
          }
          else
          {
            one(httpResponse).setHeader("Cache-Control", "max-age=0");
            one(httpResponse).setContentType("application/json");
            one(httpResponse).getWriter();
            will(returnValue(httpResponseWriter));
          }
        }});

        servlet.doGet(httpRequest, httpResponse);
        httpResponseWriter.flush();
        httpResponseWriter.close();
       
            context.assertIsSatisfied();

            if(jsonResponse != null)
            {
              String strResponse = out.toString();
        //System.out.println("strResponse: "+strResponse);
View Full Code Here

Examples of org.jmock.Mockery

 
  public GEDCOMCentralSiteServletTest(String testName) throws ServletException
  {
    super(testName);
        System.out.println("Running GEDCOMCentralSiteServlet... Please be patient...");
      Mockery context = new Mockery();
      final ServletConfig servletConfig = context.mock(ServletConfig.class);
      context.checking(new Expectations()
    {{
    }});
      servlet.init(servletConfig);
        context.assertIsSatisfied();
  }
View Full Code Here

Examples of org.jmock.Mockery

    }
   
    //public void nontestGCSBrowse() throws IOException
    public void testGCSBrowse() throws IOException
    {
    Mockery context = new Mockery();
    final HttpServletRequest httpRequest = context.mock(HttpServletRequest.class);
    final HttpServletResponse httpResponse = context.mock(HttpServletResponse.class);
    final ByteArrayOutputStream out = new ByteArrayOutputStream();
    final PrintWriter httpResponseWriter = new PrintWriter(out);

    try
      {
        context.checking(new Expectations()
        {{
          one(httpRequest).getMethod();
          will(returnValue("POST"));
          one(httpRequest).getRequestURI();
          will(returnValue("/GCS/"));
          one(httpRequest).getServletPath();
          will(returnValue("/GCS"));
          one(httpRequest).getMethod();
          will(returnValue("POST"));
          one(httpRequest).getContentType();
          will(returnValue("application/x-www-form-urlencoded"));
          //will(returnValue("multipart/form-data"));
          one(httpRequest).getRequestURL();
          will(returnValue(new StringBuffer("http://localhost:8081/gedapi/GCS/")));
          one(httpResponse).setHeader("Cache-Control", "max-age=0");
          one(httpResponse).setHeader("ETag", "W0006/\"5296-1244677883000\"");
          one(httpResponse).setDateHeader("Last-Modified", 1244677883000l);
          one(httpResponse).setContentType("application/json");
          one(httpResponse).getWriter();
          will(returnValue(httpResponseWriter));
         
          //"multipart/mixed";
          //"multipart/form-data";
          //will(returnValue("/upload/somefile.ged"));
        }});
       
        servlet.service(httpRequest, httpResponse);
        httpResponseWriter.flush();
        httpResponseWriter.close();
       
        context.assertIsSatisfied();
            String strResponse = out.toString();
            String jsonResponse = "{\"content\":[{\"isFile\":false,\"jsContent\":\"/http~~~_3~~~1freespace.virgin.net\",\"linkContent\":\"http://freespace.virgin.net\",\"linkURL\":\"http://localhost:8081/gedapi/GCS/http~~~_3~~~1freespace.virgin.net\"},{\"isFile\":false,\"jsContent\":\"/http~~~_3~~~1gedcom.surnames.com\",\"linkContent\":\"http://gedcom.surnames.com\",\"linkURL\":\"http://localhost:8081/gedapi/GCS/http~~~_3~~~1gedcom.surnames.com\"},{\"isFile\":false,\"jsContent\":\"/http~~~_3~~~1glinktest.test.com\",\"linkContent\":\"http://glinktest.test.com\",\"linkURL\":\"http://localhost:8081/gedapi/GCS/http~~~_3~~~1glinktest.test.com\"},{\"isFile\":false,\"jsContent\":\"/http~~~_3~~~1greer-family-tree.com\",\"linkContent\":\"http://greer-family-tree.com\",\"linkURL\":\"http://localhost:8081/gedapi/GCS/http~~~_3~~~1greer-family-tree.com\"},{\"isFile\":false,\"jsContent\":\"/http~~~_3~~~1homepages.rootsweb.ancestry.com\",\"linkContent\":\"http://homepages.rootsweb.ancestry.com\",\"linkURL\":\"http://localhost:8081/gedapi/GCS/http~~~_3~~~1homepages.rootsweb.ancestry.com\"},{\"isFile\":false,\"jsContent\":\"/http~~~_3~~~1jdmcox.com\",\"linkContent\":\"http://jdmcox.com\",\"linkURL\":\"http://localhost:8081/gedapi/GCS/http~~~_3~~~1jdmcox.com\"},{\"isFile\":false,\"jsContent\":\"/http~~~_3~~~1localgedcom~~~_38081\",\"linkContent\":\"http://localgedcom:8081\",\"linkURL\":\"http://localhost:8081/gedapi/GCS/http~~~_3~~~1localgedcom~~~_38081\"},{\"isFile\":false,\"jsContent\":\"/http~~~_3~~~1localhost_8081\",\"linkContent\":\"http://localhost_8081\",\"linkURL\":\"http://localhost:8081/gedapi/GCS/http~~~_3~~~1localhost_8081\"},{\"isFile\":false,\"jsContent\":\"/http~~~_3~~~1localhost~~~_38081\",\"linkContent\":\"http://localhost:8081\",\"linkURL\":\"http://localhost:8081/gedapi/GCS/http~~~_3~~~1localhost~~~_38081\"},{\"isFile\":false,\"jsContent\":\"/http~~~_3~~~1testglink.test.com\",\"linkContent\":\"http://testglink.test.com\",\"linkURL\":\"http://localhost:8081/gedapi/GCS/http~~~_3~~~1testglink.test.com\"},{\"isFile\":false,\"jsContent\":\"/http~~~_3~~~1us.geocities.com\",\"linkContent\":\"http://us.geocities.com\",\"linkURL\":\"http://localhost:8081/gedapi/GCS/http~~~_3~~~1us.geocities.com\"},{\"isFile\":false,\"jsContent\":\"/http~~~_3~~~1vlado.fmf.uni-lj.si\",\"linkContent\":\"http://vlado.fmf.uni-lj.si\",\"linkURL\":\"http://localhost:8081/gedapi/GCS/http~~~_3~~~1vlado.fmf.uni-lj.si\"},{\"isFile\":false,\"jsContent\":\"/http~~~_3~~~1www-personal.umich.edu\",\"linkContent\":\"http://www-personal.umich.edu\",\"linkURL\":\"http://localhost:8081/gedapi/GCS/http~~~_3~~~1www-personal.umich.edu\"},{\"isFile\":false,\"jsContent\":\"/http~~~_3~~~1www.angelfire.com\",\"linkContent\":\"http://www.angelfire.com\",\"linkURL\":\"http://localhost:8081/gedapi/GCS/http~~~_3~~~1www.angelfire.com\"},{\"isFile\":false,\"jsContent\":\"/http~~~_3~~~1www.avac.uklinux.net\",\"linkContent\":\"http://www.avac.uklinux.net\",\"linkURL\":\"http://localhost:8081/gedapi/GCS/http~~~_3~~~1www.avac.uklinux.net\"},{\"isFile\":false,\"jsContent\":\"/http~~~_3~~~1www.coryfamsoc.com\",\"linkContent\":\"http://www.coryfamsoc.com\",\"linkURL\":\"http://localhost:8081/gedapi/GCS/http~~~_3~~~1www.coryfamsoc.com\"},{\"isFile\":false,\"jsContent\":\"/http~~~_3~~~1www.cursiter.com\",\"linkContent\":\"http://www.cursiter.com\",\"linkURL\":\"http://localhost:8081/gedapi/GCS/http~~~_3~~~1www.cursiter.com\"},{\"isFile\":false,\"jsContent\":\"/http~~~_3~~~1www.daml.org\",\"linkContent\":\"http://www.daml.org\",\"linkURL\":\"http://localhost:8081/gedapi/GCS/http~~~_3~~~1www.daml.org\"},{\"isFile\":false,\"jsContent\":\"/http~~~_3~~~1www.discovergenealogy.com\",\"linkContent\":\"http://www.discovergenealogy.com\",\"linkURL\":\"http://localhost:8081/gedapi/GCS/http~~~_3~~~1www.discovergenealogy.com\"},{\"isFile\":false,\"jsContent\":\"/http~~~_3~~~1www.geocities.com\",\"linkContent\":\"http://www.geocities.com\",\"linkURL\":\"http://localhost:8081/gedapi/GCS/http~~~_3~~~1www.geocities.com\"},{\"isFile\":false,\"jsContent\":\"/http~~~_3~~~1www.jdweaver.com\",\"linkContent\":\"http://www.jdweaver.com\",\"linkURL\":\"http://localhost:8081/gedapi/GCS/http~~~_3~~~1www.jdweaver.com\"},{\"isFile\":false,\"jsContent\":\"/http~~~_3~~~1www.moonrakers.org.uk\",\"linkContent\":\"http://www.moonrakers.org.uk\",\"linkURL\":\"http://localhost:8081/gedapi/GCS/http~~~_3~~~1www.moonrakers.org.uk\"},{\"isFile\":false,\"jsContent\":\"/http~~~_3~~~1www.mosesclawson.com\",\"linkContent\":\"http://www.mosesclawson.com\",\"linkURL\":\"http://localhost:8081/gedapi/GCS/http~~~_3~~~1www.mosesclawson.com\"},{\"isFile\":false,\"jsContent\":\"/http~~~_3~~~1www.reardon-family.org\",\"linkContent\":\"http://www.reardon-family.org\",\"linkURL\":\"http://localhost:8081/gedapi/GCS/http~~~_3~~~1www.reardon-family.org\"},{\"isFile\":false,\"jsContent\":\"/http~~~_3~~~1www.rootsweb.ancestry.com\",\"linkContent\":\"http://www.rootsweb.ancestry.com\",\"linkURL\":\"http://localhost:8081/gedapi/GCS/http~~~_3~~~1www.rootsweb.ancestry.com\"},{\"isFile\":false,\"jsContent\":\"/http~~~_3~~~1www.spoonergen.com\",\"linkContent\":\"http://www.spoonergen.com\",\"linkURL\":\"http://localhost:8081/gedapi/GCS/http~~~_3~~~1www.spoonergen.com\"},{\"isFile\":false,\"jsContent\":\"/http~~~_3~~~1www.ussery.net\",\"linkContent\":\"http://www.ussery.net\",\"linkURL\":\"http://localhost:8081/gedapi/GCS/http~~~_3~~~1www.ussery.net\"},{\"isFile\":false,\"jsContent\":\"/uploads\",\"linkContent\":\"uploads\",\"linkURL\":\"http://localhost:8081/gedapi/GCS/uploads\"}],\"gedcomurl\":\"\",\"tabIndex\":\"gcs\"}";
            boolean equalResponses = jsonResponse.equals(strResponse);
        if(!equalResponses)
        {
View Full Code Here

Examples of org.jmock.Mockery

   
  public GedapiServletTest( String testName ) throws ServletException
    {
        super( testName );
        LOG.finest("Running GedapiServletTest... Please be patient...");
      Mockery context = new Mockery();
      final ServletConfig servletConfig = context.mock(ServletConfig.class);
      //final ServletContext servletContext = context.mock(ServletContext.class);

      //try
      //{
        context.checking(new Expectations()
      {{
        // Expectations for servlet.init invocation
        //one(servletConfig).getServletContext();
        //will(returnValue(servletContext));
        //one(servletContext).getInitParameter("CentralSiteRoot");
        //will(returnValue(centralSiteRoot));
      }});
        servlet.init(servletConfig);
            context.assertIsSatisfied();
    //}
    //catch(Exception ex)
    //{
    //  ex.printStackTrace();
      //    assertTrue(false);
View Full Code Here

Examples of org.jmock.Mockery

                        final long ifNoneMatch, final long lastModified,
                        final String eTag, final String xNetworkReload,
                        final String requestMethod, final String errorMessage, final int testID)
      throws IOException, ServletException
  {
    Mockery context = new Mockery();
    final HttpServletRequest httpRequest = context.mock(HttpServletRequest.class);
    final HttpServletResponse httpResponse = context.mock(HttpServletResponse.class);
    final ByteArrayOutputStream out = new ByteArrayOutputStream();
    final PrintWriter httpResponseWriter = new PrintWriter(out);
   
      //try
      //{
        context.checking(new Expectations()
        {{
          // Expectations for servlet.doGet invocation
          one(httpRequest).getMethod();
          will(returnValue(requestMethod));
          if(!("http post not allowed".equals(errorMessage)))
          {
            one(httpRequest).getRequestURI();
            will(returnValue(requestURI));
          }
         
          if(!("invalid protocol".equals(errorMessage) || "http post not allowed".equals(errorMessage)))
          {
            one(httpRequest).getHeader("If-None-Match");
            if(ifNoneMatch < 0)
            {
              will(returnValue(null));
            }
            else
            {
              will(returnValue(GLinkURL.JSON_ETAG_VERSION+"/\""+jsonResponse.length()+"-"+String.valueOf(ifNoneMatch)+"\""));
            }
            one(httpRequest).getHeader("X-Network-Reload");
            will(returnValue(xNetworkReload));
        }
         
          if(errorMessage != null)
          {
            one(httpResponse).setContentType("application/json");
            one(httpResponse).setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
              one(httpResponse).getWriter();
              will(returnValue(httpResponseWriter));
          }
          else if(ifNoneMatch < 0 || "true".equals(xNetworkReload))
          {
            if("true".equals(xNetworkReload))
            {
              LOG.finest(testID+") Sending the browser new JSON content!!");
            }
            else
            {
              LOG.finest(testID+") Sending the browser cached JSON content!!");
            }
            one(httpResponse).setHeader("Cache-Control", "max-age=0");
            one(httpRequest).getAttribute("X-Downloading-GEDCOM");
            will(returnValue(null));
           
            // DONE: Figure out how to use JMock to say that I expect this method
            // to be invoked with String.class parameter
              one(httpResponse).setHeader(with(equal("ETag")), with(any(String.class)));
             
              one(httpResponse).setDateHeader("Last-Modified", lastModified);
              one(httpResponse).setContentType("application/json");
              one(httpResponse).getWriter();
              will(returnValue(httpResponseWriter));
          }
          else
          {
            LOG.finest(testID+") Telling the browser to use cached JSON content!!");
            one(httpResponse).setStatus(HttpServletResponse.SC_NOT_MODIFIED);
            one(httpResponse).setHeader(with(equal("ETag")), with(any(String.class)));
          }
        }});

        servlet.doGet(httpRequest, httpResponse);
        httpResponseWriter.flush();
        httpResponseWriter.close();
       
            context.assertIsSatisfied();

            String strResponse = out.toString();
            boolean equalResponses = jsonResponse.equals(strResponse);
        if(!equalResponses)
        {
View Full Code Here

Examples of org.jmock.Mockery

  public GLinkServletTest( String testName )
    {
        super( testName );
        System.out.println("Running GLinkServletTest... Please be patient...");
      Mockery context = new Mockery();
      final ServletConfig servletConfig = context.mock(ServletConfig.class);
      //final ServletContext servletContext = context.mock(ServletContext.class);

      try
      {
        // DONE: need to setup an initial context here so that the correct DataSource object
        // an be registered and then found later on to query the database as part of these tests
        Properties props = new Properties();
        props.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.naming.java.javaURLContextFactory");
        System.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.naming.java.javaURLContextFactory");
       
        InitialContext jndiContext = new InitialContext(props);
        try
        {
          jndiContext.createSubcontext("java:comp");
          jndiContext.createSubcontext("java:comp/env");
          jndiContext.createSubcontext("java:comp/env/jdbc");
          //jndiContext.createSubcontext("java:comp/env/jdbc");
         
  //        <Resource
  //        name="jdbc/LiferayPool"
  //        auth="Container"
  //        type="javax.sql.DataSource"
  //        driverClassName="com.mysql.jdbc.Driver"
  //        url="jdbc:mysql://localhost:3306/lportal?useUnicode=true&amp;characterEncoding=UTF-8&amp;useFastDateParsing=false"
  //        username="root"
  //        password="@@mysql.password@@"
  //        maxActive="50"
  //      />
          BasicDataSource dataSource = new BasicDataSource();
          dataSource.setDriverClassName("com.mysql.jdbc.Driver");
          dataSource.setUrl("jdbc:mysql://localhost:3306/lportal?useUnicode=true&amp;characterEncoding=UTF-8&amp;useFastDateParsing=false");
          dataSource.setUsername("root");
          dataSource.setPassword("password");
          dataSource.setMaxActive(50);
          jndiContext.bind("java:comp/env/jdbc/LiferayPool", dataSource);
        }
        catch(NameAlreadyBoundException ex)
        {
          ex.printStackTrace();
        }
       
        context.checking(new Expectations()
      {{
        // Expectations for servlet.init invocation
        //one(servletConfig).getServletContext();
        //will(returnValue(servletContext));
        //one(servletContext).getInitParameter("CentralSiteRoot");
        //will(returnValue(centralSiteRoot));
      }});
        servlet.init(servletConfig);
            context.assertIsSatisfied();
    }
    catch(Exception ex)
    {
      ex.printStackTrace();
          assertTrue(false);
View Full Code Here

Examples of org.jmock.Mockery

            tearDownContext();
        }
    }

    private void initContext() {
        context = new Mockery();
        STATICALLY_ACCESSIBLE_CONTEXT.set(context);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.