Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Genesys PGR
Genesys Backend
Commits
872c662c
Commit
872c662c
authored
Dec 30, 2014
by
Matija Obreza
Browse files
HazelcastRunner for local testing
parent
5b59a217
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/test/java/org/genesys2/hazelcast/HazelcastRunner.java
0 → 100644
View file @
872c662c
package
org.genesys2.hazelcast
;
import
java.io.IOException
;
import
org.genesys2.spring.config.SpringProperties
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Import
;
import
org.springframework.test.context.ActiveProfiles
;
import
com.hazelcast.config.Config
;
import
com.hazelcast.config.GroupConfig
;
import
com.hazelcast.config.JoinConfig
;
import
com.hazelcast.config.NetworkConfig
;
import
com.hazelcast.config.TcpIpConfig
;
import
com.hazelcast.core.Hazelcast
;
import
com.hazelcast.core.HazelcastInstance
;
import
com.hazelcast.core.ManagedContext
;
import
com.hazelcast.spring.context.SpringManagedContext
;
public
class
HazelcastRunner
{
@Configuration
@ActiveProfiles
(
"dev"
)
@Import
({
SpringProperties
.
class
})
public
static
class
AppConfig
{
protected
int
hazelPort
=
5702
;
@Value
(
"${hazelcast.instanceName}"
)
protected
String
instanceName
=
"genesys"
;
@Value
(
"${hazelcast.password}"
)
protected
String
password
;
@Value
(
"${hazelcast.name}"
)
protected
String
name
;
@Bean
public
Long
number
()
{
return
new
Long
(
13
);
}
@Bean
public
ManagedContext
managedContext
()
{
return
new
SpringManagedContext
();
}
@Bean
public
HazelcastInstance
hazelcast
(
ManagedContext
managedContext
)
{
Config
cfg
=
new
Config
();
cfg
.
setManagedContext
(
managedContext
);
cfg
.
setInstanceName
(
instanceName
);
GroupConfig
groupConfig
=
cfg
.
getGroupConfig
();
groupConfig
.
setName
(
name
);
groupConfig
.
setPassword
(
password
);
cfg
.
setProperty
(
"hazelcast.merge.first.run.delay.seconds"
,
"5"
);
cfg
.
setProperty
(
"hazelcast.merge.next.run.delay.seconds"
,
"5"
);
cfg
.
setProperty
(
"hazelcast.logging.type"
,
"log4j"
);
cfg
.
setProperty
(
"hazelcast.icmp.enabled"
,
"true"
);
NetworkConfig
network
=
cfg
.
getNetworkConfig
();
network
.
setPort
(
hazelPort
);
network
.
setPortAutoIncrement
(
true
);
JoinConfig
join
=
network
.
getJoin
();
join
.
getMulticastConfig
().
setEnabled
(
false
);
TcpIpConfig
tcpIpConfig
=
join
.
getTcpIpConfig
();
tcpIpConfig
.
setEnabled
(
true
);
tcpIpConfig
.
setConnectionTimeoutSeconds
(
20
);
// See if there's a local HZ running
tcpIpConfig
.
addMember
(
"127.0.0.1:5701"
);
HazelcastInstance
instance
=
Hazelcast
.
newHazelcastInstance
(
cfg
);
return
instance
;
}
}
public
static
void
main
(
String
[]
args
)
{
AnnotationConfigApplicationContext
ctx
=
new
AnnotationConfigApplicationContext
(
AppConfig
.
class
);
HazelcastInstance
instance
=
ctx
.
getBean
(
HazelcastInstance
.
class
);
System
.
out
.
println
(
instance
);
System
.
out
.
println
(
"Press any key to quit."
);
try
{
System
.
in
.
read
();
}
catch
(
IOException
e
)
{
}
ctx
.
close
();
}
}
src/test/resources/spring/spring.properties
View file @
872c662c
...
...
@@ -14,7 +14,12 @@
# limitations under the License.
#-------------------------------------------------------------------------------
base.url
=
http://localhost:8080
base.host
=
localhost
base.hostname
=
${base.host}:8080
base.url
=
http://${base.hostname}
base.cookie-domain
=
base.cookie-secure
=
false
base.cookie-http-only
=
false
#DB connection properties
#In-memory HSQLDB
...
...
@@ -69,8 +74,8 @@ mail.debug.message= Email has been sent succesfully\n\
# Hazelcast
hazelcast.instanceName
=
genesys
hazelcast.name
=
genesys
hazelcast.instanceName
=
hz-
genesys
hazelcast.name
=
genesys
-hz-3.5
hazelcast.password
=
hazelcasts
hazelcast.port
=
5701
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment