[ARIES-2002] test for unproxying of getSingletons
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/cxf/CxfJaxrsServiceRegistrator.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/cxf/CxfJaxrsServiceRegistrator.java
index 22dfc88..760a94a 100644
--- a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/cxf/CxfJaxrsServiceRegistrator.java
+++ b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/cxf/CxfJaxrsServiceRegistrator.java
@@ -30,7 +30,6 @@
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -46,7 +45,6 @@
 import javax.ws.rs.core.Feature;
 import javax.ws.rs.core.FeatureContext;
 import javax.ws.rs.ext.Provider;
-import javax.ws.rs.ext.RuntimeDelegate;
 
 import org.apache.aries.component.dsl.CachingServiceReference;
 import org.apache.aries.component.dsl.OSGi;
@@ -269,6 +267,9 @@
             bean.getProperties(true).putAll(appProps);
         }
         bean.setApplication(app);
+        if (_bus != null) {
+            bean.setBus(_bus);
+        }
 
         if (JAXRSServerFactoryBean.class.isAssignableFrom(endpointType)) {
             return endpointType.cast(bean);
diff --git a/jax-rs.whiteboard/src/test/java/org/apache/aries/jax/rs/whiteboard/internal/cxf/CxfJaxrsServiceRegistratorTest.java b/jax-rs.whiteboard/src/test/java/org/apache/aries/jax/rs/whiteboard/internal/cxf/CxfJaxrsServiceRegistratorTest.java
new file mode 100644
index 0000000..3013cdd
--- /dev/null
+++ b/jax-rs.whiteboard/src/test/java/org/apache/aries/jax/rs/whiteboard/internal/cxf/CxfJaxrsServiceRegistratorTest.java
@@ -0,0 +1,65 @@
+/*
+ * 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.aries.jax.rs.whiteboard.internal.cxf;
+
+import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
+import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
+import org.apache.cxf.jaxrs.model.ClassResourceInfo;
+import org.junit.Test;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.core.Application;
+import java.util.Set;
+
+import static java.util.Collections.emptyMap;
+import static java.util.Collections.singleton;
+import static java.util.Collections.singletonList;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class CxfJaxrsServiceRegistratorTest {
+    @Test
+    public void unproxy() {
+        final JAXRSServerFactoryBean bean = new CxfJaxrsServiceRegistrator(
+                null, null, emptyMap(), null
+        ).createEndpoint(new Application() {
+            @Override
+            public Set<Object> getSingletons() {
+                return singleton(new MyResource$$Proxy());
+            }
+        }, JAXRSServerFactoryBean.class);
+        bean.setStart(false);
+        bean.create();
+        assertEquals(singletonList(MyResource.class), bean.getResourceClasses());
+        final ClassResourceInfo cri = bean.getServiceFactory().getClassResourceInfo().iterator().next();
+        assertEquals(MyResource.class, cri.getServiceClass());
+        assertEquals(MyResource.class, cri.getResourceClass());
+        assertTrue(SingletonResourceProvider.class.isInstance(cri.getResourceProvider()));
+    }
+
+    @Path("my")
+    public static class MyResource {
+        @GET
+        public String get() {
+            return "";
+        }
+    }
+
+    public static class MyResource$$Proxy extends MyResource {
+    }
+}