Package com.google.jstestdriver

Examples of com.google.jstestdriver.FileInfo


   * update the testcase with.
   */
  private List<FileInfo> updateCache(List<FileInfo> newFiles) {
    List<FileInfo> replace = Lists.newArrayList();
    for (FileInfo file : newFiles) {
      FileInfo oldFile = files.getFile(file.getDisplayPath());
      if (oldFile == null) {
        files.addFile(file);
        logger.debug("adding {}", file.getDisplayPath());
      } else if (oldFile.shouldReplaceWith(file)) {
        logger.debug("replacing {}", oldFile.getDisplayPath());
        files.addFile(file);
      } else if (file.isLoaded()) {
        logger.debug("updating {} (loaded)", file.getDisplayPath());
        files.addFile(file);
      } else if (oldFile.isLoaded() && !file.isLoaded()){
        logger.debug("not replacing {}", file.getDisplayPath());
        // the old file the same as the new, except the old is loaded.
        replace.add(oldFile);
      } else {
        logger.debug("files are equal {}", file.getDisplayPath());
View Full Code Here


        new PathResolver(tmpDirs,
            Sets.<FileParsePostProcessor>newHashSet(new FileParsePostProcessor(){
              public Set<FileInfo> process(Set<FileInfo> files) {
                Set<FileInfo> processed = Sets.newHashSet();
                for (FileInfo fileInfo : files) {
                  processed.add(new FileInfo(fileInfo.getFilePath(),
                      code.lastModified(), -1, false, true, null, fileInfo.getDisplayPath()));
                }
                return processed;
              }
            }), new DisplayPathSanitizer()), createFlags());
View Full Code Here

   
    doScriptTest(script);
  }

  private void doScriptTest(ScriptBuilder script) {
    FileInfo test = new FileInfo("foo.js", 20, -1, false, false, script.buildTest(), "foo.js");
    FileInfo expected = new FileInfo(test.getFilePath(),
                                     test.getTimestamp(),
                                     -1,
                                     test.isPatch(),
                                     test.isServeOnly(),
                                     script.buildExpect(),
                                     test.getDisplayPath());
    FileInfo actual = new InlineHtmlProcessor(new HtmlDocParser(),
        new HtmlDocLexer()).process(test);
    assertEquals(expected.getFilePath(), actual.getFilePath());
    assertEquals(expected.getTimestamp(), actual.getTimestamp());
    assertEquals(expected.isPatch(), actual.isPatch());
    assertEquals(expected.isServeOnly(), actual.isServeOnly());
    assertEquals(expected.getData(), actual.getData());
  }
View Full Code Here

    assertEquals(
        new JstdTestCase(DEPS_2, Lists.newArrayList(TEST_3), PLUGINS_2, ""), processedTests.get(2));
  }
 
  private static FileInfo getFileInfo(String name) {
    return new FileInfo(name, 0, 0, false, false, "", "");
  }
View Full Code Here


    JstdTestCaseStore store = new JstdTestCaseStore();
    store.addCase(new JstdTestCase(
        Lists.newArrayList(
            new FileInfo("dummy.js", -1, -1, false, false, "data", "dummy.js"),
            new FileInfo("dummytoo.js", 20, -1, false, false, "more data", "dummytoo.js")),
        Collections.<FileInfo>emptyList(),
        Collections.<FileInfo>emptyList(),
            "id"));
    TestResourceHandler handler =
        new TestResourceHandler(null, response, store);
View Full Code Here

  public void testWriteFileInfos() throws Exception {
    Set<FileInfoScheme> defaultSchemes = Sets.<FileInfoScheme>newHashSet(new HttpFileInfoScheme());

    TestFileUtil testFileUtil = new TestFileUtil(createFileCache(
      new FileInfo("/foo.js", 0, 0, false, false, null, "foo.js"),
      new FileInfo("/serveonly.js", 0, 0, false, true, null, "/serveonly.js"),
      new FileInfo("/bar.js", 0, 0, false, false, null, "bar.js"),
      new FileInfo("http://somehost/bar.js", 0, 0, false, false, null, "http://somehost/bar.js")
      ),
      new NullPathPrefix(), defaultSchemes, new Gson());

    final List<String> paths = Lists.newArrayList();
View Full Code Here

 
  public void testWriteFileInfosWindowsPath() throws Exception {
    Set<FileInfoScheme> defaultSchemes = Sets.<FileInfoScheme>newHashSet(new HttpFileInfoScheme());

    TestFileUtil testFileUtil = new TestFileUtil(createFileCache(
      new FileInfo("C:\\Sagitta\\Main\\Source\\Web\\Sagitta.Web.JavaScriptTests\\lib\\jasmine\\jasmine.js",
        0, 0, false, false, null, "/test/lib/jasmine/jasmine.js")),
      new NullPathPrefix(), defaultSchemes, new Gson());

    StringWriter writer = new StringWriter();
    HtmlWriter htmlWriter = new HtmlWriter(writer, new NullPathPrefix());
View Full Code Here

        return unhandledPath.equals(path);
      }
    });

    TestFileUtil testFileUtil = new TestFileUtil(createFileCache(
      new FileInfo("/foo.js", 0, 0, false, false, null, "foo.js"),
      new FileInfo("/serveonly.js", 0, 0, false, true, null, "/serveonly.js"),
      new FileInfo("/bar.js", 0, 0, false, false, null, "bar.js"),
      new FileInfo(unhandledPath, 0, 0, false, false, null, unhandledPath),
      new FileInfo("http://somehost/bar.js", 0, 0, false, false, null, "http://somehost/bar.js")
      ),
      new NullPathPrefix(), schemes, new Gson());

    final List<String> paths = Lists.newArrayList();
View Full Code Here

        new NullPathPrefix(), Collections.<FileInfoScheme>emptySet(), new Gson()), false));
  }

  public void testWriteResources() throws IOException {
    Map<String, FileInfo> files = Maps.newHashMap();
    FileInfo fileInfo = new FileInfo("foo.js", -1, -1, false, false, "", "foo.js");
    NullPathPrefix prefix = new NullPathPrefix();
    Set<FileInfoScheme> schemes = Collections.<FileInfoScheme>emptySet();
    JstdTestCaseStore store = new JstdTestCaseStore();
    String id = "foo";
    store.addCase(new JstdTestCase(Collections.<FileInfo>emptyList(), Lists.newArrayList(fileInfo),
        Collections.<FileInfo>emptyList(), id));
    RunnerPage page = new RunnerPage(new TestFileUtil(store, prefix, schemes, new Gson()), false);
   
    Map<String, String> properties = Maps.newHashMap();
    properties.put(SlavePageRequest.TESTCASE_ID, id);
    SlavePageRequest request =
        new SlavePageRequest(properties, null, prefix, null);
    CharArrayWriter writer = new CharArrayWriter();
    final HtmlWriter htmlWriter = new HtmlWriter(writer, prefix);
    page.render(htmlWriter, request);
    String html = writer.toString();
    String jsonFileInfo = new Gson().toJson(fileInfo.toFileSource(prefix, schemes));

    assertTrue(jsonFileInfo + " is not found in " + html, html.contains(jsonFileInfo));
  }
View Full Code Here

    FileCacheHandler handler = new FileCacheHandler(
        request, response, gson, new HashSet<FileInfo>(), new FileSetCacheStrategy());
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    PrintWriter writer = new PrintWriter(out);

    FileInfo info = new FileInfo("asdf", 1, -1, false, true, "data", "asdf");

    EasyMock.expect(request.getParameter("fileSet"))
        .andReturn(gson.toJson(new FileInfo[] {info}));
    EasyMock.expect(response.getWriter()).andReturn(writer);
View Full Code Here

TOP

Related Classes of com.google.jstestdriver.FileInfo

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.