Examples of JstdTestCase


Examples of com.google.jstestdriver.model.JstdTestCase

    EasyMock.expectLastCall().anyTimes();
    EasyMock.replay(response);


    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(),
View Full Code Here

Examples of com.google.jstestdriver.model.JstdTestCase

    assertEquals(Lists.newArrayList("/test/foo.js","/test/bar.js"), paths);
  }

  private JstdTestCaseStore createFileCache(FileInfo... files) {
    JstdTestCaseStore store = new JstdTestCaseStore();
    store.addCase(new JstdTestCase(Lists.newArrayList(files), Collections.<FileInfo>emptyList(), Collections.<FileInfo>emptyList(), TESTCASE_ID));
   
    return store;
  }
View Full Code Here

Examples of com.google.jstestdriver.model.JstdTestCase

    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);
View Full Code Here

Examples of com.google.jstestdriver.model.JstdTestCase

*/
public class JstdTestCaseStoreTest extends TestCase {
  public void testAddTestCase() throws Exception {
    FileInfo one = new FileInfo("foo.js", 10, -1, false, false, null, "foo.js");
    JstdTestCaseStore store = new JstdTestCaseStore();
    JstdTestCase testCase =
        new JstdTestCase(Lists.<FileInfo>newArrayList(), Lists.<FileInfo>newArrayList(one),
            Lists.<FileInfo>newArrayList(), "1");
    store.addCase(testCase);
    assertTrue(store.getCases().contains(testCase));
  }
View Full Code Here

Examples of com.google.jstestdriver.model.JstdTestCase

    String testCaseIdTwo = "2";
    String testCaseIdThree = "3";
    FileInfo one = new FileInfo("foo.js", 1, -1, false, false, null, "foo.js");
    FileInfo two = new FileInfo("foo.js", 1, -1, false, false, "foo2", "foo.js");
    JstdTestCaseStore store = new JstdTestCaseStore();
    JstdTestCase testCaseOne =
        new JstdTestCase(Lists.<FileInfo>newArrayList(), Lists.<FileInfo>newArrayList(one),
            Lists.<FileInfo>newArrayList(), testCaseIdOne);
    JstdTestCase testCaseTwo =
        new JstdTestCase(Lists.<FileInfo>newArrayList(), Lists.<FileInfo>newArrayList(two),
            Lists.<FileInfo>newArrayList(), testCaseIdTwo);
    JstdTestCase testCaseThree =
        new JstdTestCase(Lists.<FileInfo>newArrayList(), Lists.<FileInfo>newArrayList(one),
            Lists.<FileInfo>newArrayList(), testCaseIdThree);
    store.addCase(testCaseOne);
    assertTrue(store.getCases().contains(testCaseOne));
    store.addCase(testCaseTwo);
    assertTrue(store.getCases().contains(testCaseTwo));
View Full Code Here

Examples of com.google.jstestdriver.model.JstdTestCase

