JcloudsLocation extends AbstractCloudMachineProvisioningLocation implements
        JcloudsLocationPublic { @Deprecated @VisibleForTesting static int[] toIntPortArray(Object v) { PortRange portRange = PortRanges.fromIterable(Collections.singletonList(v)); return ArrayUtils.toPrimitive(Iterables.toArray(portRange, Integer.class)); } JcloudsLocation();  JcloudsLocation(Map<?,?> conf); @Override @Deprecated JcloudsLocation configure(Map<?,?> properties); @Override void init(); @Override void rebind(); @Override JcloudsLocation newSubLocation(Map<?,?> newFlags); @Override JcloudsLocation newSubLocation(Class<? extends AbstractCloudMachineProvisioningLocation> type, Map<?,?> newFlags); @Override String toString(); @Override String toVerboseString(); @Override String getProvider(); @Override String getIdentity(); @Override String getCredential(); @Override String getRegion(); @Override String getEndpoint(); String getUser(ConfigBag config); boolean isWindows(Template template, ConfigBag config); boolean isWindows(Image image, ConfigBag config); boolean isWindows(NodeMetadata node, ConfigBag config); boolean isLocationFirewalldEnabled(SshMachineLocation location); Collection<JcloudsLocationCustomizer> getCustomizers(ConfigBag setup); ConnectivityResolver getLocationNetworkInfoCustomizer(ConfigBag setup); void setDefaultImageId(String val); void setTagMapping(Map<String,Map<String, ? extends Object>> val); @Override Map<String,Object> getProvisioningFlags(Collection<String> tags); static final Set<ConfigKey<?>> getAllSupportedProperties(); ComputeService getComputeService(); ComputeService getComputeService(Map<?,?> flags); ComputeService getComputeService(ConfigBag config); @Override Map<String, MachineManagementMixins.MachineMetadata> listMachines(); @Override MachineManagementMixins.MachineMetadata getMachineMetadata(MachineLocation l); @Override void killMachine(String cloudServiceId); @Override void killMachine(MachineLocation l); MachineLocation obtain(); MachineLocation obtain(TemplateBuilder tb); MachineLocation obtain(Map<?,?> flags, TemplateBuilder tb); @Override MachineLocation obtain(Map<?,?> flags); @Override void suspendMachine(MachineLocation rawLocation); @Override JcloudsMachineLocation resumeMachine(Map<?, ?> flags); @Deprecated Template buildTemplate(ComputeService computeService, ConfigBag config, Collection<JcloudsLocationCustomizer> customizers); Template buildTemplate(ComputeService computeService, ConfigBag config, JcloudsLocationCustomizer customizersDelegate); @Override String toStringNice(); JcloudsMachineLocation registerMachine(ConfigBag flags); JcloudsMachineLocation registerMachine(Map<?,?> flags); @Override void release(MachineLocation rawMachine); @Override PersistenceObjectStore newPersistenceObjectStore(String container); @Deprecated static File asFile(Object o); @Deprecated static String fileAsString(Object o); static final Logger LOG; static final Map<ConfigKey<?>, ? extends TemplateBuilderCustomizer> SUPPORTED_TEMPLATE_BUILDER_PROPERTIES; static final Map<ConfigKey<?>, ? extends TemplateOptionCustomizer> SUPPORTED_TEMPLATE_OPTIONS_PROPERTIES; }
@Test public void testSingleInttoIntPortArray() { int port = 1; int[] intArray = new int[] {1}; Assert.assertEquals(JcloudsLocation.toIntPortArray(port), intArray); }
@Test public void testSingleStringtoIntPortArray() { String portString = "1"; int[] intArray = new int[] {1}; Assert.assertEquals(JcloudsLocation.toIntPortArray(portString), intArray); }
@Test public void testStringListWithBracketstoIntPortArray() { String listString = "[1, 2, 3, 4]"; int[] intArray = new int[] {1, 2, 3, 4}; Assert.assertEquals(JcloudsLocation.toIntPortArray(listString), intArray); }
@Test public void testStringListWithoutBracketstoIntPortArray() { String listString = "1, 2, 3, 4"; int[] intArray = new int[] {1, 2, 3, 4}; Assert.assertEquals(JcloudsLocation.toIntPortArray(listString), intArray); }
@Test public void testEmptyStringListtoIntPortArray() { String listString = "[]"; int[] intArray = new int[] {}; Assert.assertEquals(JcloudsLocation.toIntPortArray(listString), intArray); }
@Test public void testIntArraytoIntPortArray() { int[] intArray = new int[] {1, 2, 3, 4}; Assert.assertEquals(JcloudsLocation.toIntPortArray(intArray), intArray); }
@Test public void testObjectArrayOfIntegerstoIntPortArray() { Object[] integerObjectArray = new Object[] {1, 2, 3, 4}; int[] intArray = new int[] {1, 2, 3, 4}; Assert.assertEquals(JcloudsLocation.toIntPortArray(integerObjectArray), intArray); }
@Test public void testObjectArrayOfStringstoIntPortArray() { Object[] stringObjectArray = new Object[] {"1", "2", "3", "4"}; int[] intArray = new int[] {1, 2, 3, 4}; Assert.assertEquals(JcloudsLocation.toIntPortArray(stringObjectArray), intArray); }
@Test public void testStringArraytoIntPortArray() { String[] stringArray = new String[] {"1", "2", "3"}; int[] intArray = new int[] {1, 2, 3}; Assert.assertEquals(JcloudsLocation.toIntPortArray(stringArray), intArray); }
@Test public void testStringPortRangetoIntPortArray() { String portRange = "1-100"; int[] intArray = Ints.toArray(ContiguousSet.create(Range.closed(1, 100), DiscreteDomain.integers())); Assert.assertEquals(intArray, JcloudsLocation.toIntPortArray(portRange)); }
@Test public void testStringPortPlustoIntPortArray() { String portPlus = "100+"; int[] intArray = Ints.toArray(ContiguousSet.create(Range.closed(100, 65535), DiscreteDomain.integers())); Assert.assertEquals(intArray, JcloudsLocation.toIntPortArray(portPlus)); }
@Test public void testCombinationOfInputstoIntPortArray() { Collection<Object> portInputs = Lists.newLinkedList(); portInputs.add(1); portInputs.add("2"); portInputs.add("3-100"); portInputs.add("101,102,103"); portInputs.add("[104,105,106]"); portInputs.add(new int[] {107, 108, 109}); portInputs.add(new String[] {"110", "111", "112"}); portInputs.add(new Object[] {113, 114, 115}); int[] intArray = Ints.toArray(ContiguousSet.create(Range.closed(1, 115), DiscreteDomain.integers())); Assert.assertEquals(intArray, JcloudsLocation.toIntPortArray(portInputs)); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testMalformedStringNumbertoIntPortArray() { String numberStr = "1i"; JcloudsLocation.toIntPortArray(numberStr); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testMalformedStringRangetoIntPortArray() { String rangeString = "1-"; JcloudsLocation.toIntPortArray(rangeString); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testMalformedStringListWithBracketstoIntPortArray() { String listString = "[1,2,e]"; JcloudsLocation.toIntPortArray(listString); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testMalformedStringListWithoutBracketstoIntPortArray() { String listString = "1,2,e"; JcloudsLocation.toIntPortArray(listString); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testMalformedStringArraytoIntPortArray() { String[] stringArray = new String[] {"1", "2", "e"}; JcloudsLocation.toIntPortArray(stringArray); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testIllegalObjectArrayOfDoublestoIntPortArray() { Object[] doubleObjectArray = new Object[] {1.0, 2.0, 3.0}; JcloudsLocation.toIntPortArray(doubleObjectArray); }