Package com.gentics.cr

Examples of com.gentics.cr.CRResolvableBean


   * Test for mimetype.
   * @throws Exception
   */
  @Test
  public void testTypePerMimetype() throws Exception {
    CRResolvableBean bean = new CRResolvableBean();
    bean.set("mimetype", "image/jpeg");
    String type = ImageMimetypeMapper.getTypeFromBean(bean);
    String shouldbe = "jpeg";
    assertEquals("The type (" + type + ") should be (" + shouldbe + ")", type, shouldbe);
  }
View Full Code Here


   * Test for mimetype.
   * @throws Exception
   */
  @Test
  public void testTypePerStrangeIEMimetype() throws Exception {
    CRResolvableBean bean = new CRResolvableBean();
    bean.set("mimetype", "image/pjpeg");
    String type = ImageMimetypeMapper.getTypeFromBean(bean);
    String shouldbe = "jpeg";
    assertEquals("The type (" + type + ") should be (" + shouldbe + ")", type, shouldbe);
  }
View Full Code Here

   * Test for default.
   * @throws Exception
   */
  @Test
  public void testTypePerDefault() throws Exception {
    CRResolvableBean bean = new CRResolvableBean();
    bean.set("mimetype", "somefrigginwrongthing");
    String type = ImageMimetypeMapper.getTypeFromBean(bean);
    String shouldbe = "png";
    assertEquals("The type (" + type + ") should be (" + shouldbe + ")", type, shouldbe);
  }
View Full Code Here

   * bee more object with the same URL in the repository.
   * @param request
   * @return a Resolvable Object based on the passed URL.
   */
  public final CRResolvableBean getObject(final CRRequest request) {
    CRResolvableBean contentObject = null;
    String url = request.getUrl();
    if (url != null) {

      CRRequest r = new CRRequest();

View Full Code Here

   * [..] => Folders<br>
   * [n=> Page<br>
   */
  public static List<CRResolvableBean> getParents(final CRResolvableBean resolvable, final String folderattribute) {
    Vector<CRResolvableBean> parents = new Vector<CRResolvableBean>();
    CRResolvableBean parent;
    CRResolvableBean current = resolvable;
    while ((parent = (CRResolvableBean) current.get(folderattribute)) != null) {
      parents.add(0, parent);
      current = parent;
    }
    return parents;
  };
View Full Code Here

    String filterExpression = config.getString("filter");
    File[] files = DirectoryScanner.listFiles(directory, filterExpression);
    if (files != null) {
      ArrayList<CRResolvableBean> result = new ArrayList<CRResolvableBean>();
      for (File file : files) {
        CRResolvableBean bean = new CRResolvableBean();
        bean.set("filename", file.getName());
        bean.set("pub_dir", directory.toURI().relativize(file.toURI()));
        bean.set("obj_type", FileTypeDetector.getObjType(file));
        bean.set("timestamp", file.lastModified() / 1000);
        //TODO add the content of the file as stream in the right attribute
      }
      return result;
    }
    return new ArrayList<CRResolvableBean>(0);
View Full Code Here

  public void testTransformerDOTX() throws Exception {
    testDocument("testdoc.dotx");
  }
 
  private void testDocument(String filename) throws IOException, CRException {
    CRResolvableBean bean = new CRResolvableBean();
    bean.set(BINARY_ATTRIBUTE, getContentFromFile(filename));
    t.processBean(bean);
    assertEquals("Testtext ÄÖÜäüö߀\n", bean.get(BINARY_ATTRIBUTE));
  }
View Full Code Here

    testPresentation("testdoc.pptx");
  }
 
 
  private void testPresentation(String filename) throws IOException, CRException {
    CRResolvableBean bean = new CRResolvableBean();
    bean.set(BINARY_ATTRIBUTE, getContentFromFile(filename));
    t.processBean(bean);
    assertEquals("Testtext ÄÖÜäüö߀\n\n", bean.get(BINARY_ATTRIBUTE));
  }
View Full Code Here

  public void testTransformerXLTX() throws Exception {
    testSpreadsheet("testdoc.xltx");
  }
 
  private void testSpreadsheet(String filename) throws IOException, CRException {
    CRResolvableBean bean = new CRResolvableBean();
    bean.set(BINARY_ATTRIBUTE, getContentFromFile(filename));
    t.processBean(bean);
    assertEquals("Tabelle1\ntesttext ÄÖÜäüö߀\nTabelle2\nTabelle3\n",
        bean.get(BINARY_ATTRIBUTE));
  }
View Full Code Here

    assertEquals("Pending Space was not handled correctly.", "a... ", transform("a.... "));
  }

  @Test
  public void testByteArray() throws CRException, UnsupportedEncodingException {
    CRResolvableBean bean = new CRResolvableBean();
    bean.set(CONTENT_ATTRIBUTE, UMLAUTS.getBytes());
    ContentTransformer transformer = new CleanupTextTransformer(config);
    transformer.processBean(bean);
    String result = bean.getString(CONTENT_ATTRIBUTE);
    assertEquals("Cannot handle the byte array correctly.", UMLAUTS, result);
  }
View Full Code Here

TOP

Related Classes of com.gentics.cr.CRResolvableBean

Copyright © 2018 www.massapicom. 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.