Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[sre][network] Add project for testing the network module of Janus.
Signed-off-by: Stéphane Galland <galland@arakhne.org>
- Loading branch information
1 parent
ec36924
commit 75aa86d
Showing
14 changed files
with
1,818 additions
and
0 deletions.
There are no files selected for viewing
120 changes: 120 additions & 0 deletions
120
sre/io.janusproject/io.janusproject.network.tests/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>io.janusproject.sre</groupId> | ||
<artifactId>io.janusproject</artifactId> | ||
<version>0.12.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>io.janusproject.network.tests</artifactId> | ||
<name>Janus Network Tests</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.janusproject</groupId> | ||
<artifactId>io.janusproject.kernel.network</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.janusproject.sre</groupId> | ||
<artifactId>io.janusproject.test.framework</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>build-helper-maven-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>add-test-source-folders</id> | ||
<phase>initialize</phase> | ||
<goals> | ||
<goal>add-test-source</goal> | ||
</goals> | ||
<configuration> | ||
<sources> | ||
<source>src/test/sarl</source> | ||
<source>src/test/generated-sources/sarl</source> | ||
</sources> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>io.sarl.maven</groupId> | ||
<artifactId>sarl-maven-plugin</artifactId> | ||
<!-- Maven extension mechanism seems not working because the plugin is | ||
defined in the same project. The different goals must be explicitly provided. --> | ||
<executions> | ||
<execution> | ||
<id>sarl-compiler-init</id> | ||
<phase>initialize</phase> | ||
<goals> | ||
<goal>initialize</goal> | ||
</goals> | ||
</execution> | ||
<execution> | ||
<id>sarl-compiler-compile</id> | ||
<phase>compile</phase> | ||
<goals> | ||
<goal>compile</goal> | ||
</goals> | ||
</execution> | ||
<execution> | ||
<id>sarl-compiler-testCompile</id> | ||
<phase>test-compile</phase> | ||
<goals> | ||
<goal>testCompile</goal> | ||
</goals> | ||
</execution> | ||
<execution> | ||
<id>sarl-compiler-clean</id> | ||
<phase>clean</phase> | ||
<goals> | ||
<goal>clean</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<source>${sarl-dsl.min.jdk.version}</source> | ||
<target>${sarl-dsl.min.jdk.version}</target> | ||
<encoding>${project.build.sourceEncoding}</encoding> | ||
<generateInlines>true</generateInlines> | ||
<generateStorageFiles>false</generateStorageFiles> | ||
<generateTraceFiles>false</generateTraceFiles> | ||
</configuration> | ||
</plugin> | ||
<!-- The following plugin is needed to avoid the standard Java compilation before | ||
the SARL compiler has generated the Java code. --> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>default-compile</id> | ||
<phase>compile</phase> | ||
<goals> | ||
<goal>compile</goal> | ||
</goals> | ||
<configuration> | ||
<skip>true</skip> | ||
</configuration> | ||
</execution> | ||
<execution> | ||
<id>default-testCompile</id> | ||
<phase>test-compile</phase> | ||
<goals> | ||
<goal>testCompile</goal> | ||
</goals> | ||
<configuration> | ||
<skip>true</skip> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
Binary file added
BIN
+6.04 KB
...ources/sarl/io/sarl/sre/network/tests/units/services/.HazelcastContextServiceTest.sarlbin
Binary file not shown.
Binary file added
BIN
+8.78 KB
...sarl/io/sarl/sre/network/tests/units/services/.HazelcastEventTransportServiceTest.sarlbin
Binary file not shown.
Binary file added
BIN
+6.05 KB
...urces/sarl/io/sarl/sre/network/tests/units/services/.HazelcastSpaceRepositoryTest.sarlbin
Binary file not shown.
Binary file added
BIN
+21.3 KB
...n/generated-sources/sarl/io/sarl/sre/network/tests/units/services/mocks/.IMapMock.sarlbin
Binary file not shown.
126 changes: 126 additions & 0 deletions
126
...ed-sources/sarl/io/sarl/sre/network/tests/units/services/HazelcastContextServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
/** | ||
* $Id$ | ||
* | ||
* SARL is an general-purpose agent programming language. | ||
* More details on http://www.sarl.io | ||
* | ||
* Copyright (C) 2014-2021 the original authors or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.sarl.sre.network.tests.units.services; | ||
|
||
import com.hazelcast.collection.ISet; | ||
import com.hazelcast.core.HazelcastInstance; | ||
import com.hazelcast.map.IMap; | ||
import io.sarl.lang.annotation.SarlElementType; | ||
import io.sarl.lang.annotation.SarlSpecification; | ||
import io.sarl.lang.annotation.SyntheticMember; | ||
import io.sarl.sre.boot.configs.SreConfig; | ||
import io.sarl.sre.boot.configs.subconfigs.BootConfig; | ||
import io.sarl.sre.internal.Factories; | ||
import io.sarl.sre.network.services.HazelcastContextService; | ||
import io.sarl.sre.network.tests.units.services.mocks.IMapMock; | ||
import io.sarl.sre.services.context.Context; | ||
import io.sarl.sre.tests.framework.SreTestUtilities; | ||
import io.sarl.sre.tests.framework.units.services.context.AbstractInjectionBasedContextServiceTest; | ||
import io.sarl.tests.api.Nullable; | ||
import java.util.UUID; | ||
import javax.inject.Provider; | ||
import org.eclipse.xtext.xbase.lib.Pure; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Tag; | ||
import org.mockito.ArgumentMatchers; | ||
import org.mockito.Mockito; | ||
|
||
/** | ||
* @author $Author: sgalland$ | ||
* @version $FullVersion$ | ||
* @mavengroupid $GroupId$ | ||
* @mavenartifactid $ArtifactId$ | ||
*/ | ||
@DisplayName("unit: HazelcastContextService test") | ||
@Tag("unit") | ||
@Tag("janus") | ||
@Tag("sre-unit") | ||
@Tag("sre-network") | ||
@SarlSpecification("0.12") | ||
@SarlElementType(10) | ||
@SuppressWarnings("all") | ||
public class HazelcastContextServiceTest extends AbstractInjectionBasedContextServiceTest<HazelcastContextService> { | ||
@Nullable | ||
private SreConfig sreConfig; | ||
|
||
@Nullable | ||
private HazelcastInstance hazelcast; | ||
|
||
@SuppressWarnings("raw_type") | ||
@Nullable | ||
private ISet internalSet; | ||
|
||
@Nullable | ||
private IMap<UUID, UUID> istructure; | ||
|
||
@BeforeEach | ||
@Override | ||
public void setUp() { | ||
final UUID cid = UUID.randomUUID(); | ||
final UUID sid = UUID.randomUUID(); | ||
final BootConfig bootConfig = Mockito.<BootConfig>mock(BootConfig.class); | ||
Mockito.<UUID>when(bootConfig.getRootContextID()).thenReturn(cid); | ||
Mockito.<UUID>when(bootConfig.getRootSpaceID()).thenReturn(sid); | ||
this.sreConfig = Mockito.<SreConfig>mock(SreConfig.class); | ||
Mockito.<BootConfig>when(this.sreConfig.getBoot()).thenReturn(bootConfig); | ||
IMapMock<UUID, UUID> _iMapMock = new IMapMock<UUID, UUID>(); | ||
this.istructure = _iMapMock; | ||
this.internalSet = Mockito.<ISet>mock(ISet.class); | ||
this.hazelcast = Mockito.<HazelcastInstance>mock(HazelcastInstance.class); | ||
Mockito.<ISet<Object>>when(this.hazelcast.<Object>getSet(ArgumentMatchers.anyString())).thenReturn(this.internalSet); | ||
Mockito.<IMap<UUID, UUID>>when(this.hazelcast.<UUID, UUID>getMap(ArgumentMatchers.anyString())).thenReturn(this.istructure); | ||
super.setUp(); | ||
} | ||
|
||
@Override | ||
public HazelcastContextService newService(final Context rootContext) { | ||
final Provider<Factories> _function = () -> { | ||
return SreTestUtilities.newFactories(); | ||
}; | ||
return new HazelcastContextService( | ||
this.sreConfig, rootContext, | ||
this.loggingService, | ||
this.injector, | ||
this.contextFactory, _function, | ||
this.hazelcast); | ||
} | ||
|
||
@Override | ||
@Pure | ||
@SyntheticMember | ||
public boolean equals(final Object obj) { | ||
return super.equals(obj); | ||
} | ||
|
||
@Override | ||
@Pure | ||
@SyntheticMember | ||
public int hashCode() { | ||
int result = super.hashCode(); | ||
return result; | ||
} | ||
|
||
@SyntheticMember | ||
public HazelcastContextServiceTest() { | ||
super(); | ||
} | ||
} |
Oops, something went wrong.