Tests fixed. Added probes autostart.
diff --git a/pom.xml b/pom.xml
index 539ec36..6398f48 100644
--- a/pom.xml
+++ b/pom.xml
@@ -36,7 +36,6 @@
<maven.shade.plugin.ver>3.1.0</maven.shade.plugin.ver>
<maven.source.plugin.ver>3.0.1</maven.source.plugin.ver>
<maven.gpg.plugin.ver>1.6</maven.gpg.plugin.ver>
- <maven.nexus.staging.plugin>1.6.7</maven.nexus.staging.plugin>
<maven.enforcer.plugin.ver>1.4.1</maven.enforcer.plugin.ver>
<maven.surefire.plugin.ver>2.22.1</maven.surefire.plugin.ver>
<maven.javadoc.plugin.ver>3.0.0-M1</maven.javadoc.plugin.ver>
@@ -291,18 +290,6 @@
</execution>
</executions>
</plugin>
- <plugin>
- <groupId>org.sonatype.plugins</groupId>
- <artifactId>nexus-staging-maven-plugin</artifactId>
- <version>${maven.nexus.staging.plugin}</version>
- <extensions>true</extensions>
- <configuration>
- <serverId>ossrh</serverId>
- <nexusUrl>https://oss.sonatype.org/</nexusUrl>
- <autoReleaseAfterClose>false</autoReleaseAfterClose>
- <skipLocalStaging>true</skipLocalStaging>
- </configuration>
- </plugin>
</plugins>
</build>
diff --git a/src/main/resources/log4j2.xml b/src/main/resources/log4j2.xml
index b3aa2e2..5809b27 100644
--- a/src/main/resources/log4j2.xml
+++ b/src/main/resources/log4j2.xml
@@ -24,10 +24,10 @@
</Console>
</Appenders>
<Loggers>
- <Root level="DEBUG">
+ <Root level="INFO">
<AppenderRef ref="CONSOLE"/>
</Root>
- <Logger name="org.apache.nlpcraft" level="DEBUG" additivity="false">
+ <Logger name="org.apache.nlpcraft" level="INFO" additivity="false">
<AppenderRef ref="CONSOLE"/>
</Logger>
</Loggers>
diff --git a/src/test/java/org/apache/nlpcraft/client/NCAskSyncTest.java b/src/test/java/org/apache/nlpcraft/client/NCAskSyncTest.java
index 4bcc2f4..102deb7 100644
--- a/src/test/java/org/apache/nlpcraft/client/NCAskSyncTest.java
+++ b/src/test/java/org/apache/nlpcraft/client/NCAskSyncTest.java
@@ -17,8 +17,11 @@
package org.apache.nlpcraft.client;
+import org.apache.nlpcraft.examples.alarm.AlarmModel;
+import org.apache.nlpcraft.model.NCModel;
import org.junit.jupiter.api.Test;
+import java.util.Optional;
import java.util.function.Consumer;
/**
@@ -27,7 +30,12 @@
class NCAskSyncTest extends NCTestAdapter {
//
private static final String MDL_ID = "nlpcraft.alarm.ex";
-
+
+ @Override
+ Optional<Class<? extends NCModel>> getModelClass() {
+ return Optional.of(AlarmModel.class);
+ }
+
/**
*
* @param txt
diff --git a/src/test/java/org/apache/nlpcraft/client/NCAskTest.java b/src/test/java/org/apache/nlpcraft/client/NCAskTest.java
index 6f362d5..dcefb9c 100644
--- a/src/test/java/org/apache/nlpcraft/client/NCAskTest.java
+++ b/src/test/java/org/apache/nlpcraft/client/NCAskTest.java
@@ -17,6 +17,8 @@
package org.apache.nlpcraft.client;
+import org.apache.nlpcraft.examples.alarm.AlarmModel;
+import org.apache.nlpcraft.model.NCModel;
import org.junit.jupiter.api.Test;
import java.util.List;
@@ -34,7 +36,12 @@
/** */
private static final int MAX_TEST_TIME = 20000;
-
+
+ @Override
+ Optional<Class<? extends NCModel>> getModelClass() {
+ return Optional.of(AlarmModel.class);
+ }
+
/**
*
* @param txt
diff --git a/src/test/java/org/apache/nlpcraft/client/NCCompanyTest.java b/src/test/java/org/apache/nlpcraft/client/NCCompanyTest.java
index 603b69b..bdb16a3 100644
--- a/src/test/java/org/apache/nlpcraft/client/NCCompanyTest.java
+++ b/src/test/java/org/apache/nlpcraft/client/NCCompanyTest.java
@@ -21,7 +21,7 @@
import java.util.UUID;
-import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* REST client test. Methods `company/*`.
diff --git a/src/test/java/org/apache/nlpcraft/client/NCConversationTest.java b/src/test/java/org/apache/nlpcraft/client/NCConversationTest.java
index 36129ba..7dcc5d0 100644
--- a/src/test/java/org/apache/nlpcraft/client/NCConversationTest.java
+++ b/src/test/java/org/apache/nlpcraft/client/NCConversationTest.java
@@ -17,19 +17,28 @@
package org.apache.nlpcraft.client;
+import org.apache.nlpcraft.examples.weather.WeatherModel;
+import org.apache.nlpcraft.model.NCModel;
import org.junit.jupiter.api.Test;
+import java.util.Optional;
import java.util.function.Consumer;
/**
* REST client test. Methods `clear/conversation`.
*/
class NCConversationTest extends NCTestAdapter {
- /** */
- private static final String MDL_ID = "nlpcraft.weather.ex";
-
/**
*
+ */
+ private static final String MDL_ID = "nlpcraft.weather.ex";
+
+ @Override
+ Optional<Class<? extends NCModel>> getModelClass() {
+ return Optional.of(WeatherModel.class);
+ }
+
+ /**
* @param txt
* @param resConsumer
* @throws Exception
@@ -37,39 +46,37 @@
private void check(String txt, Consumer<NCResult> resConsumer) throws Exception {
resConsumer.accept(admCli.askSync(MDL_ID, txt, null, true, null, null));
}
-
+
/**
- *
* @throws Exception
*/
@Test
void test1() throws Exception {
check("What's the weather in Moscow?", this::checkOk);
-
+
// Should be answered with conversation.
check("Moscow", this::checkOk);
-
+
admCli.clearConversation(MDL_ID, null, null);
-
+
// Cannot be answered without conversation.
check("Moscow", this::checkError);
}
-
+
/**
- *
* @throws Exception
*/
@Test
void test2() throws Exception {
check("What's the weather in Moscow?", this::checkOk);
-
+
// Should be answered with conversation.
check("Moscow", this::checkOk);
-
+
admCli.clearConversation(MDL_ID,
// Finds its own ID.
get(admCli.getAllUsers(), (u) -> NCClientBuilder.DFLT_EMAIL.equals(u.getEmail())).getId(), null);
-
+
// Cannot be answered without conversation.
check("Moscow", this::checkError);
}
diff --git a/src/test/java/org/apache/nlpcraft/client/NCFeedbackTest.java b/src/test/java/org/apache/nlpcraft/client/NCFeedbackTest.java
index 43829fd..9a114f3 100644
--- a/src/test/java/org/apache/nlpcraft/client/NCFeedbackTest.java
+++ b/src/test/java/org/apache/nlpcraft/client/NCFeedbackTest.java
@@ -17,8 +17,12 @@
package org.apache.nlpcraft.client;
+import org.apache.nlpcraft.examples.alarm.AlarmModel;
+import org.apache.nlpcraft.model.NCModel;
import org.junit.jupiter.api.Test;
+import java.util.Optional;
+
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
@@ -27,7 +31,12 @@
class NCFeedbackTest extends NCTestAdapter {
/** */
private static final String MDL_ID = "nlpcraft.alarm.ex";
-
+
+ @Override
+ Optional<Class<? extends NCModel>> getModelClass() {
+ return Optional.of(AlarmModel.class);
+ }
+
/**
*
* @param usrId
diff --git a/src/test/java/org/apache/nlpcraft/client/NCMultiClientsTest.java b/src/test/java/org/apache/nlpcraft/client/NCMultiClientsTest.java
index 4b583e0..231d521 100644
--- a/src/test/java/org/apache/nlpcraft/client/NCMultiClientsTest.java
+++ b/src/test/java/org/apache/nlpcraft/client/NCMultiClientsTest.java
@@ -18,8 +18,11 @@
package org.apache.nlpcraft.client;
import org.apache.http.client.config.RequestConfig;
+import org.apache.nlpcraft.examples.alarm.AlarmModel;
+import org.apache.nlpcraft.model.NCModel;
import org.junit.jupiter.api.Test;
+import java.util.Optional;
import java.util.Random;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
@@ -27,6 +30,7 @@
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.MINUTES;
/**
@@ -35,23 +39,29 @@
class NCMultiClientsTest extends NCTestAdapter {
/** */
private static final String MDL_ID = "nlpcraft.alarm.ex";
-
+
+ @Override
+ Optional<Class<? extends NCModel>> getModelClass() {
+ return Optional.of(AlarmModel.class);
+ }
+
/**
*
* @throws Exception
*/
@Test
void test() throws Throwable {
- int clientsCnt = 5;
- int textTimeMs = 20000;
-
+ int clientsCnt = 3;
+ int testTimeMs = 10000;
+ int timeoutMs = 60000;
+
ExecutorService pool = Executors.newFixedThreadPool(clientsCnt);
Random rnd = new Random();
AtomicReference<Throwable> err = new AtomicReference<>();
AtomicInteger cnt = new AtomicInteger(0);
- long maxTime = System.currentTimeMillis() + textTimeMs;
+ long maxTime = System.currentTimeMillis() + testTimeMs;
CountDownLatch cdl = new CountDownLatch(clientsCnt);
@@ -65,9 +75,9 @@
client = new NCClientBuilder().
setRequestConfig(
RequestConfig.custom().
- setSocketTimeout(20000).
- setConnectionRequestTimeout(20000).
- setConnectTimeout(20000).
+ setSocketTimeout(timeoutMs).
+ setConnectionRequestTimeout(timeoutMs).
+ setConnectTimeout(timeoutMs).
build()
).build();
@@ -103,7 +113,7 @@
});
}
- cdl.await(5, MINUTES);
+ cdl.await(timeoutMs * 2, MILLISECONDS);
if (err.get() != null)
throw err.get();
diff --git a/src/test/java/org/apache/nlpcraft/client/NCPermissionsTest.java b/src/test/java/org/apache/nlpcraft/client/NCPermissionsTest.java
index a65b861..9e9cad5 100644
--- a/src/test/java/org/apache/nlpcraft/client/NCPermissionsTest.java
+++ b/src/test/java/org/apache/nlpcraft/client/NCPermissionsTest.java
@@ -17,10 +17,14 @@
package org.apache.nlpcraft.client;
+import org.apache.nlpcraft.examples.alarm.AlarmModel;
+import org.apache.nlpcraft.model.NCModel;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import java.util.Optional;
+
/**
* REST client test. Checks user permissions.
*/
@@ -30,7 +34,12 @@
/** */
private NCClient client;
-
+
+ @Override
+ Optional<Class<? extends NCModel>> getModelClass() {
+ return Optional.of(AlarmModel.class);
+ }
+
/**
*
* @throws Exception
diff --git a/src/test/java/org/apache/nlpcraft/client/NCProbesTest.java b/src/test/java/org/apache/nlpcraft/client/NCProbesTest.java
index d574f08..0285558 100644
--- a/src/test/java/org/apache/nlpcraft/client/NCProbesTest.java
+++ b/src/test/java/org/apache/nlpcraft/client/NCProbesTest.java
@@ -17,14 +17,23 @@
package org.apache.nlpcraft.client;
+import org.apache.nlpcraft.examples.alarm.AlarmModel;
+import org.apache.nlpcraft.model.NCModel;
import org.junit.jupiter.api.Test;
+import java.util.Optional;
+
import static org.junit.jupiter.api.Assertions.assertFalse;
/**
* REST client test. Methods `probe/*`.
*/
class NCProbesTest extends NCTestAdapter {
+ @Override
+ Optional<Class<? extends NCModel>> getModelClass() {
+ return Optional.of(AlarmModel.class);
+ }
+
/**
*
* @throws Exception
diff --git a/src/test/java/org/apache/nlpcraft/client/NCTestAdapter.java b/src/test/java/org/apache/nlpcraft/client/NCTestAdapter.java
index fc32254..15e33f9 100644
--- a/src/test/java/org/apache/nlpcraft/client/NCTestAdapter.java
+++ b/src/test/java/org/apache/nlpcraft/client/NCTestAdapter.java
@@ -17,6 +17,8 @@
package org.apache.nlpcraft.client;
+import org.apache.nlpcraft.model.NCModel;
+import org.apache.nlpcraft.probe.embedded.NCEmbeddedProbe;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
@@ -25,12 +27,15 @@
import java.util.Optional;
import java.util.function.Predicate;
-import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* REST client test adapter.
*/
-class NCTestAdapter {
+abstract class NCTestAdapter {
/**
*
*/
@@ -47,6 +52,17 @@
/** */
protected long admUsrId;
+
+ /** */
+ private Optional<Class<? extends NCModel>> mdlOpt = getModelClass();
+
+ /**
+ *
+ * @return
+ */
+ Optional<Class<? extends NCModel>> getModelClass() {
+ return Optional.empty();
+ }
/**
*
@@ -54,6 +70,9 @@
*/
@BeforeEach
void setUp() throws Exception {
+ if (mdlOpt.isPresent())
+ NCEmbeddedProbe.start(mdlOpt.get());
+
admCli = new NCClientBuilder().build();
admUsrId = get(admCli.getAllUsers(), (u) -> NCClientBuilder.DFLT_EMAIL.equals(u.getEmail())).getId();
@@ -73,6 +92,9 @@
admCli.close();
}
+
+ if (mdlOpt.isPresent())
+ NCEmbeddedProbe.stop();
}
/**
diff --git a/src/test/java/org/apache/nlpcraft/client/NCUserTest.java b/src/test/java/org/apache/nlpcraft/client/NCUserTest.java
index b09e6cd..ff0fa15 100644
--- a/src/test/java/org/apache/nlpcraft/client/NCUserTest.java
+++ b/src/test/java/org/apache/nlpcraft/client/NCUserTest.java
@@ -17,11 +17,15 @@
package org.apache.nlpcraft.client;
+import org.apache.nlpcraft.examples.alarm.AlarmModel;
+import org.apache.nlpcraft.model.NCModel;
import org.junit.jupiter.api.Test;
import java.util.List;
+import java.util.Optional;
-import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
/**
* REST client test. Methods `user/*`.
@@ -29,7 +33,12 @@
class NCUserTest extends NCTestAdapter {
/** */
private static final String MDL_ID = "nlpcraft.alarm.ex";
-
+
+ @Override
+ Optional<Class<? extends NCModel>> getModelClass() {
+ return Optional.of(AlarmModel.class);
+ }
+
/**
*
* @param u