  public void testApplyDelta() throws Exception {
    String contents = "foo";
    String testCaseIdOne = "1";
    FileInfo one = new FileInfo("foo.js", 1, -1, false, false, null, "foo.js");
    JstdTestCaseStore store = new JstdTestCaseStore();
    JstdTestCase testCaseOne =
      new JstdTestCase(Lists.<FileInfo>newArrayList(), Lists.<FileInfo>newArrayList(one),
          Lists.<FileInfo>newArrayList(), testCaseIdOne);
    JstdTestCaseDelta unloadedDelta = store.addCase(testCaseOne);

    store.applyDelta(new JstdTestCaseDelta(
        Lists.<FileInfo>newArrayList(),
        Lists.<FileInfo>newArrayList(one.load(contents, 1)),
        Lists.<FileInfo>newArrayList()));

    assertEquals("The data will be updated for test case one", contents,
        store.getCase(testCaseIdOne).getTests().get(0).getData());
   
    String testCaseIdTwo = "2";
    JstdTestCase testCaseTwo =
      new JstdTestCase(Lists.<FileInfo>newArrayList(), Lists.<FileInfo>newArrayList(one),
          Lists.<FileInfo>newArrayList(), testCaseIdTwo);
    store.addCase(testCaseTwo);

    assertEquals("The data will be updated for test case two", contents,
        store.getCase(testCaseIdTwo).getTests().get(0).getData());
View Full Code Here

Examples of com.google.jstestdriver.model.JstdTestCase

   * Writes as many of the test files into the HtmlWriter, until it reaches a
   * FileInfo that cannot be handled using a &lt;link&gt; or a &lt;script&gt;.
   * @param writer The output writer.
   */
  public void writeTestFiles(HtmlWriter writer, String testCaseId) {
    JstdTestCase testCase;

    if (store.getCase(testCaseId) == null) { // no optimization without testcase id
      if (store.getCases().size() == 1) {
        testCase = store.getCases().iterator().next();
        logger.debug("One test case found, writing: {}", testCase);
      } else {
        logger.debug("More than one testcase found:\n{}", store.getCases());
        // no point in writing out random test cases, just quit.
        return;
      }
    } else {
      testCase = store.getCase(testCaseId);
      logger.debug("Testcase found at id {}: {}", testCaseId, testCase);
    }

    logger.info("preloading {}", testCase.getId());
    for (FileInfo file : testCase) {
      if (file.isServeOnly()) {
        continue;
      }
      // TODO(corysmith): This is a problematic optimization.
View Full Code Here

Examples of com.google.jstestdriver.model.JstdTestCase

    this.gson = gson;
  }

  @Override
  public BrowserFileSet handle(SlaveBrowser browser, String data) {
    JstdTestCase testCase = gson.fromJson(data, JstdTestCase.class);
    if (browser == null) {
      logger.debug("no browser, returning empty set.");
      return new BrowserFileSet(Collections.<FileInfo>emptyList(),
          Collections.<FileInfo>emptyList(), false);
    }

    if (browser.hasFileLoadErrors()) {
      logger.debug("errors in the previous load, requesting refresh.");
      return new BrowserFileSet(Lists.<FileInfo>newLinkedList(),
          Lists.<FileInfo>newLinkedList(), true);
    }

    final List<FileInfo> filesToUpdate = Lists.newLinkedList();
    final List<FileInfo> extraFiles = Lists.newLinkedList();
    boolean reset = false;
    logger.debug("Determing files to update {}, {}", testCase.toFileSet(), browser.getFileSet());
    for (FileInfo newFile : testCase.getServable()) {
      if (browser.getFileSet().contains(newFile)) {
        for (FileInfo oldFile : browser.getFileSet()) {
          if (oldFile.shouldReplaceWith(newFile)) {
            filesToUpdate.add(newFile);
          }
        }
      } else {
        filesToUpdate.add(newFile);
      }
    }
    extraFiles.addAll(browser.getFileSet());
    extraFiles.removeAll(testCase.toFileSet());

    if (!(filesToUpdate.isEmpty() && extraFiles.isEmpty())
        && (browser.getBrowserInfo().getName().contains("Safari")
            || browser.getBrowserInfo().getName().contains("Opera")
            || browser.getBrowserInfo().getName().contains("Konqueror"))) {
      // reload all files if Safari, Opera, or Konqueror, because they don't
      // overwrite properly.
      // TODO(corysmith): Replace this with polymorphic browser classes.
      logger.info("Resetting browser fileset to ensure proper overwriting. {} {}", filesToUpdate.isEmpty(), extraFiles);
      filesToUpdate.addAll(testCase.toFileSet());
      // TODO(corysmith): Change the browser to handle it's own resets.
      browser.resetFileSet();
      reset = true;
    }
View Full Code Here

Examples of com.google.jstestdriver.model.JstdTestCase

  /**
   * Adds a testcase to the store, returning a delta of files that need to be
   * loaded.
   */
  public JstdTestCaseDelta addCase(JstdTestCase testCase) {
    JstdTestCase updatedTestCase;
    synchronized (files) {
      updatedTestCase = testCase.applyDelta(new JstdTestCaseDelta(
          updateCache(testCase.getDependencies()),
          updateCache(testCase.getTests()),
          updateCache(testCase.getPlugins())));
    }
    logger.info("adding TestCase {} to {}", testCase.getId(), this);
    cases.put(testCase.getId(), updatedTestCase);
    return updatedTestCase.createUnloadedDelta();
  }
View Full Code Here

Examples of com.google.jstestdriver.model.JstdTestCase

    // Add each test file of each JstdTestCase into its own JstdTestCase
    for (JstdTestCase jstdTestCase : testCases) {
      List<FileInfo> tests = jstdTestCase.getTests();

      for (FileInfo test : tests) {
        JstdTestCase testCase = new JstdTestCase(
            jstdTestCase.getDependencies(), Lists.newArrayList(test), jstdTestCase.getPlugins(), test.getDisplayPath().replace("/", "_"));
        isolatedTestCases.add(testCase);
      }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.