Package org.apache.wookie.w3c

Examples of org.apache.wookie.w3c.W3CWidgetFactory


    outputFolder.delete();
    outputFolder.mkdir();

    System.out.println(outputFolder.getPath());

    W3CWidgetFactory fac = new W3CWidgetFactory();
    fac.setOutputDirectory(outputFolder.getPath());
    W3CWidget widget = fac.parse(file);
    assertEquals("Unsupported widget widget", widget.getLocalName("en"));
  }
View Full Code Here


      get.releaseConnection();

      //
      // check the downloaded file
      //
      W3CWidgetFactory fac = new W3CWidgetFactory();
      fac.setStartPageProcessor(null);
      File outputDir = new File("src-tests" + File.separatorChar + "testdata" + File.separatorChar + "widgets");
      outputDir.mkdirs();
      fac.setOutputDirectory("src-tests" + File.separatorChar + "testdata" + File.separatorChar + "widgets");
      W3CWidget widget = fac.parse(downloadedFile);
     
      //
      // Cleanup
      //
      FileUtils.deleteQuietly(downloadedFile);
View Full Code Here

    out.flush();
    out.close();
    get.releaseConnection();

    // check the downloaded file
    W3CWidgetFactory fac = new W3CWidgetFactory();
    fac.setStartPageProcessor(null);
    File outputDir = new File("src-tests" + File.separatorChar + "testdata" + File.separatorChar + "widgets");
    outputDir.mkdirs();
    fac.setOutputDirectory("src-tests" + File.separatorChar + "testdata" + File.separatorChar + "widgets");
    W3CWidget widget = fac.parse(downloadedFile);
    File file = fac.getUnzippedWidgetDirectory();
    assertEquals("src-tests" + File.separatorChar + "testdata"
        + File.separatorChar + "widgets" + File.separatorChar
        + "www.getwookie.org" + File.separatorChar + "widgets"
        + File.separatorChar + "weather", file.getPath());
    assertTrue(file.isDirectory());
View Full Code Here

  public static void setup() throws KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException{
    KeyStore keyStore = KeyStore.getInstance("JKS");
    keyStore.load(null, null);
    File schema = new File("src/org/apache/wookie/util/digitalsignature/xmldsig-core-schema.xsd");
    proc = new DigitalSignatureProcessor(keyStore, schema.getPath(), true, false);
    fac = new W3CWidgetFactory();
    fac.setDigitalSignatureParser(proc);
    fac.setOutputDirectory(createTempDirectory().getAbsolutePath());
  }
View Full Code Here

  @Test
  public void loadModifySaveReload() throws Exception{

    // Load the widget
    W3CWidgetFactory fac = new W3CWidgetFactory();
    fac.setLocalPath("/widgets");
    fac.setFeatures(new String[]{"feature:a9bb79c1"});
    fac.setEncodings(new String[]{"UTF-8", "ISO-8859-1","Windows-1252"});
    if (download.exists()) download.delete();
    if (output.exists()) output.delete();
    output.mkdir();
    fac.setOutputDirectory(output.getAbsolutePath());
    File widgetFile = WidgetUploader.downloadWidget("http://dev.w3.org/2006/waf/widgets/test-suite/test-cases/ta-RRZxvvTFHx/001/b6.wgt");
    W3CWidget widget = fac.parse(widgetFile);
   
    IName name = widget.getNames().get(0);
    name.setName("Re-Modified Widget");
    WidgetOutputter outputter = new WidgetOutputter();
    outputter.setWidgetFolder("/widgets");
   
    // Save the config.xml
    File widgetFolder = new File(output.getPath()+"/b6");
    File configXml = new File(widgetFolder, "config.xml");
    outputter.outputXML(widget, configXml);
   
    // Pack up the widget
    File zip = File.createTempFile("wookie-output", ".wgt");
    WidgetPackageUtils.repackZip(widgetFolder, zip);
   
    // Reload the widget but using a new path
    fac.setLocalPath("/zaphod.bee.ble/brox");
    widget = fac.parse(zip);
    assertEquals("Re-Modified Widget", widget.getLocalName("en"));
    // Check the content is now pointing to the new location
    assertEquals("/zaphod.bee.ble/brox/b6/index.html", widget.getContentList().get(0).getSrc());
  }
View Full Code Here

    assertEquals("Re-Modified Widget", widget.getLocalName("en"));
    // Check the content is now pointing to the new location
    assertEquals("/zaphod.bee.ble/brox/b6/index.html", widget.getContentList().get(0).getSrc());
  }
  private W3CWidget load(File file) throws BadWidgetZipFileException, BadManifestException, Exception{
    W3CWidgetFactory fac = getFactory();
    W3CWidget widget = fac.parse(file);
    return widget;   
  }
View Full Code Here

  }
 
  private W3CWidgetFactory getFactory() throws Exception{
    String outputPath = "/widgets";
    // Load the widget
    W3CWidgetFactory fac = new W3CWidgetFactory();
    fac.setLocalPath(outputPath);
    fac.setFeatures(new String[]{"feature:a9bb79c1","http://wave.google.com", "http://wookie.apache.org/ext"});
    fac.setEncodings(new String[]{"UTF-8", "ISO-8859-1","Windows-1252"});
    if (download.exists()) download.delete();
    if (output.exists()) output.delete();
    output.mkdir();
    fac.setOutputDirectory(output.getAbsolutePath());
    return fac;
  }
View Full Code Here

  }
 
  @Test
  public void testCreateFactory(){
    try {
      @SuppressWarnings("unused")
      W3CWidgetFactory fac = new W3CWidgetFactory();
    } catch (Exception e) {
      fail();
    }
  }
View Full Code Here

    }
  }
 
  @Test(expected = NullPointerException.class)
  public void testSetOutputDirectoryNull() throws Exception{
    W3CWidgetFactory fac = new W3CWidgetFactory();
    fac.setOutputDirectory(null);
  }
View Full Code Here

    fac.setOutputDirectory(null);
  }
 
  @Test(expected = IOException.class)
  public void testSetOutputDirectoryInvalid() throws Exception{
    W3CWidgetFactory fac = new W3CWidgetFactory();
    fac.setOutputDirectory("FAIL");
  }
View Full Code Here

TOP

Related Classes of org.apache.wookie.w3c.W3CWidgetFactory

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.