diff --git a/.gitignore b/.gitignore index 79d582a..d070345 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,4 @@ hs_err_pid* **/.project **/.classpath **/.settings +**/.idea diff --git a/lib/aqapi.jar b/lib/aqapi.jar deleted file mode 100644 index f31b1dc..0000000 Binary files a/lib/aqapi.jar and /dev/null differ diff --git a/lib/jmscommon.jar b/lib/jmscommon.jar deleted file mode 100644 index dad227f..0000000 Binary files a/lib/jmscommon.jar and /dev/null differ diff --git a/lib/ojdbc8.jar b/lib/ojdbc8.jar deleted file mode 100644 index bf41243..0000000 Binary files a/lib/ojdbc8.jar and /dev/null differ diff --git a/lib/orai18n-collation.jar b/lib/orai18n-collation.jar deleted file mode 100644 index 87d1700..0000000 Binary files a/lib/orai18n-collation.jar and /dev/null differ diff --git a/lib/orai18n-mapping.jar b/lib/orai18n-mapping.jar deleted file mode 100644 index 2054c0c..0000000 Binary files a/lib/orai18n-mapping.jar and /dev/null differ diff --git a/lib/ucp.jar b/lib/ucp.jar deleted file mode 100644 index 3d86a52..0000000 Binary files a/lib/ucp.jar and /dev/null differ diff --git a/pom.xml b/pom.xml index 8b0e019..7bcfb82 100644 --- a/pom.xml +++ b/pom.xml @@ -3,17 +3,16 @@ 4.0.0 com.salvis emptracker - 1.0.0-SNAPSHOT + 1.1.0-SNAPSHOT UTF-8 1.8 - 4.3.10.RELEASE true org.springframework.boot spring-boot-starter-parent - 1.5.8.RELEASE + 2.7.5 @@ -21,72 +20,35 @@ ${project.basedir}/src/test/java - org.apache.maven.plugins - maven-surefire-plugin - - ${skipTests} - - - - org.apache.maven.plugins - maven-jar-plugin - - ${project.artifactId} - - false - - true - false - lib/ - com.salvis.emptracker.EmptrackerApplication - true - - - lib/aqapi-12.2.0.jar lib/jmscommon-12.2.0.jar lib/ojdbc8-12.2.0.jar lib/orai18n-collation-12.2.0.jar lib/orai18n-mapping-12.2.0.jar lib/ucp-12.2.0.jar - - - - - - org.apache.maven.plugins - maven-dependency-plugin + org.springframework.boot + spring-boot-maven-plugin - copy-dependencies-runtime - package - copy-dependencies + repackage - - target/lib - false - true - false - runtime - - - - copy-dependencies-system - package - - copy-dependencies - - - target/lib - false - true - false - system - + + org.apache.maven.plugins + maven-surefire-plugin + + ${skipTests} + + - org.springframework.boot - spring-boot-starter + org.apache.maven.plugins + maven-clean-plugin + 3.2.0 + maven-plugin + + + org.springframework.boot + spring-boot-starter org.springframework @@ -103,7 +65,7 @@ org.twitter4j twitter4j-core - 4.0.6 + 4.1.2 javax.transaction @@ -115,62 +77,35 @@ javax.servlet-api - org.springframework.boot - spring-boot-starter-test - test - - - org.springframework - spring-test - test - - - junit - junit - test + com.oracle.database.jdbc + ojdbc8-production + 21.7.0.0 + pom - - oracle + com.oracle.database.messaging aqapi - 12.2.0 - system - ${project.basedir}/lib/aqapi.jar - - - oracle - jmscommon - 12.2.0 - system - ${project.basedir}/lib/jmscommon.jar + 21.3.0.0 - oracle - ojdbc8 - 12.2.0 - system - ${project.basedir}/lib/ojdbc8.jar + com.oracle.database.jdbc + ucp + 21.7.0.0 - oracle - orai18n-collation - 12.2.0 - system - ${project.basedir}/lib/orai18n-collation.jar + org.springframework.boot + spring-boot-starter-test + test - oracle - orai18n-mapping - 12.2.0 - system - ${project.basedir}/lib/orai18n-mapping.jar + org.springframework + spring-test + test - oracle - ucp - 12.2.0 - system - ${project.basedir}/lib/ucp.jar + org.junit.jupiter + junit-jupiter + test diff --git a/src/main/java/com/salvis/emptracker/AppConfig.java b/src/main/java/com/salvis/emptracker/AppConfig.java index 90fdf41..532ba1e 100644 --- a/src/main/java/com/salvis/emptracker/AppConfig.java +++ b/src/main/java/com/salvis/emptracker/AppConfig.java @@ -23,7 +23,8 @@ import javax.jms.TopicConnectionFactory; import javax.sql.DataSource; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -37,14 +38,12 @@ import oracle.ucp.jdbc.PoolDataSource; import oracle.ucp.jdbc.PoolDataSourceFactory; import twitter4j.Twitter; -import twitter4j.TwitterFactory; -import twitter4j.conf.ConfigurationBuilder; @EnableTransactionManagement @Configuration @PropertySource(value = "file:${user.home}/emptracker.properties", ignoreResourceNotFound = true) public class AppConfig { - private final Logger logger = Logger.getLogger(AppConfig.class); + private final Logger logger = LoggerFactory.getLogger(AppConfig.class); @Value("${db.url}") private String url; @@ -75,13 +74,10 @@ public class AppConfig { @Bean public Twitter twitter() { - ConfigurationBuilder cb = new ConfigurationBuilder(); - cb.setOAuthConsumerKey(consumerKey) - .setOAuthConsumerSecret(consumerSecret) - .setOAuthAccessToken(accessToken) - .setOAuthAccessTokenSecret(accessTokenSecret); - TwitterFactory tf = new TwitterFactory(cb.build()); - Twitter twitter = tf.getInstance(); + Twitter twitter = Twitter.newBuilder() + .oAuthConsumer(consumerKey, consumerSecret) + .oAuthAccessToken(accessToken, accessTokenSecret) + .build(); return twitter; } diff --git a/src/main/java/com/salvis/emptracker/TextMessageListener.java b/src/main/java/com/salvis/emptracker/TextMessageListener.java index 819a9c4..db3a70c 100644 --- a/src/main/java/com/salvis/emptracker/TextMessageListener.java +++ b/src/main/java/com/salvis/emptracker/TextMessageListener.java @@ -25,7 +25,8 @@ import javax.jms.Topic; import javax.jms.TopicSession; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.jms.listener.SessionAwareMessageListener; @@ -33,12 +34,12 @@ import oracle.jms.AQjmsAgent; import oracle.jms.AQjmsTopicPublisher; -import twitter4j.Status; import twitter4j.Twitter; +import twitter4j.v1.Status; @Component public class TextMessageListener implements SessionAwareMessageListener { - private final Logger logger = Logger.getLogger(TextMessageListener.class.getName()); + private final Logger logger = LoggerFactory.getLogger(TextMessageListener.class.getName()); @Autowired private Twitter twitter; @@ -115,7 +116,7 @@ public void onMessage(final TextMessage request, final Session session) { text = getText(ename, oldSal, newSal); } logger.info(text); - Status status = twitter.updateStatus(text); + Status status = twitter.v1().tweets().updateStatus(text); String screenName = status.getUser().getScreenName(); logger.debug("tweet by " + screenName); sendResponse(request, session, screenName + ": " + text, "INFO"); diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 8cb1686..e05956c 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -5,7 +5,7 @@ spring.profiles.active=default app.name=EmpTracker # EmpTracker -db.url=jdbc:oracle:thin:@localhost:1521:odb +db.url=jdbc:oracle:thin:@fillmore:1521:odb db.user=emptracker db.password=emptracker db.queue=requests_aq diff --git a/src/test/java/com/salvis/emptracker/tests/TweetTest.java b/src/test/java/com/salvis/emptracker/tests/TweetTest.java index 251caef..e47bd97 100644 --- a/src/test/java/com/salvis/emptracker/tests/TweetTest.java +++ b/src/test/java/com/salvis/emptracker/tests/TweetTest.java @@ -15,22 +15,19 @@ */ package com.salvis.emptracker.tests; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.Import; -import org.springframework.test.context.junit4.SpringRunner; import com.salvis.emptracker.AppConfig; -import twitter4j.Status; import twitter4j.Twitter; import twitter4j.TwitterException; +import twitter4j.v1.Status; -@RunWith(SpringRunner.class) -@SpringBootTest +@SpringBootTest(classes=AppConfig.class) @Import(AppConfig.class) public class TweetTest { @@ -39,9 +36,9 @@ public class TweetTest { @Test public void postTweet() throws TwitterException { - String text = "SCOTT got a pay raise of $150. Making $3000 a month now. Congrats."; - Status status = twitter.updateStatus(text); - Assert.assertEquals(text, status.getText()); + String text = "SCOTT got a pay raise of $250. Making $3100 a month now. Congrats."; + Status status = twitter.v1().tweets().updateStatus(text); + Assertions.assertEquals(text, status.getText()); } }