@Override
  public void setOuter(JUnit4 junit4) {
    this.junit4 = junit4;
   
    if (this.targetFile == null) {
      throw new BuildException("'file' attribute is required (target file name ending in .html, .json or .jsonp).");
    }

    if (method == OutputMethod.HTML) {
      if (Strings.isNullOrEmpty(jsonpMethod)) {
        setJsonpMethod("testData");
      } else if (!"testData".equals(jsonpMethod)) {
        throw new BuildException("JSONP method must be empty or equal 'testData' for HTML output.");
      }
    }
    
    if (method == OutputMethod.JSONP) {
      if (Strings.isNullOrEmpty(jsonpMethod)) {
        setJsonpMethod("testData");
      }
    }
    
    try {
      Files.createParentDirs(targetFile);

      File jsonFile = targetFile;
      if (method == OutputMethod.HTML) {
        jsonFile = new File(removeExtension(targetFile.getAbsolutePath()) + ".jsonp");
      }

      writer = new OutputStreamWriter(
          new BufferedOutputStream(new FileOutputStream(jsonFile)),Charsets.UTF_8);
      
      if (!Strings.isNullOrEmpty(jsonpMethod)) {
        writer.write(jsonpMethod);
        writer.write("(");
      }

      jsonWriter = new JsonWriter(writer);
      jsonWriter.setHtmlSafe(false);
      jsonWriter.setIndent("  ");

      jsonWriter.beginObject(); // Main holder.

      // junit4 object with properties.
      jsonWriter.name("junit4");
      jsonWriter.beginObject();
      jsonWriter.name("tests.seed");
      jsonWriter.value(junit4.getSeed());
      jsonWriter.name("project.name");
      jsonWriter.value(getProjectName());
      jsonWriter.endObject();

      // suites and an array of suites follows.
      jsonWriter.name("suites");
      jsonWriter.beginArray();
    } catch (IOException e) {
      throw new BuildException("Could not emit JSON report.", e);
    }
  }
@ Override public void setOuter ( JUnit4 junit4 ) { this . junit4 = junit4 ; if ( this . targetFile == null ) { throw new BuildException ( "'file' attribute is required (target file name ending in .html, .json or .jsonp)." ) ; } if ( method == OutputMethod . HTML ) { if ( Strings . isNullOrEmpty ( jsonpMethod ) ) { setJsonpMethod ( "testData" ) ; } else if ( ! "testData" . equals ( jsonpMethod ) ) { throw new BuildException ( "JSONP method must be empty or equal 'testData' for HTML output." ) ; } } if ( method == OutputMethod . JSONP ) { if ( Strings . isNullOrEmpty ( jsonpMethod ) ) { setJsonpMethod ( "testData" ) ; } } try { Files . createParentDirs ( targetFile ) ; File jsonFile = targetFile ; if ( method == OutputMethod . HTML ) { jsonFile = new File ( removeExtension ( targetFile . getAbsolutePath ( ) ) + ".jsonp" ) ; } writer = new OutputStreamWriter ( new BufferedOutputStream ( new FileOutputStream ( jsonFile ) ) , Charsets . UTF_8 ) ; if ( ! Strings . isNullOrEmpty ( jsonpMethod ) ) { writer . write ( jsonpMethod ) ; writer . write ( "(" ) ; } jsonWriter = new JsonWriter ( writer ) ; jsonWriter . setHtmlSafe ( false ) ; jsonWriter . setIndent ( "  " ) ; jsonWriter . beginObject ( ) ; jsonWriter . name ( "junit4" ) ; jsonWriter . beginObject ( ) ; jsonWriter . name ( "tests.seed" ) ; jsonWriter . value ( junit4 . getSeed ( ) ) ; jsonWriter . name ( "project.name" ) ; jsonWriter . value ( getProjectName ( ) ) ; jsonWriter . endObject ( ) ; jsonWriter . name ( "suites" ) ; jsonWriter . beginArray ( ) ; } catch ( IOException e ) { throw new BuildException ( "Could not emit JSON report." , e ) ; } }
/*