maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From khmarba...@apache.org
Subject [4/5] maven git commit: Squashed commit of the following:
Date Sun, 27 Aug 2017 14:46:07 GMT
Squashed commit of the following:

commit c829bdcfc275b207e23fc568b3c16d98195675be
Author: rfscholte <rfscholte@apache.org>
Date:   Thu Aug 24 10:54:08 2017 +0200

    [MNG-6275] ServiceLoaderFactory can't find implementations via ClassRealm


Project: http://git-wip-us.apache.org/repos/asf/maven/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven/commit/f047ea14
Tree: http://git-wip-us.apache.org/repos/asf/maven/tree/f047ea14
Diff: http://git-wip-us.apache.org/repos/asf/maven/diff/f047ea14

Branch: refs/heads/MNG-6216
Commit: f047ea143766fd22ae42040e6805bef287f3cc3e
Parents: 785bad6
Author: rfscholte <rfscholte@apache.org>
Authored: Thu Aug 24 11:33:01 2017 +0200
Committer: rfscholte <rfscholte@apache.org>
Committed: Thu Aug 24 11:33:01 2017 +0200

----------------------------------------------------------------------
 .../classrealm/DefaultClassRealmManager.java    |   2 +-
 .../DefaultClassRealmManagerTest.java           | 101 +++++++++++++++++++
 2 files changed, 102 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven/blob/f047ea14/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java
----------------------------------------------------------------------
diff --git a/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java
b/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java
index 6ce1925..d517924 100644
--- a/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java
+++ b/maven-core/src/main/java/org/apache/maven/classrealm/DefaultClassRealmManager.java
@@ -120,7 +120,7 @@ public class DefaultClassRealmManager
             {
                 try
                 {
-                    ClassRealm classRealm = world.newRealm( realmId, null );
+                    ClassRealm classRealm = world.newRealm( realmId, ClassLoader.getSystemClassLoader()
);
 
                     if ( logger.isDebugEnabled() )
                     {

http://git-wip-us.apache.org/repos/asf/maven/blob/f047ea14/maven-core/src/test/java/org/apache/maven/classrealm/DefaultClassRealmManagerTest.java
----------------------------------------------------------------------
diff --git a/maven-core/src/test/java/org/apache/maven/classrealm/DefaultClassRealmManagerTest.java
b/maven-core/src/test/java/org/apache/maven/classrealm/DefaultClassRealmManagerTest.java
new file mode 100644
index 0000000..726199f
--- /dev/null
+++ b/maven-core/src/test/java/org/apache/maven/classrealm/DefaultClassRealmManagerTest.java
@@ -0,0 +1,101 @@
+package org.apache.maven.classrealm;
+
+/*
+ * 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.
+ */
+
+import java.util.ServiceLoader;
+
+import javax.script.ScriptEngineFactory;
+
+import org.apache.maven.model.Model;
+import org.apache.maven.model.Plugin;
+import org.codehaus.plexus.ContainerConfiguration;
+import org.codehaus.plexus.PlexusConstants;
+import org.codehaus.plexus.PlexusTestCase;
+import org.codehaus.plexus.classworlds.realm.ClassRealm;
+import org.junit.Test;
+
+public class DefaultClassRealmManagerTest extends PlexusTestCase
+{
+    private ClassRealmManager classRealmManager;
+
+    @Override
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+        this.classRealmManager = lookup( ClassRealmManager.class );
+    }
+
+    @Override
+    protected void customizeContainerConfiguration( ContainerConfiguration configuration
)
+    {
+        configuration.setClassPathScanning( PlexusConstants.SCANNING_INDEX );
+    }
+
+    @Test
+    public void testMNG6275_pluginRealmDefaultParentClassLoader()
+    {
+        Plugin plugin = new Plugin();
+        plugin.setVersion( "VERSION" );
+        
+        ClassLoader parent = null;
+        
+        ClassRealm pluginRealm = classRealmManager.createPluginRealm( plugin, parent, null,
null, null );
+        ServiceLoader<ScriptEngineFactory> sef = ServiceLoader.load( ScriptEngineFactory.class,
pluginRealm );
+        assertTrue( sef.iterator().hasNext() );
+    }
+
+    @Test
+    public void testMNG6275_extensionRealmDefaultParentClassLoader()
+    {
+        Plugin extension = new Plugin();
+        extension.setVersion( "VERSION" );
+        
+        ClassRealm extensionRealm = classRealmManager.createExtensionRealm( extension, null
);
+        ServiceLoader<ScriptEngineFactory> sef = ServiceLoader.load( ScriptEngineFactory.class,
extensionRealm );
+        assertTrue( sef.iterator().hasNext() );
+    }
+
+    @Test
+    public void testMNG6275_projectRealmDefaultParentClassLoader()
+    {
+        Model model = new Model();
+        
+        ClassRealm projectRealm = classRealmManager.createProjectRealm( model, null );
+        ServiceLoader<ScriptEngineFactory> sef = ServiceLoader.load( ScriptEngineFactory.class,
projectRealm );
+        assertTrue( sef.iterator().hasNext() );
+    }
+
+    @Test
+    public void testMNG6275_mavenApiRealmDefaultParentClassLoader()
+    {
+        ClassRealm mavenApiRealm = classRealmManager.getMavenApiRealm();
+        ServiceLoader<ScriptEngineFactory> sef = ServiceLoader.load( ScriptEngineFactory.class,
mavenApiRealm );
+        assertTrue( sef.iterator().hasNext() );
+    }
+
+    @Test
+    public void testMNG6275_coreRealmDefaultParentClassLoader()
+    {
+        ClassRealm coreRealm = classRealmManager.getCoreRealm();
+        ServiceLoader<ScriptEngineFactory> sef = ServiceLoader.load( ScriptEngineFactory.class,
coreRealm );
+        assertTrue( sef.iterator().hasNext() );
+    }
+}


Mime
View raw message