Repository: brooklyn-server Updated Branches: refs/heads/master 78f41f8d6 -> 68babc6f2
Rename to AbstractRebindHistoricTest (from RebindAbstractCommandFeedTest), and support getPersistanceFile for more types Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/749a96fe Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/749a96fe Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/749a96fe Branch: refs/heads/master Commit: 749a96fef7ebd361894a84b5055614c9ee0218fb Parents: 78f41f8 Author: Aled Sage <[email protected]> Authored: Thu Jun 8 14:52:35 2017 +0100 Committer: Aled Sage <[email protected]> Committed: Fri Jun 9 17:50:04 2017 +0100 ---------------------------------------------------------------------- .../mgmt/rebind/AbstractRebindHistoricTest.java | 66 ++++++++++++++++++++ .../rebind/RebindAbstractCommandFeedTest.java | 61 ------------------ .../mgmt/rebind/RebindHistoricSshFeedTest.java | 2 +- ...RebindWindowsPerformanceCounterFeedTest.java | 4 +- .../feed/windows/RebindWinrmCmdFeedTest.java | 4 +- 5 files changed, 71 insertions(+), 66 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/749a96fe/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/AbstractRebindHistoricTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/AbstractRebindHistoricTest.java b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/AbstractRebindHistoricTest.java new file mode 100644 index 0000000..1a0face --- /dev/null +++ b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/AbstractRebindHistoricTest.java @@ -0,0 +1,66 @@ +/* + * 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.mgmt.rebind; + +import com.google.common.io.Files; +import org.apache.brooklyn.api.mgmt.rebind.RebindExceptionHandler; +import org.apache.brooklyn.api.mgmt.rebind.RebindManager; +import org.apache.brooklyn.api.objs.BrooklynObjectType; +import org.apache.brooklyn.core.test.entity.TestApplication; +import org.apache.brooklyn.util.os.Os; +import org.apache.brooklyn.util.stream.Streams; + +import java.io.File; + +public abstract class AbstractRebindHistoricTest extends RebindTestFixtureWithApp { + + @Override + protected TestApplication rebind() throws Exception { + RebindExceptionHandler exceptionHandler = RebindExceptionHandlerImpl.builder() + .danglingRefFailureMode(RebindManager.RebindFailureMode.FAIL_AT_END) + .rebindFailureMode(RebindManager.RebindFailureMode.FAIL_AT_END) + .addConfigFailureMode(RebindManager.RebindFailureMode.FAIL_AT_END) + .addPolicyFailureMode(RebindManager.RebindFailureMode.FAIL_AT_END) + .loadPolicyFailureMode(RebindManager.RebindFailureMode.FAIL_AT_END) + .build(); + return super.rebind(RebindOptions.create().exceptionHandler(exceptionHandler)); + } + + protected void addMemento(BrooklynObjectType type, String label, String id) throws Exception { + String mementoFilename = label+"-"+id; + String memento = Streams.readFullyString(getClass().getResourceAsStream(mementoFilename)); + + File persistedFile = getPersistanceFile(type, id); + Files.write(memento.getBytes(), persistedFile); + } + + protected File getPersistanceFile(BrooklynObjectType type, String id) { + String dir; + switch (type) { + case ENTITY: dir = "entities"; break; + case LOCATION: dir = "locations"; break; + case POLICY: dir = "policies"; break; + case ENRICHER: dir = "enrichers"; break; + case FEED: dir = "feeds"; break; + case CATALOG_ITEM: dir = "catalog"; break; + default: throw new UnsupportedOperationException("type="+type); + } + return new File(mementoDir, Os.mergePaths(dir, id)); + } +} http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/749a96fe/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindAbstractCommandFeedTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindAbstractCommandFeedTest.java b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindAbstractCommandFeedTest.java deleted file mode 100644 index 2c419a1..0000000 --- a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindAbstractCommandFeedTest.java +++ /dev/null @@ -1,61 +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.mgmt.rebind; - -import com.google.common.io.Files; -import org.apache.brooklyn.api.mgmt.rebind.RebindExceptionHandler; -import org.apache.brooklyn.api.mgmt.rebind.RebindManager; -import org.apache.brooklyn.api.objs.BrooklynObjectType; -import org.apache.brooklyn.core.test.entity.TestApplication; -import org.apache.brooklyn.util.os.Os; -import org.apache.brooklyn.util.stream.Streams; - -import java.io.File; - -public abstract class RebindAbstractCommandFeedTest extends RebindTestFixtureWithApp { - - @Override - protected TestApplication rebind() throws Exception { - RebindExceptionHandler exceptionHandler = RebindExceptionHandlerImpl.builder() - .danglingRefFailureMode(RebindManager.RebindFailureMode.FAIL_AT_END) - .rebindFailureMode(RebindManager.RebindFailureMode.FAIL_AT_END) - .addConfigFailureMode(RebindManager.RebindFailureMode.FAIL_AT_END) - .addPolicyFailureMode(RebindManager.RebindFailureMode.FAIL_AT_END) - .loadPolicyFailureMode(RebindManager.RebindFailureMode.FAIL_AT_END) - .build(); - return super.rebind(RebindOptions.create().exceptionHandler(exceptionHandler)); - } - - protected void addMemento(BrooklynObjectType type, String label, String id) throws Exception { - String mementoFilename = label+"-"+id; - String memento = Streams.readFullyString(getClass().getResourceAsStream(mementoFilename)); - - File persistedFile = getPersistanceFile(type, id); - Files.write(memento.getBytes(), persistedFile); - } - - protected File getPersistanceFile(BrooklynObjectType type, String id) { - String dir; - switch (type) { - case FEED: dir = "feeds"; break; - default: throw new UnsupportedOperationException("type="+type); - } - return new File(mementoDir, Os.mergePaths(dir, id)); - } -} http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/749a96fe/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindHistoricSshFeedTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindHistoricSshFeedTest.java b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindHistoricSshFeedTest.java index a612bb0..3043406 100644 --- a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindHistoricSshFeedTest.java +++ b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindHistoricSshFeedTest.java @@ -22,7 +22,7 @@ import org.apache.brooklyn.api.objs.BrooklynObjectType; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -public class RebindHistoricSshFeedTest extends RebindAbstractCommandFeedTest { +public class RebindHistoricSshFeedTest extends AbstractRebindHistoricTest { @Override @BeforeMethod(alwaysRun=true) public void setUp() throws Exception { http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/749a96fe/software/winrm/src/test/java/org/apache/brooklyn/feed/windows/RebindWindowsPerformanceCounterFeedTest.java ---------------------------------------------------------------------- diff --git a/software/winrm/src/test/java/org/apache/brooklyn/feed/windows/RebindWindowsPerformanceCounterFeedTest.java b/software/winrm/src/test/java/org/apache/brooklyn/feed/windows/RebindWindowsPerformanceCounterFeedTest.java index 9549fd5..fece5e6 100644 --- a/software/winrm/src/test/java/org/apache/brooklyn/feed/windows/RebindWindowsPerformanceCounterFeedTest.java +++ b/software/winrm/src/test/java/org/apache/brooklyn/feed/windows/RebindWindowsPerformanceCounterFeedTest.java @@ -19,10 +19,10 @@ package org.apache.brooklyn.feed.windows; import org.apache.brooklyn.api.objs.BrooklynObjectType; -import org.apache.brooklyn.core.mgmt.rebind.RebindAbstractCommandFeedTest; +import org.apache.brooklyn.core.mgmt.rebind.AbstractRebindHistoricTest; import org.testng.annotations.Test; -public class RebindWindowsPerformanceCounterFeedTest extends RebindAbstractCommandFeedTest { +public class RebindWindowsPerformanceCounterFeedTest extends AbstractRebindHistoricTest { @Test public void testWindowsPerformanceCounterFeed_2017_06() throws Exception { http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/749a96fe/software/winrm/src/test/java/org/apache/brooklyn/feed/windows/RebindWinrmCmdFeedTest.java ---------------------------------------------------------------------- diff --git a/software/winrm/src/test/java/org/apache/brooklyn/feed/windows/RebindWinrmCmdFeedTest.java b/software/winrm/src/test/java/org/apache/brooklyn/feed/windows/RebindWinrmCmdFeedTest.java index 70aed9b..e73cd53 100644 --- a/software/winrm/src/test/java/org/apache/brooklyn/feed/windows/RebindWinrmCmdFeedTest.java +++ b/software/winrm/src/test/java/org/apache/brooklyn/feed/windows/RebindWinrmCmdFeedTest.java @@ -19,10 +19,10 @@ package org.apache.brooklyn.feed.windows; import org.apache.brooklyn.api.objs.BrooklynObjectType; -import org.apache.brooklyn.core.mgmt.rebind.RebindAbstractCommandFeedTest; +import org.apache.brooklyn.core.mgmt.rebind.AbstractRebindHistoricTest; import org.testng.annotations.Test; -public class RebindWinrmCmdFeedTest extends RebindAbstractCommandFeedTest { +public class RebindWinrmCmdFeedTest extends AbstractRebindHistoricTest { @Test public void testWinrmCmdFeed_2017_04() throws Exception {
