コード例 #1
0
  public void testLoadSchemaFromClasspath() throws ResourceException, URISyntaxException {
    String absoluteSchemaFilePath =
        FileTools.resourceFile("/schema/" + this.adjustSchemaName("BasicSchema.xsd"))
            .getAbsolutePath();
    File testSchemasDirectory = new File(absoluteSchemaFilePath).getParentFile().getParentFile();
    String testSchemasDirectoryPath = testSchemasDirectory.getPath();
    String schemaResourceName =
        absoluteSchemaFilePath.substring(testSchemasDirectoryPath.length() + 1);

    // test schema not on classpath
    MWOXProject project =
        new MWOXProject(
            "Test Load Schema From Classpath", MappingsModelTestTools.buildSPIManager());
    MWXmlSchemaRepository schemaRepository = project.getSchemaRepository();
    try {
      schemaRepository.createSchemaFromClasspath("SchemaFromClasspath", schemaResourceName);
      assertTrue("ResourceException was not thrown.", false);
    } catch (ResourceException re) {
    } catch (Throwable t) {
      assertTrue("ResourceException was not thrown.", false);
    }

    // test schema on classpath
    project.getRepository().addClasspathEntry(testSchemasDirectoryPath);
    schemaRepository.createSchemaFromClasspath("SchemaFromClasspath", schemaResourceName);
  }
コード例 #2
0
  public void testLoadSchemaFromUrl() throws ResourceException, URISyntaxException {
    String schemaUrlString =
        this.getClass()
            .getResource("/schema/" + this.adjustSchemaName("BasicSchema.xsd"))
            .toString();

    MWOXProject project =
        new MWOXProject("Test Load Schema From URL", MappingsModelTestTools.buildSPIManager());
    MWXmlSchemaRepository repository = project.getSchemaRepository();
    MWXmlSchema schema = repository.createSchemaFromUrl("SchemaFromUrl", schemaUrlString);
    schema.reload();
  }
コード例 #3
0
  public void testLoadSchemaFromFile() throws ResourceException, URISyntaxException {
    String absoluteSchemaFilePath =
        FileTools.resourceFile("/schema/" + this.adjustSchemaName("BasicSchema.xsd"))
            .getAbsolutePath();
    File testSchemasDirectory = new File(absoluteSchemaFilePath).getParentFile().getParentFile();
    String testSchemasDirectoryPath = testSchemasDirectory.getPath();
    String relativeSchemaFilePath =
        "." + absoluteSchemaFilePath.substring(testSchemasDirectoryPath.length());

    MWOXProject project =
        new MWOXProject("Test Load Schema From File", MappingsModelTestTools.buildSPIManager());
    project.setSaveDirectory(testSchemasDirectory);
    MWXmlSchemaRepository repository = project.getSchemaRepository();

    // test absolute file location
    MWXmlSchema absolutePathSchema =
        repository.createSchemaFromFile("AbsolutePathSchemaFromFile", absoluteSchemaFilePath);
    absolutePathSchema.reload();

    // test relative file location
    MWXmlSchema relativePathSchema =
        repository.createSchemaFromFile("RelativePathSchemaFromFile", relativeSchemaFilePath);
    relativePathSchema.reload();
  }