@Test public void testChainingString() throws Exception { DynamicStringProperty node1 = new DynamicStringProperty("node1", "v1"); StringProperty node2 = new HystrixPropertiesChainedArchaiusProperty.StringProperty("node2", node1); HystrixPropertiesChainedArchaiusProperty.StringProperty node3 = new HystrixPropertiesChainedArchaiusProperty.StringProperty("node3", node2); assertTrue("" + node3.get(), "v1".equals(node3.get())); ConfigurationManager.getConfigInstance().setProperty("node1", "v11"); assertTrue("v11".equals(node3.get())); ConfigurationManager.getConfigInstance().setProperty("node2", "v22"); assertTrue("v22".equals(node3.get())); ConfigurationManager.getConfigInstance().clearProperty("node1"); assertTrue("v22".equals(node3.get())); ConfigurationManager.getConfigInstance().setProperty("node3", "v33"); assertTrue("v33".equals(node3.get())); ConfigurationManager.getConfigInstance().clearProperty("node2"); assertTrue("v33".equals(node3.get())); ConfigurationManager.getConfigInstance().setProperty("node2", "v222"); assertTrue("v33".equals(node3.get())); ConfigurationManager.getConfigInstance().clearProperty("node3"); assertTrue("v222".equals(node3.get())); ConfigurationManager.getConfigInstance().clearProperty("node2"); assertTrue("v1".equals(node3.get())); ConfigurationManager.getConfigInstance().setProperty("node2", "v2222"); assertTrue("v2222".equals(node3.get())); }
@Override public void run() { logger.debug("Property changed: '{} = {}'", getName(), getValue()); checkAndFlip(); } });
@Test public void testAddCallback() throws Exception { final DynamicStringProperty node1 = new DynamicStringProperty("n1", "n1"); final HystrixPropertiesChainedArchaiusProperty.StringProperty node2 = new HystrixPropertiesChainedArchaiusProperty.StringProperty("n2", node1); final AtomicInteger callbackCount = new AtomicInteger(0); node2.addCallback(new Runnable() { @Override public void run() { callbackCount.incrementAndGet(); } }); assertTrue(0 == callbackCount.get()); assertTrue("n1".equals(node2.get())); assertTrue(0 == callbackCount.get()); ConfigurationManager.getConfigInstance().setProperty("n1", "n11"); assertTrue("n11".equals(node2.get())); assertTrue(0 == callbackCount.get()); ConfigurationManager.getConfigInstance().setProperty("n2", "n22"); assertTrue("n22".equals(node2.get())); assertTrue(1 == callbackCount.get()); ConfigurationManager.getConfigInstance().clearProperty("n1"); assertTrue("n22".equals(node2.get())); assertTrue(1 == callbackCount.get()); ConfigurationManager.getConfigInstance().setProperty("n2", "n222"); assertTrue("n222".equals(node2.get())); assertTrue(2 == callbackCount.get()); ConfigurationManager.getConfigInstance().clearProperty("n2"); assertTrue("n1".equals(node2.get())); assertTrue(3 == callbackCount.get()); }
public StringProperty(DynamicStringProperty sProperty, DynamicStringProperty next) { this(sProperty, new StringProperty(next)); }
public StringProperty(DynamicStringProperty sProperty, StringProperty next) { super(next); // setup next pointer sProp = sProperty; sProp.addCallback(new Runnable() { @Override public void run() { logger.debug("Property changed: '{} = {}'", getName(), getValue()); checkAndFlip(); } }); checkAndFlip(); }
public StringProperty(String name, DynamicStringProperty sProperty) { this(name, new StringProperty(sProperty)); }
@Override public void run() { logger.debug("Property changed: '{} = {}'", getName(), getValue()); checkAndFlip(); } });
public StringProperty(DynamicStringProperty sProperty, DynamicStringProperty next) { this(sProperty, new StringProperty(next)); }
@Test public void testString() throws Exception { DynamicStringProperty pString = new DynamicStringProperty("defaultString", "default-default"); HystrixPropertiesChainedArchaiusProperty.StringProperty fString = new HystrixPropertiesChainedArchaiusProperty.StringProperty("overrideString", pString); assertTrue("default-default".equals(fString.get())); ConfigurationManager.getConfigInstance().setProperty("defaultString", "default"); assertTrue("default".equals(fString.get())); ConfigurationManager.getConfigInstance().setProperty("overrideString", "override"); assertTrue("override".equals(fString.get())); ConfigurationManager.getConfigInstance().clearProperty("overrideString"); assertTrue("default".equals(fString.get())); ConfigurationManager.getConfigInstance().clearProperty("defaultString"); assertTrue("default-default".equals(fString.get())); }
public StringProperty(String name, DynamicStringProperty sProperty) { this(name, new StringProperty(sProperty)); }
public StringProperty(DynamicStringProperty sProperty, StringProperty next) { super(next); // setup next pointer sProp = sProperty; sProp.addCallback(new Runnable() { @Override public void run() { logger.debug("Property changed: '{} = {}'", getName(), getValue()); checkAndFlip(); } }); checkAndFlip(); }