File tree Expand file tree Collapse file tree
main/java/org/javaee7/jaxrs/singleton
test/java/org/javaee7/jaxrs/singleton Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package org .javaee7 .jaxrs .singleton ;
2+
3+ import javax .ws .rs .ApplicationPath ;
4+ import javax .ws .rs .core .Application ;
5+
6+ /**
7+ * @author Arun Gupta
8+ */
9+ @ ApplicationPath ("webresources" )
10+ public class MyAnnotatedApplication extends Application {
11+ }
Original file line number Diff line number Diff line change 4949@ ApplicationPath ("webresources" )
5050public class MyApplication extends Application {
5151
52- // @Override
53- // public Set<Object> getSingletons() {
54- // Set<Object> resources = new java.util.HashSet<>();
55- // resources.add(new ApplicationSingletonResource());
56- // return resources;
57- // }
52+ @ Override
53+ public Set <Object > getSingletons () {
54+ Set <Object > resources = new java .util .HashSet <>();
55+ resources .add (new ApplicationSingletonResource ());
56+ return resources ;
57+ }
5858}
Original file line number Diff line number Diff line change @@ -54,9 +54,8 @@ public void tearDown() {
5454 public static WebArchive createDeployment () {
5555 return ShrinkWrap .create (WebArchive .class )
5656 .addClasses (
57- MyApplication .class ,
58- AnnotatedSingletonResource .class ,
59- ApplicationSingletonResource .class );
57+ MyAnnotatedApplication .class ,
58+ AnnotatedSingletonResource .class );
6059 }
6160
6261 @ Test
@@ -72,13 +71,13 @@ public void test1Post() {
7271 assertEquals (4 , tokens .countTokens ());
7372 }
7473
75- // @Test
74+ @ Test
7675 public void test2Get () {
7776 String response = target .path ("2" ).request ().get (String .class );
7877 assertEquals ("kiwi" , response );
7978 }
8079
81- // @Test
80+ @ Test
8281 public void test3Delete () {
8382 target .path ("kiwi" ).request ().delete ();
8483
@@ -87,7 +86,7 @@ public void test3Delete() {
8786 assertEquals (3 , tokens .countTokens ());
8887 }
8988
90- // @Test
89+ @ Test
9190 public void test4Put () {
9291 target .request ().put (Entity .text ("apple" ));
9392
Original file line number Diff line number Diff line change @@ -53,8 +53,7 @@ public void tearDown() {
5353 public static WebArchive createDeployment () {
5454 return ShrinkWrap .create (WebArchive .class )
5555 .addClasses (
56- MyApplication .class ,
57- AnnotatedSingletonResource .class ,
56+ MyApplication .class ,
5857 ApplicationSingletonResource .class );
5958 }
6059
You can’t perform that action at this time.
0 commit comments