Repository: cxf-dosgi Updated Branches: refs/heads/master a9d93602c -> 5d8bbd2bd
[DOSGI-241] Simplify Tests Project: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/commit/5d8bbd2b Tree: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/tree/5d8bbd2b Diff: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/diff/5d8bbd2b Branch: refs/heads/master Commit: 5d8bbd2bd12df5345bc5fa167be52749818e44a3 Parents: a9d9360 Author: Christian Schneider <[email protected]> Authored: Fri Jul 1 11:26:23 2016 +0200 Committer: Christian Schneider <[email protected]> Committed: Fri Jul 1 11:26:23 2016 +0200 ---------------------------------------------------------------------- .../systests2/multi/TestImportService.java | 11 +-- .../multi/importservice/GreeterDataImpl.java | 39 ---------- .../multi/importservice/MyActivator.java | 45 ------------ .../multi/importservice/MyServiceTracker.java | 76 -------------------- .../importservice/StartServiceTracker.java | 44 ------------ 5 files changed, 1 insertion(+), 214 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/5d8bbd2b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestImportService.java ---------------------------------------------------------------------- diff --git a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestImportService.java b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestImportService.java index fce0114..9e435a8 100644 --- a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestImportService.java +++ b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestImportService.java @@ -29,11 +29,7 @@ import javax.inject.Inject; import org.apache.cxf.aegis.databinding.AegisDatabinding; import org.apache.cxf.dosgi.samples.greeter.GreeterService; import org.apache.cxf.dosgi.samples.greeter.GreetingPhrase; -import org.apache.cxf.dosgi.systests2.multi.importservice.GreeterDataImpl; -import org.apache.cxf.dosgi.systests2.multi.importservice.MyActivator; -import org.apache.cxf.dosgi.systests2.multi.importservice.MyServiceTracker; import org.apache.cxf.dosgi.systests2.multi.importservice.SimpleGreeter; -import org.apache.cxf.dosgi.systests2.multi.importservice.StartServiceTracker; import org.apache.cxf.endpoint.Server; import org.apache.cxf.frontend.ServerFactoryBean; import org.junit.After; @@ -68,14 +64,9 @@ public class TestImportService extends AbstractDosgiTest { protected static InputStream createServiceConsumerBundle() { return TinyBundles.bundle() // - .add(MyActivator.class) // - .add(MyServiceTracker.class) // - .add(StartServiceTracker.class) // - .add(GreeterDataImpl.class) // .add("OSGI-INF/remote-service/remote-services.xml", TestImportService.class.getResource("/rs-test1.xml")) // - .set(Constants.BUNDLE_SYMBOLICNAME, "testClientBundle") // - .set(Constants.BUNDLE_ACTIVATOR, MyActivator.class.getName()) // + .set(Constants.BUNDLE_SYMBOLICNAME, "importConfig") // .build(TinyBundles.withBnd()); } http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/5d8bbd2b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/importservice/GreeterDataImpl.java ---------------------------------------------------------------------- diff --git a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/importservice/GreeterDataImpl.java b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/importservice/GreeterDataImpl.java deleted file mode 100644 index 096d116..0000000 --- a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/importservice/GreeterDataImpl.java +++ /dev/null @@ -1,39 +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.cxf.dosgi.systests2.multi.importservice; - -import org.apache.cxf.dosgi.samples.greeter.GreeterData; - -public class GreeterDataImpl implements GreeterData { - - public int getAge() { - // TODO Auto-generated method stub - return 0; - } - - public String getName() { - // TODO Auto-generated method stub - return null; - } - - public boolean isException() { - // TODO Auto-generated method stub - return false; - } -} http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/5d8bbd2b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/importservice/MyActivator.java ---------------------------------------------------------------------- diff --git a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/importservice/MyActivator.java b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/importservice/MyActivator.java deleted file mode 100644 index 08fe288..0000000 --- a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/importservice/MyActivator.java +++ /dev/null @@ -1,45 +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.cxf.dosgi.systests2.multi.importservice; - -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; -import org.osgi.framework.Filter; -import org.osgi.util.tracker.ServiceTracker; - -@SuppressWarnings("rawtypes") -public class MyActivator implements BundleActivator { - private ServiceTracker startTracker; - private ServiceTracker tracker; - - public void start(final BundleContext bc) throws Exception { - Filter filter = bc.createFilter("(&(objectClass=java.lang.Object)(testName=test1))"); - tracker = new MyServiceTracker(bc); - - // The start tracker waits until a service from the test class is set before the - // 'MyServiceTracker' is activated. - startTracker = new StartServiceTracker(bc, filter, tracker); - startTracker.open(); - } - - public void stop(BundleContext bc) throws Exception { - startTracker.close(); - tracker.close(); - } -} http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/5d8bbd2b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/importservice/MyServiceTracker.java ---------------------------------------------------------------------- diff --git a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/importservice/MyServiceTracker.java b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/importservice/MyServiceTracker.java deleted file mode 100644 index cc2d8ba..0000000 --- a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/importservice/MyServiceTracker.java +++ /dev/null @@ -1,76 +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.cxf.dosgi.systests2.multi.importservice; - -import java.util.Dictionary; -import java.util.Hashtable; -import java.util.Map; - -import org.apache.cxf.dosgi.samples.greeter.GreeterException; -import org.apache.cxf.dosgi.samples.greeter.GreeterService; -import org.apache.cxf.dosgi.samples.greeter.GreetingPhrase; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; -import org.osgi.util.tracker.ServiceTracker; - -public class MyServiceTracker extends ServiceTracker<GreeterService, GreeterService> { - - private static StringBuffer invocationResult = new StringBuffer(); - - public MyServiceTracker(BundleContext context) { - super(context, GreeterService.class, null); - } - - @Override - public GreeterService addingService(ServiceReference<GreeterService> reference) { - GreeterService service = super.addingService(reference); - System.out.println("[client] Got a GreeterService..."); - invokeGreeter(service); - return service; - } - - public static String getResult() { - return invocationResult.toString(); - } - - private void invokeGreeter(GreeterService svc) { - try { - Map<GreetingPhrase, String> result = svc.greetMe("OSGi"); - for (Map.Entry<GreetingPhrase, String> e : result.entrySet()) { - GreetingPhrase key = e.getKey(); - invocationResult.append(key.getPhrase()); - invocationResult.append(e.getValue()); - } - try { - svc.greetMe(new GreeterDataImpl()); - } catch (GreeterException ex) { - invocationResult.append(";exception"); - } - Dictionary<String, Object> props = new Hashtable<String, Object>(); - props.put("result", invocationResult.toString()); - props.put("testResult", "test1"); - - System.out.println("[client] Successfully invoked remote service. Registering test response service..."); - context.registerService(String.class.getName(), "test1", props); - } catch (Exception x) { - System.err.println("[client] Error during remote service invocation:"); - x.printStackTrace(System.err); - } - } -} http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/5d8bbd2b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/importservice/StartServiceTracker.java ---------------------------------------------------------------------- diff --git a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/importservice/StartServiceTracker.java b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/importservice/StartServiceTracker.java deleted file mode 100644 index cd14c2b..0000000 --- a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/importservice/StartServiceTracker.java +++ /dev/null @@ -1,44 +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.cxf.dosgi.systests2.multi.importservice; - -import org.osgi.framework.BundleContext; -import org.osgi.framework.Filter; -import org.osgi.framework.ServiceReference; -import org.osgi.util.tracker.ServiceTracker; - -@SuppressWarnings({ - "unchecked", "rawtypes" - }) -public class StartServiceTracker extends ServiceTracker { - - private ServiceTracker tracker; - - public StartServiceTracker(BundleContext context, Filter filter, ServiceTracker tracker) { - super(context, filter, null); - this.tracker = tracker; - } - - @Override - public Object addingService(ServiceReference reference) { - System.out.println("Test object available, so starting the service client tracker..."); - tracker.open(); - return super.addingService(reference); - } -}
