Github user aledsage commented on a diff in the pull request:
https://github.com/apache/incubator-brooklyn/pull/506#discussion_r24327310
--- Diff:
core/src/test/java/brooklyn/entity/rebind/ActivePartialRebindTest.java ---
@@ -0,0 +1,84 @@
+/*
+ * 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 brooklyn.entity.rebind;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import brooklyn.basic.BrooklynObject;
+import brooklyn.entity.Entity;
+import brooklyn.entity.basic.AbstractEntity;
+import brooklyn.entity.basic.Entities;
+import brooklyn.entity.proxying.EntitySpec;
+import brooklyn.test.entity.TestEntity;
+import brooklyn.util.text.Strings;
+
+public class ActivePartialRebindTest extends RebindTestFixtureWithApp {
+
+ private static final Logger log =
LoggerFactory.getLogger(ActivePartialRebindTest.class);
+
+ protected void doPartialRebindOfIds(String ...objectsToRebindIds) {
+ RebindManagerImpl rm = (RebindManagerImpl)
origManagementContext.getRebindManager();
+ rm.rebindPartialActive(null, objectsToRebindIds);
+ }
+
+ @Test
+ public void testRebindOneSimple() throws Exception {
+ TestEntity c1 =
origApp.addChild(EntitySpec.create(TestEntity.class));
+ Entities.manage(c1);
+ AbstractEntity c1r = Entities.deproxy(c1);
+
+ doPartialRebindOfIds(c1.getId());
+
+ BrooklynObject c2 = origManagementContext.lookup(c1.getId());
+ AbstractEntity c2r = Entities.deproxy((Entity)c2);
+
+ Assert.assertTrue(c2 == c1, "Proxy instance should be the same:
"+c1+" / "+c2);
+ Assert.assertFalse(c2r == c1r, "Real instance should NOT be the
same: "+c1r+" / "+c2r);
+ }
+
+ @Test(groups="Integration")
+ public void testRebindCheckingMemoryLeak() throws Exception {
+ TestEntity c1 =
origApp.addChild(EntitySpec.create(TestEntity.class));
+ Entities.manage(c1);
+ c1.setConfig(TestEntity.CONF_NAME, Strings.makeRandomId(1000000));
+
+ gcAndLog("before");
+ long used0 = Runtime.getRuntime().totalMemory() -
Runtime.getRuntime().freeMemory();
--- End diff --
Minor preference: I'd set assign this to -1 or some such, given it will
always be overwritten when `i==5`.
---
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.
---