コード例 #1
0
 public void testSetGetProject() throws Exception {
   ILaunchConfigurationWorkingCopy wc = createWorkingCopy();
   assertEquals(null, BootLaunchConfigurationDelegate.getProject(wc));
   IProject project = getProject("foo");
   BootLaunchConfigurationDelegate.setProject(wc, project);
   assertEquals(project, BootLaunchConfigurationDelegate.getProject(wc));
 }
コード例 #2
0
  public void testGetSetJMXPort() throws Exception {
    ILaunchConfigurationWorkingCopy wc = createWorkingCopy();
    assertEquals("", BootLaunchConfigurationDelegate.getJMXPort(wc));

    BootLaunchConfigurationDelegate.setJMXPort(wc, "something");
    assertEquals("something", BootLaunchConfigurationDelegate.getJMXPort(wc));
  }
コード例 #3
0
  public void testLaunchWithProperties() throws Exception {
    createLaunchReadyProject(TEST_PROJECT);
    ILaunchConfigurationWorkingCopy wc = createBaseWorkingCopy();

    BootLaunchConfigurationDelegate.setProperties(
        wc,
        Arrays.asList(
            pv("foo", "foo is enabled", true),
            pv("bar", "bar is not enabled", false),
            pv("zor", "zor enabled", true),
            pv("zor", "zor disabled", false)));

    int jmxPort = JmxBeanSupport.randomPort(); // must set or it will be generated randomly
    // and then we can't make the 'assert' below pass easily.
    BootLaunchConfigurationDelegate.setJMXPort(wc, "" + jmxPort);

    LaunchResult result = LaunchUtil.synchLaunch(wc);

    assertContains(":: Spring Boot ::", result.out);
    assertPropertyDump(
        result.out,
        "debug=null\n"
            + "zor='zor enabled'\n"
            + "foo='foo is enabled'\n"
            + "bar=null\n"
            + "com.sun.management.jmxremote.port='"
            + jmxPort
            + "'");
    assertOk(result);
  }
コード例 #4
0
 public void testClearProperties() throws Exception {
   ILaunchConfigurationWorkingCopy wc = createWorkingCopy();
   BootLaunchConfigurationDelegate.setProperties(
       wc, Arrays.asList(pv("some", "thing", true), pv("some.other", "thing", false)));
   assertFalse(BootLaunchConfigurationDelegate.getProperties(wc).isEmpty());
   BootLaunchConfigurationDelegate.clearProperties(wc);
   assertTrue(BootLaunchConfigurationDelegate.getProperties(wc).isEmpty());
 }
コード例 #5
0
  public void testSetGetProfile() throws Exception {
    ILaunchConfigurationWorkingCopy wc = createWorkingCopy();
    assertEquals("", BootLaunchConfigurationDelegate.getProfile(wc));

    BootLaunchConfigurationDelegate.setProfile(wc, "deployment");
    assertEquals("deployment", BootLaunchConfigurationDelegate.getProfile(wc));

    BootLaunchConfigurationDelegate.setProfile(wc, null);
    assertEquals("", BootLaunchConfigurationDelegate.getProfile(wc));
  }
コード例 #6
0
  public void testGetSetDebug() throws Exception {
    ILaunchConfigurationWorkingCopy wc = createWorkingCopy();
    boolean deflt = BootLaunchConfigurationDelegate.DEFAULT_ENABLE_DEBUG_OUTPUT;
    boolean other = !deflt;
    assertEquals(deflt, BootLaunchConfigurationDelegate.getEnableDebugOutput(wc));

    BootLaunchConfigurationDelegate.setEnableDebugOutput(wc, other);
    assertEquals(other, BootLaunchConfigurationDelegate.getEnableDebugOutput(wc));

    BootLaunchConfigurationDelegate.setEnableDebugOutput(wc, deflt);
    assertEquals(deflt, BootLaunchConfigurationDelegate.getEnableDebugOutput(wc));
  }
コード例 #7
0
  public void testGetSetLiveBean() throws Exception {
    ILaunchConfigurationWorkingCopy wc = createWorkingCopy();
    boolean deflt = BootLaunchConfigurationDelegate.DEFAULT_ENABLE_LIVE_BEAN_SUPPORT;
    boolean other = !deflt;

    assertEquals(deflt, BootLaunchConfigurationDelegate.getEnableLiveBeanSupport(wc));

    BootLaunchConfigurationDelegate.setEnableLiveBeanSupport(wc, other);
    assertEquals(other, BootLaunchConfigurationDelegate.getEnableLiveBeanSupport(wc));

    BootLaunchConfigurationDelegate.setEnableLiveBeanSupport(wc, deflt);
    assertEquals(deflt, BootLaunchConfigurationDelegate.getEnableLiveBeanSupport(wc));
  }
コード例 #8
0
  public void testLaunchWithLiveBeans() throws Exception {
    createLaunchReadyProject(TEST_PROJECT);
    ILaunchConfigurationWorkingCopy wc = createBaseWorkingCopy();

    BootLaunchConfigurationDelegate.setEnableLiveBeanSupport(wc, true);
    int port = JmxBeanSupport.randomPort();
    BootLaunchConfigurationDelegate.setJMXPort(wc, "" + port);

    LaunchResult result = LaunchUtil.synchLaunch(wc);

    System.out.println(result);

    assertContains(":: Spring Boot ::", result.out);
    // The following check doesn't real prove the live bean graph works, but at least it shows the
    // VM args are
    // taking effect.
    assertContains("com.sun.management.jmxremote.port='" + port + "'", result.out);
    assertOk(result);
  }
コード例 #9
0
  public void testLaunchWithProfile() throws Exception {
    createLaunchReadyProject(TEST_PROJECT);
    ILaunchConfigurationWorkingCopy wc = createBaseWorkingCopy();

    BootLaunchConfigurationDelegate.setProfile(wc, "special");

    LaunchResult result = LaunchUtil.synchLaunch(wc);

    assertContains(":: Spring Boot ::", result.out);
    assertContains("foo='special foo'", result.out);
    assertOk(result);
  }
コード例 #10
0
  public void testLaunchWithDebugOutput() throws Exception {
    createLaunchReadyProject(TEST_PROJECT);
    ILaunchConfigurationWorkingCopy wc = createBaseWorkingCopy();

    BootLaunchConfigurationDelegate.setEnableDebugOutput(wc, true);

    LaunchResult result = LaunchUtil.synchLaunch(wc);

    assertContains(":: Spring Boot ::", result.out);
    assertContains("AUTO-CONFIGURATION REPORT", result.out);
    assertOk(result);
  }
コード例 #11
0
  public void testRunAsLaunch() throws Exception {
    IProject project = createLaunchReadyProject(TEST_PROJECT);

    // Creates a launch conf similar to that created by 'Run As' menu.
    ILaunchConfigurationWorkingCopy wc = createWorkingCopy();
    BootLaunchConfigurationDelegate.setDefaults(wc, project, TEST_MAIN_CLASS);

    LaunchResult result = LaunchUtil.synchLaunch(wc);
    System.out.println(result); // Great help in debugging this :-)
    assertContains(":: Spring Boot ::", result.out);
    assertOk(result);
  }
コード例 #12
0
  public void testGetSetProperties() throws Exception {
    ILaunchConfigurationWorkingCopy wc = createWorkingCopy();
    assertProperties(
        BootLaunchConfigurationDelegate.getProperties(wc)
        /*empty*/
        );

    BootLaunchConfigurationDelegate.setProperties(wc, null); // accepts null in lieu of empty list,
    assertProperties(
        BootLaunchConfigurationDelegate.getProperties(wc)
        /*empty*/
        );

    // store one single property
    doGetAndSetProps(wc, pv("foo", "Hello", true));

    // store empty property list
    doGetAndSetProps(
        wc
        /*empty*/
        );

    // store a few properties
    doGetAndSetProps(
        wc,
        pv("foo.bar", "snuffer.nazz", true),
        pv("neala", "nolo", false),
        pv("Hohoh", "Santa Claus", false));

    // store properties with identical keys
    doGetAndSetProps(
        wc,
        pv("foo", "snuffer.nazz", true),
        pv("foo", "nolo", false),
        pv("bar", "Santa Claus", false),
        pv("bar", "Santkkk ", false));
  }
コード例 #13
0
  private ILaunchConfigurationWorkingCopy createBaseWorkingCopy() throws Exception {
    ILaunchConfigurationWorkingCopy wc = createWorkingCopy();
    BootLaunchConfigurationDelegate.setDefaults(wc, getProject(TEST_PROJECT), TEST_MAIN_CLASS);

    // Explictly set all options in the config to 'disabled' irrespective of
    // their default values (tests will be more robust w.r.t changing of the defaults).
    BootLaunchConfigurationDelegate.setEnableDebugOutput(wc, false);
    BootLaunchConfigurationDelegate.setEnableLiveBeanSupport(wc, false);
    BootLaunchConfigurationDelegate.setJMXPort(wc, "");
    BootLaunchConfigurationDelegate.setProfile(wc, "");
    BootLaunchConfigurationDelegate.setProperties(wc, null);
    return wc;
  }
コード例 #14
0
 private void doGetAndSetProps(ILaunchConfigurationWorkingCopy wc, PropVal... props) {
   BootLaunchConfigurationDelegate.setProperties(wc, Arrays.asList(props));
   List<PropVal> retrieved = BootLaunchConfigurationDelegate.getProperties(wc);
   assertProperties(retrieved, props);
 }