brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From drigod...@apache.org
Subject [1/2] brooklyn-server git commit: BROOKLYN-499: avoid log.warn “no-arg constructor accessible”
Date Fri, 26 May 2017 14:42:40 GMT
Repository: brooklyn-server
Updated Branches:
  refs/heads/master 0fe535e36 -> e69da19f9


BROOKLYN-499: avoid log.warn “no-arg constructor accessible”

Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/0e16b2ec
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/0e16b2ec
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/0e16b2ec

Branch: refs/heads/master
Commit: 0e16b2ec47f5e14bf2f295c806180a9be65b3d5a
Parents: 75e8cc8
Author: Aled Sage <aled.sage@gmail.com>
Authored: Thu May 25 16:10:38 2017 +0100
Committer: Aled Sage <aled.sage@gmail.com>
Committed: Thu May 25 16:10:38 2017 +0100

----------------------------------------------------------------------
 .../software/base/SoftwareProcessImpl.java      | 16 +++--
 .../entity/machine/MachineEntityRebindTest.java | 72 +++++++++++++++++---
 2 files changed, 76 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/0e16b2ec/software/base/src/main/java/org/apache/brooklyn/entity/software/base/SoftwareProcessImpl.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/org/apache/brooklyn/entity/software/base/SoftwareProcessImpl.java
b/software/base/src/main/java/org/apache/brooklyn/entity/software/base/SoftwareProcessImpl.java
index 89e49dd..ea31359 100644
--- a/software/base/src/main/java/org/apache/brooklyn/entity/software/base/SoftwareProcessImpl.java
+++ b/software/base/src/main/java/org/apache/brooklyn/entity/software/base/SoftwareProcessImpl.java
@@ -131,9 +131,12 @@ public abstract class SoftwareProcessImpl extends AbstractEntity implements
Soft
     }
     
     /**
+     * This class should be considered internal, and not instantiated directly. It is only
public 
+     * to better support rebind.
+     * 
      * @since 0.8.0
      */
-    protected static class ServiceNotUpDiagnosticsCollector extends AbstractEnricher implements
SensorEventListener<Object> {
+    public static class ServiceNotUpDiagnosticsCollector extends AbstractEnricher implements
SensorEventListener<Object> {
         public ServiceNotUpDiagnosticsCollector() {
         }
         
@@ -207,10 +210,15 @@ public abstract class SoftwareProcessImpl extends AbstractEntity implements
Soft
         }
     }
 
