Example #1
0
 /**
  * Simply creates an empty default Workflow model page and save it.
  *
  * @throws ClientException if a request to the server fails for any reason
  */
 @Category(SmokeTest.class)
 @Test
 public void testCreateNewWorkflowModelPage() throws ClientException {
   // first check if a model page can be created at all
   String modelPath = null;
   try {
     modelPath = wAdminClient.createNewModelPage("dummy", "dummy").getPath();
   } catch (ClientException e) {
     Assert.fail("Creating a Workflow Model Page failed! " + e.getMessage());
   }
   // check if save works on the model
   try {
     wAdminClient.saveModel(modelPath);
   } catch (ClientException e) {
     Assert.fail("Can't save a workflow model page! " + e.getMessage());
   }
   // clean up
   wAdminClient.delete(modelPath);
 }
  /**
   * CQ5-17328 : Design Importer: Hosted CSS files are not imported
   *
   * @throws IOException
   */
  @Test
  public void testAbsoluteURLCSS() throws IOException {

    String LPPath = null;

    try {
      // create a blank landing page
      LPPath = authorAdmin.createPage(pageLabel, pageTitle, parentPath, template).getPath();

    } catch (ClientException e) {
      e.printStackTrace();
      Assert.fail("Could not create LP" + LPPath);
    }

    try {
      String designFileName =
          designPathWithAbsoluteUrlCss.substring(designPathWithAbsoluteUrlCss.lastIndexOf('/') + 1);
      // Upload a design package to a blank landing page
      authorAdmin.uploadDesignPackage(
          LPPath,
          getResourceAsStream(designPathWithAbsoluteUrlCss),
          getResourceStreamLength(designPathWithAbsoluteUrlCss),
          mimeType,
          designFileName);

      JsonNode canvasNode = authorAdmin.getJsonNode(LPPath + "/jcr:content/canvas", -1);
      String canvasPath = canvasNode.path("sling:resourceType").getValueAsText();
      String canvasNodeName = canvasPath.substring(canvasPath.lastIndexOf('/') + 1);

      Boolean absoluteURLCSSfound = false;

      InputStream is =
          authorAdmin.getBinary(
              "/apps/" + canvasPath + "/" + canvasNodeName + ".jsp/" + "jcr:content", null);
      BufferedReader br = new BufferedReader(new InputStreamReader(is));
      String absoluteURLCSS =
          "<link rel='stylesheet' type='text/css' href='http://unbouncepages-com.s3.amazonaws.com/templates.unbounce.com/lead-gen-wide-banner/reset.css' /><link rel='stylesheet' type='text/css' href='http://unbouncepages-com.s3.amazonaws.com/templates.unbounce.com/lead-gen-wide-banner/page_defaults.css' /><script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js'></script><script type='text/javascript' src='http://assets.unbounce.com/m/lp-webapp/0.0.9/lp-text/1.1/main.js'></script><script type='text/javascript' src='http://assets.unbounce.com/m/lp-webapp/0.0.9/jquery-validate/1.6/jquery.validate.min.js'></script><script type='text/javascript' src='http://assets.unbounce.com/m/lp-webapp/0.0.9/jquery-validate/1.6/additional-methods.js'></script><script type='text/javascript' src='http://assets.unbounce.com/m/lp-webapp/0.0.9/lp-form/1.6.6/main.js'></script><script type='text/javascript' src='http://assets.unbounce.com/m/lp-webapp/jquery.fancybox-1.3.4/fancybox/jquery.fancybox-1.3.4.pack.js'></script><script type='text/javascript' src='http://assets.unbounce.com/m/lp-webapp/jquery.fancybox-1.3.4/fancybox/jquery.easing-1.3.pack.js'></script><script type='text/javascript' src='http://assets.unbounce.com/m/lp-webapp/0.0.9/lp-button/1.0/main.js'></script><link rel='stylesheet' type='text/css' href='http://assets.unbounce.com/m/lp-webapp/jquery.fancybox-1.3.4/fancybox/jquery.fancybox-1.3.4.css' />";
      String strLine;
      while ((strLine = br.readLine()) != null) {
        if (strLine.equals(absoluteURLCSS)) {
          absoluteURLCSSfound = true;
          break;
        }
      }
      Assert.assertTrue("Absolute URL scripts not written to canvas.jsp", absoluteURLCSSfound);
      is.close();
    } catch (ClientException e) {
      e.printStackTrace();
      Assert.fail("Could not uplaod design archive");
    }
    try {
      // delete the landing page
      authorAdmin.deletePage(new String[] {LPPath}, false, false);
    } catch (ClientException e) {
      e.printStackTrace();
      Assert.fail("Could not delete LP" + LPPath);
    }
  }
  /**
   * CQ5-18471 : Incorrect handling of <link> tag
   *
   * @throws IOException
   */
  @Test
  public void testHTMLLinkTag() throws IOException {

    String LPPath = null;

    try {
      // create a blank landing page
      LPPath = authorAdmin.createPage(pageLabel, pageTitle, parentPath, template).getPath();

    } catch (ClientException e) {
      e.printStackTrace();
      Assert.fail("Could not create LP" + LPPath);
    }

    try {
      String designFileName =
          designPathWithLinkTags.substring(designPathWithLinkTags.lastIndexOf('/') + 1);
      // Upload a design package to a blank landing page
      authorAdmin.uploadDesignPackage(
          LPPath,
          getResourceAsStream(designPathWithLinkTags),
          getResourceStreamLength(designPathWithLinkTags),
          mimeType,
          designFileName);

      JsonNode contentNode = authorAdmin.getJsonNode(LPPath + "/jcr:content", -1);

      String etcdesignPath = contentNode.get("cq:designPath").getValueAsText();

      InputStream is =
          authorAdmin.getBinary(
              etcdesignPath + "/headindex.htmlclientlibs/css.txt/jcr:content", null);
      BufferedReader br = new BufferedReader(new InputStreamReader(is));
      String linkTagsInHead = "";
      String strLine;
      while ((strLine = br.readLine()) != null) {
        linkTagsInHead += strLine;
      }
      Assert.assertEquals(
          "Link tags outputted to headindex.htmclientlibs/css.txt not as intended",
          "../css/site_global.css../css/master_master.css../css/index.css../pageheadstyles.css",
          linkTagsInHead);
      is.close();
    } catch (ClientException e) {
      e.printStackTrace();
      Assert.fail("Could not uplaod design archive");
    }
    try {
      // delete the landing page
      authorAdmin.deletePage(new String[] {LPPath}, false, false);
    } catch (ClientException e) {
      e.printStackTrace();
      Assert.fail("Could not delete LP" + LPPath);
    }
  }