Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
joram
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
joram
joram
Commits
5a618b9a
Commit
5a618b9a
authored
Apr 04, 2019
by
Andre Freyssinet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleaning code.
parent
3adb2c45
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
122 additions
and
135 deletions
+122
-135
tests/src/joram/base/Test_Temp_T.java
tests/src/joram/base/Test_Temp_T.java
+79
-87
tests/src/joram/base/Test_Temp_T2.java
tests/src/joram/base/Test_Temp_T2.java
+43
-48
No files found.
tests/src/joram/base/Test_Temp_T.java
View file @
5a618b9a
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2007 ScalAgent Distributed Technologies
* Copyright (C) 2007
- 2019
ScalAgent Distributed Technologies
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
...
...
@@ -33,101 +33,93 @@ import javax.jms.TextMessage;
import
javax.naming.Context
;
import
javax.naming.InitialContext
;
import
framework.TestCas
e
;
import
org.objectweb.joram.client.jms.admin.AdminModul
e
;
import
org.objectweb.joram.client.jms.admin.User
;
import
org.objectweb.joram.client.jms.tcp.TcpConnectionFactory
;
import
framework.TestCase
;
/**
*
Test the functioning of Temporary Topic
*
* Test the functioning of Temporary Topic
*
Creates e temporary topic then exchanges a message.
*/
public
class
Test_Temp_T
extends
TestCase
implements
javax
.
jms
.
MessageListener
{
public
static
void
main
(
String
[]
args
)
{
new
Test_Temp_T
().
run
();
}
public
void
run
()
{
try
{
System
.
out
.
println
(
"server start"
);
startAgentServer
((
short
)
0
);
admin
();
System
.
out
.
println
(
"admin config ok"
);
Context
ictx
=
new
InitialContext
();
ConnectionFactory
cf
=
(
ConnectionFactory
)
ictx
.
lookup
(
"cf"
);
ictx
.
close
();
Connection
cnx
=
cf
.
createConnection
();
Session
sessionp
=
cnx
.
createSession
(
false
,
Session
.
AUTO_ACKNOWLEDGE
);
Session
sessionc
=
cnx
.
createSession
(
false
,
Session
.
AUTO_ACKNOWLEDGE
);
// temporary topic is creating by a session
TemporaryTopic
temptopic
=
sessionp
.
createTemporaryTopic
();
cnx
.
start
();
// create a producer and a consumer
MessageProducer
producer
=
sessionp
.
createProducer
(
temptopic
);
MessageConsumer
consumer
=
sessionc
.
createConsumer
(
temptopic
);
// the consumer records on the topic
consumer
.
setMessageListener
(
this
);
TextMessage
msg
=
sessionp
.
createTextMessage
();
msg
.
setText
(
"test_temporary_topic"
);
producer
.
send
(
msg
);
cnx
.
close
();
}
catch
(
Throwable
exc
)
{
exc
.
printStackTrace
();
error
(
exc
);
}
finally
{
System
.
out
.
println
(
"Server stop "
);
stopAgentServer
((
short
)
0
);
endTest
();
}
}
/**
* Admin : Create a user anonymous
* use jndi
*/
public
void
admin
()
throws
Exception
{
// conexion
org
.
objectweb
.
joram
.
client
.
jms
.
admin
.
AdminModule
.
connect
(
"localhost"
,
2560
,
"root"
,
"root"
,
60
);
// create a user
org
.
objectweb
.
joram
.
client
.
jms
.
admin
.
User
user
=
org
.
objectweb
.
joram
.
client
.
jms
.
admin
.
User
.
create
(
"anonymous"
,
"anonymous"
);
javax
.
jms
.
ConnectionFactory
cf
=
org
.
objectweb
.
joram
.
client
.
jms
.
tcp
.
TcpConnectionFactory
.
create
(
"localhost"
,
2560
);
javax
.
naming
.
Context
jndiCtx
=
new
javax
.
naming
.
InitialContext
();
jndiCtx
.
bind
(
"cf"
,
cf
);
jndiCtx
.
close
();
org
.
objectweb
.
joram
.
client
.
jms
.
admin
.
AdminModule
.
disconnect
();
public
static
void
main
(
String
[]
args
)
{
new
Test_Temp_T
().
run
();
}
public
void
run
()
{
try
{
System
.
out
.
println
(
"server start"
);
startAgentServer
((
short
)
0
);
admin
();
System
.
out
.
println
(
"admin config ok"
);
Context
ictx
=
new
InitialContext
();
ConnectionFactory
cf
=
(
ConnectionFactory
)
ictx
.
lookup
(
"cf"
);
ictx
.
close
();
Connection
cnx
=
cf
.
createConnection
();
Session
sessionp
=
cnx
.
createSession
(
false
,
Session
.
AUTO_ACKNOWLEDGE
);
Session
sessionc
=
cnx
.
createSession
(
false
,
Session
.
AUTO_ACKNOWLEDGE
);
// temporary topic is creating by a session
TemporaryTopic
temptopic
=
sessionp
.
createTemporaryTopic
();
cnx
.
start
();
// create a producer and a consumer
MessageProducer
producer
=
sessionp
.
createProducer
(
temptopic
);
MessageConsumer
consumer
=
sessionc
.
createConsumer
(
temptopic
);
// the consumer records on the topic
consumer
.
setMessageListener
(
this
);
TextMessage
msg
=
sessionp
.
createTextMessage
();
msg
.
setText
(
"test_temporary_topic"
);
producer
.
send
(
msg
);
cnx
.
close
();
}
catch
(
Throwable
exc
)
{
exc
.
printStackTrace
();
error
(
exc
);
}
finally
{
System
.
out
.
println
(
"Server stop "
);
stopAgentServer
((
short
)
0
);
endTest
();
}
}
/**
* Admin : Create a user anonymous
* use jndi
*/
public
void
admin
()
throws
Exception
{
// Connexion to the Joram server
AdminModule
.
connect
(
"localhost"
,
2560
,
"root"
,
"root"
,
60
);
// Creates a user
User
user
=
User
.
create
(
"anonymous"
,
"anonymous"
);
// Initializes the ConnectionFactory
javax
.
jms
.
ConnectionFactory
cf
=
TcpConnectionFactory
.
create
(
"localhost"
,
2560
);
javax
.
naming
.
Context
jndiCtx
=
new
javax
.
naming
.
InitialContext
();
jndiCtx
.
bind
(
"cf"
,
cf
);
jndiCtx
.
close
();
org
.
objectweb
.
joram
.
client
.
jms
.
admin
.
AdminModule
.
disconnect
();
}
public
void
onMessage
(
Message
message
)
{
System
.
out
.
println
(
"message receive"
);
try
{
TextMessage
msg
=
(
TextMessage
)
message
;
//test messages
assertEquals
(
"test_temporary_topic"
,
msg
.
getText
());
}
catch
(
javax
.
jms
.
JMSException
JE
){
JE
.
printStackTrace
(
);
}
public
void
onMessage
(
Message
message
)
{
System
.
out
.
println
(
"message receive"
);
try
{
TextMessage
msg
=
(
TextMessage
)
message
;
//test messages
assertEquals
(
"test_temporary_topic"
,
msg
.
getText
());
}
catch
(
javax
.
jms
.
JMSException
JE
){
JE
.
printStackTrace
(
);
}
}
}
tests/src/joram/base/Test_Temp_T2.java
View file @
5a618b9a
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2007 - 20
0
9 ScalAgent Distributed Technologies
* Copyright (C) 2007 - 20
1
9 ScalAgent Distributed Technologies
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
...
...
@@ -37,26 +37,34 @@ import org.objectweb.joram.client.jms.admin.AdminModule;
import
framework.TestCase
;
import
org.objectweb.joram.client.jms.admin.AdminModule
;
import
org.objectweb.joram.client.jms.admin.User
;
import
org.objectweb.joram.client.jms.tcp.TcpConnectionFactory
;
/**
*
Test delete of Temporary Topic
*
*
Test the desletion of a Temporary Topic.
*
Verify that the remaining messages are not sent to the DMQ.
*/
public
class
Test_Temp_T2
extends
TestCase
{
static
Topic
adminTopic
=
null
;
public
class
Test_Temp_T2
extends
TestCase
{
static
Destination
adminTopic
=
null
;
public
static
void
main
(
String
[]
args
)
{
new
Test_Temp_T2
().
run
();
}
public
static
void
printDestinations
(
Destination
[]
destinations
)
{
System
.
out
.
print
(
"destinations=["
);
for
(
Destination
destination
:
destinations
)
{
System
.
out
.
print
(
destination
+
" "
);
}
System
.
out
.
println
(
"]"
);
}
public
void
run
()
{
try
{
System
.
out
.
println
(
"server start"
);
startAgentServer
((
short
)
0
);
admin
();
System
.
out
.
println
(
"admin config ok"
);
...
...
@@ -64,38 +72,35 @@ public class Test_Temp_T2 extends TestCase {
ConnectionFactory
cf
=
(
ConnectionFactory
)
ictx
.
lookup
(
"cf"
);
ictx
.
close
();
Connection
cnx
=
cf
.
createConnection
();
org
.
objectweb
.
joram
.
client
.
jms
.
admin
.
AdminModule
.
connect
(
"localhost"
,
2560
,
"root"
,
"root"
,
60
);
Destination
[]
destinations
=
AdminModule
.
getDestinations
();
TemporaryTopic
topic
=
(
TemporaryTopic
)
destinations
[
0
];
adminTopic
=
topic
;
printDestinations
(
destinations
);
adminTopic
=
destinations
[
0
];
// temporary topic is creating by a session
Connection
cnx
=
cf
.
createConnection
();
cnx
.
start
();
Session
sessionp
=
cnx
.
createSession
(
false
,
Session
.
AUTO_ACKNOWLEDGE
);
TemporaryTopic
temptopic
=
sessionp
.
createTemporaryTopic
();
sessionp
.
createTemporaryTopic
();
cnx
.
close
();
Thread
.
sleep
(
1000L
);
testTempTopic
();
cnx
=
cf
.
createConnection
();
cnx
.
start
();
sessionp
=
cnx
.
createSession
(
false
,
Session
.
AUTO_ACKNOWLEDGE
);
temptopic
=
sessionp
.
createTemporaryTopic
();
TemporaryTopic
temptopic1
=
sessionp
.
createTemporaryTopic
();
TemporaryTopic
temptopic2
=
sessionp
.
createTemporaryTopic
();
TemporaryTopic
temptopic3
=
sessionp
.
createTemporaryTopic
();
TemporaryTopic
temptopic4
=
sessionp
.
createTemporaryTopic
();
sessionp
=
cnx
.
createSession
(
false
,
Session
.
AUTO_ACKNOWLEDGE
);
sessionp
.
createTemporaryTopic
();
sessionp
.
createTemporaryTopic
();
sessionp
.
createTemporaryTopic
();
sessionp
.
createTemporaryTopic
();
sessionp
.
createTemporaryTopic
();
cnx
.
close
();
Thread
.
sleep
(
1000L
);
testTempTopic
();
}
catch
(
Throwable
exc
)
{
exc
.
printStackTrace
();
error
(
exc
);
...
...
@@ -111,37 +116,27 @@ public class Test_Temp_T2 extends TestCase {
* use jndi
*/
public
void
admin
()
throws
Exception
{
// conexion
org
.
objectweb
.
joram
.
client
.
jms
.
admin
.
AdminModule
.
connect
(
"localhost"
,
2560
,
"root"
,
"root"
,
60
);
// create a user
org
.
objectweb
.
joram
.
client
.
jms
.
admin
.
User
user
=
org
.
objectweb
.
joram
.
client
.
jms
.
admin
.
User
.
create
(
"anonymous"
,
"anonymous"
);
javax
.
jms
.
ConnectionFactory
cf
=
org
.
objectweb
.
joram
.
client
.
jms
.
tcp
.
TcpConnectionFactory
.
create
(
"localhost"
,
2560
);
// Connexion to the Joram server
AdminModule
.
connect
(
"localhost"
,
2560
,
"root"
,
"root"
,
60
);
// Creates a user
User
user
=
User
.
create
(
"anonymous"
,
"anonymous"
);
// Initializes the ConnectionFactory
javax
.
jms
.
ConnectionFactory
cf
=
TcpConnectionFactory
.
create
(
"localhost"
,
2560
);
javax
.
naming
.
Context
jndiCtx
=
new
javax
.
naming
.
InitialContext
();
jndiCtx
.
bind
(
"cf"
,
cf
);
jndiCtx
.
close
();
org
.
objectweb
.
joram
.
client
.
jms
.
admin
.
AdminModule
.
disconnect
();
}
private
static
void
testTempTopic
()
throws
Exception
{
int
j
=
0
;
Destination
[]
destinations
=
AdminModule
.
getDestinations
();
printDestinations
(
destinations
);
assertEquals
(
1
,
destinations
.
length
);
for
(
Destination
destination
:
destinations
)
{
j
++;
TemporaryTopic
topic
=
(
TemporaryTopic
)
destination
;
assertEquals
(
adminTopic
,
topic
);
assertEquals
(
adminTopic
,
destination
);
}
assertEquals
(
1
,
j
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment