Package org.apache.twill.internal

Examples of org.apache.twill.internal.JvmOptions


    throws JsonParseException {
    JsonObject jsonObj = json.getAsJsonObject();
    String extraOptions = context.deserialize(jsonObj.get("extraOptions"), String.class);
    JvmOptions.DebugOptions debugOptions = context.deserialize(jsonObj.get("debugOptions"),
                                                               JvmOptions.DebugOptions.class);
    return new JvmOptions(extraOptions, debugOptions);
  }
View Full Code Here


*/
public class JvmOptionsCodecTest {

  @Test
  public void testNoNulls() throws Exception {
    JvmOptions options = new JvmOptions("-version",
                                        new JvmOptions.DebugOptions(true, false, ImmutableSet.of("one", "two")));
    final StringWriter writer = new StringWriter();
    JvmOptionsCodec.encode(options, new OutputSupplier<Writer>() {
      @Override
      public Writer getOutput() throws IOException {
        return writer;
      }
    });
    JvmOptions options1 = JvmOptionsCodec.decode(new InputSupplier<Reader>() {
      @Override
      public Reader getInput() throws IOException {
        return new StringReader(writer.toString());
      }
    });
    Assert.assertEquals(options.getExtraOptions(), options1.getExtraOptions());
    Assert.assertEquals(options.getDebugOptions().doDebug(), options1.getDebugOptions().doDebug());
    Assert.assertEquals(options.getDebugOptions().doSuspend(), options1.getDebugOptions().doSuspend());
    Assert.assertEquals(options.getDebugOptions().getRunnables(), options1.getDebugOptions().getRunnables());
  }
View Full Code Here

    Assert.assertEquals(options.getDebugOptions().getRunnables(), options1.getDebugOptions().getRunnables());
  }

  @Test
  public void testSomeNulls() throws Exception {
    JvmOptions options = new JvmOptions(null, new JvmOptions.DebugOptions(false, false, null));
    final StringWriter writer = new StringWriter();
    JvmOptionsCodec.encode(options, new OutputSupplier<Writer>() {
      @Override
      public Writer getOutput() throws IOException {
        return writer;
      }
    });
    JvmOptions options1 = JvmOptionsCodec.decode(new InputSupplier<Reader>() {
      @Override
      public Reader getInput() throws IOException {
        return new StringReader(writer.toString());
      }
    });
    Assert.assertEquals(options.getExtraOptions(), options1.getExtraOptions());
    Assert.assertEquals(options.getDebugOptions().doDebug(), options1.getDebugOptions().doDebug());
    Assert.assertEquals(options.getDebugOptions().doSuspend(), options1.getDebugOptions().doSuspend());
    Assert.assertEquals(options.getDebugOptions().getRunnables(), options1.getDebugOptions().getRunnables());
  }
View Full Code Here

  }

  @Test
  public void testNoRunnables() throws Exception {
    List<String> noRunnables = Collections.emptyList();
    JvmOptions options = new JvmOptions(null, new JvmOptions.DebugOptions(true, false, noRunnables));
    final StringWriter writer = new StringWriter();
    JvmOptionsCodec.encode(options, new OutputSupplier<Writer>() {
      @Override
      public Writer getOutput() throws IOException {
        return writer;
      }
    });
    JvmOptions options1 = JvmOptionsCodec.decode(new InputSupplier<Reader>() {
      @Override
      public Reader getInput() throws IOException {
        return new StringReader(writer.toString());
      }
    });
    Assert.assertEquals(options.getExtraOptions(), options1.getExtraOptions());
    Assert.assertEquals(options.getDebugOptions().doDebug(), options1.getDebugOptions().doDebug());
    Assert.assertEquals(options.getDebugOptions().doSuspend(), options1.getDebugOptions().doSuspend());
    Assert.assertEquals(options.getDebugOptions().getRunnables(), options1.getDebugOptions().getRunnables());
  }
View Full Code Here

  }

  private JvmOptions loadJvmOptions() throws IOException {
    final File jvmOptsFile = new File(Constants.Files.JVM_OPTIONS);
    if (!jvmOptsFile.exists()) {
      return new JvmOptions(null, JvmOptions.DebugOptions.NO_DEBUG);
    }
    return JvmOptionsCodec.decode(new InputSupplier<Reader>() {
      @Override
      public Reader getInput() throws IOException {
        return new FileReader(jvmOptsFile);
View Full Code Here

      // If no vm options, no need to localize the file.
      return;
    }
    LOG.debug("Create and copy {}", Constants.Files.JVM_OPTIONS);
    final Location location = createTempLocation(Constants.Files.JVM_OPTIONS);
    JvmOptionsCodec.encode(new JvmOptions(extraOptions, debugOptions), new OutputSupplier<Writer>() {
      @Override
      public Writer getOutput() throws IOException {
        return new OutputStreamWriter(location.getOutputStream(), Charsets.UTF_8);
      }
    });
View Full Code Here

TOP

Related Classes of org.apache.twill.internal.JvmOptions

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.