package com.example.rest;
import jakarta.ws.rs.ApplicationPath;
import jakarta.ws.rs.core.Application;
@ApplicationPath("/api")
public class MyApplication extends Application {
}
package com.example.test;
import org.junit.Test;
import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.ServiceReference;
import com.example.rest.MyApplication;
public class MyApplicationTest {
private BundleContext bundleContext;
public MyApplicationTest() {
bundleContext = FrameworkUtil.getBundle(MyApplicationTest.class).getBundleContext();
}
@Test
public void testRestfulAPI() {
ServiceReference<MyApplication> serviceRef = bundleContext.getServiceReference(MyApplication.class);
MyApplication myApp = bundleContext.getService(serviceRef);
}
}