November 4, 2017

Tinkering with Twitter: Setting up an API Testing environment with Twitter4J

This is Part Three of a multi-part blog series on putting together a basic API test framework for the Twitter Search API. Care to go back to the beginning

The last few posts we covered a lot of ground:

For this entry, we will be walking a user through setting up an API development environment with IntelliJ, Java, and Twitter4J.



Step One: Download and Install IntelliJ IDEA


Step Two: Set Up a New Project

  • Run IntelliJ IDEA. The main splash screen should appear.

The IntelliJ IDEA splash screen


  • From the splash screen, select "Create Project".
  • This time, let's create a  Maven project. Select "Maven" in the left-hand menu, make sure that Java 1.8 is selected, and hit "Next".

Select Maven, the Java 1.8 SDK, and choose "Next". 
  • What do you want to use as a group id? Since I have my website "tjmaher.com", I used that as a package name: com.tjmaher. 
  • What do you want to call the project? I selected TinkeringWithTwitter as a name. Select "Next". 

Enter a group id, artifact id, and keep the default snapshot version. Select "Next". 

  • Select "Finish" on the next screen. 
  • Your Java project is now set up!

Step Three: Set up the Twitter4J Dependencies in the POM.Xml file
  • Review the "Maven Integration" section on the main page for Twitter4J on http://twitter4j.org/en/index.html
  • Go to the pom.xml file that was created automatically in the root folder of the project.
  • If it is not there already, after the group id, artifact id, and version, add the dependency block, placing the group id, artifact id, and version for Twitter4J inside it. It will look something like this: 
   <dependencies>  
     <dependency>  
       <groupId>org.twitter4j</groupId>  
       <artifactId>twitter4j-core</artifactId>  
       <version>[4.0,)</version>  
     </dependency>  
     <dependency>  
       <groupId>org.testng</groupId>  
       <artifactId>testng</artifactId>  
       <version>6.8</version>  
       <scope>test</scope>  
     </dependency>  
   </dependencies>  

  • The Twitter4J Java Library should automatically download. 
  • We will include the test framework TestNG.

Step Four: Set up the Twitter credentials for Twitter4J to use

  • Once you are at the root folder of the project, create a new file by going to the horizontal menu, and select File -> New -> File.
  • Create a new file "twitter4j.properties".
  • Copy and paste the following code into the twitter4j.properties:
 debug=true  
 oauth.consumerKey=****************  
 oauth.consumerSecret=****************  
 oauth.accessToken=****************  
 oauth.accessTokenSecret=****************  

  • Did you create a new Twitter account, create a Twitter app, and get credentials that this project could use? If not, follow the instructions.
  • Cut-and-paste the consumer key, consumer secret, access token, and access token secret into the file, replacing the asterisks. 

... Now, our project is all set! Next, we will work through posting Tweets to your Twitter account using Twitter4J!



Happy Testing!



-T.J. Maher
Twitter | LinkedIn | GitHub

// Sr. QA Engineer, Software Engineer in Test, Software Tester since 1996.
// Contributing Writer for TechBeacon.
// "Looking to move away from manual QA? Follow Adventures in Automation on Facebook!"

8 comments:

for ict 99 said...

IEEE Final Year projects Project Centers in Chennai are consistently sought after. Final Year Students Projects take a shot at them to improve their aptitudes, while specialists like the enjoyment in interfering with innovation. For experts, it's an alternate ball game through and through. Smaller than expected IEEE Final Year project centers ground for all fragments of CSE & IT engineers hoping to assemble. Final Year Projects for CSE It gives you tips and rules that is progressively critical to consider while choosing any final year project point.

Spring Framework has already made serious inroads as an integrated technology stack for building user-facing applications. Spring Framework Corporate TRaining the authors explore the idea of using Java in Big Data platforms.
Specifically, Spring Framework provides various tasks are geared around preparing data for further analysis and visualization. Spring Training in Chennai


The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training

for ict 99 said...

IEEE Final Year projects Project Centers in Chennai are consistently sought after. Final Year Students Projects take a shot at them to improve their aptitudes, while specialists like the enjoyment in interfering with innovation. For experts, it's an alternate ball game through and through. Smaller than expected IEEE Final Year project centers ground for all fragments of CSE & IT engineers hoping to assemble. Final Year Projects for CSE It gives you tips and rules that is progressively critical to consider while choosing any final year project point.

Spring Framework has already made serious inroads as an integrated technology stack for building user-facing applications. Spring Framework Corporate TRaining the authors explore the idea of using Java in Big Data platforms.
Specifically, Spring Framework provides various tasks are geared around preparing data for further analysis and visualization. Spring Training in Chennai


The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training

Lauren Chevalier said...

For the excellent company Begin with the internet site, the customer service over the cell phone, to the detailed care they deliver in your presence
Carhartt Men's Quilted Flannel Lined Duck Active Jacket

shoaib said...

https://cracklabs.info/sai-1-2-5-crack-torrent-key-full-version-free-download/

Free Crack Softwares said...

I like your all post. You have done really good work. Thank you for the information you provide, it helped me a lot. I hope to have many more entries or so from you.
Very interesting blog.visit my wepsite https://vstking.net/

JetBrains PhpStorm Crack

Resolume Arena crack

SmartDraw crack

Wondershare Filmora crack

Activatorfix.info said...

It is very informative. Very easy to understand. Great work team. Keep me updated for all such articles
Your work is great it provides me great knowledge visit below links..
Avast Premier Crack
SmartDraw Crack
CleanMyMac X Crack
Sketchup Pro Crack

vé máy bay từ canada về việt nam said...

Mua vé máy bay tại Aivivu, tham khảo

Vé máy bay đi Mỹ

vé máy bay từ mỹ về việt nam mùa dịch

giá vé máy bay từ đức về việt nam

chuyến bay từ nga về việt nam

vé máy bay từ anh về việt nam vietnam airlines

các chuyến bay từ châu âu về việt nam

giá vé máy bay tết

Sultan said...

I am a professional web blogger so visit my website link is given below!To get more information
freeprosoftz.co/
Resolume Arena Crack
Synapse Audio DUNE Crack
Pixellu SmartAlbums Crack
DiskDigger Crack/
Prosoft Data Rescue Professional Crack
The Sims Crack