Github user johnmccabe commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/132#discussion_r62522025
  
    --- Diff: 
locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/JcloudsByonLocationResolverStubbedTest.java
 ---
    @@ -0,0 +1,157 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +package org.apache.brooklyn.location.jclouds;
    +
    +import static org.testng.Assert.assertEquals;
    +
    +import java.util.Collection;
    +import java.util.Map;
    +import java.util.Set;
    +
    +import org.apache.brooklyn.api.location.Location;
    +import org.apache.brooklyn.api.location.LocationSpec;
    +import org.apache.brooklyn.api.location.MachineLocation;
    +import org.apache.brooklyn.core.internal.BrooklynProperties;
    +import org.apache.brooklyn.core.mgmt.internal.LocalManagementContext;
    +import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests;
    +import 
org.apache.brooklyn.location.byon.FixedListMachineProvisioningLocation;
    +import org.jclouds.compute.domain.ComputeMetadata;
    +import org.jclouds.compute.domain.NodeMetadata;
    +import org.jclouds.compute.domain.NodeMetadata.Status;
    +import org.jclouds.compute.domain.NodeMetadataBuilder;
    +import org.jclouds.compute.domain.Template;
    +import org.jclouds.domain.LoginCredentials;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +import org.testng.annotations.Test;
    +
    +import com.google.common.base.Predicate;
    +import com.google.common.collect.ImmutableList;
    +import com.google.common.collect.ImmutableMap;
    +import com.google.common.collect.ImmutableSet;
    +import com.google.common.collect.Iterables;
    +
    +public class JcloudsByonLocationResolverStubbedTest extends 
AbstractJcloudsStubbedLiveTest {
    +
    +    @SuppressWarnings("unused")
    +    private static final Logger log = 
LoggerFactory.getLogger(JcloudsByonLocationResolverStubbedTest.class);
    +    
    +    private final String nodeId = "mynodeid";
    +    private final String nodePublicAddress = "173.194.32.123";
    +    private final String nodePrivateAddress = "172.168.10.11";
    +    
    +    protected LocalManagementContext newManagementContext() {
    +        // This really is stubbed; no live access to the cloud
    +        LocalManagementContext result = 
LocalManagementContextForTests.builder(true).build();
    +        BrooklynProperties brooklynProperties = 
result.getBrooklynProperties();
    +        
brooklynProperties.put("brooklyn.location.jclouds."+SOFTLAYER_PROVIDER+".identity",
 "myidentity");
    +        
brooklynProperties.put("brooklyn.location.jclouds."+SOFTLAYER_PROVIDER+".credential",
 "mycredential");
    +        return result;
    +
    +    }
    +
    +    @Override
    +    protected NodeCreator newNodeCreator() {
    +        return new NodeCreator() {
    +            @Override
    +            public Set<? extends NodeMetadata> 
listNodesDetailsMatching(Predicate<ComputeMetadata> filter) {
    +                NodeMetadata result = new NodeMetadataBuilder()
    +                        .id(nodeId)
    +                        
.credentials(LoginCredentials.builder().identity("dummy").credential("dummy").build())
    +                        .loginPort(22)
    +                        .status(Status.RUNNING)
    +                        
.publicAddresses(ImmutableList.of(nodePublicAddress))
    +                        
.privateAddresses(ImmutableList.of(nodePrivateAddress))
    +                        .build();
    +                return 
ImmutableSet.copyOf(Iterables.filter(ImmutableList.of(result), filter));
    +            }
    +            @Override
    +            protected NodeMetadata newNode(String group, Template 
template) {
    +                throw new UnsupportedOperationException();
    +            }
    +        };
    +    }
    +
    +    @Test
    +    public void testResolvesHostInSpec() throws Exception {
    +        String spec = 
"jcloudsByon:(provider=\""+SOFTLAYER_PROVIDER+"\",region=\""+SOFTLAYER_AMS01_REGION_NAME+"\",user=\"myuser\",password=\"mypassword\",hosts=\""+nodeId+"\")";
    +        Map<?,?> specFlags = 
ImmutableMap.of(JcloudsLocationConfig.COMPUTE_SERVICE_REGISTRY, 
computeServiceRegistry);
    +
    +        FixedListMachineProvisioningLocation<MachineLocation> location = 
getLocationManaged(spec, specFlags);
    +        
    +        JcloudsSshMachineLocation machine = (JcloudsSshMachineLocation) 
Iterables.getOnlyElement(location.getAllMachines());
    +        assertEquals(machine.getJcloudsId(), nodeId);
    +        assertEquals(machine.getPublicAddresses(), 
ImmutableSet.of(nodePublicAddress));
    +        assertEquals(machine.getPrivateAddresses(), 
ImmutableSet.of(nodePrivateAddress));
    +        
    +        // TODO what user/password should we expect? Fails below because 
has "dummy":
    +//        assertEquals(machine.getUser(), "myuser");
    --- End diff --
    
    This is whats throwing the NPE mentioned earlier, previously it was these 
user/password values that were being used.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to