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

    https://github.com/apache/brooklyn-server/pull/342#discussion_r80077697
  
    --- Diff: 
core/src/test/java/org/apache/brooklyn/core/mgmt/internal/LocalUsageManagerTest.java
 ---
    @@ -16,67 +16,77 @@
      * specific language governing permissions and limitations
      * under the License.
      */
    -package org.apache.brooklyn.entity.software.base.test.core.mgmt.usage;
    +
    +package org.apache.brooklyn.core.mgmt.internal;
     
     import static org.testng.Assert.assertTrue;
     
     import java.util.List;
     
    -import org.apache.brooklyn.test.Asserts;
    -import org.slf4j.Logger;
    -import org.slf4j.LoggerFactory;
    -import org.testng.annotations.AfterMethod;
    -import org.testng.annotations.BeforeMethod;
    -import org.testng.annotations.Test;
     import org.apache.brooklyn.api.location.Location;
    -import org.apache.brooklyn.core.entity.Entities;
     import org.apache.brooklyn.core.internal.BrooklynProperties;
    -import org.apache.brooklyn.core.mgmt.internal.ManagementContextInternal;
    +import org.apache.brooklyn.core.mgmt.usage.RecordingUsageListener;
     import org.apache.brooklyn.core.mgmt.usage.UsageListener;
     import org.apache.brooklyn.core.mgmt.usage.UsageManager;
    +import org.apache.brooklyn.core.test.BrooklynAppUnitTestSupport;
     import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests;
     import org.apache.brooklyn.core.test.entity.TestApplication;
    +import org.apache.brooklyn.test.Asserts;
    +import org.testng.annotations.AfterMethod;
    +import org.testng.annotations.BeforeMethod;
    +import org.testng.annotations.Test;
     
     import com.google.common.collect.ImmutableList;
     import com.google.common.collect.Iterables;
     import com.google.common.collect.Lists;
     
    -public class UsageListenerTest {
    +public class LocalUsageManagerTest extends BrooklynAppUnitTestSupport {
     
         // Also see {Application|Location}UsageTrackingTest for listener 
functionality
    -    
    -    private static final Logger LOG = 
LoggerFactory.getLogger(ApplicationUsageTrackingTest.class);
    -
    -    protected TestApplication app;
    -    protected ManagementContextInternal mgmt;
     
    +    @Override
         protected boolean shouldSkipOnBoxBaseDirResolution() {
             return true;
         }
     
    +    @Override
         @BeforeMethod(alwaysRun=true)
         public void setUp() throws Exception {
             RecordingStaticUsageListener.clearInstances();
    +        super.setUp();
         }
     
    +    @Override
         @AfterMethod(alwaysRun=true)
         public void tearDown() throws Exception {
    -        try {
    -            if (mgmt != null) Entities.destroyAll(mgmt);
    -        } catch (Throwable t) {
    -            LOG.error("Caught exception in tearDown method", t);
    -        } finally {
    -            mgmt = null;
    -            RecordingStaticUsageListener.clearInstances();
    -        }
    +        super.tearDown();
    +        RecordingStaticUsageListener.clearInstances();
    +    }
    +
    +    @Test
    +    public void testAddUsageListenerInstance() throws Exception {
    +        BrooklynProperties brooklynProperties = 
BrooklynProperties.Factory.newEmpty();
    +        brooklynProperties.put(UsageManager.USAGE_LISTENERS, 
ImmutableList.of(new RecordingStaticUsageListener()));
    +        mgmt = 
LocalManagementContextForTests.newInstance(brooklynProperties);
    +        assertUsageListenerCalledWhenApplicationStarted();
         }
     
         @Test
         public void testAddUsageListenerViaProperties() throws Exception {
             BrooklynProperties brooklynProperties = 
BrooklynProperties.Factory.newEmpty();
             brooklynProperties.put(UsageManager.USAGE_LISTENERS, 
RecordingStaticUsageListener.class.getName());
             mgmt = 
LocalManagementContextForTests.newInstance(brooklynProperties);
    -        
    +        assertUsageListenerCalledWhenApplicationStarted();
    +    }
    +
    +    @Test(expectedExceptions = ClassCastException   .class)
    --- End diff --
    
    Accidental tab. Why doesn't GitHub show I've fixed this any more?


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to