Merge "Issue #2106 Add ability to run deploy tests again" into development

Former-commit-id: dc8ea99af9 [formerly 889fadcd5b4e6f261d275cab3a5b67e3edbb50d9]
Former-commit-id: 02ceb9d667
This commit is contained in:
Dustin Johnson 2013-07-08 15:52:12 -05:00 committed by Gerrit Code Review
commit 2cb1fe005c
3 changed files with 49 additions and 7 deletions

View file

@ -23,6 +23,11 @@ import java.io.ByteArrayInputStream;
import java.io.IOException; import java.io.IOException;
import java.util.Properties; import java.util.Properties;
import org.junit.Ignore;
import com.raytheon.uf.common.auth.RequestConstants;
import com.raytheon.uf.common.datadelivery.request.DataDeliveryConstants;
/** /**
* Configuration for deploy tests. * Configuration for deploy tests.
* *
@ -34,12 +39,14 @@ import java.util.Properties;
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Sep 14, 2012 1169 djohnson Initial creation * Sep 14, 2012 1169 djohnson Initial creation
* Dec 06, 2012 1397 djohnson Also set the request server. * Dec 06, 2012 1397 djohnson Also set the request server.
* Jul 08, 2013 2106 djohnson Add @Ignore, use constants.
* *
* </pre> * </pre>
* *
* @author djohnson * @author djohnson
* @version 1.0 * @version 1.0
*/ */
@Ignore
public final class DeployTestProperties { public final class DeployTestProperties {
private static volatile DeployTestProperties INSTANCE; private static volatile DeployTestProperties INSTANCE;
@ -57,8 +64,9 @@ public final class DeployTestProperties {
*/ */
private DeployTestProperties(Properties properties) { private DeployTestProperties(Properties properties) {
this.dataDeliveryServer = properties this.dataDeliveryServer = properties
.getProperty("datadelivery.server"); .getProperty(DataDeliveryConstants.DATA_DELIVERY_SERVER);
this.requestServer = properties.getProperty("request.server"); this.requestServer = properties
.getProperty(RequestConstants.REQUEST_SERVER);
this.userId = properties.getProperty("user.id"); this.userId = properties.getProperty("user.id");
} }
@ -117,4 +125,5 @@ public final class DeployTestProperties {
} }
return result; return result;
} }
} }

View file

@ -26,7 +26,12 @@ import static org.mockito.Mockito.verify;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import com.raytheon.uf.common.auth.RequestConstants;
import com.raytheon.uf.common.datadelivery.request.DataDeliveryConstants;
import com.raytheon.uf.common.registry.RegistryConstants;
import com.raytheon.uf.common.util.DeployTestProperties;
import com.raytheon.uf.common.util.registry.RegistryException; import com.raytheon.uf.common.util.registry.RegistryException;
import com.raytheon.uf.edex.auth.RemoteServerRequestRouter;
/** /**
* Test {@link RequestRouter}. * Test {@link RequestRouter}.
@ -39,6 +44,7 @@ import com.raytheon.uf.common.util.registry.RegistryException;
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Nov 14, 2012 1286 djohnson Initial creation * Nov 14, 2012 1286 djohnson Initial creation
* Mar 05, 2013 1754 djohnson Test that infinite loop for request server does not occur. * Mar 05, 2013 1754 djohnson Test that infinite loop for request server does not occur.
* Jul 08, 2013 2106 djohnson Add setDeployInstance().
* *
* </pre> * </pre>
* *
@ -60,6 +66,33 @@ public class RequestRouterTest {
private final IServerRequest serverRequest = mock(IServerRequest.class); private final IServerRequest serverRequest = mock(IServerRequest.class);
/**
* Configures the {@link RequestRouter} to route to deployed EDEX instances.
*/
public static void setDeployInstance() {
try {
RequestRouterTest.clearRegistry();
final DeployTestProperties deployTestProperties = DeployTestProperties
.getInstance();
final RemoteServerRequestRouter requestRouter = new RemoteServerRequestRouter(
deployTestProperties.getRequestServer());
final RemoteServerRequestRouter dataDeliveryRouter = new RemoteServerRequestRouter(
deployTestProperties.getDataDeliveryServer());
RequestRouterTest.register(
DataDeliveryConstants.DATA_DELIVERY_SERVER,
dataDeliveryRouter);
RequestRouterTest.register(
RegistryConstants.EBXML_REGISTRY_SERVICE,
dataDeliveryRouter);
RequestRouterTest.register(RequestConstants.REQUEST_SERVER,
requestRouter);
} catch (RegistryException e) {
throw new RuntimeException(e);
}
}
/** /**
* Registers a router for the specified server key. * Registers a router for the specified server key.
* *
@ -118,8 +151,7 @@ public class RequestRouterTest {
} }
@Test(expected = IllegalStateException.class) @Test(expected = IllegalStateException.class)
public void testUnregisteredRouterWillThrowException() public void testUnregisteredRouterWillThrowException() throws Exception {
throws Exception {
RequestRouter.route(serverRequest, "noRegisteredServer"); RequestRouter.route(serverRequest, "noRegisteredServer");
} }

View file

@ -40,7 +40,7 @@ import java.util.List;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.apache.log4j.lf5.util.StreamUtils; import org.apache.commons.io.IOUtils;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Ignore; import org.junit.Ignore;
@ -60,6 +60,7 @@ import com.raytheon.uf.common.time.util.TimeUtil;
* Sep 07, 2012 1102 djohnson Add test for more specification defined properties of hashCode/equals. * Sep 07, 2012 1102 djohnson Add test for more specification defined properties of hashCode/equals.
* Oct 23, 2012 1286 djohnson setupTestClassDir() takes any class. * Oct 23, 2012 1286 djohnson setupTestClassDir() takes any class.
* Jun 05, 2013 2038 djohnson Add constant for metadata tx manager. * Jun 05, 2013 2038 djohnson Add constant for metadata tx manager.
* Jul 08, 2013 2106 djohnson Use IOUtils instead of log4j for stream copying.
* *
* </pre> * </pre>
* *
@ -182,7 +183,7 @@ public final class TestUtil {
try { try {
is = callingClass.getResourceAsStream(file); is = callingClass.getResourceAsStream(file);
StreamUtils.copy(is, bos); IOUtils.copy(is, bos);
String contents = bos.toString("UTF-8"); String contents = bos.toString("UTF-8");
@ -324,7 +325,7 @@ public final class TestUtil {
try { try {
is = callingClass.getResourceAsStream(resource); is = callingClass.getResourceAsStream(resource);
try { try {
StreamUtils.copy(is, bos); IOUtils.copy(is, bos);
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }