Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
spring-boot-admin
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
openSource
spring-boot-admin
Commits
d0ba735a
Commit
d0ba735a
authored
Jul 31, 2014
by
Thomas Bosch
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'upstream/master'
parents
a789ad8a
37fd5316
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
111 additions
and
2 deletions
+111
-2
pom.xml
pom.xml
+7
-0
ApplicationRegistry.java
...e/codecentric/boot/admin/service/ApplicationRegistry.java
+21
-2
ApplicationRegistryTest.java
...decentric/boot/admin/service/ApplicationRegistryTest.java
+83
-0
No files found.
pom.xml
View file @
d0ba735a
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
</licenses>
</licenses>
<properties>
<properties>
<spring-boot.version>
1.1.4.RELEASE
</spring-boot.version>
<spring-boot.version>
1.1.4.RELEASE
</spring-boot.version>
<spring.version>
4.0.6.RELEASE
</spring.version>
<bootstrap.version>
2.3.2
</bootstrap.version>
<bootstrap.version>
2.3.2
</bootstrap.version>
<jquery.version>
1.11.0
</jquery.version>
<jquery.version>
1.11.0
</jquery.version>
<angularjs.version>
1.2.12
</angularjs.version>
<angularjs.version>
1.2.12
</angularjs.version>
...
@@ -67,6 +68,12 @@
...
@@ -67,6 +68,12 @@
<version>
4.10
</version>
<version>
4.10
</version>
<scope>
test
</scope>
<scope>
test
</scope>
</dependency>
</dependency>
<dependency>
<groupId>
org.springframework
</groupId>
<artifactId>
spring-test
</artifactId>
<version>
${spring.version}
</version>
<scope>
test
</scope>
</dependency>
</dependencies>
</dependencies>
<repositories>
<repositories>
<repository>
<repository>
...
...
src/main/java/de/codecentric/boot/admin/service/ApplicationRegistry.java
View file @
d0ba735a
...
@@ -15,12 +15,14 @@
...
@@ -15,12 +15,14 @@
*/
*/
package
de
.
codecentric
.
boot
.
admin
.
service
;
package
de
.
codecentric
.
boot
.
admin
.
service
;
import
java.net.MalformedURLException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
org.apache.commons.lang3.Validate
;
import
org.apache.commons.lang3.Validate
;
import
org.apache.tomcat.util.net.URL
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
de.codecentric.boot.admin.model.Application
;
import
de.codecentric.boot.admin.model.Application
;
...
@@ -42,12 +44,29 @@ public class ApplicationRegistry {
...
@@ -42,12 +44,29 @@ public class ApplicationRegistry {
*/
*/
public
Application
register
(
Application
app
)
{
public
Application
register
(
Application
app
)
{
Validate
.
notNull
(
app
,
"Application must not be null"
);
Validate
.
notNull
(
app
,
"Application must not be null"
);
Validate
.
notNull
(
app
.
getId
(),
"Application ID must not be null"
);
Validate
.
notNull
(
app
.
getId
(),
"ID must not be null"
);
Validate
.
notNull
(
app
.
getUrl
(),
"Application URL must not be null"
);
Validate
.
notNull
(
app
.
getUrl
(),
"URL must not be null"
);
Validate
.
isTrue
(
checkUrl
(
app
.
getUrl
()),
"URL is not valid"
);
return
registry
.
put
(
app
.
getId
(),
app
);
return
registry
.
put
(
app
.
getId
(),
app
);
}
}
/**
/**
* Checks the syntax of the given URL.
*
* @param url
* The URL.
* @return true, if valid.
*/
private
boolean
checkUrl
(
String
url
)
{
try
{
new
URL
(
url
);
}
catch
(
MalformedURLException
e
)
{
return
false
;
}
return
true
;
}
/**
* Checks, if an application is already registerd.
* Checks, if an application is already registerd.
*
*
* @param id
* @param id
...
...
src/test/java/de/codecentric/boot/admin/service/ApplicationRegistryTest.java
0 → 100644
View file @
d0ba735a
package
de
.
codecentric
.
boot
.
admin
.
service
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.test.context.ContextConfiguration
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
de.codecentric.boot.admin.config.WebappConfig
;
import
de.codecentric.boot.admin.model.Application
;
@ContextConfiguration
(
classes
=
{
WebappConfig
.
class
})
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
public
class
ApplicationRegistryTest
{
@Autowired
private
ApplicationRegistry
registry
;
@Test
(
expected
=
NullPointerException
.
class
)
public
void
registerFailed1
()
throws
Exception
{
registry
.
register
(
new
Application
());
}
@Test
(
expected
=
NullPointerException
.
class
)
public
void
registerFailed2
()
throws
Exception
{
Application
app
=
new
Application
();
app
.
setId
(
"abc"
);
registry
.
register
(
app
);
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
registerFailed3
()
throws
Exception
{
Application
app
=
new
Application
();
app
.
setId
(
"abc"
);
app
.
setUrl
(
"not-an-url"
);
registry
.
register
(
app
);
}
@Test
public
void
register
()
throws
Exception
{
Application
app
=
new
Application
();
app
.
setId
(
"abc"
);
app
.
setUrl
(
"http://localhost:8080"
);
registry
.
register
(
app
);
}
@Test
public
void
isRegistered
()
throws
Exception
{
Application
app
=
new
Application
();
app
.
setId
(
"abc"
);
app
.
setUrl
(
"http://localhost:8080"
);
registry
.
register
(
app
);
assertFalse
(
registry
.
isRegistered
(
"xyz"
));
assertTrue
(
registry
.
isRegistered
(
"abc"
));
}
@Test
public
void
getApplication
()
throws
Exception
{
Application
app
=
new
Application
();
app
.
setId
(
"abc"
);
app
.
setUrl
(
"http://localhost:8080"
);
registry
.
register
(
app
);
assertEquals
(
app
,
registry
.
getApplication
(
"abc"
));
}
@Test
public
void
getApplications
()
throws
Exception
{
Application
app
=
new
Application
();
app
.
setId
(
"abc"
);
app
.
setUrl
(
"http://localhost:8080"
);
registry
.
register
(
app
);
assertEquals
(
1
,
registry
.
getApplications
().
size
());
assertEquals
(
app
,
registry
.
getApplications
().
get
(
0
));
}
}
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