Permalink
Browse files

Use TestNG

  • Loading branch information...
Randgalt committed Nov 27, 2012
1 parent e4f9bf9 commit 954977be5ae1919e78c6c9e6382cbfc47906caf5
View
@@ -118,7 +118,6 @@ project(':curator-x-discovery-server')
compile 'javax.ws.rs:jsr311-api:1.1.1'
compile 'com.google.inject:guice:3.0' // only for TypeLiteral - in the future will be replaced by Guava 13
testCompile project(':curator-test')
- testCompile 'junit:junit-dep:4.10'
testCompile 'com.sun.jersey:jersey-server:1.11'
testCompile 'com.sun.jersey:jersey-servlet:1.11'
testCompile 'com.sun.jersey:jersey-client:1.11'
@@ -22,6 +22,7 @@
import com.netflix.curator.x.discovery.ProviderStrategy;
import com.netflix.curator.x.discovery.ServiceDiscovery;
import com.netflix.curator.x.discovery.server.rest.DiscoveryContext;
+import javax.ws.rs.ext.ContextResolver;
import javax.ws.rs.ext.Provider;
import java.util.Map;
@@ -30,7 +31,7 @@
* payload
*/
@Provider
-public class MapDiscoveryContext extends GenericDiscoveryContext<Map<String, String>>
+public class MapDiscoveryContext extends GenericDiscoveryContext<Map<String, String>> implements ContextResolver<DiscoveryContext<Map<String, String>>>
{
public MapDiscoveryContext(ServiceDiscovery<Map<String, String>> serviceDiscovery, ProviderStrategy<Map<String, String>> providerStrategy, int instanceRefreshMs)
{
@@ -39,12 +39,12 @@
import com.sun.jersey.api.core.DefaultResourceConfig;
import com.sun.jersey.spi.container.servlet.ServletContainer;
import junit.framework.Assert;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.servlet.Context;
import org.mortbay.jetty.servlet.ServletHolder;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
import javax.ws.rs.core.Application;
import javax.ws.rs.core.MediaType;
import java.util.Map;
@@ -58,7 +58,7 @@
private JsonServiceInstancesMarshaller<Map<String, String>> serviceInstancesMarshaller;
private MapDiscoveryContext context;
- @Before
+ @BeforeMethod
public void setup() throws Exception
{
context = new MapDiscoveryContext(new MockServiceDiscovery<Map<String, String>>(), new RandomStrategy<Map<String, String>>(), 1000);
@@ -95,7 +95,7 @@ public void setup() throws Exception
server.start();
}
- @After
+ @AfterMethod
public void teardown() throws Exception
{
server.stop();
@@ -1,19 +1,17 @@
/*
+ * Copyright 2012 Netflix, Inc.
*
- * Copyright 2011 Netflix, Inc.
+ * Licensed 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
*
- * Licensed 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.
+ * 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 com.netflix.curator.x.discovery.server.jetty_jersey;
@@ -25,9 +23,6 @@
import junit.framework.Assert;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.servlet.Context;
import org.mortbay.jetty.servlet.ServletHolder;
@@ -50,6 +45,9 @@
import com.sun.jersey.api.client.config.DefaultClientConfig;
import com.sun.jersey.api.core.DefaultResourceConfig;
import com.sun.jersey.spi.container.servlet.ServletContainer;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
public class TestObjectPayloadWithJersey
{
@@ -59,7 +57,7 @@
private JsonServiceInstancesMarshaller<ServiceDetails> serviceInstancesMarshaller;
private ServiceDetailsDiscoveryContext context;
- @Before
+ @BeforeMethod
public void setup() throws Exception
{
context = new ServiceDetailsDiscoveryContext(new MockServiceDiscovery<ServiceDetails>(), new RandomStrategy<ServiceDetails>(), 1000);
@@ -96,7 +94,7 @@ public void setup() throws Exception
server.start();
}
- @After
+ @AfterMethod
public void teardown() throws Exception
{
server.stop();
@@ -38,12 +38,12 @@
import com.sun.jersey.api.core.DefaultResourceConfig;
import com.sun.jersey.spi.container.servlet.ServletContainer;
import junit.framework.Assert;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.servlet.Context;
import org.mortbay.jetty.servlet.ServletHolder;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
import javax.ws.rs.core.Application;
import javax.ws.rs.core.MediaType;
import java.util.Set;
@@ -56,7 +56,7 @@
private JsonServiceInstancesMarshaller<String> serviceInstancesMarshaller;
private StringDiscoveryContext context;
- @Before
+ @BeforeMethod
public void setup() throws Exception
{
context = new StringDiscoveryContext(new MockServiceDiscovery<String>(), new RandomStrategy<String>(), 1000);
@@ -93,7 +93,7 @@ public void setup() throws Exception
server.start();
}
- @After
+ @AfterMethod
public void teardown() throws Exception
{
server.stop();
@@ -29,12 +29,12 @@
import org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher;
import org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap;
import org.jboss.resteasy.spi.ResteasyProviderFactory;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.servlet.Context;
import org.mortbay.jetty.servlet.ServletHolder;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
import javax.ws.rs.core.MediaType;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
@@ -51,7 +51,7 @@
{
private Server server;
- @Before
+ @BeforeMethod
public void setup() throws Exception
{
RestEasyApplication.singletonsRef.set(new RestEasySingletons());
@@ -68,7 +68,7 @@ public void setup() throws Exception
server.start();
}
- @After
+ @AfterMethod
public void teardown() throws Exception
{
server.stop();

0 comments on commit 954977b

Please sign in to comment.