diff options
author | Michael Shitrit <ms172g@att.com> | 2017-12-12 08:51:19 +0200 |
---|---|---|
committer | Michael Shitrit <ms172g@att.com> | 2017-12-21 08:19:05 +0200 |
commit | 7712aebd58699838b4926c577b46536de1e25baa (patch) | |
tree | ea9d1aa35559dcb4eb3f006f5b1ff2c1ff20b25d /sdc-distribution-ci/src | |
parent | 59f54a06971a40ba061268ab77fb80fa650d7667 (diff) |
Issue-ID: SDC-744
Change-Id: I965cb1ad1c9dae6aa38a3c3baced3bbbb1d8f5af
Signed-off-by: Michael Shitrit <ms172g@att.com>
Diffstat (limited to 'sdc-distribution-ci/src')
-rw-r--r-- | sdc-distribution-ci/src/main/java/org/openecomp/test/ClientTest.java | 98 | ||||
-rw-r--r-- | sdc-distribution-ci/src/main/java/org/openecomp/test/SimpleConfiguration.java | 16 |
2 files changed, 88 insertions, 26 deletions
diff --git a/sdc-distribution-ci/src/main/java/org/openecomp/test/ClientTest.java b/sdc-distribution-ci/src/main/java/org/openecomp/test/ClientTest.java index e44013c..872240b 100644 --- a/sdc-distribution-ci/src/main/java/org/openecomp/test/ClientTest.java +++ b/sdc-distribution-ci/src/main/java/org/openecomp/test/ClientTest.java @@ -21,43 +21,93 @@ package org.openecomp.test; import org.openecomp.sdc.api.IDistributionClient; -import org.openecomp.sdc.api.consumer.INotificationCallback; +import org.openecomp.sdc.api.consumer.IComponentDoneStatusMessage; +import org.openecomp.sdc.api.consumer.IStatusCallback; +import org.openecomp.sdc.api.notification.INotificationData; +import org.openecomp.sdc.api.notification.IStatusData; import org.openecomp.sdc.api.results.IDistributionClientResult; import org.openecomp.sdc.impl.DistributionClientFactory; -import org.openecomp.sdc.tosca.parser.api.ISdcCsarHelper; -import org.openecomp.sdc.tosca.parser.impl.SdcToscaParserFactory; -import org.slf4j.LoggerFactory; - -import ch.qos.logback.classic.Level; -import ch.qos.logback.classic.LoggerContext; +import org.openecomp.sdc.utils.DistributionStatusEnum; public class ClientTest { public static void main(String[] args) throws Exception { - - LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); - lc.getLogger("org.apache.http").setLevel(Level.INFO); + soWdListner(); + clientSender(); + + } + + private static void clientSender() { IDistributionClient client = DistributionClientFactory.createDistributionClient(); - INotificationCallback callback; - Boolean download = SimpleConfiguration.toDownload(); - if( download ){ - callback = new AdvanceCallBack(client); - } - else{ - callback = new SimpleCallback(client); + IDistributionClientResult result = client.init(new SimpleConfiguration(), new SimpleCallback(client)); + System.err.println("Init Status: " + result.toString()); + + IDistributionClientResult start = client.start(); + + System.err.println("Start Status: " + start.toString()); + for( int i = 0; i < 2; i++ ){ + try { + Thread.sleep(10000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + client.sendComponentDoneStatus(new IComponentDoneStatusMessage() { + + @Override + public long getTimestamp() { + return System.currentTimeMillis(); + } + + @Override + public DistributionStatusEnum getStatus() { + return DistributionStatusEnum.COMPONENT_DONE_OK; + } + + @Override + public String getDistributionID() { + // TODO Auto-generated method stub + return ""; + } + + @Override + public String getConsumerID() { + return client.getConfiguration().getConsumerID(); + } + + @Override + public String getComponentName() { + return "MSO"; + } + }); } - IDistributionClientResult result = client.init(new SimpleConfiguration(), callback); + + } - System.out.println(result.getDistributionMessageResult()); + private static void soWdListner() { + IDistributionClient client = DistributionClientFactory.createDistributionClient(); + IDistributionClientResult result = client.init(new SimpleConfiguration() { + @Override + public boolean isConsumeProduceStatusTopic() { + return true; + } + }, new SimpleCallback(client) { + @Override + public void activateCallback(INotificationData data) { + System.err.println("Monitor Recieved Notification: " + data.toString()); - System.out.println("Starting client..."); - IDistributionClientResult startResult = client.start(); + } + }, new IStatusCallback() { - // Thread.sleep(10000); - // client.stop(); + @Override + public void activateCallback(IStatusData data) { + System.err.println("Monitor Recieved Status: " + data.toString()); - System.out.println(startResult.getDistributionMessageResult()); + } + }); + System.err.println("Init Status: " + result.toString()); + IDistributionClientResult start = client.start(); + System.err.println("Start Status: " + start.toString()); } } diff --git a/sdc-distribution-ci/src/main/java/org/openecomp/test/SimpleConfiguration.java b/sdc-distribution-ci/src/main/java/org/openecomp/test/SimpleConfiguration.java index 60bb7d4..417f564 100644 --- a/sdc-distribution-ci/src/main/java/org/openecomp/test/SimpleConfiguration.java +++ b/sdc-distribution-ci/src/main/java/org/openecomp/test/SimpleConfiguration.java @@ -20,8 +20,11 @@ package org.openecomp.test; +import java.util.ArrayList; +import java.util.Arrays; import java.util.List; +import org.apache.commons.lang3.StringUtils; import org.openecomp.sdc.api.consumer.IConfiguration; public class SimpleConfiguration implements IConfiguration{ @@ -162,9 +165,13 @@ public class SimpleConfiguration implements IConfiguration{ } @Override + public List<String> getMsgBusAddress() { + return new ArrayList<>(); + } + + @Override public String getKeyStorePath() { - //return ""; - return "etc/asdc-client.jks"; + return StringUtils.EMPTY; } @Override @@ -189,4 +196,9 @@ public class SimpleConfiguration implements IConfiguration{ return true; } + @Override + public boolean isConsumeProduceStatusTopic() { + return false; + } + } |