@Test public void testPrintModes() throws Exception { Jar jar = newCapsuleJar() .setAttribute("Application-Class", "com.acme.Foo") .setAttribute("Application-Version", "12.34") .setAttribute("ModeX", "System-Properties", "bar baz=55 foo=w") .setAttribute("ModeX", "Description", "This is a secret mode") .setAttribute("ModeY", "Description", "This is another secret mode") .setAttribute("ModeZ", "Foo", "xxx") .setAttribute("ModeX-Linux", "System-Properties", "bar baz=55 foo=w os=lin") .setAttribute("ModeX-MacOS", "System-Properties", "bar baz=55 foo=w os=mac") .setAttribute("ModeX-Windows", "System-Properties", "bar baz=55 foo=w os=win") .setAttribute("ModeY-Java-15", "Description", "This is a secret mode") .addEntry("foo.jar", emptyInputStream()); props.setProperty("capsule.modes", ""); Class<?> capsuleClass = loadCapsule(jar); setProperties(capsuleClass, props); StringPrintStream out = setSTDOUT(capsuleClass, new StringPrintStream()); Object capsule = newCapsule(capsuleClass); boolean found = runActions(capsule, null); String res = out.toString(); assert_().that(found).isTrue(); assert_().that(res).contains("* ModeX: This is a secret mode"); assert_().that(res).contains("* ModeY: This is another secret mode"); assert_().that(res).contains("* ModeZ"); assert_().that(res).doesNotContain("* ModeX-Linux"); assert_().that(res).doesNotContain("* ModeY-Java-15"); }
void printModes(List<String> args) { verifyNonEmpty("Cannot print modes of a wrapper capsule."); STDOUT.println(LOG_PREFIX + "Application " + getAppId()); STDOUT.println("Available modes:"); final Set<String> modes = getModes(); if (modes.isEmpty()) STDOUT.println("Default mode only"); else { for (String m : modes) { final String desc = getModeDescription(m); STDOUT.println("* " + m + (desc != null ? ": " + desc : "")); } } }
Capsule implements Runnable, InvocationHandler { void printModes(List<String> args) { verifyNonEmpty("Cannot print modes of a wrapper capsule."); STDOUT.println(LOG_PREFIX + "Application " + getAppId()); STDOUT.println("Available modes:"); final Set<String> modes = getModes(); if (modes.isEmpty()) STDOUT.println("Default mode only"); else { for (String m : modes) { final String desc = getModeDescription(m); STDOUT.println("* " + m + (desc != null ? ": " + desc : "")); } } } }
Capsule implements Runnable, InvocationHandler { void printModes(List<String> args) { verifyNonEmpty("Cannot print modes of a wrapper capsule."); STDOUT.println(LOG_PREFIX + "Application " + getAppId()); STDOUT.println("Available modes:"); final Set<String> modes = getModes(); if (modes.isEmpty()) STDOUT.println("Default mode only"); else { for (String m : modes) { final String desc = getModeDescription(m); STDOUT.println("* " + m + (desc != null ? ": " + desc : "")); } } } @SuppressWarnings({"OverridableMethodCallInConstructor", "LeakingThisInConstructor"}) protected  Capsule(Path jarFile); @SuppressWarnings("LeakingThisInConstructor") protected  Capsule(Capsule pred); }
Capsule implements Runnable, InvocationHandler { void printModes(List<String> args) { verifyNonEmpty("Cannot print modes of a wrapper capsule."); STDOUT.println(LOG_PREFIX + "Application " + getAppId()); STDOUT.println("Available modes:"); final Set<String> modes = getModes(); if (modes.isEmpty()) STDOUT.println("Default mode only"); else { for (String m : modes) { final String desc = getModeDescription(m); STDOUT.println("* " + m + (desc != null ? ": " + desc : "")); } } } @SuppressWarnings({"OverridableMethodCallInConstructor", "LeakingThisInConstructor"}) protected  Capsule(Path jarFile); @SuppressWarnings("LeakingThisInConstructor") protected  Capsule(Capsule pred); static final void main(String[] args); @SuppressWarnings({"BroadCatchBlock", "UnusedAssignment"}) static int main0(String[] args0); static void premain(String agentArgs, Instrumentation inst); static Object getCapsule(String capletClassName); boolean isAgent(); @Override final void run(); @Override Object invoke(Object proxy, Method method, Object[] args); @Override final int hashCode(); @Override final boolean equals(Object obj); @Override String toString(); }
Capsule implements Runnable, InvocationHandler { void printModes(List<String> args) { verifyNonEmpty("Cannot print modes of a wrapper capsule."); STDOUT.println(LOG_PREFIX + "Application " + getAppId()); STDOUT.println("Available modes:"); final Set<String> modes = getModes(); if (modes.isEmpty()) STDOUT.println("Default mode only"); else { for (String m : modes) { final String desc = getModeDescription(m); STDOUT.println("* " + m + (desc != null ? ": " + desc : "")); } } } @SuppressWarnings({"OverridableMethodCallInConstructor", "LeakingThisInConstructor"}) protected  Capsule(Path jarFile); @SuppressWarnings("LeakingThisInConstructor") protected  Capsule(Capsule pred); static final void main(String[] args); @SuppressWarnings({"BroadCatchBlock", "UnusedAssignment"}) static int main0(String[] args0); static void premain(String agentArgs, Instrumentation inst); static Object getCapsule(String capletClassName); boolean isAgent(); @Override final void run(); @Override Object invoke(Object proxy, Method method, Object[] args); @Override final int hashCode(); @Override final boolean equals(Object obj); @Override String toString(); static final String VERSION; }