protected void runTest(Map<String,?> flags) throws Exception { String tag = getClass().getSimpleName().toLowerCase(); Map<String,?> allFlags = MutableMap.<String,Object>builder() .put("tags", ImmutableList.of(tag)) .putAll(flags) .build(); jcloudsLocation = mgmt.getLocationRegistry().getLocationManaged(PROVIDER, allFlags); doTest(jcloudsLocation); }
@Override public Map<String, String> getShellEnvironment() { return MutableMap.<String, String>builder().putAll(super.getShellEnvironment()) .put("PORT", Integer.toString(getHttpPort())) .build(); }
@Override protected Location createLocation() { // Image: {id=CENTOS_6_64, providerId=CENTOS_6_64, os={family=centos, version=6.5, description=CentOS / CentOS / 6.5-64 LAMP for Bare Metal, is64Bit=true}, description=CENTOS_6_64, status=AVAILABLE, loginUser=root} Map<String, ?> allFlags = MutableMap.<String, Object>builder() .put("provider", PROVIDER) .put("tags", ImmutableList.of(getClass().getName())) .put("vmNameMaxLength", 30) .put("imageId", "CENTOS_6_64") .build(); return mgmt.getLocationRegistry().getLocationManaged(PROVIDER, allFlags); }
@Test public void testEnricherSpecThrowsOnPropagatesAndPropagatesAllSet() throws Exception { try { app.enrichers().add(EnricherSpec.create(Propagator.class) .configure(MutableMap.builder() .put(Propagator.PRODUCER, entity) .put(Propagator.PROPAGATING, ImmutableList.of(TestEntity.NAME)) .put(Propagator.PROPAGATING_ALL, true) .build())); } catch (Exception e) { IllegalStateException ise = Exceptions.getFirstThrowableOfType(e, IllegalStateException.class); if (ise == null) throw e; } }
@BeforeClass(groups="Live") public void setUpClass() throws Exception { classManagementContext = newManagementContext(); classLoc = (JcloudsLocation) classManagementContext.getLocationRegistry().getLocationManaged(SOFTLAYER_LOCATION_SPEC); classVm = (JcloudsSshMachineLocation)classLoc.obtain(MutableMap.<String,Object>builder() .put("inboundPorts", ImmutableList.of(22)) .build()); slVmUser = classVm.getUser(); slVmInstanceId = classVm.getJcloudsId(); slVmIp = classVm.getAddress().getHostAddress(); slVmHostname = classVm.getNode().getHostname(); }
@Test public void testBasicJmxFromFlag() { assertJmxWithPropsHasPhrases( MutableMap.builder(). put("useJmx", true). build(), EXPECTED_BASIC_JMX_OPTS, FORBIDDEN_BASIC_JMX_OPTS); }
@Test public void testConfigPassedInAtConstructionIsAvailable() throws Exception { MyEnricher enricher = new MyEnricher(MutableMap.builder() .put(MyEnricher.STR_KEY, "aval") .put(MyEnricher.INT_KEY, 2) .build()); app.enrichers().add(enricher); assertEquals(enricher.getConfig(MyEnricher.STR_KEY), "aval"); assertEquals(enricher.getConfig(MyEnricher.INT_KEY), (Integer)2); assertEquals(enricher.getConfig(MyEnricher.STR_KEY_WITH_DEFAULT), MyEnricher.STR_KEY_WITH_DEFAULT.getDefaultValue()); }
@Test public void testUnknownConfigPassedInAtConstructionIsWarnedAndIgnored() throws Exception { // TODO Also assert it's warned MyEnricher enricher = new MyEnricher(MutableMap.builder() .put(differentKey, "aval") .build()); app.enrichers().add(enricher); assertEquals(enricher.getConfig(differentKey), null); assertEquals(enricher.getEnricherType().getConfigKey(differentKey.getName()), null); }
@Test public void testUnknownConfigPassedInAtConstructionIsWarnedAndIgnored() throws Exception { // TODO Also assert it's warned MyPolicy policy = new MyPolicy(MutableMap.builder() .put(differentKey, "aval") .build()); app.policies().add(policy); assertEquals(policy.getConfig(differentKey), null); assertEquals(policy.getPolicyType().getConfigKey(differentKey.getName()), null); }
@Override public EnricherSpec<?> build() { return super.build().configure(MutableMap.builder() .putIfNotNull(Transformer.PRODUCER, fromEntity) .put(Transformer.TARGET_SENSOR, publishing) .put(Transformer.SOURCE_SENSOR, transforming) .putIfNotNull(Transformer.TRANSFORMATION_FROM_VALUE, computing) .putIfNotNull(Transformer.TRANSFORMATION_FROM_EVENT, computingFromEvent) .build()); }
@Override public EnricherSpec<?> build() { return super.build().configure(MutableMap.builder() .putIfNotNull(Combiner.PRODUCER, fromEntity) .put(Combiner.TARGET_SENSOR, publishing) .put(Combiner.SOURCE_SENSORS, combining) .putIfNotNull(Combiner.TRANSFORMATION, computing) .putIfNotNull(Combiner.VALUE_FILTER, valueFilter) .build()); }
@Test(groups = "Live", dataProvider="cloudAndImageNames") public void testCreatesWindowsVm(String locationSpec, String imageNameRegex, Map<String, ?> additionalConfig) throws Exception { jcloudsLocation = (JcloudsLocation) managementContext.getLocationRegistry().getLocationManaged(locationSpec); JcloudsWinRmMachineLocation machine = obtainWinrmMachine(MutableMap.<String,Object>builder() .putIfAbsent("inboundPorts", ImmutableList.of(5986, 5985, 3389)) .put(JcloudsLocation.IMAGE_NAME_REGEX.getName(), imageNameRegex) .put(JcloudsLocation.USE_JCLOUDS_SSH_INIT.getName(), false) .put(JcloudsLocation.OS_FAMILY_OVERRIDE.getName(), OsFamily.WINDOWS) .putAll(additionalConfig != null ? additionalConfig : ImmutableMap.<String, Object>of()) .build()); assertWinrmable(machine); }
@Test public void testBasicJmxFromConfig() { assertJmxWithPropsHasPhrases( MutableMap.builder(). put(UsesJmx.USE_JMX, true). build(), EXPECTED_BASIC_JMX_OPTS, FORBIDDEN_BASIC_JMX_OPTS); }
public void applyAgentJmxJavaSystemProperties(Builder<String, Object> result) { result. put(JmxmpAgent.USE_SSL_PROPERTY, true). put(JmxmpAgent.AUTHENTICATE_CLIENTS_PROPERTY, true). // the option below wants a jmxremote.password file; we use certs (above) to authenticate put("com.sun.management.jmxremote.authenticate", false); result. put(JmxmpAgent.JMXMP_KEYSTORE_FILE_PROPERTY, getJmxSslKeyStoreFilePath()). put(JmxmpAgent.JMXMP_TRUSTSTORE_FILE_PROPERTY, getJmxSslTrustStoreFilePath()); }
@Override public Map<String, String> getShellEnvironment() { return MutableMap.<String, String>builder() .putAll(super.getShellEnvironment()) .put("RABBITMQ_HOME", getRunDir()) .put("RABBITMQ_LOG_BASE", getRunDir()) .put("RABBITMQ_NODENAME", getEntity().getId()) .put("RABBITMQ_NODE_PORT", getAmqpPort().toString()) .put("RABBITMQ_PID_FILE", getRunDir()+"/"+getPidFile()) .put("RABBITMQ_CONFIG_FILE", getConfigPath()) .build(); }
@Override public Map<String, String> getShellEnvironment() { return MutableMap.<String, String>builder() .putAll(super.getShellEnvironment()) .put("JETTY_RUN", getRunDir()) .put("JETTY_HOME", getRunDir()) .put("JETTY_LOGS", Os.mergePathsUnix(getRunDir(), "logs")) .put("JETTY_PORT", getHttpPort().toString()) .renameKey("JAVA_OPTS", "JAVA_OPTIONS") .build(); } }
@Test public void testConfigSetterOverridesConstructorValue() throws Exception { MyEnricher enricher = new MyEnricher(MutableMap.builder() .put(MyEnricher.STR_KEY, "aval") .build()); enricher.config().set(MyEnricher.STR_KEY, "diffval"); app.enrichers().add(enricher); assertEquals(enricher.getConfig(MyEnricher.STR_KEY), "diffval"); }
public static Map<String,Object> getBasicAddonSubstitutions(EntityDriver driver, String addon) { return MutableMap.<String,Object>builder() .putAll(getBasicEntitySubstitutions(driver)) .put("addon", addon) .build(); }