private void browse(URI uri) throws IOException { assertState(Desktop.isDesktopSupported(), String.format(CliStrings.DESKTOP_APP_RUN_ERROR_MESSAGE, System.getProperty("os.name"))); Desktop.getDesktop().browse(uri); }
@Test public void testAssertStateIsInvalid() { assertThatThrownBy(() -> { Assert.assertState(false, "The actual state is %1$s!", "invalid"); }).isInstanceOf(IllegalStateException.class).hasMessage("The actual state is invalid!"); } }
@Test public void testAssertStateIsValid() { Assert.assertState(true, ""); }
/** * Gets a proxy to the DistributedSystemMXBean from the GemFire Manager's MBeanServer, or null if * unable to find the DistributedSystemMXBean. * </p> * * @return a proxy to the DistributedSystemMXBean from the GemFire Manager's MBeanServer, or null * if unable to find the DistributedSystemMXBean. */ public static DistributedSystemMXBean getDistributedSystemMXBean() throws IOException, MalformedObjectNameException { assertState(Gfsh.isCurrentInstanceConnectedAndReady(), "Gfsh must be connected in order to get proxy to a GemFire DistributedSystemMXBean."); return Gfsh.getCurrentInstance().getOperationInvoker().getDistributedSystemMXBean(); }
String geodeHome = System.getenv("GEODE_HOME"); assertState(StringUtils.isNotBlank(geodeHome), CliStrings.GEODE_HOME_NOT_FOUND_ERROR_MESSAGE); assertState(IOUtils.isExistingPathname(getPathToVsd()), String.format(CliStrings.START_VSD__NOT_FOUND_ERROR_MESSAGE, geodeHome));
public static MemberMXBean getMemberMXBean(final String serviceName, final String member) throws IOException { assertState(Gfsh.isCurrentInstanceConnectedAndReady(), "Gfsh must be connected in order to get proxy to a GemFire Member MBean."); MemberMXBean memberBean = null; try { String objectNamePattern = ManagementConstants.OBJECTNAME__PREFIX; objectNamePattern += (org.apache.geode.internal.lang.StringUtils.isBlank(serviceName) ? org.apache.geode.internal.lang.StringUtils.EMPTY : "service=" + serviceName + org.apache.geode.internal.lang.StringUtils.COMMA_DELIMITER); objectNamePattern += "type=Member,*"; // NOTE throws a MalformedObjectNameException, however, this should not happen since the // ObjectName is constructed // here in a conforming pattern final ObjectName objectName = ObjectName.getInstance(objectNamePattern); final QueryExp query = Query.or(Query.eq(Query.attr("Name"), Query.value(member)), Query.eq(Query.attr("Id"), Query.value(member))); final Set<ObjectName> memberObjectNames = Gfsh.getCurrentInstance().getOperationInvoker().queryNames(objectName, query); if (!memberObjectNames.isEmpty()) { memberBean = Gfsh.getCurrentInstance().getOperationInvoker() .getMBeanProxy(memberObjectNames.iterator().next(), MemberMXBean.class); } } catch (MalformedObjectNameException e) { Gfsh.getCurrentInstance().logSevere(e.getMessage(), e); } return memberBean; }