Refine search
public void start(@Observes Start start) { log.info(">>> Starting managed UPnP service..."); // First start the registry before we can receive messages through the transport getRegistry().addListener(registryListenerAdapter); enableRouterEvent.fire(new EnableRouter()); log.info("<<< Managed UPnP service started successfully"); }
@Test public void testReImport() throws Exception { when(path.getFileName()).thenReturn("pom.xml"); when(path.toURI()).thenReturn("file://project1/pom.xml"); when(resourceResolver.resolveModule(any(Path.class))).thenReturn(module); abstractProjectService.reImport(path); verify(invalidateDMOCache).fire(any(InvalidateDMOModuleCacheEvent.class)); }
@Test public void testSelectColumn() { when(view.getSelectedColumnId()).thenReturn("column2"); GroupFunction groupFunction = new GroupFunction("column1", "column1", AggregateFunctionType.COUNT); presenter.init(metadata, groupFunction, null, "Title", true, true); presenter.onColumnSelected(); assertEquals(presenter.getGroupFunction().getSourceId(), "column2"); verify(changeEvent).fire(any(GroupFunctionChangedEvent.class)); }
@Test @SpecAssertions({ @SpecAssertion(section = EVENT, id = "f") }) @SuppressWarnings("serial") public <T> void testUnresolvedTypeVariableDetected2() { try { // T cannot be resolved event.select(new TypeLiteral<Map<Exception, T>>() { }).fire(new HashMap<Exception, T>()); Assert.fail(); } catch (IllegalArgumentException expected) { } }
private void thenExpectMessageWithStatus(final TestResultMessage message, final JobStatus status) { final JobResult jobResult = helper.testProject(null, "repositoryAlias", "project"); verify(testService).runAllTests(eq("JobRequestHelper"), any(Path.class), captor.capture()); captor.getValue().fire(message); assertEquals(status, jobResult.getStatus()); }
@Test @SpecAssertions({ @SpecAssertion(section = OBSERVER_ORDERING, id = "b") }) public void testFireEventToMultipleObserversWithPriority() { ActionSequence.reset(); sunset.fire(new Sunset()); assertEquals(ActionSequence.getSequenceSize(), 3); // 2599, 2600, 2700 assertTrue(ActionSequence.getSequence().beginsWith(SunsetObservers.AsianObserver.class.getName(), SunsetObservers.EuropeanObserver.class.getName(), SunsetObservers.AmericanObserver.class.getName())); }
@Test @SpecAssertions({ @SpecAssertion(section = FIRING_EVENTS_ASYNCHRONOUSLY, id = "a") }) public void testAsyncObserversCalledInDifferentThread() throws InterruptedException { BlockingQueue<Experiment> queue = new LinkedBlockingQueue<>(); int threadId = (int) Thread.currentThread().getId(); event.fireAsync(new ScientificExperiment()).thenAccept(queue::offer); Experiment experiment2 = queue.poll(2, TimeUnit.SECONDS); assertEquals(experiment2.getUniversities().size(), 2); assertTrue(experiment2.getUniversities().contains(StandfordUniversityObserver.class)); assertTrue(experiment2.getUniversities().contains(MassachusettsInstituteObserver.class)); assertNotEquals(threadId, MassachusettsInstituteObserver.threadId.get()); }
private void testNotify(int code, String message, NotificationType notificationType, int times) { service.notifyUser(new GitRepository(REPO, new Space(VALID_SPACE)), code); ArgumentCaptor<PostCommitNotificationEvent> eventCaptor = ArgumentCaptor.forClass(PostCommitNotificationEvent.class); verify(notificationEvent, times(times)).fire(eventCaptor.capture()); Assertions.assertThat(eventCaptor.getValue()) .isNotNull() .hasFieldOrPropertyWithValue("text", message) .hasFieldOrPropertyWithValue("type", notificationType); }
@Test @SpecAssertions({ @SpecAssertion(section = DECORATOR_INVOCATION, id = "aca") }) public void testDecoratorIsInvoked() { Foo payload = new Foo(false); fooEvent.fire(payload); assertTrue(observer.isObserved()); assertTrue(payload.isDecorated()); }
@Test @SpecAssertions({ @SpecAssertion(section = OBSERVER_RESOLUTION, id = "f"), @SpecAssertion(section = EVENT, id = "eda") }) public void testQualifiedAsyncEventIsDeliveredOnlyToAsyncObservers() throws InterruptedException { BlockingQueue<Experiment> queue = new LinkedBlockingQueue<>(); event.select(American.AmericanLiteral.INSTANCE).fireAsync(new ScientificExperiment()).thenAccept(queue::offer); Experiment experiment = queue.poll(2, TimeUnit.SECONDS); assertEquals(experiment.getUniversities().size(), 3); assertTrue(experiment.getUniversities().contains(YaleUniversityObserver.class)); assertTrue(experiment.getUniversities().contains(StandfordUniversityObserver.class)); assertTrue(experiment.getUniversities().contains(MassachusettsInstituteObserver.class)); }
@Test @SpecAssertions({ @SpecAssertion(section = OBSERVES, id = "a"), @SpecAssertion(section = SPECIALIZATION, id = "cc") }) public void testEvent() { Factory.reset(); event.fire(new FactoryEvent()); assertFalse(Factory.isEventDelivered()); } }
@Test @SpecAssertion(section = OBSERVER_METHOD_INVOCATION_CONTEXT, id = "ab") public void testAsyncObserverIsCalledInNewTransactionContext() throws Exception { userTransaction.begin(); BlockingQueue<Message> queue = new LinkedBlockingQueue<>(); event.fireAsync(new Message()).thenAccept(queue::offer); Message message = queue.poll(2l, TimeUnit.SECONDS); assertNotNull(message); assertEquals(Status.STATUS_NO_TRANSACTION, AsyncMessageObserver.status.get()); userTransaction.commit(); }
@Test public void testRemoveError() { final ServerInstanceKey serverInstanceKey = new ServerInstanceKey( "templateId", "serverName", "serverInstanceId", "url" ); presenter.onSelect( new ServerInstanceSelected( serverInstanceKey ) ); doThrow( new RuntimeException() ).when( specManagementService ).deleteServerInstance( serverInstanceKey ); presenter.remove(); final ArgumentCaptor<NotificationEvent> notificationCaptor = ArgumentCaptor.forClass( NotificationEvent.class ); verify( notification ).fire( notificationCaptor.capture() ); assertEquals( NotificationEvent.NotificationType.ERROR, notificationCaptor.getValue().getType() ); }
@Test @SpecAssertions({ @SpecAssertion(section = OBSERVER_METHOD_INVOCATION_CONTEXT, id = "aa"), @SpecAssertion(section = REQUEST_CONTEXT, id = "da") }) public void testAsyncObserverIsCalledInNewRequestContext() throws Exception { counter.increment(); BlockingQueue<String> queue = new LinkedBlockingQueue<>(); stringEvent.fireAsync(new String()).thenAccept(queue::offer); String string = queue.poll(2l, TimeUnit.SECONDS); assertNotNull(string); assertTrue(AsyncMessageObserver.requestScopeActive.get()); assertTrue(AsyncMessageObserver.counterIsZero.get()); }
@Test @SpecAssertions({ @SpecAssertion(section = FIRING_EVENTS_SYNCHRONOUSLY, id = "e"), @SpecAssertion(section = FIRING_EVENTS_SYNCHRONOUSLY, id = "f") }) public void testSyncObservesCalledInSameThread() { event.fire(new Letter()); helper.addThreadID((int) Thread.currentThread().getId()); Assert.assertEquals(helper.getCounter(), 2); Assert.assertEquals(helper.getThreadIDs().size(), 1); }
@Test @SpecAssertions({ @SpecAssertion(section = EVENT, id = "edb") }) public void testSelectedEventTypeCombinedWithEventObjectRuntimeTypeForResolvingEventTypeArguments2() { reset(); @SuppressWarnings("serial") Event<List<Character>> selectedEvent = event.select(new TypeLiteral<List<Character>>() { }); selectedEvent.fire(new ArrayList<Character>()); assertTrue(observer.isCharacterListObserved()); }