PageRenderTime 5071ms CodeModel.GetById 31ms RepoModel.GetById 2ms app.codeStats 0ms

/rabbit.data.xml.test/src/rabbit/data/internal/xml/merge/MergerModuleTest.java

https://code.google.com/
Java | 79 lines | 49 code | 10 blank | 20 comment | 0 complexity | cbba82bd531485498479380ebf071125 MD5 | raw file
  1. /*
  2. * Copyright 2010 The Rabbit Eclipse Plug-in Project
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package rabbit.data.internal.xml.merge;
  17. import rabbit.data.internal.xml.schema.events.CommandEventType;
  18. import rabbit.data.internal.xml.schema.events.FileEventType;
  19. import rabbit.data.internal.xml.schema.events.JavaEventType;
  20. import rabbit.data.internal.xml.schema.events.LaunchEventType;
  21. import rabbit.data.internal.xml.schema.events.PartEventType;
  22. import rabbit.data.internal.xml.schema.events.PerspectiveEventType;
  23. import rabbit.data.internal.xml.schema.events.SessionEventType;
  24. import rabbit.data.internal.xml.schema.events.TaskFileEventType;
  25. import com.google.inject.Guice;
  26. import com.google.inject.Injector;
  27. import com.google.inject.Key;
  28. import com.google.inject.TypeLiteral;
  29. import static org.hamcrest.CoreMatchers.instanceOf;
  30. import static org.junit.Assert.assertThat;
  31. import org.junit.Test;
  32. import org.junit.runner.RunWith;
  33. import org.junit.runners.Parameterized;
  34. import org.junit.runners.Parameterized.Parameters;
  35. import java.util.Arrays;
  36. import java.util.Collection;
  37. /**
  38. * Tests for {@link MergerModule}.
  39. */
  40. @RunWith(Parameterized.class)
  41. public class MergerModuleTest {
  42. @Parameters
  43. public static Collection<Object[]> data() {
  44. // @formatter:off
  45. return Arrays.asList(new Object[][] {
  46. {new TypeLiteral<IMerger<CommandEventType>> () {}, CommandEventTypeMerger .class},
  47. {new TypeLiteral<IMerger<FileEventType>> () {}, FileEventTypeMerger .class},
  48. {new TypeLiteral<IMerger<JavaEventType>> () {}, JavaEventTypeMerger .class},
  49. {new TypeLiteral<IMerger<LaunchEventType>> () {}, LaunchEventTypeMerger .class},
  50. {new TypeLiteral<IMerger<PartEventType>> () {}, PartEventTypeMerger .class},
  51. {new TypeLiteral<IMerger<PerspectiveEventType>> () {}, PerspectiveEventTypeMerger .class},
  52. {new TypeLiteral<IMerger<SessionEventType>> () {}, SessionEventTypeMerger .class},
  53. {new TypeLiteral<IMerger<TaskFileEventType>> () {}, TaskFileEventTypeMerger .class},
  54. });
  55. // @formatter:on
  56. }
  57. private final Injector injector;
  58. private TypeLiteral<?> mergerInterface;
  59. private Class<?> mergerImpl;
  60. public MergerModuleTest(TypeLiteral<?> mergerInterface, Class<?> mergerImpl) {
  61. this.mergerInterface = mergerInterface;
  62. this.mergerImpl = mergerImpl;
  63. this.injector = Guice.createInjector(new MergerModule());
  64. }
  65. @Test
  66. public void shouldBindTheCorrectMerger() {
  67. assertThat(injector.getInstance(Key.get(mergerInterface)), instanceOf(mergerImpl));
  68. }
  69. }