This is an automated email from the ASF dual-hosted git repository.

mmerli pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/incubator-pulsar.git

commit e5d3bda9607703c2e012983c7ef64f5eb4118de7
Author: Matteo Merli <mme...@apache.org>
AuthorDate: Mon May 14 13:56:07 2018 -0700

    Removed multifunction.jar from sources (#1774)
    
    * Removed multifunction.jar from sources
    
    * Added test dependency
    
    * Removed test scoped dependency on test examples
    
    * Removed tests
---
 pulsar-functions/pom.xml                           |   2 +-
 pulsar-functions/utils/pom.xml                     |   1 -
 .../functioncache/FunctionCacheEntryTest.java      | 146 -------------------
 .../FunctionCacheManagerImplTest.java              | 162 ---------------------
 .../functioncache/FunctionClassLoadersTest.java    |  56 -------
 .../utils/src/test/resources/multifunction.jar     | Bin 1744 -> 0 bytes
 6 files changed, 1 insertion(+), 366 deletions(-)

diff --git a/pulsar-functions/pom.xml b/pulsar-functions/pom.xml
index 0b84804..682e436 100644
--- a/pulsar-functions/pom.xml
+++ b/pulsar-functions/pom.xml
@@ -35,6 +35,7 @@
     <module>proto</module>
     <module>proto-shaded</module>
     <module>api-java</module>
+    <module>java-examples</module>
     <module>utils</module>
     <module>metrics</module>
     <module>instance</module>
@@ -43,7 +44,6 @@
     <module>runtime-all</module>
     <module>worker</module>
     <module>worker-shaded</module>
-    <module>java-examples</module>
   </modules>
 
   <dependencyManagement>
diff --git a/pulsar-functions/utils/pom.xml b/pulsar-functions/utils/pom.xml
index bc00261..82b798f 100644
--- a/pulsar-functions/utils/pom.xml
+++ b/pulsar-functions/utils/pom.xml
@@ -129,7 +129,6 @@
     <dependency>
       <groupId>io.netty</groupId>
       <artifactId>netty-all</artifactId>
-      <version>4.1.12.Final</version>
     </dependency>
 
     <dependency>
diff --git 
a/pulsar-functions/utils/src/test/java/org/apache/pulsar/functions/utils/functioncache/FunctionCacheEntryTest.java
 
b/pulsar-functions/utils/src/test/java/org/apache/pulsar/functions/utils/functioncache/FunctionCacheEntryTest.java
deleted file mode 100644
index b42be14..0000000
--- 
a/pulsar-functions/utils/src/test/java/org/apache/pulsar/functions/utils/functioncache/FunctionCacheEntryTest.java
+++ /dev/null
@@ -1,146 +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.pulsar.functions.utils.functioncache;
-
-import static org.testng.Assert.fail;
-import static org.testng.AssertJUnit.assertFalse;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.io.IOException;
-import java.net.URI;
-import java.net.URL;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.testng.annotations.Test;
-
-/**
- * Unit test of {@link FunctionCacheEntry}.
- */
-public class FunctionCacheEntryTest {
-
-    private final URL jarUrl;
-    private final Set<String> jarFiles;
-    private final Set<URL> classpaths;
-    private final URL[] libraryUrls;
-
-    public FunctionCacheEntryTest() {
-        this.jarUrl = 
getClass().getClassLoader().getResource("multifunction.jar");
-        this.jarFiles = new HashSet<>();
-        this.jarFiles.add(jarUrl.getPath());
-        this.libraryUrls = new URL[] { jarUrl };
-        this.classpaths = Collections.emptySet();
-    }
-
-    @Test
-    public void testConstructor() {
-        String iid = java.util.UUID.randomUUID().toString();
-        FunctionCacheEntry entry = new FunctionCacheEntry(
-            jarFiles,
-            classpaths,
-            libraryUrls,
-            iid);
-        assertTrue(entry.isInstanceRegistered(iid));
-        entry.close();
-    }
-
-    @Test
-    public void testUnregister() {
-        String iid1 = java.util.UUID.randomUUID().toString();
-        String iid2 = java.util.UUID.randomUUID().toString();
-        FunctionCacheEntry entry = new FunctionCacheEntry(
-            jarFiles,
-            classpaths,
-            libraryUrls,
-            iid1);
-        assertTrue(entry.isInstanceRegistered(iid1));
-        assertFalse(entry.isInstanceRegistered(iid2));
-
-        assertFalse(entry.unregister(iid2));
-        assertTrue(entry.unregister(iid1));
-        assertFalse(entry.isInstanceRegistered(iid1));
-        entry.close();
-    }
-
-    @Test
-    public void testRegisterJarFilesDontMatch() {
-        String iid = java.util.UUID.randomUUID().toString();
-        FunctionCacheEntry entry = new FunctionCacheEntry(
-            jarFiles,
-            classpaths,
-            libraryUrls,
-            iid);
-        String iid2 = java.util.UUID.randomUUID().toString();
-        try {
-            entry.register(
-                iid2,
-                Collections.emptySet(),
-                Collections.emptySet());
-            fail("Should fail to register an instance if jar files don't 
match");
-        } catch (IllegalStateException e) {
-            assertTrue(e.getMessage().contains("jar files"));
-        } finally {
-            entry.close();
-        }
-    }
-
-    @Test
-    public void testRegisterClasspathsDontMatch() throws IOException {
-        String iid = java.util.UUID.randomUUID().toString();
-        FunctionCacheEntry entry = new FunctionCacheEntry(
-            jarFiles,
-            classpaths,
-            libraryUrls,
-            iid);
-        String iid2 = java.util.UUID.randomUUID().toString();
-        try {
-            entry.register(
-                iid2,
-                jarFiles,
-                
Collections.singletonList(URI.create("http://localhost";).toURL()));
-            fail("Should fail to register an instance if jar files don't 
match");
-        } catch (IllegalStateException e) {
-            assertTrue(e.getMessage().contains("classpaths"));
-        } finally {
-            entry.close();
-        }
-    }
-
-    @Test
-    public void testRegister() {
-        String iid1 = java.util.UUID.randomUUID().toString();
-        String iid2 = java.util.UUID.randomUUID().toString();
-        FunctionCacheEntry entry = new FunctionCacheEntry(
-            jarFiles,
-            classpaths,
-            libraryUrls,
-            iid1);
-        assertTrue(entry.isInstanceRegistered(iid1));
-        assertFalse(entry.isInstanceRegistered(iid2));
-
-        entry.register(
-            iid2,
-            jarFiles,
-            classpaths);
-        assertTrue(entry.isInstanceRegistered(iid2));
-        entry.close();
-    }
-}
diff --git 
a/pulsar-functions/utils/src/test/java/org/apache/pulsar/functions/utils/functioncache/FunctionCacheManagerImplTest.java
 
b/pulsar-functions/utils/src/test/java/org/apache/pulsar/functions/utils/functioncache/FunctionCacheManagerImplTest.java
deleted file mode 100644
index 00049d3..0000000
--- 
a/pulsar-functions/utils/src/test/java/org/apache/pulsar/functions/utils/functioncache/FunctionCacheManagerImplTest.java
+++ /dev/null
@@ -1,162 +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.pulsar.functions.utils.functioncache;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertSame;
-import static org.testng.Assert.assertTrue;
-
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.function.Function;
-
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-/**
- * Unit test of {@link FunctionCacheManagerImpl}.
- */
-public class FunctionCacheManagerImplTest {
-
-    private URL jarUrl;
-    private List<String> jarFiles;
-    private List<URL> classpaths;
-    private FunctionCacheManagerImpl cacheManager;
-
-    @BeforeMethod
-    public void setUp() {
-        this.jarUrl = 
getClass().getClassLoader().getResource("multifunction.jar");
-        this.jarFiles = new 
ArrayList<>(Collections.singletonList(jarUrl.getPath()));
-        this.classpaths = Collections.emptyList();
-        this.cacheManager = new FunctionCacheManagerImpl();
-    }
-
-    @AfterMethod
-    public void tearDown() {
-        this.cacheManager.close();
-    }
-
-    void verifyClassLoader(ClassLoader clsLoader) throws Exception {
-        assertNotNull(clsLoader);
-        Class<? extends Function<Integer, Integer>> cls =
-            (Class<? extends Function<Integer, Integer>>)
-                
clsLoader.loadClass("org.apache.pulsar.functions.runtime.functioncache.AddFunction");
-        Function<Integer, Integer> func = cls.newInstance();
-        assertEquals(4, func.apply(2).intValue());
-    }
-
-    @Test(expectedExceptions = NullPointerException.class)
-    public void testGetClassLoaderNullFunctionID() {
-        this.cacheManager.getClassLoader(null);
-    }
-
-    @Test(expectedExceptions = IllegalStateException.class)
-    public void testGetClassLoaderNotFound() {
-        
this.cacheManager.getClassLoader(java.util.UUID.randomUUID().toString());
-    }
-
-    @Test(expectedExceptions = NullPointerException.class)
-    public void testRegisterNullFunctionID() throws Exception {
-        this.cacheManager.registerFunctionInstance(
-            null,
-                java.util.UUID.randomUUID().toString(),
-            Collections.emptyList(),
-            Collections.emptyList());
-    }
-
-    @Test
-    public void testRegister() throws Exception {
-        String fid = java.util.UUID.randomUUID().toString();
-        String eid = java.util.UUID.randomUUID().toString();
-        this.cacheManager.registerFunctionInstance(fid, eid,
-            jarFiles,
-            classpaths);
-
-        assertEquals(1, cacheManager.getCacheFunctions().size());
-        FunctionCacheEntry entry = cacheManager.getCacheFunctions().get(fid);
-        assertNotNull(entry);
-        assertTrue(entry.isInstanceRegistered(eid));
-        verifyClassLoader(cacheManager.getClassLoader(fid));
-    }
-
-    @Test
-    public void testRegisterTwoInstances() throws Exception {
-        String fid = java.util.UUID.randomUUID().toString();
-        String iid1 = java.util.UUID.randomUUID().toString();
-        String iid2 = java.util.UUID.randomUUID().toString();
-
-        this.cacheManager.registerFunctionInstance(
-            fid,
-            iid1,
-            jarFiles,
-            classpaths);
-
-        assertEquals(1, cacheManager.getCacheFunctions().size());
-        FunctionCacheEntry entry1 = cacheManager.getCacheFunctions().get(fid);
-        assertNotNull(entry1);
-        assertTrue(entry1.isInstanceRegistered(iid1));
-        verifyClassLoader(cacheManager.getClassLoader(fid));
-
-        this.cacheManager.registerFunctionInstance(
-            fid,
-            iid2,
-            jarFiles,
-            classpaths);
-
-        assertEquals(1, cacheManager.getCacheFunctions().size());
-        FunctionCacheEntry entry2 = cacheManager.getCacheFunctions().get(fid);
-        assertNotNull(entry2);
-        assertSame(entry1, entry2);
-        assertTrue(entry1.isInstanceRegistered(iid2));
-    }
-
-    @Test
-    public void testUnregister() throws Exception {
-        String fid = java.util.UUID.randomUUID().toString();
-        String iid = java.util.UUID.randomUUID().toString();
-
-        this.cacheManager.registerFunctionInstance(
-            fid,
-            iid,
-            jarFiles,
-            classpaths);
-
-        assertEquals(1, cacheManager.getCacheFunctions().size());
-        FunctionCacheEntry entry = cacheManager.getCacheFunctions().get(fid);
-        assertNotNull(entry);
-        assertTrue(entry.isInstanceRegistered(iid));
-        verifyClassLoader(cacheManager.getClassLoader(fid));
-
-        this.cacheManager.unregisterFunctionInstance(
-            fid,
-            iid);
-
-        assertEquals(0, cacheManager.getCacheFunctions().size());
-        assertNull(cacheManager.getCacheFunctions().get(fid));
-        assertFalse(entry.isInstanceRegistered(iid));
-    }
-
-}
diff --git 
a/pulsar-functions/utils/src/test/java/org/apache/pulsar/functions/utils/functioncache/FunctionClassLoadersTest.java
 
b/pulsar-functions/utils/src/test/java/org/apache/pulsar/functions/utils/functioncache/FunctionClassLoadersTest.java
deleted file mode 100644
index cfd5203..0000000
--- 
a/pulsar-functions/utils/src/test/java/org/apache/pulsar/functions/utils/functioncache/FunctionClassLoadersTest.java
+++ /dev/null
@@ -1,56 +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.pulsar.functions.utils.functioncache;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertSame;
-
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.function.Function;
-import org.testng.annotations.Test;
-
-/**
- * Unit test of {@link FunctionClassLoaders}.
- */
-public class FunctionClassLoadersTest {
-
-    @Test
-    public void testCreateClassLoader() throws Exception {
-        URL jarUrl = 
getClass().getClassLoader().getResource("multifunction.jar");
-        ClassLoader parent = getClass().getClassLoader();
-        URLClassLoader clsLoader = FunctionClassLoaders.create(
-            new URL[] { jarUrl },
-            parent);
-        assertSame(parent, clsLoader.getParent());
-        Class<? extends Function<Integer, Integer>> cls =
-            (Class<? extends Function<Integer, Integer>>)
-                
clsLoader.loadClass("org.apache.pulsar.functions.runtime.functioncache.AddFunction");
-        Function<Integer, Integer> func = cls.newInstance();
-        assertEquals(4, func.apply(2).intValue());
-    }
-
-    @Test(expectedExceptions = ClassNotFoundException.class)
-    public void testClassNotFound() throws Exception {
-        ClassLoader clsLoader = getClass().getClassLoader();
-        
clsLoader.loadClass("org.apache.pulsar.functions.runtime.functioncache.AddFunction");
-    }
-
-}
diff --git a/pulsar-functions/utils/src/test/resources/multifunction.jar 
b/pulsar-functions/utils/src/test/resources/multifunction.jar
deleted file mode 100644
index 9f8e181..0000000
Binary files a/pulsar-functions/utils/src/test/resources/multifunction.jar and 
/dev/null differ

-- 
To stop receiving notification emails like this one, please contact
mme...@apache.org.

Reply via email to