Skip to content

Commit 220dccb

Browse files
author
Philipp Kraus
committed
Merge branch 'master' of github.com:LightJason/AgentSpeak-Java-Testing
2 parents eb81c97 + e36cbdf commit 220dccb

File tree

2 files changed

+76
-11
lines changed

2 files changed

+76
-11
lines changed

TestCActionNames.java

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* @cond LICENSE
3+
* ######################################################################################
4+
* # LGPL License #
5+
* # #
6+
* # This file is part of the LightJason AgentSpeak(L++) #
7+
* # Copyright (c) 2015-19, LightJason (info@lightjason.org) #
8+
* # This program is free software: you can redistribute it and/or modify #
9+
* # it under the terms of the GNU Lesser General Public License as #
10+
* # published by the Free Software Foundation, either version 3 of the #
11+
* # License, or (at your option) any later version. #
12+
* # #
13+
* # This program is distributed in the hope that it will be useful, #
14+
* # but WITHOUT ANY WARRANTY; without even the implied warranty of #
15+
* # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
16+
* # GNU Lesser General Public License for more details. #
17+
* # #
18+
* # You should have received a copy of the GNU Lesser General Public License #
19+
* # along with this program. If not, see http://www.gnu.org/licenses/ #
20+
* ######################################################################################
21+
* @endcond
22+
*/
23+
24+
package org.lightjason.agentspeak.testing;
25+
26+
import org.junit.Assert;
27+
import org.junit.Test;
28+
import org.lightjason.agentspeak.action.IAction;
29+
import org.lightjason.agentspeak.common.CCommon;
30+
31+
import javax.annotation.Nonnull;
32+
import java.util.Locale;
33+
34+
35+
/**
36+
* action name tests
37+
*/
38+
public final class TestCActionNames
39+
{
40+
41+
/**
42+
* run test
43+
*/
44+
@Test
45+
public void actionnames()
46+
{
47+
CCommon.actionsFromPackage().parallel().forEach( TestCActionNames::checkname );
48+
}
49+
50+
/**
51+
* check action name
52+
*
53+
* @param p_action action
54+
*/
55+
private static void checkname( @Nonnull final IAction p_action )
56+
{
57+
Assert.assertTrue(
58+
p_action.getClass().getCanonicalName(),
59+
p_action.name().toString().contains( p_action.getClass().getSimpleName().substring( 1 ).toLowerCase( Locale.ROOT ) )
60+
);
61+
}
62+
63+
}
Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
import com.github.javaparser.ast.visitor.VoidVisitorAdapter;
3333
import org.apache.commons.lang3.ClassUtils;
3434
import org.apache.commons.lang3.StringUtils;
35+
import org.junit.Assert;
36+
import org.junit.Assume;
3537
import org.junit.Test;
3638
import org.lightjason.agentspeak.common.CCommon;
3739

@@ -63,14 +65,13 @@
6365
import java.util.stream.Stream;
6466

6567
import static org.junit.Assert.assertFalse;
66-
import static org.junit.Assert.assertTrue;
6768
import static org.junit.Assume.assumeTrue;
6869

6970

7071
/**
7172
* test all resource strings
7273
*/
73-
public final class CLanguageLabel extends IBaseTest
74+
public final class TestCLanguageLabel extends IBaseTest
7475
{
7576
/**
7677
* classpath separator
@@ -91,7 +92,7 @@ public final class CLanguageLabel extends IBaseTest
9192
URI l_uri = null;
9293
try
9394
{
94-
l_uri = CLanguageLabel.concaturl( CLanguageLabel.resourceurl(), "../../src/main/java/" ).toURI();
95+
l_uri = TestCLanguageLabel.concaturl( TestCLanguageLabel.resourceurl(), "../../src/main/java/" ).toURI();
9596
}
9697
catch ( final Exception l_exception )
9798
{
@@ -108,8 +109,8 @@ public final class CLanguageLabel extends IBaseTest
108109
{
109110
LANGUAGEPROPERY.put(
110111
l_languages[i],
111-
CLanguageLabel.concaturl(
112-
CLanguageLabel.resourceurl(),
112+
TestCLanguageLabel.concaturl(
113+
TestCLanguageLabel.resourceurl(),
113114
MessageFormat.format(
114115
"{0}/{1}/{2}",
115116
l_resource,
@@ -183,7 +184,8 @@ public void testTranslation()
183184
@Test
184185
public void testResourceString() throws IOException
185186
{
186-
assumeTrue( "no languages are defined for checking", !LANGUAGEPROPERY.isEmpty() );
187+
Assume.assumeTrue( "no languages are defined for checking", !LANGUAGEPROPERY.isEmpty() );
188+
Assume.assumeTrue( "language files does not exist", LANGUAGEPROPERY.values().stream().anyMatch( i -> new File( i ).isFile() ) );
187189

188190
final Set<String> l_ignoredlabel = new HashSet<>();
189191

@@ -202,7 +204,7 @@ public void testResourceString() throws IOException
202204
}
203205
catch ( final IOException l_excpetion )
204206
{
205-
assertTrue( MessageFormat.format( "io error on file [{0}]: {1}", i, l_excpetion.getMessage() ), false );
207+
Assert.fail( MessageFormat.format( "io error on file [{0}]: {1}", i, l_excpetion.getMessage() ) );
206208
return Stream.empty();
207209
}
208210
catch ( final ParseProblemException l_exception )
@@ -239,7 +241,7 @@ public void testResourceString() throws IOException
239241
);
240242

241243
// --- check of any label is found
242-
assertFalse( "translation labels are empty, check naming of translation method", l_label.isEmpty() );
244+
Assert.assertFalse( "translation labels are empty, check naming of translation method", l_label.isEmpty() );
243245

244246
// --- check label towards the property definition
245247
if ( l_ignoredlabel.size() > 0 )
@@ -261,7 +263,7 @@ public void testResourceString() throws IOException
261263

262264
// --- check if all property items are within the parsed labels
263265
l_parseditems.removeAll( l_propertyitems );
264-
assertTrue(
266+
Assert.assertTrue(
265267
MessageFormat.format(
266268
"the following {1,choice,1#key|1<keys} in language [{0}] {1,choice,1#is|1<are} not existing within the language file:\n{2}",
267269
k,
@@ -280,7 +282,7 @@ public void testResourceString() throws IOException
280282
.allMatch( l -> false )
281283
)
282284
.collect( Collectors.toSet() );
283-
assertTrue(
285+
Assert.assertTrue(
284286
MessageFormat.format(
285287
"the following {1,choice,1#key|1<keys} in language [{0}] {1,choice,1#is|1<are} not existing within the source code:\n{2}",
286288
k,
@@ -292,7 +294,7 @@ public void testResourceString() throws IOException
292294
}
293295
catch ( final IOException l_exception )
294296
{
295-
assertTrue( MessageFormat.format( "io exception: {0}", l_exception.getMessage() ), false );
297+
Assert.fail( MessageFormat.format( "io exception: {0}", l_exception.getMessage() ) );
296298
}
297299
} );
298300
}

0 commit comments

Comments
 (0)