Commit 883d9519 by Amir Aharon

adjust test

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