Skip to content

Commit

Permalink
Merge pull request #2 from PhilippSalvisberg/feature/issue-1-jdk17
Browse files Browse the repository at this point in the history
Feature/issue 1 jdk17
  • Loading branch information
PhilippSalvisberg authored Nov 13, 2022
2 parents c1a4d27 + ec3a41e commit 69bccf4
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 130 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ hs_err_pid*
**/.project
**/.classpath
**/.settings
**/.idea
Binary file removed lib/aqapi.jar
Binary file not shown.
Binary file removed lib/jmscommon.jar
Binary file not shown.
Binary file removed lib/ojdbc8.jar
Binary file not shown.
Binary file removed lib/orai18n-collation.jar
Binary file not shown.
Binary file removed lib/orai18n-mapping.jar
Binary file not shown.
Binary file removed lib/ucp.jar
Binary file not shown.
143 changes: 39 additions & 104 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,90 +3,52 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.salvis</groupId>
<artifactId>emptracker</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>1.1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jdk.version>1.8</jdk.version>
<spring.version>4.3.10.RELEASE</spring.version>
<skipTests>true</skipTests>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.8.RELEASE</version>
<version>2.7.5</version>
<relativePath/>
</parent>
<build>
<sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
<testSourceDirectory>${project.basedir}/src/test/java</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>${skipTests}</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<finalName>${project.artifactId}</finalName>
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
<manifest>
<addClasspath>true</addClasspath>
<useUniqueVersions>false</useUniqueVersions>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>com.salvis.emptracker.EmptrackerApplication</mainClass>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
<manifestEntries>
<Class-Path>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</Class-Path>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies-runtime</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
<goal>repackage</goal>
</goals>
<configuration>
<outputDirectory>target/lib</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
<excludeTransitive>false</excludeTransitive>
<includeScope>runtime</includeScope>
</configuration>
</execution>
<execution>
<id>copy-dependencies-system</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>target/lib</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
<excludeTransitive>false</excludeTransitive>
<includeScope>system</includeScope>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>${skipTests}</skipTests>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>3.2.0</version>
<type>maven-plugin</type>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
Expand All @@ -103,7 +65,7 @@
<dependency>
<groupId>org.twitter4j</groupId>
<artifactId>twitter4j-core</artifactId>
<version>4.0.6</version>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>javax.transaction</groupId>
Expand All @@ -115,62 +77,35 @@
<artifactId>javax.servlet-api</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8-production</artifactId>
<version>21.7.0.0</version>
<type>pom</type>
</dependency>
<!-- Oracle dependencies not available in public maven repositories -->
<dependency>
<groupId>oracle</groupId>
<groupId>com.oracle.database.messaging</groupId>
<artifactId>aqapi</artifactId>
<version>12.2.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/aqapi.jar</systemPath>
</dependency>
<dependency>
<groupId>oracle</groupId>
<artifactId>jmscommon</artifactId>
<version>12.2.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/jmscommon.jar</systemPath>
<version>21.3.0.0</version>
</dependency>
<dependency>
<groupId>oracle</groupId>
<artifactId>ojdbc8</artifactId>
<version>12.2.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/ojdbc8.jar</systemPath>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ucp</artifactId>
<version>21.7.0.0</version>
</dependency>
<dependency>
<groupId>oracle</groupId>
<artifactId>orai18n-collation</artifactId>
<version>12.2.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/orai18n-collation.jar</systemPath>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>oracle</groupId>
<artifactId>orai18n-mapping</artifactId>
<version>12.2.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/orai18n-mapping.jar</systemPath>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>oracle</groupId>
<artifactId>ucp</artifactId>
<version>12.2.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/ucp.jar</systemPath>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

Expand Down
18 changes: 7 additions & 11 deletions src/main/java/com/salvis/emptracker/AppConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
9 changes: 5 additions & 4 deletions src/main/java/com/salvis/emptracker/TextMessageListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,21 @@
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;
import org.springframework.stereotype.Component;

import oracle.jms.AQjmsAgent;
import oracle.jms.AQjmsTopicPublisher;
import twitter4j.Status;
import twitter4j.Twitter;
import twitter4j.v1.Status;

@Component
public class TextMessageListener implements SessionAwareMessageListener<TextMessage> {
private final Logger logger = Logger.getLogger(TextMessageListener.class.getName());
private final Logger logger = LoggerFactory.getLogger(TextMessageListener.class.getName());

@Autowired
private Twitter twitter;
Expand Down Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 7 additions & 10 deletions src/test/java/com/salvis/emptracker/tests/TweetTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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());
}

}

0 comments on commit 69bccf4

Please sign in to comment.