Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
TTool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mbe-tools
TTool
Commits
16b3f493
Commit
16b3f493
authored
6 years ago
by
Minh Hiep Pham
Browse files
Options
Downloads
Patches
Plain Diff
Test isAValidId + namePrimirivePortInUse 1
parent
96cdc6dc
Branches
Branches containing commit
No related tags found
1 merge request
!101
checking the valid port names
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/tmltranslator/TMLSyntaxChecking.java
+1
-1
1 addition, 1 deletion
src/main/java/tmltranslator/TMLSyntaxChecking.java
ttool/src/test/java/ui/tmlcompd/TMLCPrimitivePortTest.java
+148
-0
148 additions, 0 deletions
ttool/src/test/java/ui/tmlcompd/TMLCPrimitivePortTest.java
with
149 additions
and
1 deletion
src/main/java/tmltranslator/TMLSyntaxChecking.java
+
1
−
1
View file @
16b3f493
...
...
@@ -396,7 +396,7 @@ public class TMLSyntaxChecking {
TMLCPrimitiveComponent
tmlcpc
=
(
TMLCPrimitiveComponent
)
t
.
getReferenceObject
();
for
(
TMLCPrimitivePort
tmlcpp
:
tmlcpc
.
getAllInternalPrimitivePorts
())
{
String
s
=
tmlcpp
.
getPortName
();
if
(!
TAttribute
.
isAValidId
(
s
,
false
,
true
,
false
))
{
if
(!
TAttribute
.
isAValidId
(
s
,
false
,
true
,
false
,
true
))
{
addError
(
t
,
null
,
WRONG_VARIABLE_IDENTIFIER
+
": invalid port name ("
+
s
+
")"
,
TMLError
.
ERROR_STRUCTURE
);
}
}
...
...
This diff is collapsed.
Click to expand it.
ttool/src/test/java/ui/tmlcompd/TMLCPrimitivePortTest.java
0 → 100644
+
148
−
0
View file @
16b3f493
package
ui.tmlcompd
;
import
org.junit.Before
;
import
org.junit.BeforeClass
;
import
org.junit.Test
;
import
ui.*
;
import
java.io.File
;
import
static
org
.
junit
.
Assert
.*;
public
class
TMLCPrimitivePortTest
extends
AbstractUITest
{
static
TDiagramPanel
diagramPanel
;
static
TMLCChannelOutPort
eventPortIn
;
static
TMLCChannelOutPort
channelPortIn
;
static
TMLCChannelOutPort
requestPortIn
;
static
TMLCChannelOutPort
eventPortOut
;
static
TMLCChannelOutPort
channelPortOut
;
static
TMLCChannelOutPort
requestPortOut
;
static
TMLCPrimitiveComponent
primitiveComponent1
;
static
TMLCPrimitiveComponent
primitiveComponent2
;
final
String
VALID_NAME
=
"valid_name"
;
final
String
INVALID_NAME_1
=
"1_name"
;
//name begins by number
final
String
INVALID_NAME_2
=
"name 2"
;
// name with whitespace
final
String
INVALID_NAME_3
=
"clock"
;
//one of UPPAAL keywords
final
String
INVALID_NAME_4
=
"name?"
;
//name with specialized characters
final
String
INVALID_NAME_5
=
""
;
//final String INVALID_NAME_6 = "protected"; //one of java keywords
//final String INVALID_NAME_7 = "exit"; //one of RTLOTOS keywords
final
String
INVALID_NAME_6
=
"Natural"
;
//one of String type
final
String
INVALID_NAME_7
=
"ENDTASK"
;
// one of TMLkeywords
final
String
CHANNEL_IN
=
"channel_in"
;
final
String
CHANNEL_OUT
=
"channel_out"
;
final
String
EVENT_IN
=
"event_in"
;
final
String
EVENT_OUT
=
"event_out"
;
final
String
REQUEST_IN
=
"request_in"
;
final
String
REQUEST_OUT
=
"request_out"
;
@BeforeClass
public
static
void
setUpBeforeClass
()
throws
Exception
{
RESOURCES_DIR
=
getBaseResourcesDir
()
+
"/ui/tmlcompd/input/TestPortName.xml"
;
//RESOURCES_DIR = "/home/pham/Documents/TToolDev/TTool/ttool/src/test/resources/ui/tmlcompd/input/TestPortName.xml";
}
public
TMLCPrimitivePortTest
()
{
super
();
mainGUI
.
openProjectFromFile
(
new
File
(
RESOURCES_DIR
));
}
@Before
public
void
setUp
()
throws
Exception
{
diagramPanel
=
null
;
for
(
TURTLEPanel
_tab
:
mainGUI
.
getTabs
())
{
if
(
_tab
instanceof
TMLComponentDesignPanel
)
{
for
(
TDiagramPanel
tdp
:
_tab
.
getPanels
())
{
if
(
tdp
instanceof
TMLComponentTaskDiagramPanel
)
{
diagramPanel
=
tdp
;
mainGUI
.
selectTab
(
tdp
);
break
;
}
}
break
;
}
}
for
(
TGComponent
tgc
:
diagramPanel
.
getComponentList
())
{
if
(
tgc
.
getValue
().
equals
(
"CompositeComponent"
))
{
for
(
TMLCPrimitiveComponent
tmlcpp
:
((
TMLCCompositeComponent
)
tgc
).
getAllPrimitiveComponents
())
{
if
(
tmlcpp
.
getValue
().
equals
(
"PrimitiveComp1"
))
{
primitiveComponent1
=
tmlcpp
;
}
if
(
tmlcpp
.
getValue
().
equals
(
"PrimitiveComp2"
))
{
primitiveComponent2
=
tmlcpp
;
}
}
}
}
if
(
diagramPanel
!=
null
&&
primitiveComponent1
!=
null
&&
primitiveComponent2
!=
null
)
{
eventPortOut
=
new
TMLCChannelOutPort
(
509
,
672
,
-
13
,
187
,
-
13
,
583
,
true
,
primitiveComponent1
,
diagramPanel
);
eventPortOut
.
isOrigin
=
true
;
eventPortOut
.
typep
=
1
;
eventPortIn
=
new
TMLCChannelOutPort
(
708
,
694
,
-
13
,
187
,
-
13
,
578
,
true
,
primitiveComponent2
,
diagramPanel
);
eventPortIn
.
isOrigin
=
false
;
eventPortIn
.
typep
=
1
;
channelPortOut
=
new
TMLCChannelOutPort
(
509
,
625
,
-
13
,
187
,
-
13
,
583
,
true
,
primitiveComponent1
,
diagramPanel
);
channelPortOut
.
isOrigin
=
true
;
channelPortOut
.
typep
=
0
;
channelPortIn
=
new
TMLCChannelOutPort
(
708
,
630
,
-
13
,
187
,
-
13
,
578
,
true
,
primitiveComponent2
,
diagramPanel
);
channelPortIn
.
isOrigin
=
false
;
channelPortIn
.
typep
=
0
;
requestPortOut
=
new
TMLCChannelOutPort
(
509
,
730
,
-
13
,
187
,
-
13
,
583
,
true
,
primitiveComponent1
,
diagramPanel
);
requestPortOut
.
isOrigin
=
true
;
requestPortOut
.
typep
=
2
;
requestPortIn
=
new
TMLCChannelOutPort
(
708
,
747
,
-
13
,
187
,
-
13
,
578
,
true
,
primitiveComponent2
,
diagramPanel
);
requestPortIn
.
isOrigin
=
false
;
requestPortIn
.
typep
=
2
;
}
}
@Test
public
void
testEventPortName
()
throws
Exception
{
assertTrue
(
"Test : Port name in use"
,((
TMLComponentTaskDiagramPanel
)
diagramPanel
).
namePrimitivePortInUse
(
eventPortIn
,
EVENT_IN
));
assertTrue
(
"Test : Port name in use"
,((
TMLComponentTaskDiagramPanel
)
diagramPanel
).
namePrimitivePortInUse
(
eventPortOut
,
EVENT_OUT
));
assertFalse
(
"Test : Port name in use"
,((
TMLComponentTaskDiagramPanel
)
diagramPanel
).
namePrimitivePortInUse
(
eventPortOut
,
EVENT_IN
));
assertFalse
(
"Test : Port name in use"
,((
TMLComponentTaskDiagramPanel
)
diagramPanel
).
namePrimitivePortInUse
(
eventPortIn
,
EVENT_OUT
));
}
@Test
public
void
testChannelPortName
()
throws
Exception
{
assertTrue
(
"Test : Port name in use"
,((
TMLComponentTaskDiagramPanel
)
diagramPanel
).
namePrimitivePortInUse
(
channelPortIn
,
CHANNEL_IN
));
assertTrue
(
"Test : Port name in use"
,((
TMLComponentTaskDiagramPanel
)
diagramPanel
).
namePrimitivePortInUse
(
channelPortOut
,
CHANNEL_OUT
));
assertFalse
(
"Test : Port name in use"
,((
TMLComponentTaskDiagramPanel
)
diagramPanel
).
namePrimitivePortInUse
(
channelPortOut
,
CHANNEL_IN
));
assertFalse
(
"Test : Port name in use"
,((
TMLComponentTaskDiagramPanel
)
diagramPanel
).
namePrimitivePortInUse
(
channelPortIn
,
CHANNEL_OUT
));
}
@Test
public
void
tesRequestPortName
()
throws
Exception
{
assertTrue
(
"Test : Port name in use"
,((
TMLComponentTaskDiagramPanel
)
diagramPanel
).
namePrimitivePortInUse
(
requestPortIn
,
EVENT_IN
));
assertTrue
(
"Test : Port name in use"
,((
TMLComponentTaskDiagramPanel
)
diagramPanel
).
namePrimitivePortInUse
(
requestPortOut
,
EVENT_OUT
));
assertFalse
(
"Test : Port name in use"
,((
TMLComponentTaskDiagramPanel
)
diagramPanel
).
namePrimitivePortInUse
(
requestPortOut
,
REQUEST_IN
));
assertFalse
(
"Test : Port name in use"
,((
TMLComponentTaskDiagramPanel
)
diagramPanel
).
namePrimitivePortInUse
(
requestPortIn
,
REQUEST_OUT
));
}
@Test
public
void
testInAValidName
()
throws
Exception
{
assertTrue
(
TAttribute
.
isAValidId
(
VALID_NAME
,
false
,
true
,
false
));
assertFalse
(
TAttribute
.
isAValidId
(
INVALID_NAME_1
,
false
,
true
,
false
));
assertFalse
(
TAttribute
.
isAValidId
(
INVALID_NAME_2
,
false
,
true
,
false
));
assertFalse
(
TAttribute
.
isAValidId
(
INVALID_NAME_3
,
false
,
true
,
false
));
assertFalse
(
TAttribute
.
isAValidId
(
INVALID_NAME_4
,
false
,
true
,
false
));
assertFalse
(
TAttribute
.
isAValidId
(
INVALID_NAME_5
,
false
,
true
,
false
));
assertFalse
(
TAttribute
.
isAValidId
(
INVALID_NAME_6
,
false
,
true
,
false
));
assertFalse
(
TAttribute
.
isAValidId
(
INVALID_NAME_7
,
false
,
true
,
false
,
true
));
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment