PageRenderTime 197ms CodeModel.GetById 20ms RepoModel.GetById 4ms app.codeStats 0ms

/components/camel-guice/src/test/java/org/apache/camel/guice/CollectionOfCustomRoutesTest.java

https://gitlab.com/matticala/apache-camel
Java | 63 lines | 32 code | 10 blank | 21 comment | 0 complexity | bc70470012c2c70e6a488a94f0702c0d MD5 | raw file
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. package org.apache.camel.guice;
  18. import java.util.Collection;
  19. import java.util.List;
  20. import com.google.common.collect.Lists;
  21. import com.google.inject.Guice;
  22. import com.google.inject.Injector;
  23. import com.google.inject.Provides;
  24. import com.google.inject.name.Named;
  25. import org.apache.camel.CamelContext;
  26. import org.apache.camel.Route;
  27. import org.apache.camel.RoutesBuilder;
  28. import org.junit.Assert;
  29. import org.junit.Test;
  30. /**
  31. * Create a collection of routes via a provider method
  32. *
  33. * @version
  34. */
  35. public class CollectionOfCustomRoutesTest extends Assert {
  36. public static class MyModule extends CamelModuleWithMatchingRoutes {
  37. @Provides
  38. @Named("foo")
  39. protected Collection<? extends RoutesBuilder> myRoutes() {
  40. return Lists.newArrayList(new MyConfigurableRoute2("direct:a", "direct:b"), new MyConfigurableRoute2("direct:c", "direct:d"));
  41. }
  42. }
  43. @Test
  44. public void testDummy() throws Exception {
  45. }
  46. public void xtestGuice() throws Exception {
  47. Injector injector = Guice.createInjector(new MyModule());
  48. CamelContext camelContext = injector.getInstance(CamelContext.class);
  49. List<Route> list = camelContext.getRoutes();
  50. assertEquals("size of " + list, 2, list.size());
  51. GuiceTest.assertCamelContextRunningThenCloseInjector(injector);
  52. }
  53. }