Commit 883d9519 by Amir Aharon

adjust test

parent adaa72f1
...@@ -47,6 +47,13 @@ sourceSets { ...@@ -47,6 +47,13 @@ sourceSets {
compileClasspath += sourceSets.clients.runtimeClasspath compileClasspath += sourceSets.clients.runtimeClasspath
} }
test {
compileClasspath += sourceSets.common.runtimeClasspath
compileClasspath += sourceSets.servicePubsub.runtimeClasspath
compileClasspath += sourceSets.clients.runtimeClasspath
compileClasspath += sourceSets.app.runtimeClasspath
}
} }
dependencies { dependencies {
...@@ -110,7 +117,7 @@ dependencies { ...@@ -110,7 +117,7 @@ dependencies {
task commonJar(type: Jar) { task commonJar(type: Jar) {
from configurations.commonCompile.collect { zipTree it } from configurations.commonCompile.collect { zipTree it }
from sourceSets.common.output from sourceSets.common.output
version = '1.0.0' version = '1.0.1'
archiveName = "microservice-common.jar" archiveName = "microservice-common.jar"
destinationDir = file("build/common") destinationDir = file("build/common")
} }
...@@ -119,7 +126,7 @@ task commonJar(type: Jar) { ...@@ -119,7 +126,7 @@ task commonJar(type: Jar) {
task servicePubsubJar(type: Jar) { task servicePubsubJar(type: Jar) {
dependsOn commonJar dependsOn commonJar
mustRunAfter commonJar mustRunAfter commonJar
from configurations.servicePubsubCompile.collect { zipTree it } //from configurations.servicePubsubCompile.collect { zipTree it }
from sourceSets.servicePubsub.output from sourceSets.servicePubsub.output
version = '1.0.0' version = '1.0.0'
archiveName = "microservice-service-pubsub.jar" archiveName = "microservice-service-pubsub.jar"
...@@ -130,7 +137,7 @@ task servicePubsubJar(type: Jar) { ...@@ -130,7 +137,7 @@ task servicePubsubJar(type: Jar) {
task clientsJar(type: Jar) { task clientsJar(type: Jar) {
dependsOn commonJar dependsOn commonJar
mustRunAfter commonJar mustRunAfter commonJar
from configurations.clientsCompile.collect { zipTree it } //from configurations.clientsCompile.collect { zipTree it }
from sourceSets.clients.output from sourceSets.clients.output
version = '1.0.0' version = '1.0.0'
archiveName = "microservice-clients.jar" archiveName = "microservice-clients.jar"
...@@ -233,6 +240,14 @@ publishing { ...@@ -233,6 +240,14 @@ publishing {
// adding dependencies // adding dependencies
pom.withXml { pom.withXml {
def dependenciesNode = asNode().appendNode('dependencies') def dependenciesNode = asNode().appendNode('dependencies')
configurations.clientsCompile.dependencies.each {
if (it.group != null && it.name != null){
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
}
}
} }
artifact clientsJar artifact clientsJar
} }
...@@ -243,6 +258,14 @@ publishing { ...@@ -243,6 +258,14 @@ publishing {
// adding dependencies // adding dependencies
pom.withXml { pom.withXml {
def dependenciesNode = asNode().appendNode('dependencies') def dependenciesNode = asNode().appendNode('dependencies')
configurations.servicePubsubCompile.dependencies.each {
if (it.group != null && it.name != null){
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
}
}
} }
artifact servicePubsubJar artifact servicePubsubJar
} }
......
package microservice.services; package service.microservice;
import common.microservice.context.PubSubMsg; import common.microservice.context.PubSubMsg;
import common.microservice.defs.Constants; import common.microservice.defs.Constants;
import common.microservice.defs.Enums; import common.microservice.defs.Enums;
import common.microservice.io.iface.IApp;
import common.microservice.io.iface.ILogger; import common.microservice.io.iface.ILogger;
import common.microservice.io.iface.IServiceDiscovery; import common.microservice.io.iface.IServiceDiscovery;
import common.microservice.services.CommonServices; import common.microservice.services.CommonServices;
import common.microservice.utils.IDGenerator; import common.microservice.utils.IDGenerator;
import microservice.MicroserviceApp; import common.microservice.params.PulsarParams;
import microservice.handlers.Reactor;
import microservice.params.PulsarParams;
import org.apache.pulsar.client.admin.PulsarAdmin; import org.apache.pulsar.client.admin.PulsarAdmin;
import org.apache.pulsar.client.admin.PulsarAdminException; import org.apache.pulsar.client.admin.PulsarAdminException;
import org.apache.pulsar.client.admin.Tenants; import org.apache.pulsar.client.admin.Tenants;
...@@ -28,6 +27,8 @@ import java.util.concurrent.ExecutorService; ...@@ -28,6 +27,8 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import static common.microservice.services.CommonServices.buildServiceKey;
/** /**
* This class implements PubSubService for Apache Pulsar * This class implements PubSubService for Apache Pulsar
...@@ -81,16 +82,16 @@ public class IPubSubServicePulsarImpl extends CommonServices.IPubSubService { ...@@ -81,16 +82,16 @@ public class IPubSubServicePulsarImpl extends CommonServices.IPubSubService {
} }
@Override @Override
public boolean init() { public boolean init(IApp app) {
final MicroserviceApp microserviceApp = MicroserviceApp.getsInstance(); this.app = app;
if (microserviceApp != null) { if (app != null) {
clientId = microserviceApp.getAppName() + '-' clientId = app.getAppName() + '-'
+ microserviceApp.getServerName() + '-' + app.getServerName() + '-'
+ microserviceApp.getId(); + app.getId();
logger = MicroserviceApp.getsInstance().getLogger(); logger = app.getLogger();
namespacePrefix = TOPIC_PREFIX + "/" + microserviceApp.getAppName(); namespacePrefix = TOPIC_PREFIX + "/" + app.getAppName();
} else { } else {
// for tests where there is no MicroserviceApp // for tests where there is no MicroserviceApp
namespacePrefix = TOPIC_PREFIX + "/" + "testApp"; namespacePrefix = TOPIC_PREFIX + "/" + "testApp";
...@@ -167,7 +168,7 @@ public class IPubSubServicePulsarImpl extends CommonServices.IPubSubService { ...@@ -167,7 +168,7 @@ public class IPubSubServicePulsarImpl extends CommonServices.IPubSubService {
if (topic.length() > namespacePrefix.length() && if (topic.length() > namespacePrefix.length() &&
topic.startsWith(namespacePrefix)) { topic.startsWith(namespacePrefix)) {
topic = topic.substring(namespacePrefix.length()); topic = topic.substring(namespacePrefix.length());
String key = Reactor.buildServiceKey(Enums.EnumServiceType.E_PUBSUB, String key = buildServiceKey(Enums.EnumServiceType.E_PUBSUB,
CommonServices.EnumPubSubCommands.E_NOTIFY, CommonServices.EnumPubSubCommands.E_NOTIFY,
topic); topic);
reactor.delegate(this, key, msgCtx); reactor.delegate(this, key, msgCtx);
...@@ -334,9 +335,8 @@ public class IPubSubServicePulsarImpl extends CommonServices.IPubSubService { ...@@ -334,9 +335,8 @@ public class IPubSubServicePulsarImpl extends CommonServices.IPubSubService {
* wildcard topic: * wildcard topic:
* {persistent|non-persistent}://<tenant>/<namespace>/<regular expression> * {persistent|non-persistent}://<tenant>/<namespace>/<regular expression>
*/ */
final MicroserviceApp microserviceApp = MicroserviceApp.getsInstance();
String pattern = namespacePrefix + "/.*"; String pattern = namespacePrefix + "/.*";
adminValidateTenantAndNamespace(Constants.DEFAULT_TENANT,microserviceApp.getAppName()); adminValidateTenantAndNamespace(Constants.DEFAULT_TENANT,app.getAppName());
Pattern allTopicsInNamespace = Pattern.compile(pattern); Pattern allTopicsInNamespace = Pattern.compile(pattern);
consumer = client.newConsumer(JSONSchema.of(PubSubMsg.class)) consumer = client.newConsumer(JSONSchema.of(PubSubMsg.class))
.subscriptionName(clientId) .subscriptionName(clientId)
......
package microservice; package microservice;
import clients.microservice.impl.IRestClientHttpImpl;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ObjectNode;
import common.microservice.context.RestContext; import common.microservice.context.RestContext;
import common.microservice.defs.Enums; import common.microservice.defs.Enums;
import common.microservice.io.iface.IRestClient;
import common.microservice.params.*; import common.microservice.params.*;
import common.microservice.services.CommonServices; import common.microservice.services.CommonServices;
import common.microservice.io.iface.IRestClient;
import microservice.io.impl.*;
import services.impl.IRestServiceHttpImpl;
import services.impl.IRestServiceZmqImpl;
import common.microservice.types.BaseRestResponse; import common.microservice.types.BaseRestResponse;
import microservice.io.impl.IRestServerRMQImpl;
import microservice.io.impl.IRestServerUndertowImpl;
import microservice.io.impl.IServiceDiscoveryConsulImpl;
import microservice.service.pubsub.impl.IRestServiceHttpImpl;
import microservice.service.pubsub.impl.IRestServiceZmqImpl;
import microservice.utils.ServiceBuilderFactory; import microservice.utils.ServiceBuilderFactory;
import org.eclipse.paho.client.mqttv3.MqttException; import org.eclipse.paho.client.mqttv3.MqttException;
import org.junit.Test; import org.junit.Test;
...@@ -37,7 +39,7 @@ public class TestMicroserviceApp { ...@@ -37,7 +39,7 @@ public class TestMicroserviceApp {
String appName = "testApp"; String appName = "testApp";
//ILogger logger = new ILogger4jImpl(appName); //ILogger logger = new ILogger4jImpl(appName);
microservice.MicroserviceApp msApp = new microservice.MicroserviceApp(appName); MicroserviceApp msApp = new microservice.MicroserviceApp(appName);
msApp.withMetrics() msApp.withMetrics()
//.withDefaultServiceAuthorization() //.withDefaultServiceAuthorization()
.withPubSub(new microservice.io.impl.IPubSubMQTTImpl("tcp://localhost",0,null,0)) .withPubSub(new microservice.io.impl.IPubSubMQTTImpl("tcp://localhost",0,null,0))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment