Renamed to MachineDetailsIntegrationTest (cherry picked from commit ee0cabde0e2da32a5ba60c2312432baa3e847b25)
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/59623743 Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/59623743 Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/59623743 Branch: refs/heads/0.11.x Commit: 5962374329b305bd21a026a9fae1aac83ce8ca47 Parents: 5e1ed0a Author: Aled Sage <[email protected]> Authored: Tue Apr 18 10:03:13 2017 +0100 Committer: Richard Downer <[email protected]> Committed: Tue Apr 18 13:37:44 2017 +0100 ---------------------------------------------------------------------- .../location/MachineDetailsIntegrationTest.java | 83 ++++++++++++++++++++ .../core/location/MachineDetailsTest.java | 83 -------------------- 2 files changed, 83 insertions(+), 83 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/59623743/core/src/test/java/org/apache/brooklyn/core/location/MachineDetailsIntegrationTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/core/location/MachineDetailsIntegrationTest.java b/core/src/test/java/org/apache/brooklyn/core/location/MachineDetailsIntegrationTest.java new file mode 100644 index 0000000..e54cb08 --- /dev/null +++ b/core/src/test/java/org/apache/brooklyn/core/location/MachineDetailsIntegrationTest.java @@ -0,0 +1,83 @@ +/* + * 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.core.location; + +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNotNull; + +import java.util.Arrays; + +import org.apache.brooklyn.api.location.LocationSpec; +import org.apache.brooklyn.api.location.MachineDetails; +import org.apache.brooklyn.api.location.OsDetails; +import org.apache.brooklyn.api.mgmt.ManagementContext; +import org.apache.brooklyn.api.mgmt.Task; +import org.apache.brooklyn.core.entity.Entities; +import org.apache.brooklyn.core.location.BasicMachineDetails; +import org.apache.brooklyn.core.test.entity.TestApplication; +import org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation; +import org.apache.brooklyn.location.ssh.SshMachineLocation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +public class MachineDetailsIntegrationTest { + + private static final Logger LOG = LoggerFactory.getLogger(MachineDetailsIntegrationTest.class); + + TestApplication app; + ManagementContext mgmt; + SshMachineLocation host; + + @BeforeMethod(alwaysRun=true) + public void setup() throws Exception { + app = TestApplication.Factory.newManagedInstanceForTests(); + mgmt = app.getManagementContext(); + + LocalhostMachineProvisioningLocation localhost = mgmt.getLocationManager().createLocation( + LocationSpec.create(LocalhostMachineProvisioningLocation.class)); + host = localhost.obtain(); + app.start(Arrays.asList(host)); + } + + @AfterMethod(alwaysRun=true) + public void tearDown() throws Exception { + if (mgmt != null) Entities.destroyAll(mgmt); + mgmt = null; + } + + @Test(groups = "Integration") + public void testGetMachineDetails() { + Task<BasicMachineDetails> detailsTask = app.getExecutionContext().submit( + BasicMachineDetails.taskForSshMachineLocation(host)); + MachineDetails machine = detailsTask.getUnchecked(); + LOG.info("Found the following on localhost: {}", machine); + assertNotNull(machine); + OsDetails details = machine.getOsDetails(); + assertNotNull(details); + assertNotNull(details.getArch()); + assertNotNull(details.getName()); + assertNotNull(details.getVersion()); + assertFalse(details.getArch().startsWith("architecture:"), "architecture prefix not removed from details"); + assertFalse(details.getName().startsWith("name:"), "name prefix not removed from details"); + assertFalse(details.getVersion().startsWith("version:"), "version prefix not removed from details"); + } +} http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/59623743/core/src/test/java/org/apache/brooklyn/core/location/MachineDetailsTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/core/location/MachineDetailsTest.java b/core/src/test/java/org/apache/brooklyn/core/location/MachineDetailsTest.java deleted file mode 100644 index d45547e..0000000 --- a/core/src/test/java/org/apache/brooklyn/core/location/MachineDetailsTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * 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.core.location; - -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; - -import java.util.Arrays; - -import org.apache.brooklyn.api.location.LocationSpec; -import org.apache.brooklyn.api.location.MachineDetails; -import org.apache.brooklyn.api.location.OsDetails; -import org.apache.brooklyn.api.mgmt.ManagementContext; -import org.apache.brooklyn.api.mgmt.Task; -import org.apache.brooklyn.core.entity.Entities; -import org.apache.brooklyn.core.location.BasicMachineDetails; -import org.apache.brooklyn.core.test.entity.TestApplication; -import org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation; -import org.apache.brooklyn.location.ssh.SshMachineLocation; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -public class MachineDetailsTest { - - private static final Logger LOG = LoggerFactory.getLogger(MachineDetailsTest.class); - - TestApplication app; - ManagementContext mgmt; - SshMachineLocation host; - - @BeforeMethod(alwaysRun=true) - public void setup() throws Exception { - app = TestApplication.Factory.newManagedInstanceForTests(); - mgmt = app.getManagementContext(); - - LocalhostMachineProvisioningLocation localhost = mgmt.getLocationManager().createLocation( - LocationSpec.create(LocalhostMachineProvisioningLocation.class)); - host = localhost.obtain(); - app.start(Arrays.asList(host)); - } - - @AfterMethod(alwaysRun=true) - public void tearDown() throws Exception { - if (mgmt != null) Entities.destroyAll(mgmt); - mgmt = null; - } - - @Test(groups = "Integration") - public void testGetMachineDetails() { - Task<BasicMachineDetails> detailsTask = app.getExecutionContext().submit( - BasicMachineDetails.taskForSshMachineLocation(host)); - MachineDetails machine = detailsTask.getUnchecked(); - LOG.info("Found the following on localhost: {}", machine); - assertNotNull(machine); - OsDetails details = machine.getOsDetails(); - assertNotNull(details); - assertNotNull(details.getArch()); - assertNotNull(details.getName()); - assertNotNull(details.getVersion()); - assertFalse(details.getArch().startsWith("architecture:"), "architecture prefix not removed from details"); - assertFalse(details.getName().startsWith("name:"), "name prefix not removed from details"); - assertFalse(details.getVersion().startsWith("version:"), "version prefix not removed from details"); - } -}