-    /** subscribes to SERVICE_PROCESS_IS_RUNNING and SERVICE_UP; the latter has no effect
if the former is set,
+    /**
+     * Subscribes to SERVICE_PROCESS_IS_RUNNING and SERVICE_UP; the latter has no effect
if the former is set,
      * but to support entities which set SERVICE_UP directly we want to make sure that the
absence of 
-     * SERVICE_PROCESS_IS_RUNNING does not trigger any not-up indicators */
-    protected static class UpdatingNotUpFromServiceProcessIsRunning extends AbstractEnricher
implements SensorEventListener<Object> {
+     * SERVICE_PROCESS_IS_RUNNING does not trigger any not-up indicators.
+     * 
+     * This class should be considered internal, and not instantiated directly. It is only
public 
+     * to better support rebind.
+     */
+    public static class UpdatingNotUpFromServiceProcessIsRunning extends AbstractEnricher
implements SensorEventListener<Object> {
         public UpdatingNotUpFromServiceProcessIsRunning() {}
         
         @Override

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/0e16b2ec/software/base/src/test/java/org/apache/brooklyn/entity/machine/MachineEntityRebindTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/org/apache/brooklyn/entity/machine/MachineEntityRebindTest.java
b/software/base/src/test/java/org/apache/brooklyn/entity/machine/MachineEntityRebindTest.java
index f9f9d41..1ad5dfe 100644
--- a/software/base/src/test/java/org/apache/brooklyn/entity/machine/MachineEntityRebindTest.java
+++ b/software/base/src/test/java/org/apache/brooklyn/entity/machine/MachineEntityRebindTest.java
@@ -18,33 +18,89 @@
  */
 package org.apache.brooklyn.entity.machine;
 
+import static org.testng.Assert.assertTrue;
+
+import java.util.List;
+
 import org.apache.brooklyn.api.entity.Entity;
 import org.apache.brooklyn.api.entity.EntitySpec;
 import org.apache.brooklyn.api.location.LocationSpec;
 import org.apache.brooklyn.core.entity.Attributes;
+import org.apache.brooklyn.core.entity.BrooklynConfigKeys;
 import org.apache.brooklyn.core.entity.EntityAsserts;
 import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
 import org.apache.brooklyn.core.mgmt.rebind.RebindTestFixtureWithApp;
+import org.apache.brooklyn.core.objs.proxy.InternalFactory;
 import org.apache.brooklyn.location.ssh.SshMachineLocation;
+import org.apache.brooklyn.test.LogWatcher;
 import org.apache.brooklyn.util.core.internal.ssh.RecordingSshTool;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
 import com.google.common.collect.ImmutableList;
 
+import ch.qos.logback.classic.spi.ILoggingEvent;
+
 public class MachineEntityRebindTest extends RebindTestFixtureWithApp {
 
-    @Test
-    public void testRebindToMachineEntity() throws Exception {
-        SshMachineLocation loc = mgmt().getLocationManager().createLocation(LocationSpec.create(SshMachineLocation.class)
+    private SshMachineLocation origMachine;
+
+    @BeforeMethod(alwaysRun=true)
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
+        
+        origMachine = mgmt().getLocationManager().createLocation(LocationSpec.create(SshMachineLocation.class)
                 .configure("address", "localhost")
                 .configure(SshMachineLocation.SSH_TOOL_CLASS, RecordingSshTool.class.getName()));
-        MachineEntity machine = origApp.createAndManageChild(EntitySpec.create(MachineEntity.class));
-        origApp.start(ImmutableList.of(loc));
-        EntityAsserts.assertAttributeEqualsEventually(machine, Attributes.SERVICE_STATE_ACTUAL,
Lifecycle.RUNNING);
+    }
+    
+    @AfterMethod(alwaysRun=true)
+    @Override
+    public void tearDown() throws Exception {
+        try {
+            super.tearDown();
+        } finally {
+            RecordingSshTool.clear();
+        }
+    }
+    
+    @Test
+    public void testRebindToMachineEntity() throws Exception {
+        MachineEntity entity = origApp.createAndManageChild(EntitySpec.create(MachineEntity.class)
+                .configure(BrooklynConfigKeys.SKIP_ON_BOX_BASE_DIR_RESOLUTION, true));
+        origApp.start(ImmutableList.of(origMachine));
+        EntityAsserts.assertAttributeEqualsEventually(entity, Attributes.SERVICE_STATE_ACTUAL,
Lifecycle.RUNNING);
         
         rebind();
         
-        Entity machine2 = mgmt().getEntityManager().getEntity(machine.getId());
-        EntityAsserts.assertAttributeEqualsEventually(machine2, Attributes.SERVICE_STATE_ACTUAL,
Lifecycle.RUNNING);
+        Entity newEntity = mgmt().getEntityManager().getEntity(entity.getId());
+        EntityAsserts.assertAttributeEqualsEventually(newEntity, Attributes.SERVICE_STATE_ACTUAL,
Lifecycle.RUNNING);
+    }
+    
+    @Test
+    public void testNoLogWarningsWhenRebindToMachineEntity() throws Exception {
+        String loggerName = InternalFactory.class.getName();
+        ch.qos.logback.classic.Level logLevel = ch.qos.logback.classic.Level.WARN;
+        Predicate<ILoggingEvent> filter = Predicates.alwaysTrue();
+        LogWatcher watcher = new LogWatcher(loggerName, logLevel, filter);
+
+        watcher.start();
+        try {
+            origApp.createAndManageChild(EntitySpec.create(MachineEntity.class)
+                    .configure(BrooklynConfigKeys.SKIP_ON_BOX_BASE_DIR_RESOLUTION, true));
+            origApp.start(ImmutableList.of(origMachine));
+            
+            rebind();
+        
+            List<ILoggingEvent> events = watcher.getEvents();
+            assertTrue(events.isEmpty(), "events="+events);
+            
+        } finally {
+            watcher.close();
+        }
     }
 }


Mime
View raw message