예제 #1
0
  protected void verifyCanonical(String filename) throws IOException {
    // Figure out base URL
    String root =
        TestFileUtils.getTestdataOutputDirectory()
            + File.separator
            + testdataDirectory
            + File.separator;
    LocatorIF base = new URILocator(new File(root));

    // Import the TM
    String xtmfile = root + "out" + File.separator + filename;
    Reader reader = new FileReader(xtmfile);
    XTMTopicMapReader xtmReader = new XTMTopicMapReader(reader, base);
    xtmReader.setExternalReferenceHandler(new NullResolvingExternalReferenceHandler());
    TopicMapIF importedTM = xtmReader.read();
    reader.close();
    TMRAPTestCase.filterUnifyingTopics(importedTM);

    // Canonicalize the reimported TM
    Writer out = new FileWriter(xtmfile + ".cxtm");
    new CanonicalXTMWriter(out).write(importedTM);
    out.close();

    // Compare results
    String baseline = TestFileUtils.getTestInputFile(testdataDirectory, "baseline", filename);
    Assert.assertTrue(
        filename + " did not match baseline",
        FileUtils.compareFileToResource(xtmfile + ".cxtm", baseline));
  }
예제 #2
0
  protected static void setupRAPServlet(RAPServlet rapServlet, String viewURIPrefix)
      throws ServletException {
    String base = TestFileUtils.getTestdataOutputDirectory() + testdataDirectory + File.separator;

    Hashtable initParams = new Hashtable();
    initParams.put(
        "source_config",
        TestFileUtils.getTestInputFile(testdataDirectory, "WEB-INF/config/tm-sources.xml"));
    FakeServletContext servletContext = new FakeServletContext(base, new Hashtable(), initParams);

    Map params = new HashMap();
    String viewURI = viewURIPrefix + "get-topic/models/topic_complete.jsp?tm=%tmid%&id=%topicid%";
    params.put("view_uri", viewURI);

    Hashtable paramsTable = TMRAPTestUtils.tabularizeParameters(params);
    FakeServletConfig servletConfig = new FakeServletConfig(servletContext, paramsTable);
    rapServlet.init(servletConfig);
  }