Skip to content

Commit

Permalink
Merge pull request #20 from dnwick/master
Browse files Browse the repository at this point in the history
Upgrade log4j1 to 2.17.1
  • Loading branch information
lasanthaS authored Feb 22, 2022
2 parents 5d43df5 + 0730b52 commit 29d3a7c
Show file tree
Hide file tree
Showing 15 changed files with 177 additions and 110 deletions.
4 changes: 2 additions & 2 deletions component/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ under the License.
<artifactId>siddhi-query-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.log4j.wso2</groupId>
<artifactId>log4j</artifactId>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</dependency>
<dependency>
<groupId>org.testng</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
import io.siddhi.core.util.transport.OptionHolder;
import io.siddhi.extension.io.googlepubsub.util.GooglePubSubConstants;
import io.siddhi.query.api.definition.StreamDefinition;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.io.File;
import java.io.FileInputStream;
Expand Down Expand Up @@ -102,7 +103,7 @@
*/
public class GooglePubSubSink extends Sink<State> {

private static final Logger log = Logger.getLogger(GooglePubSubSink.class);
private static final Logger log = LogManager.getLogger(GooglePubSubSink.class);
private String streamID;
private String siddhiAppName;
private GoogleCredentials credentials;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
import io.siddhi.core.util.snapshot.state.StateFactory;
import io.siddhi.core.util.transport.OptionHolder;
import io.siddhi.extension.io.googlepubsub.util.GooglePubSubConstants;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.io.File;
import java.io.FileInputStream;
Expand Down Expand Up @@ -106,7 +107,7 @@

public class GooglePubSubSource extends Source<State> {

private static final Logger log = Logger.getLogger(GooglePubSubSource.class);
private static final Logger log = LogManager.getLogger(GooglePubSubSource.class);
private String streamID;
private String siddhiAppName;
private SubscriptionAdminClient subscriptionAdminClient;
Expand Down
34 changes: 0 additions & 34 deletions component/src/main/resources/log4j.properties

This file was deleted.

40 changes: 40 additions & 0 deletions component/src/main/resources/log4j2.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#
# /*
# * Copyright (c) 2022, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
# *
# * WSO2 Inc. licenses this file to you under the Apache License,
# * Version 2.0 (the "License"); you may not use this file except
# * in compliance with the License.
# * You may obtain a copy of the License at
# *
# * http://www.apache.org/licenses/LICENSE-2.0
# *
# * Unless required by applicable law or agreed to in writing,
# * software distributed under the License is distributed on an
# * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# * KIND, either express or implied. See the License for the
# * specific language governing permissions and limitations
# * under the License.
# */
#


# For the general syntax of property based configuration files see the
# documenation of org.apache.log4j.PropertyConfigurator.

# The root category uses the appender called A1. Since no priority is
# specified, the root category assumes the default priority for root
# which is DEBUG in log4j. The root category is the only category that
# has a default priority. All other categories need not be assigned a
# priority in which case they inherit their priority from the
# hierarchy.

# Console appender configuration
appender.console.type = Console
appender.console.name = consoleLogger
appender.console.layout.type = PatternLayout
appender.console.layout.pattern = [%t] %-5p %c %x - %m%n

# Root logger referring to console appender
rootLogger.level = info
rootLogger.appenderRef.stdout.ref = consoleLogger
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
import io.siddhi.core.stream.input.InputHandler;
import io.siddhi.core.stream.output.StreamCallback;
import io.siddhi.extension.io.googlepubsub.util.ResultContainer;
import org.apache.log4j.Logger;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.testng.AssertJUnit;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
Expand All @@ -33,7 +35,7 @@

public class TestCaseOfGooglePubSubSink1 {

private static Logger log = Logger.getLogger(TestCaseOfGooglePubSubSink1.class);
private static final Logger log = LogManager.getLogger(TestCaseOfGooglePubSubSink1.class);
private volatile int count;
private volatile boolean eventArrived;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,18 @@
import io.siddhi.core.SiddhiManager;
import io.siddhi.core.exception.SiddhiAppCreationException;
import io.siddhi.core.stream.input.InputHandler;
import io.siddhi.core.stream.output.sink.Sink;
import io.siddhi.extension.io.googlepubsub.util.UnitTestAppender;
import io.siddhi.query.api.exception.SiddhiAppValidationException;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.Logger;
import org.testng.AssertJUnit;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

public class TestCaseOfGooglePubSubSink2 {

private static Logger log = Logger.getLogger(TestCaseOfGooglePubSubSink1.class);
private static final Logger log = (Logger) LogManager.getLogger(TestCaseOfGooglePubSubSink1.class);
private volatile int count;
private volatile boolean eventArrived;

Expand Down Expand Up @@ -102,9 +103,11 @@ public void googlePubSubSimplePublishTest3() throws InterruptedException {
log.info("-----------------------------------------------------------------");
log.info("Test to publish messages to a non-existing project in the server.");
log.info("-----------------------------------------------------------------");
log = Logger.getLogger(Sink.class);
UnitTestAppender testAppender = new UnitTestAppender();
log.addAppender(testAppender);
UnitTestAppender appender = new UnitTestAppender("UnitTestAppender", null);
final Logger logger = (Logger) LogManager.getRootLogger();
logger.setLevel(Level.ALL);
logger.addAppender(appender);
appender.start();
SiddhiManager siddhiManager = new SiddhiManager();
// deploying the execution plan
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(
Expand All @@ -120,10 +123,11 @@ public void googlePubSubSimplePublishTest3() throws InterruptedException {
siddhiAppRuntime.start();
fooStream.send(new Object[]{"World"});
siddhiAppRuntime.start();
AssertJUnit.assertTrue(testAppender
.getMessages()
.contains("An error is caused due to a resource NOT_FOUND in Google Pub Sub server"));
AssertJUnit.assertTrue(((UnitTestAppender) logger.getAppenders().
get("UnitTestAppender")).getMessages().
contains("An error is caused due to a resource NOT_FOUND in Google Pub Sub server"));
siddhiAppRuntime.shutdown();
logger.removeAppender(appender);
}

/**
Expand All @@ -135,9 +139,11 @@ public void googlePubSubSimplePublishTest4() throws InterruptedException {
log.info("-----------------------------------------------------------");
log.info("Test to publish messages by specifying project.id as empty.");
log.info("-----------------------------------------------------------");
log = Logger.getLogger(Sink.class);
UnitTestAppender testAppender = new UnitTestAppender();
log.addAppender(testAppender);
UnitTestAppender appender = new UnitTestAppender("UnitTestAppender", null);
final Logger logger = (Logger) LogManager.getRootLogger();
logger.setLevel(Level.ALL);
logger.addAppender(appender);
appender.start();
SiddhiManager siddhiManager = new SiddhiManager();
// deploying the execution plan
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(
Expand All @@ -153,9 +159,10 @@ public void googlePubSubSimplePublishTest4() throws InterruptedException {
siddhiAppRuntime.start();
fooStream.send(new Object[]{"World"});
siddhiAppRuntime.start();
AssertJUnit.assertTrue(testAppender
.getMessages()
.contains("An error is caused due to a resource NOT_FOUND in Google Pub Sub server"));
AssertJUnit.assertTrue(((UnitTestAppender) logger.getAppenders().
get("UnitTestAppender")).getMessages().
contains("An error is caused due to a resource NOT_FOUND in Google Pub Sub server"));
siddhiAppRuntime.shutdown();
logger.removeAppender(appender);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
import com.google.pubsub.v1.PubsubMessage;
import com.google.pubsub.v1.PushConfig;
import io.siddhi.extension.io.googlepubsub.util.ResultContainer;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.io.File;
import java.io.FileInputStream;
Expand All @@ -43,7 +44,7 @@
*/
public class TestSubscriber {

private static final Logger log = Logger.getLogger(TestSubscriber.class);
private static final Logger log = LogManager.getLogger(TestSubscriber.class);
private ResultContainer resultContainer;
private boolean eventArrived;
private int count;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
import io.siddhi.core.stream.input.source.Source;
import io.siddhi.core.stream.output.StreamCallback;
import io.siddhi.core.util.SiddhiTestHelper;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.Logger;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

Expand All @@ -34,7 +35,7 @@

public class TestCaseOfGooglePubSubSource1 {

private static Logger log = Logger.getLogger(TestCaseOfGooglePubSubSource1.class);
private static final Logger log = (Logger) LogManager.getLogger(TestCaseOfGooglePubSubSource1.class);
private AtomicInteger count = new AtomicInteger(0);
private AtomicInteger count1 = new AtomicInteger(0);
private int waitTime = 50;
Expand Down Expand Up @@ -211,7 +212,6 @@ public void testGooglePubSubSourcePause() throws Exception {
log.info("--------------------------------------------------------------------------------");
log.info("Test to configure Google Pub Sub Source with pausing and resuming functionality.");
log.info("--------------------------------------------------------------------------------");
log = Logger.getLogger(GooglePubSubSource.class);
// deploying the execution plan
SiddhiManager siddhiManager = new SiddhiManager();
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
import io.siddhi.core.exception.SiddhiAppCreationException;
import io.siddhi.extension.io.googlepubsub.util.UnitTestAppender;
import io.siddhi.query.api.exception.SiddhiAppValidationException;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.Logger;
import org.testng.AssertJUnit;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
Expand All @@ -32,7 +34,7 @@

public class TestCaseOfGooglePubSubSource2 {

private static Logger log = Logger.getLogger(TestCaseOfGooglePubSubSource1.class);
private static final Logger log = (Logger) LogManager.getLogger(TestCaseOfGooglePubSubSource1.class);
private AtomicInteger count = new AtomicInteger(0);
private AtomicInteger count1 = new AtomicInteger(0);
private int waitTime = 50;
Expand Down Expand Up @@ -83,9 +85,11 @@ public void testGooglePubSubSourceEvent4() {
log.info("---------------------------------------------------------------------------------------------------");
log.info("Test to receive messages by subscribing to topic in an unavailable project of google pubsub server.");
log.info("---------------------------------------------------------------------------------------------------");
log = Logger.getLogger(GooglePubSubSource.class);
UnitTestAppender appender = new UnitTestAppender();
log.addAppender(appender);
UnitTestAppender appender = new UnitTestAppender("UnitTestAppender", null);
final Logger logger = (Logger) LogManager.getRootLogger();
logger.setLevel(Level.ALL);
logger.addAppender(appender);
appender.start();
SiddhiManager siddhiManager = new SiddhiManager();
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(
"@App:name('TestExecutionPlan1') "
Expand All @@ -100,8 +104,11 @@ public void testGooglePubSubSourceEvent4() {
+ "Define stream FooStream2 (message string);"
+ "from FooStream2 select message insert into BarStream2;");
siddhiAppRuntime.start();
AssertJUnit.assertTrue(appender.getMessages().contains("Error in connecting to the resources at "));
AssertJUnit.assertTrue(((UnitTestAppender) logger.getAppenders().
get("UnitTestAppender")).getMessages().
contains("Error in connecting to the resources at "));
siddhiAppRuntime.shutdown();
logger.removeAppender(appender);
}

/**
Expand All @@ -114,9 +121,11 @@ public void testGooglePubSubSourceEvent6() {
log.info("----------------------------------------------------------------------------------------");
log.info("Test to receive messages by subscribing to a non-existing topic in google pubsub server.");
log.info("----------------------------------------------------------------------------------------");
log = Logger.getLogger(GooglePubSubSource.class);
UnitTestAppender appender = new UnitTestAppender();
log.addAppender(appender);
UnitTestAppender appender = new UnitTestAppender("UnitTestAppender", null);
final Logger logger = (Logger) LogManager.getRootLogger();
logger.setLevel(Level.ALL);
logger.addAppender(appender);
appender.start();
SiddhiManager siddhiManager = new SiddhiManager();
SiddhiAppRuntime siddhiAppRuntime = siddhiManager.createSiddhiAppRuntime(
"@App:name('TestExecutionPlan1') "
Expand All @@ -131,8 +140,11 @@ public void testGooglePubSubSourceEvent6() {
+ "Define stream FooStream2 (message string);"
+ "from FooStream2 select message insert into BarStream2;");
siddhiAppRuntime.start();
AssertJUnit.assertTrue(appender.getMessages().contains("Error in connecting to the resources at "));
AssertJUnit.assertTrue(((UnitTestAppender) logger.getAppenders().
get("UnitTestAppender")).getMessages().
contains("Error in connecting to the resources at "));
siddhiManager.shutdown();
logger.removeAppender(appender);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
import com.google.pubsub.v1.PubsubMessage;
import io.siddhi.core.exception.ConnectionUnavailableException;
import io.siddhi.core.exception.SiddhiAppCreationException;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.io.File;
import java.io.FileInputStream;
Expand All @@ -44,7 +45,7 @@
*/
public class TestPublisher {

private static final Logger log = Logger.getLogger(TestPublisher.class);
private static final Logger log = LogManager.getLogger(TestPublisher.class);

private TopicAdminClient topicAdminClient;
private String projectId;
Expand Down
Loading

0 comments on commit 29d3a7c

Please sign in to comment.