Examples of FileSource


Examples of org.apache.torque.generator.source.stream.FileSource

                    new File("src/test/propertyToJava"));
        File propertiesFile
                = new File(
                    projectPaths.getDefaultSourcePath(),
                    "propertiesData.properties");
        FileSource fileSource
                = new FileSource(
                        new PropertiesSourceFormat(),
                        propertiesFile,
                        new ControllerState());
        SourceElement rootElement
                = (SourceElement) fileSource.getRootElement();

        SourceElement copiedRootElement = rootElement.copy();
        if (!rootElement.graphEquals(copiedRootElement))
        {
            fail("copied tree does not equal original tree");
View Full Code Here

Examples of org.apache.torque.generator.source.stream.FileSource

    @Test
    public void testSourceToXml() throws Exception
    {
        File xmlFile
            = new File("src/test/resources/org/apache/torque/generator/source/xml/source.xml");
        FileSource fileSource = new FileSource(
                new XmlSourceFormat(),
                xmlFile,
                controllerState);
        SourceElement rootElement = fileSource.getRootElement();

        String result = new SourceToXml().toXml(rootElement, true);
        String expected = FileUtils.readFileToString(new File(
                "src/test/resources/org/apache/torque/generator/source/xml/sourceToXmlResult.xml"));
        // remove license from expected file
View Full Code Here

Examples of org.apache.torque.generator.source.stream.FileSource

    @Test
    public void testSourceToXmlWithReferences() throws Exception
    {
        File xmlFile = new File(
                "src/test/resources/org/apache/torque/generator/source/xml/source.xml");
        FileSource fileSource = new FileSource(
                new XmlSourceFormat(),
                xmlFile,
                controllerState);
        SourceElement rootElement = fileSource.getRootElement();
        rootElement.getChildren().get(2).getChildren().add(
                rootElement.getChildren().get(0).getChildren().get(0));

        String result = new SourceToXml().toXml(rootElement, true);
        String expected = FileUtils.readFileToString(new File(
View Full Code Here

Examples of org.exist.source.FileSource

            // because the target collection does not yet exist
            {ctx.setModuleLoadPath(tempDir.getAbsolutePath());}

        CompiledXQuery compiled;
        try {
            compiled = xqs.compile(ctx, new FileSource(xquery, "UTF-8", false));
            return xqs.execute(compiled, null);
        } catch (final PermissionDeniedException e) {
            throw new PackageException(e.getMessage(), e);
        }
    }
View Full Code Here

Examples of org.exist.source.FileSource

                        source = new URLSource( new URL( queryUri ) );
                    }

                } else if( queryFile != null ) {
                    log( "XQuery file " + queryFile.getAbsolutePath(), Project.MSG_DEBUG );
                    source = new FileSource( queryFile, "UTF-8", true );

                } else {
                    log( "XQuery string: " + query, Project.MSG_DEBUG );
                    source = new StringSource( query );
                }
View Full Code Here

Examples of org.exist.source.FileSource

        // Try to find the XQuery
        final String qpath = getServletContext().getRealPath(query);
        final File f = new File(qpath);
        if (!(f.canRead() && f.isFile()))
            {throw new ServletException("Cannot read XQuery source from " + f.getAbsolutePath());}
        final FileSource source = new FileSource(f, "UTF-8", true);

        try {
            // Prepare and execute the XQuery
            final Collection collection = DatabaseManager.getCollection(collectionURI.toString(), user, password);
            final XQueryService service = (XQueryService) collection.getService("XQueryService", "1.0");
View Full Code Here

Examples of org.exist.source.FileSource

               
              Exception error = null;
                if ("runtime-error".equals(scenario)) {
                  try {
                        //compile
                        CompiledXQuery compiled = xquery.compile(context, new FileSource(caseScript, "UTF8", true));

                        //execute
                        result = xquery.execute(compiled, contextSequence);
                       
                        if (outputFiles.getLength() != 0) {
                            //can be answered
                          for (int i = 0; i < outputFiles.getLength(); i++) {
                              ElementImpl outputFile = (ElementImpl)outputFiles.item(i);
         
                              String compare = outputFile.getAttribute("compare");
                              if (compare != null && compare.equalsIgnoreCase("IGNORE")) {
                                ok = true;
                                break;
                              }
         
                              if (compareResult(script, "XQTS_1_0_3/ExpectedTestResults/"+folder, outputFile, result)) {
                                  ok = true;
                                  break;
                              }
                          }
                        } else {
                          error = catchError(result);
                        }

                  } catch (Exception e) {
                    error = e;
          }
                 
                    if (!ok && error != null && expectedError != null) {// error.getMessage().contains(expectedError)) {
                      ok = true;
                    }
                } else {
                    //compile
                    CompiledXQuery compiled = xquery.compile(context, new FileSource(caseScript, "UTF8", true));

                    //execute
                    result = xquery.execute(compiled, contextSequence);

                    //check answer
View Full Code Here

Examples of org.exist.source.FileSource

            if(!f.canRead()) {
                response.setStatus(HttpServletResponse.SC_NOT_FOUND);
                sendError(output, "Cannot read source file", path);
                return;
            }
            source = new FileSource(f, encoding, true);
        }
       
        if (source == null) {
            response.setStatus(HttpServletResponse.SC_NOT_FOUND);
            sendError(output, "Source not found", path);
View Full Code Here

Examples of org.exist.source.FileSource

  @Test
  public void run() {
    try {
      XQueryService xqs = (XQueryService) testCollection.getService("XQueryService", "1.0");
      Source query = new FileSource(new File(TEST_QUERY), "UTF-8", false);
      for (File file : files) {
        xqs.declareVariable("doc", file.getName());
        ResourceSet result = xqs.execute(query);
        XMLResource resource = (XMLResource) result.getResource(0);
                System.out.println(resource.getContent());
View Full Code Here

Examples of org.exist.source.FileSource

  private static void runTests(List<String> files, String id) {
    try {
      StringBuilder results = new StringBuilder();
      XQueryService xqs = (XQueryService) rootCollection.getService("XQueryService", "1.0");
      Source query = new FileSource(new File("test/src/xquery/runTests.xql"), "UTF-8", false);
      for (String fileName : files) {
        File file = new File(fileName);
        if (!file.canRead()) {
          System.console().printf("Test file not found: %s\n", fileName);
          return;
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.