@Test
  public void shouldReQueueTestIfEventDispatchFails() throws InterruptedException, IOException {
    Queue<String> testQueue = newLinkedList(asList("test1"));
    QueueProcessor processor = createMock(QueueProcessor.class);
    processor.process("test1");
    expectLastCall().andThrow(new QueueDispatchException(new Throwable()));
    replay(processor);

    ProcessorRunnable runnable =
        new ProcessorRunnable(
            testQueue, processor, null, 1, createMock(ConcurrencyController.class));
    runnable.run();
    verify(processor);
    assertEquals("test1", getOnlyElement(testQueue));
  }
Пример #2
0
  @Test
  public void testResolveElements() throws Exception {
    URI resourceURI = URI.createFileURI("testresource.refactoringtestlanguage");
    String textualModel = "A { B { C { ref A.B } } ref B }";
    XtextResource resource = getResource(textualModel, resourceURI.toString());
    Element elementA = (Element) resource.getContents().get(0).eContents().get(0);
    Element elementB = elementA.getContained().get(0);
    Element elementC = elementB.getContained().get(0);

    URI uriB = EcoreUtil.getURI(elementB);
    URI uriC = EcoreUtil.getURI(elementC);
    String newName = "newB";

    List<URI> renamedElementURIs = newArrayList(uriB, uriC);
    IRenameStrategy renameStrategy =
        getInjector().getInstance(IRenameStrategy.Provider.class).get(elementB, null);

    IRenamedElementTracker renamedElementTracker = new RenamedElementTracker();
    Map<URI, URI> original2newElementURIs =
        renamedElementTracker.renameAndTrack(
            renamedElementURIs, newName, resource.getResourceSet(), renameStrategy, null);

    assertEquals("B", elementB.getName());
    assertEquals(2, original2newElementURIs.size());
    assertEquals(resourceURI.appendFragment(newName), original2newElementURIs.get(uriB));
    assertEquals(uriC, original2newElementURIs.get(uriC));
  }
Пример #3
0
 public void testOverriddenExtensionMethods_02() throws Exception {
   XbaseScopeProvider provider = get(XbaseScopeProvider.class);
   XExpression expression = expression("(null as java.util.Collection<String>).map(null)", true);
   IScope scope =
       provider.getScope(expression, XbasePackage.Literals.XABSTRACT_FEATURE_CALL__FEATURE);
   Iterable<IEObjectDescription> elements = scope.getElements(QualifiedName.create("map"));
   assertEquals(elements.toString(), 1, size(elements));
   IEObjectDescription description = elements.iterator().next();
   JvmFeature feature = (JvmFeature) description.getEObjectOrProxy();
   assertEquals(
       IterableExtensions.class.getCanonicalName(), feature.getDeclaringType().getIdentifier());
 }
Пример #4
0
 public void assertEventsReceived(TestState... expectedTypes) {
   ArrayList<TestState> actualTypes = new ArrayList<TestState>();
   for (TestEvent event : testEvents) {
     actualTypes.add(event.getType());
   }
   assertEquals(asList(expectedTypes), actualTypes);
 }
Пример #5
0
 public void assertStatesChanged(CoreStatus... expectedStates) {
   ArrayList<CoreStatus> actualStates = new ArrayList<CoreStatus>();
   for (PropertyChangeEvent event : propertyEvents) {
     actualStates.add((CoreStatus) event.getNewValue());
   }
   assertEquals(asList(expectedStates), actualStates);
 }
Пример #6
0
  @Test
  public void shouldTrimWhiteSpaceStrings() {
    Splitter splitter = Splitter.on(',').trimResults();

    Iterable<String> result = splitter.split("foo, bar, baz");

    assertEquals(newArrayList("foo", "bar", "baz"), newArrayList(result));
  }
Пример #7
0
  @Test
  public void shouldOmitEmptyStrings() {
    Splitter splitter = Splitter.on(',').omitEmptyStrings();

    Iterable<String> result = splitter.split("foo,bar,,baz");

    assertEquals(newArrayList("foo", "bar", "baz"), newArrayList(result));
  }
  @Test
  public void shouldReturnTheNumberOfTestsRun() {
    JavaClass javaClass = mock(JavaClass.class);

    testsToExpect(javaClass);

    assertEquals(1, core.update(updatedFiles));
  }
Пример #9
0
 public void assertTestsStarted(String... testNames) {
   // Also asserts the order
   List<String> startedTests = new ArrayList<String>();
   for (TestEvent event : testEvents) {
     if (event.getType().equals(TEST_CASE_STARTING)) {
       startedTests.add(event.getTestName());
     }
   }
   assertEquals(asList(testNames), startedTests);
 }