Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
ipgallery
/
mde
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Registry
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
49232fc7
authored
Aug 27, 2017
by
Adi Amir
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
make cisco.getParkingSpots working again
parent
27d263d1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
126 additions
and
3 deletions
build.gradle
src/main/java/logic/CiscoManager.java
src/test/java/testWebSocket/JettyWebSocket/TestJettyWebSocket.java
build.gradle
View file @
49232fc7
...
@@ -10,6 +10,7 @@ sourceCompatibility = 1.8
...
@@ -10,6 +10,7 @@ sourceCompatibility = 1.8
repositories
{
repositories
{
mavenLocal
()
mavenLocal
()
maven
{
url
"http://mandubian-mvn.googlecode.com/svn/trunk/mandubian-mvn/repository"
}
maven
{
url
"http://mandubian-mvn.googlecode.com/svn/trunk/mandubian-mvn/repository"
}
maven
{
url
"https://mvnrepository.com/artifact/org.eclipse.jetty.websocket/websocket-client"
}
maven
{
url
"http://172.16.1.132:8081/repository/internal"
}
maven
{
url
"http://172.16.1.132:8081/repository/internal"
}
}
}
...
@@ -25,6 +26,7 @@ dependencies {
...
@@ -25,6 +26,7 @@ dependencies {
compile
group:
'javax.websocket'
,
name:
'javax.websocket-api'
,
version:
'1.1'
compile
group:
'javax.websocket'
,
name:
'javax.websocket-api'
,
version:
'1.1'
compile
'com.neovisionaries:nv-websocket-client:1.30'
compile
'com.neovisionaries:nv-websocket-client:1.30'
compile
'org.java-websocket:Java-WebSocket:1.3.0'
compile
'org.java-websocket:Java-WebSocket:1.3.0'
compile
group:
'org.eclipse.jetty.websocket'
,
name:
'websocket-client'
,
version:
'9.4.0.M1'
///json-patch start
///json-patch start
compile
'com.google.guava:guava:1.18.0'
compile
'com.google.guava:guava:1.18.0'
compile
'com.github.fge:json-patch:1.9'
compile
'com.github.fge:json-patch:1.9'
...
...
src/main/java/logic/CiscoManager.java
View file @
49232fc7
...
@@ -40,8 +40,8 @@ public class CiscoManager {
...
@@ -40,8 +40,8 @@ public class CiscoManager {
// consts
// consts
public
static
String
CISCO
=
"cisco"
;
public
static
String
CISCO
=
"cisco"
;
public
static
String
CISCO_DOMAIN
=
"10.10.20.6"
;
public
static
String
CISCO_DOMAIN
=
"10.10.20.6"
;
public
static
String
API_URI
=
"/
apigw/devnetlabapi/
cdp/v1/"
;
public
static
String
API_URI
=
"/cdp/v1/"
;
public
static
String
API_TOKEN_URI
=
"/
apigw/devnetlabtokenapi
/"
;
public
static
String
API_TOKEN_URI
=
"/
cdp/v1
/"
;
//tools
//tools
private
static
PercentEscaper
pes
=
new
PercentEscaper
(
"-_.!~*\'()@:$,;/?:"
,
false
);
private
static
PercentEscaper
pes
=
new
PercentEscaper
(
"-_.!~*\'()@:$,;/?:"
,
false
);
...
@@ -302,7 +302,7 @@ public class CiscoManager {
...
@@ -302,7 +302,7 @@ public class CiscoManager {
request
.
setPort
(
80
);
request
.
setPort
(
80
);
request
.
setMethod
(
SimpleHttpRequest
.
Method
.
GET
);
request
.
setMethod
(
SimpleHttpRequest
.
Method
.
GET
);
// path
// path
String
path
=
API_URI
+
"accounts
/username
"
;
String
path
=
API_URI
+
"accounts"
;
request
.
setPath
(
path
);
request
.
setPath
(
path
);
// query string
// query string
String
queryString
=
"loginName="
+
loginInfo
.
username
;
String
queryString
=
"loginName="
+
loginInfo
.
username
;
...
...
src/test/java/testWebSocket/JettyWebSocket/TestJettyWebSocket.java
0 → 100644
View file @
49232fc7
package
testWebSocket
.
JettyWebSocket
;
//import com.google.gdata.model.atompub.Draft;
//import io.undertow.websockets.client.WebSocketClient;
//import org.java_websocket.drafts.Draft_10;
//import org.java_websocket.handshake.ServerHandshake;
//import org.java_websocket.client.WebSocketClient;
import
org.eclipse.jetty.websocket.api.StatusCode
;
import
org.eclipse.jetty.websocket.api.annotations.OnWebSocketClose
;
import
org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect
;
import
org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage
;
import
org.eclipse.jetty.websocket.api.annotations.WebSocket
;
import
org.junit.Test
;
import
java.net.URI
;
import
java.util.concurrent.CountDownLatch
;
import
java.util.concurrent.Future
;
import
java.util.concurrent.TimeUnit
;
import
org.eclipse.jetty.util.ssl.SslContextFactory
;
import
org.eclipse.jetty.websocket.api.Session
;
import
org.eclipse.jetty.websocket.client.ClientUpgradeRequest
;
import
org.eclipse.jetty.websocket.client.WebSocketClient
;
import
org.eclipse.jetty.websocket.api.WebSocketListener
;
/**
* Created by eli on 10/27/16.
*/
public
class
TestJettyWebSocket
{
@WebSocket
(
maxTextMessageSize
=
64
*
1024
)
public
class
SimpleEchoSocket
{
private
final
CountDownLatch
closeLatch
;
@SuppressWarnings
(
"unused"
)
private
Session
session
;
public
SimpleEchoSocket
()
{
this
.
closeLatch
=
new
CountDownLatch
(
1
);
}
public
boolean
awaitClose
(
int
duration
,
TimeUnit
unit
)
throws
InterruptedException
{
return
this
.
closeLatch
.
await
(
duration
,
unit
);
}
@OnWebSocketClose
public
void
onClose
(
int
statusCode
,
String
reason
)
{
System
.
out
.
printf
(
"Connection closed: %d - %s%n"
,
statusCode
,
reason
);
this
.
session
=
null
;
this
.
closeLatch
.
countDown
();
// trigger latch
}
@OnWebSocketConnect
public
void
onConnect
(
Session
session
)
{
System
.
out
.
printf
(
"Got connect: %s%n"
,
session
);
this
.
session
=
session
;
try
{
Future
<
Void
>
fut
;
fut
=
session
.
getRemote
().
sendStringByFuture
(
"Hello"
);
fut
.
get
(
2
,
TimeUnit
.
SECONDS
);
// wait for send to complete.
fut
=
session
.
getRemote
().
sendStringByFuture
(
"Thanks for the conversation."
);
fut
.
get
(
2
,
TimeUnit
.
SECONDS
);
// wait for send to complete.
//session.close(StatusCode.NORMAL,"I'm done");
}
catch
(
Throwable
t
)
{
t
.
printStackTrace
();
}
}
@OnWebSocketMessage
public
void
onMessage
(
String
msg
)
{
System
.
out
.
printf
(
"Got msg: %s%n"
,
msg
);
}
}
@Test
public
void
testJettyWebSocket
()
{
try
{
WebSocketClient
client
=
new
WebSocketClient
(
new
SslContextFactory
());
client
.
start
();
//URI echoUri = new URI("wss://ic-websocket-server.run.aws-usw02-pr.ice.predix.io/events");
URI
echoUri
=
new
URI
(
"wss://ie-websocket-server-prod.run.aws-usw02-pr.ice.predix.io/consume?routing-key=c9af2c65-c25e-4087-8b8a-122c8243e5f1&service-name=ie-traffic"
);
// wss://${env.domain_eventurl}?routing-key=c9af2c65-c25e-4087-8b8a-122c8243e5f1&service-name=ie-traffic
ClientUpgradeRequest
request
=
new
ClientUpgradeRequest
();
request
.
setHeader
(
"Authorization"
,
"Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6ImxlZ2FjeS10b2tlbi1rZXkiLCJ0eXAiOiJKV1QifQ.eyJqdGkiOiJjNWM3Yzc4Y2Q1YmQ0NDk0YmJiYWUxNmNjN2I4ZDg0MiIsInN1YiI6ImlwZ2FsbGVyeSIsInNjb3BlIjpbInVhYS5yZXNvdXJjZSIsImllLWN1cnJlbnQuU0RTSU0tSUUtUFVCTElDLVNBRkVUWS5JRS1QVUJMSUMtU0FGRVRZLkxJTUlURUQuREVWRUxPUCIsImllLWN1cnJlbnQuU0RTSU0tSUUtRU5WSVJPTk1FTlRBTC5JRS1FTlZJUk9OTUVOVEFMLkxJTUlURUQuREVWRUxPUCIsImllLWN1cnJlbnQuU0RTSU0tSUUtVFJBRkZJQy5JRS1UUkFGRklDLkxJTUlURUQuREVWRUxPUCIsImllLWN1cnJlbnQuU0RTSU0tSUUtUEFSS0lORy5JRS1QQVJLSU5HLkxJTUlURUQuREVWRUxPUCIsImllLWN1cnJlbnQuU0RTSU0tSUUtUEVERVNUUklBTi5JRS1QRURFU1RSSUFOLkxJTUlURUQuREVWRUxPUCJdLCJjbGllbn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yky_WDL5TJYVO-PlRereXepEnSZ1iOSBBI22gET6KC_th_ipmkmCmwJKdLcRk4GLDe3Oig"
);
request
.
setHeader
(
"Predix-Zone-Id"
,
"SDSIM-IE-PARKING"
);
SimpleEchoSocket
socket
=
new
SimpleEchoSocket
();
Future
<
Session
>
fut
=
client
.
connect
(
socket
,
echoUri
,
request
);
System
.
out
.
printf
(
"Connecting to : %s%n"
,
echoUri
);
fut
.
get
().
getRemote
()
.
sendString
(
"{\"bbox\":\"32.715675:-117.161230,32.708498:-117.151681\",\"eventTypes\":[\"PKIN\"]}"
);
socket
.
awaitClose
(
10
,
TimeUnit
.
SECONDS
);
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"error: "
+
e
.
toString
());
}
}
}
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