Package org.apache.wookie.w3c

Examples of org.apache.wookie.w3c.W3CWidgetFactory


  public void createFlatpackWithPreferences() throws Exception{
   
    //
    // upload a new widget to test with
    //
    W3CWidgetFactory fac = getFactory();
    File testWidget = new File("build/widgets/bubbles.wgt");
    fac.parse(testWidget);
    download = fac.getUnzippedWidgetDirectory(); //download is where we unzipped the widget
   
    //
    // Create an instance of it
    //
    IWidgetInstance instance = new WidgetInstanceMock();
    ArrayList<IPreference> prefs = new ArrayList<IPreference>();
    IPreference pref = new PreferenceMock();
    pref.setDkey("hiScore");
    pref.setDvalue("1000");
    pref.setReadOnly(false);
    prefs.add(pref);
    instance.setPreferences(prefs);
   
    //
    // Flatpack it
    //
    FlatpackFactory flatfac = new FlatpackFactory(instance);
    flatfac.setParser(fac);
    flatfac.setInputWidget(testWidget); // this is the original .wgt
    flatfac.setFlatpackFolder(flatpack); // flatpack is our new temp folder. This would probably be "/flatpack" or similar in deployment
    File file = flatfac.pack(); // Get the new .wgt file
 
    //
    // Test it works!
    //
    System.out.println(file.getAbsolutePath());
    W3CWidget fpWidget = fac.parse(file);
    assertEquals("hiScore", fpWidget.getPreferences().get(0).getName());
    assertEquals("1000", fpWidget.getPreferences().get(0).getValue());
  }
View Full Code Here


  public void createFlatpackWithPreferences2() throws Exception{
   
    //
    // upload a new widget to test with
    //
    W3CWidgetFactory fac = getFactory();
    fac.setFeatures(Features.getFeatureNames());
    File testWidget = new File("build/widgets/simplechat.wgt");
    fac.parse(testWidget);
    download = fac.getUnzippedWidgetDirectory(); //download is where we unzipped the widget
   
    //
    // Create an instance of it
    //
    IWidgetInstance instance = new WidgetInstanceMock();
    ArrayList<IPreference> prefs = new ArrayList<IPreference>();
    IPreference pref = new PreferenceMock();
    pref.setDkey("moderator");
    pref.setDvalue("true");
    pref.setReadOnly(false);
    prefs.add(pref);
    instance.setPreferences(prefs);
   
    //
    // Flatpack it
    //
    FlatpackFactory flatfac = new FlatpackFactory(instance);
    flatfac.setParser(fac);
    flatfac.setInputWidget(testWidget); // this is the original .wgt
    flatfac.setFlatpackFolder(flatpack); // flatpack is our new temp folder. This would probably be "/flatpack" or similar in deployment
    File file = flatfac.pack(); // Get the new .wgt file
 
    //
    // Test it works!
    //
    System.out.println(file.getAbsolutePath());
    W3CWidget fpWidget = fac.parse(file);
    assertEquals("moderator", fpWidget.getPreferences().get(0).getName());
    assertEquals("true", fpWidget.getPreferences().get(0).getValue());
    assertEquals(1,fpWidget.getPreferences().size());
  }
View Full Code Here

  /**
   * Construct a standard W3CWidgetFactory for testing
   */
  private W3CWidgetFactory getFactory() throws Exception{
    W3CWidgetFactory fac = new W3CWidgetFactory();
    fac.setLocalPath("/widgets");
    fac.setEncodings(new String[]{"UTF-8", "ISO-8859-1","Windows-1252"});
    fac.setOutputDirectory(output.getAbsolutePath());
    return fac;
  }
