Example #1
0
  @Test
  public void testWriteExecutionData() throws Exception {
    data.getExecutionData(Long.valueOf(0x12345678), "Foo", 42);
    data.setSessionId("stubid");

    final Socket socket = serverSocket.connect();
    final RemoteControlWriter remoteWriter = new RemoteControlWriter(socket.getOutputStream());
    final RemoteControlReader remoteReader = new RemoteControlReader(socket.getInputStream());

    // First process a NOP command to ensure the connection is initialized:
    remoteWriter.visitDumpCommand(false, false);
    remoteReader.read();

    // Now the actual test starts:
    controller.writeExecutionData(false);

    final ExecutionDataStore execStore = new ExecutionDataStore();
    remoteReader.setExecutionDataVisitor(execStore);
    final SessionInfoStore infoStore = new SessionInfoStore();
    remoteReader.setSessionInfoVisitor(infoStore);
    remoteReader.read();

    assertEquals("Foo", execStore.get(0x12345678).getName());

    final List<SessionInfo> infos = infoStore.getInfos();
    assertEquals(1, infos.size());
    assertEquals("stubid", infos.get(0).getId());

    logger.assertNoException();
    controller.shutdown();
  }
  public static void dumpJacoco() throws IOException {

    ExecutionDataFiles executionDataFiles = new ExecutionDataFiles();

    // final FileOutputStream localFile = new FileOutputStream(DESTFILE);
    // final ExecutionDataWriter localWriter = new ExecutionDataWriter(
    // localFile);
    int port =
        TomcatLauncherPlugin.getDefault()
            .getPreferenceStore()
            .getInt(TomcatLauncherPlugin.JacocoAgentPort);
    // Open a socket to the coverage agent:
    final Socket socket = new Socket(InetAddress.getByName(ADDRESS), port);
    final RemoteControlWriter writer = new RemoteControlWriter(socket.getOutputStream());
    final RemoteControlReader reader = new RemoteControlReader(socket.getInputStream());

    MemoryExecutionDataSource memoryExecutionDataSource = new MemoryExecutionDataSource();

    reader.setSessionInfoVisitor(memoryExecutionDataSource);
    reader.setExecutionDataVisitor(memoryExecutionDataSource);

    // reader.setSessionInfoVisitor(localWriter);
    // reader.setExecutionDataVisitor(localWriter);

    // Send a dump command and read the response:
    writer.visitDumpCommand(true, false);
    reader.read();

    socket.close();

    try {
      IExecutionDataSource source = executionDataFiles.newFile(memoryExecutionDataSource);
      ISessionManager sessionManager = CoverageTools.getSessionManager();
      ILaunchConfiguration launchconfig = null;
      CoverageSession Coveragesession =
          new CoverageSession(
              "tomcat coverage" + getNow(), TomcatBootstrap.getSrcRoots(), source, launchconfig);
      // SessionImporter importer=new
      // SessionImporter(sessionManager,executionDataFiles);
      // importer.importSession(s);
      // ICoverageSession session=
      ILaunch launch = null;
      // setIjavaProject

      sessionManager.addSession(Coveragesession, true, launch);

    } catch (CoreException e) {
      TomcatLauncherPlugin.log(e);
    }

    // localFile.close();
  }
Example #3
0
  /**
   * Starts the execution data request.
   *
   * @param args
   * @throws IOException
   */
  public static void main(final String[] args) throws IOException {
    final FileOutputStream localFile = new FileOutputStream(DESTFILE);
    final ExecutionDataWriter localWriter = new ExecutionDataWriter(localFile);

    // Open a socket to the coverage agent:
    final Socket socket = new Socket(InetAddress.getByName(ADDRESS), PORT);
    final RemoteControlWriter writer = new RemoteControlWriter(socket.getOutputStream());
    final RemoteControlReader reader = new RemoteControlReader(socket.getInputStream());
    reader.setSessionInfoVisitor(localWriter);
    reader.setExecutionDataVisitor(localWriter);

    // Send a dump command and read the response:
    writer.visitDumpCommand(true, false);
    reader.read();

    socket.close();
    localFile.close();
  }