Esempio n. 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));
  }
Esempio n. 2
0
  protected String canonicalizeXTM(String XTM) throws IOException {
    // Figure out base URL
    String root =
        TestFileUtils.getTestdataOutputDirectory()
            + File.separator
            + testdataDirectory
            + File.separator
            + "topicmaps"
            + File.separator;
    LocatorIF base = new URILocator(new File(root));

    // Import the TM
    StringReader reader = new StringReader(XTM);
    XTMTopicMapReader xtmReader = new XTMTopicMapReader(reader, base);
    xtmReader.setExternalReferenceHandler(new NullResolvingExternalReferenceHandler());

    TopicMapIF importedTM = xtmReader.read();
    TMRAPTestCase.filterUnifyingTopics(importedTM);

    // Canonicalize the reimported TM
    StringWriter stringWriter = new StringWriter();
    new CanonicalXTMWriter(stringWriter).write(importedTM);
    String result = stringWriter.toString();

    return result;
  }
Esempio n. 3
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);
  }
 @Parameters
 public static List generateTests() {
   return TestFileUtils.getTestInputFiles(testdataDirectory, "in", ".xml");
 }
 public CanonicalTMXMLReaderTestCase(String root, String filename) {
   this.filename = filename;
   this.base = TestFileUtils.getTestdataOutputDirectory() + testdataDirectory;
   this._testdataDirectory = testdataDirectory;
 }
Esempio n. 6
0
 @BeforeClass
 public static void transferInputFiles() throws IOException {
   TestFileUtils.transferTestInputDirectory(testdataDirectory + "/topicmaps");
 }