Package org.adoptopenjdk.jitwatch.core

Examples of org.adoptopenjdk.jitwatch.core.JITWatchConfig


  public LaunchHeadless(String filename, boolean showErrors) throws IOException
  {
    this.showErrors = showErrors;

    JITWatchConfig config = new JITWatchConfig();

    HotSpotLogParser parser = new HotSpotLogParser(this);
    parser.setConfig(config);

    parser.processLogFile(new File(filename), this);
View Full Code Here


    return runtime.execute(fqClassName, classpath, options, logListener);
  }

  private void runJITWatch() throws IOException
  {
    JITWatchConfig config = logParser.getConfig();

    List<String> sourceLocations = new ArrayList<>(config.getSourceLocations());
    List<String> classLocations = new ArrayList<>(config.getClassLocations());

    String sandboxSourceDirString = SANDBOX_SOURCE_DIR.toString();
    String sandboxClassDirString = SANDBOX_CLASS_DIR.toString();

    boolean configChanged = false;

    if (!sourceLocations.contains(sandboxSourceDirString))
    {
      configChanged = true;
      sourceLocations.add(sandboxSourceDirString);
    }

    if (!classLocations.contains(sandboxClassDirString))
    {
      configChanged = true;
      classLocations.add(sandboxClassDirString);
    }

    File jdkSrcZip = JITWatchConfig.getJDKSourceZip();

    if (jdkSrcZip != null)
    {
      String jdkSourceZipString = jdkSrcZip.toPath().toString();

      if (!sourceLocations.contains(jdkSourceZipString))
      {
        configChanged = true;
        sourceLocations.add(jdkSourceZipString);
      }
    }

    config.setSourceLocations(sourceLocations);
    config.setClassLocations(classLocations);

    if (configChanged)
    {
      config.saveConfig();
    }

    logParser.processLogFile(sandboxLogFile, sandboxStage);

    logListener.log("Parsing complete");
View Full Code Here

  }

  @Test
  public void testConfigOnlyBuiltInProfiles()
  {
    JITWatchConfig config = new JITWatchConfig(new File(testConfigFilename));

    Set<String> configNames = config.getProfileNames();

    assertEquals(2, configNames.size());

    assertTrue(configNames.contains(JITWatchConstants.S_PROFILE_DEFAULT));
    assertTrue(configNames.contains(JITWatchConstants.S_PROFILE_SANDBOX));

    List<String> sourcesList = config.getSourceLocations();

    assertEquals(0, sourcesList.size());
  }
View Full Code Here

  }

  @Test
  public void testEmptyConfigSaveReload()
  {
    JITWatchConfig config = new JITWatchConfig(new File(testConfigFilename));

    String foo = "foo";

    List<String> sourcesList = new ArrayList<String>();
    sourcesList.add(foo);

    config.setSourceLocations(sourcesList);

    config.marshalConfigToProperties();

    config.savePropertiesToFile();

    config = new JITWatchConfig(new File(testConfigFilename));

    List<String> retrievedSourcesList = config.getSourceLocations();

    assertEquals(1, retrievedSourcesList.size());

    assertTrue(retrievedSourcesList.contains(foo));

    Set<String> configNames = config.getProfileNames();

    assertEquals(2, configNames.size());

    assertTrue(configNames.contains(JITWatchConstants.S_PROFILE_DEFAULT));
    assertTrue(configNames.contains(JITWatchConstants.S_PROFILE_SANDBOX));

    config.setProfileName("MISSING");

    List<String> retrievedSourcesList2 = config.getSourceLocations();

    assertEquals(0, retrievedSourcesList2.size());

    assertFalse(retrievedSourcesList2.contains(foo));
  }
View Full Code Here

  }

  @Test
  public void testSwitchBetweenDefaultAndUserProfiles()
  {
    JITWatchConfig config = new JITWatchConfig(new File(testConfigFilename));

    String foo = "foo";

    List<String> sourcesListFoo = new ArrayList<String>();
    sourcesListFoo.add(foo);

    config.setSourceLocations(sourcesListFoo);

    config.marshalConfigToProperties();

    config.savePropertiesToFile();

    config = new JITWatchConfig(new File(testConfigFilename));

    List<String> retrievedSourcesList = config.getSourceLocations();

    assertEquals(1, retrievedSourcesList.size());

    assertTrue(retrievedSourcesList.contains(foo));

    Set<String> configNames = config.getProfileNames();

    assertEquals(2, configNames.size());

    assertTrue(configNames.contains(JITWatchConstants.S_PROFILE_DEFAULT));
    assertTrue(configNames.contains(JITWatchConstants.S_PROFILE_SANDBOX));

    String secondProfileName = "Spaceship";
   
    config.setProfileName(secondProfileName);

    List<String> retrievedSourcesList2 = config.getSourceLocations();

    assertEquals(0, retrievedSourcesList2.size());

    String bar = "bar";

    List<String> sourcesListBar = new ArrayList<String>();
    sourcesListBar.add(bar);
   
    config.setSourceLocations(sourcesListBar);
   
    config.saveConfig();
   
    assertEquals(secondProfileName, config.getProfileName());
   
    configNames = config.getProfileNames();

    assertEquals(3, configNames.size());

    assertTrue(configNames.contains(JITWatchConstants.S_PROFILE_DEFAULT));
    assertTrue(configNames.contains(JITWatchConstants.S_PROFILE_SANDBOX));
   
    assertTrue(configNames.contains(secondProfileName));

    config.setProfileName(JITWatchConstants.S_PROFILE_DEFAULT);
   
    assertEquals(JITWatchConstants.S_PROFILE_DEFAULT, config.getProfileName());

    retrievedSourcesList = config.getSourceLocations();

    assertEquals(1, retrievedSourcesList.size());

    assertTrue(retrievedSourcesList.contains(foo));
   
    config.setProfileName(secondProfileName);
   
    retrievedSourcesList2 = config.getSourceLocations();

    assertEquals(1, retrievedSourcesList2.size());

    assertTrue(retrievedSourcesList2.contains(bar));
   
View Full Code Here

  }
 
  @Test
  public void testMakeCustomProfileThenDeleteIt()
  {
    JITWatchConfig config = new JITWatchConfig(new File(testConfigFilename));

    String foo = "foo";

    List<String> sourcesListFoo = new ArrayList<String>();
    sourcesListFoo.add(foo);

    config.setSourceLocations(sourcesListFoo);

    config.marshalConfigToProperties();

    config.savePropertiesToFile();

    config = new JITWatchConfig(new File(testConfigFilename));

    List<String> retrievedSourcesList = config.getSourceLocations();

    assertEquals(1, retrievedSourcesList.size());

    assertTrue(retrievedSourcesList.contains(foo));

    Set<String> configNames = config.getProfileNames();

    assertEquals(2, configNames.size());

    assertTrue(configNames.contains(JITWatchConstants.S_PROFILE_DEFAULT));
    assertTrue(configNames.contains(JITWatchConstants.S_PROFILE_SANDBOX));

    String customProfileName = "Spaceship";
   
    config.setProfileName(customProfileName);

    List<String> retrievedSourcesList2 = config.getSourceLocations();

    assertEquals(0, retrievedSourcesList2.size());

    String bar = "bar";

    List<String> sourcesListBar = new ArrayList<String>();
    sourcesListBar.add(bar);
   
    config.setSourceLocations(sourcesListBar);
   
    config.saveConfig();
   
    assertEquals(customProfileName, config.getProfileName());
   
    configNames = config.getProfileNames();

    assertEquals(3, configNames.size());

    assertTrue(configNames.contains(JITWatchConstants.S_PROFILE_DEFAULT));
    assertTrue(configNames.contains(JITWatchConstants.S_PROFILE_SANDBOX));
   
    assertTrue(configNames.contains(customProfileName));
   
    config.deleteProfile(customProfileName);
   
    configNames = config.getProfileNames();

    assertEquals(2, configNames.size());
   
    assertTrue(configNames.contains(JITWatchConstants.S_PROFILE_DEFAULT));
    assertTrue(configNames.contains(JITWatchConstants.S_PROFILE_SANDBOX));
   
    assertFalse(configNames.contains(customProfileName));
   
    assertEquals(JITWatchConstants.S_PROFILE_DEFAULT, config.getProfileName());

    retrievedSourcesList = config.getSourceLocations();

    assertEquals(1, retrievedSourcesList.size());

    assertTrue(retrievedSourcesList.contains(foo));   
  }
View Full Code Here

TOP

Related Classes of org.adoptopenjdk.jitwatch.core.JITWatchConfig

Copyright © 2018 www.massapicom. 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.