INT-1553, fixed more tests, added new loguc to build metadataKey in the inbound adapters, tested new Twitter connectivity with real account
This commit is contained in:
@@ -39,6 +39,7 @@ import org.springframework.util.StringUtils;
|
||||
import twitter4j.DirectMessage;
|
||||
import twitter4j.Status;
|
||||
import twitter4j.Twitter;
|
||||
import twitter4j.http.OAuthAuthorization;
|
||||
|
||||
/**
|
||||
* Abstract class that defines common operations for receiving various types of
|
||||
@@ -78,10 +79,6 @@ public abstract class AbstractTwitterMessageSource<T> extends AbstractEndpoint
|
||||
public AbstractTwitterMessageSource(Twitter twitter){
|
||||
this.twitter = twitter;
|
||||
}
|
||||
//
|
||||
// public void setConfiguration(OAuthConfiguration configuration) {
|
||||
// this.configuration = configuration;
|
||||
// }
|
||||
|
||||
public void setShouldTrack(boolean shouldTrack) {
|
||||
this.historyWritingPostProcessor.setShouldTrack(shouldTrack);
|
||||
@@ -98,7 +95,7 @@ public abstract class AbstractTwitterMessageSource<T> extends AbstractEndpoint
|
||||
@Override
|
||||
protected void onInit() throws Exception{
|
||||
super.onInit();
|
||||
//Assert.notNull(this.configuration, "'configuration' can't be null");
|
||||
|
||||
if (this.metadataStore == null) {
|
||||
// first try to look for a 'messageStore' in the context
|
||||
BeanFactory beanFactory = this.getBeanFactory();
|
||||
@@ -122,7 +119,8 @@ public abstract class AbstractTwitterMessageSource<T> extends AbstractEndpoint
|
||||
else if (logger.isWarnEnabled()) {
|
||||
logger.warn(this.getClass().getSimpleName() + " has no name. MetadataStore key might not be unique.");
|
||||
}
|
||||
//metadataKeyBuilder.append(this.configuration.getConsumerKey());
|
||||
String accessToken = ((OAuthAuthorization)twitter.getAuthorization()).getOAuthAccessToken().getToken();
|
||||
metadataKeyBuilder.append(accessToken);
|
||||
this.metadataKey = metadataKeyBuilder.toString();
|
||||
}
|
||||
|
||||
@@ -146,7 +144,6 @@ public abstract class AbstractTwitterMessageSource<T> extends AbstractEndpoint
|
||||
|
||||
@Override
|
||||
protected void doStart(){
|
||||
//this.twitter = this.configuration.getTwitter();
|
||||
Assert.notNull(this.twitter, "'twitter' instance can't be null");
|
||||
historyWritingPostProcessor.setTrackableComponent(this);
|
||||
RateLimitStatusTrigger trigger = new RateLimitStatusTrigger(this.twitter);
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
</twitter:inbound-update-channel-adapter>
|
||||
<service-activator input-channel="inbound_updates" ref="twitterAnnouncer" method="updates"/>
|
||||
|
||||
<beans:bean id="twitterAnnouncer" class="org.springframework.integration.twitter.config.TwitterAnnouncer"/>
|
||||
<beans:bean id="twitterAnnouncer" class="org.springframework.integration.twitter.ignored.TwitterAnnouncer"/>
|
||||
</beans:beans>
|
||||
|
||||
|
||||
|
||||
@@ -19,18 +19,15 @@ package org.springframework.integration.twitter.inbound;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
||||
|
||||
import twitter4j.DirectMessage;
|
||||
import twitter4j.Paging;
|
||||
import twitter4j.RateLimitStatus;
|
||||
import twitter4j.ResponseList;
|
||||
import twitter4j.Twitter;
|
||||
|
||||
/**
|
||||
@@ -42,7 +39,7 @@ public class InboundDirectMessageStatusEndpointTests {
|
||||
|
||||
private DirectMessage secondMessage;
|
||||
|
||||
private Twitter twitter;
|
||||
private Twitter twitter = mock(Twitter.class);
|
||||
|
||||
|
||||
@Before
|
||||
@@ -60,12 +57,12 @@ public class InboundDirectMessageStatusEndpointTests {
|
||||
@Test
|
||||
public void testTwitterMockedUpdates() throws Exception{
|
||||
// QueueChannel channel = new QueueChannel();
|
||||
// InboundDirectMessageEndpoint endpoint = new InboundDirectMessageEndpoint();
|
||||
// endpoint.setOutputChannel(channel);
|
||||
// DirectMessageReceivingMessageSource endpoint = new DirectMessageReceivingMessageSource(twitter);
|
||||
// //endpoint.setOutputChannel(channel);
|
||||
// ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
|
||||
// scheduler.afterPropertiesSet();
|
||||
// endpoint.setTaskScheduler(scheduler);
|
||||
// endpoint.setConfiguration(this.getTestConfigurationForDirectMessages());
|
||||
// //endpoint.setConfiguration(this.getTestConfigurationForDirectMessages());
|
||||
// endpoint.setBeanName("twitterEndpoint");
|
||||
// endpoint.afterPropertiesSet();
|
||||
// endpoint.start();
|
||||
|
||||
@@ -23,11 +23,9 @@ import static org.mockito.Mockito.verify;
|
||||
import org.junit.Test;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.integration.twitter.core.TwitterHeaders;
|
||||
import org.springframework.integration.twitter.oauth.OAuthTwitterFactoryBean;
|
||||
|
||||
import twitter4j.GeoLocation;
|
||||
import twitter4j.Twitter;
|
||||
import twitter4j.http.AccessToken;
|
||||
|
||||
/**
|
||||
* @author Oleg Zhurakousky
|
||||
|
||||
Reference in New Issue
Block a user