You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by tb...@apache.org on 2017/10/17 09:19:32 UTC

[2/6] brooklyn-server git commit: Delete RebindCatalogEntityTest

Delete RebindCatalogEntityTest

Was testing use of catalog class loader, not OSGi, with catalog item
requiring custom class loader being added programmatically via 
catalog.addItem() and then fiddling with catalog on rebind to add it 
back in!

No user should be doing that; the test is not something we want to
support.

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

Branch: refs/heads/master
Commit: 4ef74facfecefe4a265dc9dda81a8746ceb5f66d
Parents: 802cbb9
Author: Aled Sage <al...@gmail.com>
Authored: Wed Oct 4 10:36:19 2017 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Tue Oct 17 09:02:51 2017 +0100

----------------------------------------------------------------------
 .../mgmt/rebind/RebindCatalogEntityTest.java    | 153 -------------------
 1 file changed, 153 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/4ef74fac/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindCatalogEntityTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindCatalogEntityTest.java b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindCatalogEntityTest.java
deleted file mode 100644
index b53d92c..0000000
--- a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindCatalogEntityTest.java
+++ /dev/null
@@ -1,153 +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 static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertNotSame;
-
-import java.io.Closeable;
-import java.net.URL;
-import java.util.List;
-
-import org.apache.brooklyn.api.entity.Application;
-import org.apache.brooklyn.api.entity.EntitySpec;
-import org.apache.brooklyn.api.mgmt.ha.ManagementNodeState;
-import org.apache.brooklyn.core.catalog.internal.CatalogInitialization;
-import org.apache.brooklyn.core.config.ConfigKeys;
-import org.apache.brooklyn.core.entity.AbstractApplication;
-import org.apache.brooklyn.core.entity.Entities;
-import org.apache.brooklyn.core.entity.EntityInternal;
-import org.apache.brooklyn.core.entity.StartableApplication;
-import org.apache.brooklyn.core.mgmt.internal.LocalManagementContext;
-import org.apache.brooklyn.core.sensor.Sensors;
-import org.apache.brooklyn.test.support.TestResourceUnavailableException;
-import org.apache.brooklyn.util.core.javalang.UrlClassLoader;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Function;
-
-public class RebindCatalogEntityTest extends RebindTestFixture<StartableApplication> {
-
-    @SuppressWarnings("unused")
-    private static final Logger LOG = LoggerFactory.getLogger(RebindCatalogEntityTest.class);
-
-    /*
-     * Code contained in brooklyn-AppInCatalog.jar is:
-     * 
-     * package brooklyn.entity.rebind;
-     * public class AppInCatalog extends AbstractApplication {
-     *     public static final ConfigKey<String> MY_CONF = ConfigKeys.newStringConfigKey("myconf");
-     *     public static final AttributeSensor<String> MY_SENSOR = Sensors.newStringSensor("mysensor");
-     * }
-     */
-
-    private static final String JAR_PATH = "/org/apache/brooklyn/core/test/rebind/sample-app-in-catalog/brooklyn-AppInCatalog.jar";
-    private static final String APP_CLASSNAME = "org.apache.brooklyn.core.test.rebind.sample_app_in_catalog.AppInCatalog";
-
-    private URL url;
-
-    @Override
-    protected boolean useEmptyCatalog() {
-        return true;
-    }
-
-    @Override
-    protected StartableApplication createApp() {
-        // do nothing here
-        return null;
-    }
-    
-    @BeforeMethod(alwaysRun=true)
-    @Override
-    public void setUp() throws Exception {
-        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), JAR_PATH);
-        url = getClass().getResource(JAR_PATH);
-        assertNotNull(url, "Could not find on classpath: "+JAR_PATH);
-        super.setUp();
-    }
-
-    // TODO Failed in jenkins (once on 20141104, with invocationCount=100): mysensor was null post-rebind.
-    //
-    // Note: to test before/after behaviour (i.e. that we're really fixing what we think we are) then comment out the body of:
-    //       AbstractMemento.injectTypeClass(Class)
-    //
-    // NB: this behaviour is generally deprecated in favour of OSGi now.
-    @SuppressWarnings("resource")
-    @Test 
-    public void testRestoresAppFromCatalogClassloader() throws Exception {
-        @SuppressWarnings("unchecked")
-        Class<? extends AbstractApplication> appClazz = (Class<? extends AbstractApplication>) new UrlClassLoader(url).loadClass(APP_CLASSNAME);
-        origManagementContext.getCatalog().addItem(appClazz);
-        
-        EntitySpec<StartableApplication> appSpec = EntitySpec.create(StartableApplication.class, appClazz)
-                .configure("myconf", "myconfval");
-        origApp = origManagementContext.getEntityManager().createEntity(appSpec);
-        ((EntityInternal)origApp).sensors().set(Sensors.newStringSensor("mysensor"), "mysensorval");
-        
-        newApp = rebindWithAppClass();
-        Entities.dumpInfo(newApp);
-        assertNotSame(newApp, origApp);
-        assertEquals(newApp.getId(), origApp.getId());
-        assertEquals(newApp.getClass().getName(), APP_CLASSNAME);
-        assertEquals(newApp.getEntityType().getName(), APP_CLASSNAME);
-        assertEquals(newApp.getAttribute(Sensors.newStringSensor("mysensor")), "mysensorval");
-        assertEquals(newApp.getConfig(ConfigKeys.newStringConfigKey("myconf")), "myconfval");
-    }
-    
-    @Test(invocationCount=100, groups="Integration")
-    public void testRestoresAppFromCatalogClassloaderManyTimes() throws Exception {
-        // Need to fix package name and rebuild brooklyn-AppInCatalog.jar
-        //  or better add it as a new test-bundles subproject
-        testRestoresAppFromCatalogClassloader();
-    }
-    
-    // TODO Not using RebindTestUtils.rebind(mementoDir, getClass().getClassLoader());
-    //      because that won't have right catalog classpath.
-    //      How to reuse that code cleanly?
-    protected StartableApplication rebindWithAppClass() throws Exception {
-        RebindTestUtils.stopPersistence(origApp);
-        LocalManagementContext newManagementContext = RebindTestUtils.newPersistingManagementContextUnstarted(mementoDir, classLoader);
-
-        UrlClassLoader ucl = new UrlClassLoader(url);
-        @SuppressWarnings("unchecked")
-        final Class<? extends AbstractApplication> appClazz = (Class<? extends AbstractApplication>) ucl.loadClass(APP_CLASSNAME);
-        // ucl.close is only introduced in java 1.7
-        if (ucl instanceof Closeable) ((Closeable)ucl).close();
-
-        newManagementContext.getCatalogInitialization().addPopulationCallback(new Function<CatalogInitialization, Void>() {
-            @Override
-            public Void apply(CatalogInitialization input) {
-                newManagementContext.getCatalog().addItem(appClazz);
-                return null;
-            }
-        });
-        
-        ClassLoader classLoader = newManagementContext.getCatalog().getRootClassLoader();
-        
-        classLoader.loadClass(appClazz.getName());
-        List<Application> newApps = newManagementContext.getRebindManager().rebind(classLoader, null, ManagementNodeState.MASTER);
-        newManagementContext.getRebindManager().startPersistence();
-        return (StartableApplication) newApps.get(0);
-    }
-
-}
\ No newline at end of file