Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 2 additions & 27 deletions modules/commons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,31 +56,6 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>default-instrument</id>
<goals>
<goal>instrument</goal>
</goals>
</execution>
<execution>
<id>default-restore-instrumented-classes</id>
<goals>
<goal>restore-instrumented-classes</goal>
</goals>
</execution>
<execution>
<id>default-report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<dataFile>target/coverage-reports/jacoco-unit-commons.exec</dataFile>
<outputDirectory>target/coverage-reports/site</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
Expand Down Expand Up @@ -259,8 +234,8 @@
<artifactId>commons-logging</artifactId>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,25 @@ public static DataSource find(String dsName, Context context) {

try {
Object dataSourceO = context.lookup(dsName);
if (dataSourceO != null && dataSourceO instanceof DataSource) {
return (DataSource) dataSourceO;
} else {
throw new SynapseCommonsException("DataSource : " + dsName + " not found " +
"when looking up using JNDI properties : " + context.getEnvironment(), log);
if (dataSourceO != null) {
// Let JNDI automatically dereference if needed
if (dataSourceO instanceof javax.naming.Reference) {
dataSourceO = javax.naming.spi.NamingManager.getObjectInstance(
dataSourceO, null, null, context.getEnvironment());
}
if (dataSourceO instanceof DataSource) {
return (DataSource) dataSourceO;
}
}
throw new SynapseCommonsException("DataSource : " + dsName + " not found " +
"when looking up using JNDI properties : " + context.getEnvironment(), log);


} catch (NamingException e) {
throw new SynapseCommonsException("Error looking up DataSource : " + dsName
+ " using JNDI" + " properties : " + context, e);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
import java.util.Collection;
import java.util.List;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBException;
import jakarta.xml.bind.Marshaller;
import jakarta.xml.bind.Unmarshaller;
import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlType;
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
import java.util.Collection;
import java.util.List;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBException;
import javax.xml.stream.XMLStreamException;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
import java.lang.reflect.Method;

import javax.xml.XMLConstants;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.annotation.XmlElementDecl;
import javax.xml.bind.annotation.XmlNs;
import javax.xml.bind.annotation.XmlRegistry;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSchema;
import javax.xml.bind.annotation.XmlType;
import jakarta.xml.bind.JAXBElement;
import jakarta.xml.bind.JAXBException;
import jakarta.xml.bind.annotation.XmlElementDecl;
import jakarta.xml.bind.annotation.XmlNs;
import jakarta.xml.bind.annotation.XmlRegistry;
import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlSchema;
import jakarta.xml.bind.annotation.XmlType;
import javax.xml.namespace.QName;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.XmlType;
import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBException;
import jakarta.xml.bind.Marshaller;
import jakarta.xml.bind.Unmarshaller;
import jakarta.xml.bind.annotation.XmlType;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
import java.lang.reflect.Method;

import javax.xml.XMLConstants;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.annotation.XmlElementDecl;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import jakarta.xml.bind.JAXBElement;
import jakarta.xml.bind.JAXBException;
import jakarta.xml.bind.annotation.XmlElementDecl;
import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlType;
import javax.xml.namespace.QName;

import junit.framework.Assert;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
*/
package org.apache.synapse.commons.staxon.core.json.jaxb.sample;

import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlElementDecl;
import javax.xml.bind.annotation.XmlRegistry;
import jakarta.xml.bind.JAXBElement;
import jakarta.xml.bind.annotation.XmlElementDecl;
import jakarta.xml.bind.annotation.XmlRegistry;
import javax.xml.namespace.QName;

@XmlRegistry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

import java.util.List;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;

import org.apache.synapse.commons.staxon.core.json.jaxb.JsonXML;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*/
package org.apache.synapse.commons.staxon.core.json.jaxb.sample;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlType;

@XmlType
public class SampleType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*/
package org.apache.synapse.commons.staxon.core.json.jaxb.sample;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlType;

@XmlType(namespace = "urn:staxon:jaxb:test")
public class SampleTypeWithNamespace {
Expand Down
Binary file removed modules/core/jacoco.exec
Binary file not shown.
76 changes: 0 additions & 76 deletions modules/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,32 +107,6 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${maven.jacoco.plugin.version}</version>
<executions>
<execution>
<id>default-instrument</id>
<goals>
<goal>instrument</goal>
</goals>
</execution>
<execution>
<id>default-restore-instrumented-classes</id>
<goals>
<goal>restore-instrumented-classes</goal>
</goals>
</execution>
<execution>
<id>default-report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<dataFile>target/coverage-reports/jacoco-unit-core.exec</dataFile>
<outputDirectory>target/coverage-reports/site</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.antlr</groupId>
Expand Down Expand Up @@ -433,51 +407,11 @@
<classifier>runtime</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-broker</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-reflect</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4-common</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-support</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
Expand Down Expand Up @@ -513,16 +447,6 @@
<groupId>com.github.stefanbirkner</groupId>
<artifactId>system-rules</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.json.wso2</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;

import java.util.Arrays;
import java.util.HashMap;
Expand All @@ -44,10 +43,7 @@
/**
* Unit tests for StatisticDataCollectionHelper class.
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest(RuntimeStatisticCollector.class)
@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*", "javax.management.*", "javax.xml.parsers.*", "org.apache" +
".xerces.jaxp.*", "javax.naming.spi.*", "javax.naming.*"})
@RunWith(MockitoJUnitRunner.class)
public class StatisticDataCollectionHelperTest {

private static Axis2MessageContext messageContext;
Expand Down Expand Up @@ -137,31 +133,35 @@ public void testIsOutOnlyFlow() {
*/
@Test
public void testCollectAggregatedParents() {
PowerMockito.mockStatic(RuntimeStatisticCollector.class);
PowerMockito.when(RuntimeStatisticCollector.isStatisticsEnabled()).thenReturn(true);
PowerMockito.when(RuntimeStatisticCollector.shouldReportStatistic(any(MessageContext.class))).thenReturn(true);
messageContextOld.setProperty(StatisticsConstants.MEDIATION_FLOW_STATISTICS_PARENT_INDEX, 1);
messageContextNew.setProperty(StatisticsConstants.MEDIATION_FLOW_STATISTICS_PARENT_INDEX, 2);
List<MessageContext> messageList = new ArrayList<>();
messageList.add(messageContextOld);
StatisticDataCollectionHelper.collectAggregatedParents(messageList, messageContextNew);
List<Integer> parentList = Arrays.asList(1);
Assert.assertEquals("should return all the parent indices in message list", parentList, messageContextNew
.getProperty(StatisticsConstants.MEDIATION_FLOW_STATISTICS_PARENT_LIST));
try (MockedStatic<RuntimeStatisticCollector> mockedCollector = Mockito.mockStatic(RuntimeStatisticCollector.class)) {
mockedCollector.when(RuntimeStatisticCollector::isStatisticsEnabled).thenReturn(true);
mockedCollector.when(() -> RuntimeStatisticCollector.shouldReportStatistic(any(MessageContext.class))).thenReturn(true);

messageContextOld.setProperty(StatisticsConstants.MEDIATION_FLOW_STATISTICS_PARENT_INDEX, 1);
messageContextNew.setProperty(StatisticsConstants.MEDIATION_FLOW_STATISTICS_PARENT_INDEX, 2);
List<MessageContext> messageList = new ArrayList<>();
messageList.add(messageContextOld);
StatisticDataCollectionHelper.collectAggregatedParents(messageList, messageContextNew);
List<Integer> parentList = Arrays.asList(1);
Assert.assertEquals("should return all the parent indices in message list", parentList, messageContextNew
.getProperty(StatisticsConstants.MEDIATION_FLOW_STATISTICS_PARENT_LIST));
}
}

/**
* Test collectData method by validating dataUnit.
*/
@Test
public void testCollectData() {
PowerMockito.mockStatic(RuntimeStatisticCollector.class);
PowerMockito.when(RuntimeStatisticCollector.isCollectingPayloads()).thenReturn(true);
PowerMockito.when(RuntimeStatisticCollector.isCollectingProperties()).thenReturn(true);
StatisticDataUnit dataUnit = new StatisticDataUnit();
StatisticDataCollectionHelper.collectData(messageContext, true, true, dataUnit);
Assert.assertNotNull("context properties should be inserted", dataUnit.getContextPropertyMap());
Assert.assertNotNull("transport properties should be inserted", dataUnit.getTransportPropertyMap());
Assert.assertNotNull("payload should be inserted", dataUnit.getPayload());
try (MockedStatic<RuntimeStatisticCollector> mockedCollector = Mockito.mockStatic(RuntimeStatisticCollector.class)) {
mockedCollector.when(RuntimeStatisticCollector::isCollectingPayloads).thenReturn(true);
mockedCollector.when(RuntimeStatisticCollector::isCollectingProperties).thenReturn(true);

StatisticDataUnit dataUnit = new StatisticDataUnit();
StatisticDataCollectionHelper.collectData(messageContext, true, true, dataUnit);
Assert.assertNotNull("context properties should be inserted", dataUnit.getContextPropertyMap());
Assert.assertNotNull("transport properties should be inserted", dataUnit.getTransportPropertyMap());
Assert.assertNotNull("payload should be inserted", dataUnit.getPayload());
}
}
}
Loading
Loading