package test.serviceloader;

import org.testng.TestNG;
import org.testng.annotations.Test;

import test.SimpleBaseTest;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;

import junit.framework.Assert;

public class ServiceLoaderTest extends SimpleBaseTest {

  @Test
  public void serviceLoaderShouldWork() throws MalformedURLException {
    TestNG tng = create(ServiceLoaderSampleTest.class);
    String jarPath = getPathToResource("serviceloader.jar");
    URL url = new URL("file://" + new File(jarPath).getAbsolutePath());
    URLClassLoader ucl = URLClassLoader.newInstance(new URL[] { url });
    tng.setServiceLoaderClassLoader(ucl);
    tng.run();

    Assert.assertEquals(1, tng.getServiceLoaderListeners().size());
  }
}

@@ -26,121 +26,8 @@
 r;%0A%0A
-import org.testng.TestNG;%0Aimport org.testng.annotations.Test;%0A%0Aimport test.SimpleBaseTest;%0A%0Aimport java.io.File;%0A
 impo
@@ -107,32 +107,95 @@
 RLClassLoader;%0A%0A
+import org.testng.TestNG;%0Aimport org.testng.annotations.Test;%0A%0A
 import junit.fra
@@ -208,16 +208,44 @@
 .Assert;
+%0Aimport test.SimpleBaseTest;
 %0A%0Apublic
@@ -438,134 +438,77 @@
     
-String jarPath = getPathToResource(%22serviceloader.jar%22);%0A    URL url = new URL(%22file://%22 + new File(jarPath).getAbsolutePath()
+URL url = getClass().getClassLoader().getResource(%22serviceloader.jar%22
 );%0A 

Fix the ServiceLoaderTest.