Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jaxrs
Overview
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
Alan de Oliveira
jaxrs
Commits
d945a7ec
Commit
d945a7ec
authored
Jun 25, 2014
by
dblevins
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reworked service and documentation
parent
ea3acb90
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
114 additions
and
19 deletions
+114
-19
README.md
README.md
+0
-0
pom.xml
pom.xml
+20
-3
Color.java
src/main/java/org/superbiz/Color.java
+70
-0
ColorService.java
src/main/java/org/superbiz/ColorService.java
+12
-8
ColorServiceTest.java
src/test/java/org/superbiz/ColorServiceTest.java
+12
-8
No files found.
README.md
View file @
d945a7ec
This diff is collapsed.
Click to expand it.
pom.xml
View file @
d945a7ec
...
...
@@ -19,11 +19,12 @@
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<!-- Change: groupId, artifactId, version -->
<groupId>
org.superbiz
</groupId>
<artifactId>
tomee-rest-arquillian
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<packaging>
war
</packaging>
<name>
Maven Project with Arquillian and TomEE JAX-RS
</name>
<dependencies>
<dependency>
...
...
@@ -54,6 +55,7 @@
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
<version>
4.11
</version>
<scope>
test
</scope>
</dependency>
</dependencies>
...
...
@@ -62,12 +64,17 @@
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-compiler-plugin
</artifactId>
<version>
3.0
</version>
<version>
3.1
</version>
<configuration>
<optimize>
true
</optimize>
<source>
1.6
</source>
<target>
1.6
</target>
</configuration>
</plugin>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-surefire-plugin
</artifactId>
<version>
2.1
3
</version>
<version>
2.1
7
</version>
</plugin>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
...
...
@@ -77,6 +84,16 @@
<failOnMissingWebXml>
false
</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>
org.apache.openejb.maven
</groupId>
<artifactId>
tomee-maven-plugin
</artifactId>
<version>
1.6.0.2
</version>
<configuration>
<tomeeVersion>
1.6.0.2
</tomeeVersion>
<tomeeClassifier>
jaxrs
</tomeeClassifier>
</configuration>
</plugin>
</plugins>
</build>
...
...
src/main/java/org/superbiz/Color.java
0 → 100644
View file @
d945a7ec
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
superbiz
;
import
javax.xml.bind.annotation.XmlRootElement
;
@XmlRootElement
public
class
Color
{
private
String
name
;
private
int
r
;
private
int
g
;
private
int
b
;
public
Color
()
{
}
public
Color
(
String
name
,
int
r
,
int
g
,
int
b
)
{
this
.
name
=
name
;
this
.
r
=
r
;
this
.
g
=
g
;
this
.
b
=
b
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
int
getR
()
{
return
r
;
}
public
void
setR
(
int
r
)
{
this
.
r
=
r
;
}
public
int
getG
()
{
return
g
;
}
public
void
setG
(
int
g
)
{
this
.
g
=
g
;
}
public
int
getB
()
{
return
b
;
}
public
void
setB
(
int
b
)
{
this
.
b
=
b
;
}
}
src/main/java/org/superbiz/Color
Bean
.java
→
src/main/java/org/superbiz/Color
Service
.java
View file @
d945a7ec
...
...
@@ -21,14 +21,17 @@ import javax.ws.rs.GET;
import
javax.ws.rs.POST
;
import
javax.ws.rs.Path
;
import
javax.ws.rs.PathParam
;
import
javax.ws.rs.Produces
;
import
static
javax
.
ws
.
rs
.
core
.
MediaType
.
APPLICATION_JSON
;
@Path
(
"/color"
)
@Singleton
public
class
Color
Bean
{
public
class
Color
Service
{
private
String
color
;
public
Color
Bean
()
{
public
Color
Service
()
{
this
.
color
=
"white"
;
}
...
...
@@ -37,15 +40,16 @@ public class ColorBean {
return
color
;
}
@Path
(
"favorite"
)
@GET
public
String
getFavoriteColor
()
{
return
"orange"
;
}
@Path
(
"{color}"
)
@POST
public
void
setColor
(
@PathParam
(
"color"
)
String
color
)
{
this
.
color
=
color
;
}
@Path
(
"object"
)
@GET
@Produces
({
APPLICATION_JSON
})
public
Color
getColorObject
()
{
return
new
Color
(
"orange"
,
0xE7
,
0x71
,
0x00
);
}
}
src/test/java/org/superbiz/Color
Bean
Test.java
→
src/test/java/org/superbiz/Color
Service
Test.java
View file @
d945a7ec
...
...
@@ -26,6 +26,7 @@ import org.junit.Assert;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
javax.ws.rs.core.MediaType
;
import
javax.ws.rs.core.Response
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
...
...
@@ -44,7 +45,7 @@ import java.net.URL;
*
*/
@RunWith
(
Arquillian
.
class
)
public
class
Color
Bean
Test
extends
Assert
{
public
class
Color
Service
Test
extends
Assert
{
/**
* ShrinkWrap is used to create a war file on the fly.
...
...
@@ -57,7 +58,7 @@ public class ColorBeanTest extends Assert {
*/
@Deployment
public
static
WebArchive
createDeployment
()
{
return
ShrinkWrap
.
create
(
WebArchive
.
class
).
addClass
(
ColorBean
.
class
);
return
ShrinkWrap
.
create
(
WebArchive
.
class
).
addClass
es
(
ColorService
.
class
,
Color
.
class
);
}
/**
...
...
@@ -99,15 +100,18 @@ public class ColorBeanTest extends Assert {
}
@Test
public
void
getFavorite
()
throws
Exception
{
final
WebClient
webClient
=
WebClient
.
create
(
webappUrl
.
toURI
());
final
Response
response
=
webClient
.
path
(
"color/favorite"
).
get
();
public
void
getColorObject
()
throws
Exception
{
assertEquals
(
200
,
response
.
getStatus
());
final
WebClient
webClient
=
WebClient
.
create
(
webappUrl
.
toURI
());
webClient
.
accept
(
MediaType
.
APPLICATION_JSON
);
final
String
content
=
slurp
((
InputStream
)
response
.
getEntity
()
);
final
Color
color
=
webClient
.
path
(
"color/object"
).
get
(
Color
.
class
);
assertEquals
(
"orange"
,
content
);
assertNotNull
(
color
);
assertEquals
(
"orange"
,
color
.
getName
());
assertEquals
(
0xE7
,
color
.
getR
());
assertEquals
(
0x71
,
color
.
getG
());
assertEquals
(
0x00
,
color
.
getB
());
}
/**
...
...
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