View Full Code Here

    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

    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

    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 persistence manager for this thread
                        IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
             try{
               persistenceManager.begin();
               File upload = WidgetFileUtils.dealWithDroppedFile(UPLOADFOLDER, f);
               W3CWidgetFactory fac = new W3CWidgetFactory();
               fac.setLocales(locales);
               fac.setLocalPath(contextPath+localWidgetFolderPath);
               fac.setOutputDirectory(WIDGETFOLDER);
               fac.setFeatures(Features.getFeatureNames());
               fac.setStartPageProcessor(new StartPageProcessor());
               W3CWidget model = fac.parse(upload);
               WidgetJavascriptSyntaxAnalyzer jsa = new WidgetJavascriptSyntaxAnalyzer(fac.getUnzippedWidgetDirectory());
               if(persistenceManager.findWidgetByGuid(model.getIdentifier()) == null) {
                 WidgetFactory.addNewWidget(model, null, upload, true)
                 String message = model.getLocalName("en") +"' - " + localizedMessages.getString("WidgetAdminServlet.19");
                 _logger.info(message);
                 FlashMessage.getInstance().message(message);
View Full Code Here

  @Test
  public void createBasicFlatpackUsingDefaults() throws Exception{
    //
    // upload a new widget to test with
    //
    W3CWidgetFactory fac = getFactory();
    File testWidget = new File("build/widgets/bubbles.wgt");
    fac.parse(testWidget);
    download = fac.getUnzippedWidgetDirectory(); //download is where we unzipped the widget
   
    //
    // Create an instance of it
    //
    IWidgetInstance instance = new WidgetInstanceMock();
   
    //
    // Flatpack it
    //
    FlatpackFactory flatfac = new FlatpackFactory(instance);
    flatfac.setInputWidget(testWidget); // this is the original .wgt
    File file = flatfac.pack(); // Get the new .wgt file
 
    //
    // Test it works!
    //
    System.out.println(file.getAbsolutePath());
    W3CWidget fpWidget = fac.parse(file);
    assertNotNull(fpWidget);
   
  }
View Full Code Here

  @Test
  public void createBasicFlatpack() throws Exception{
    //
    // upload a new widget to test with
    //
    W3CWidgetFactory fac = getFactory();
    File testWidget = new File("build/widgets/bubbles.wgt");
    fac.parse(testWidget);
    download = fac.getUnzippedWidgetDirectory(); //download is where we unzipped the widget
   
    //
    // Create an instance of it
    //
    IWidgetInstance instance = new WidgetInstanceMock();
   
    //
    // Flatpack it
    //
    FlatpackFactory flatfac = new FlatpackFactory(instance);
    flatfac.setParser(fac);
    flatfac.setInputWidget(testWidget); // this is the original .wgt
    flatfac.setFlatpackFolder(flatpack); // flatpack is our new temp folder. This would probably be "/flatpack" or similar in deployment
    File file = flatfac.pack(); // Get the new .wgt file
 
    //
    // Test it works!
    //
    System.out.println(file.getAbsolutePath());
    W3CWidget fpWidget = fac.parse(file);
    assertNotNull(fpWidget);
   
  }
View Full Code Here

  public void createFeatureFlatpackUsingDefaults() throws Exception{
   
    //
    // upload a new widget to test with
    //
    W3CWidgetFactory fac = getFactory();
    fac.setFeatures(Features.getFeatureNames());
    File testWidget = new File("build/widgets/freeder.wgt");
    fac.parse(testWidget);
   
    //
    //download is where we unzipped the widget
    //
    download = fac.getUnzippedWidgetDirectory();
   
    //
    // Create an instance of it
    //
    IWidgetInstance instance = new WidgetInstanceMock();
   
    //
    // Flatpack it
    //
    FlatpackFactory flatfac = new FlatpackFactory(instance);
    flatfac.setInputWidget(testWidget); // this is the original .wgt
    File file = flatfac.pack(); // Get the new .wgt file
 
    //
    // Test it works!
    //
    System.out.println("createFeatureFlatpackUsingDefaults: "+file.getAbsolutePath());
    W3CWidget fpWidget = fac.parse(file);
    assertNotNull(fpWidget);
   
    //
    // The JQM feature should have been removed from config.xml
    //
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.