Author: mwringe
Date: 2010-06-18 14:48:31 -0400 (Fri, 18 Jun 2010)
New Revision: 3387
Removed:
components/wsrp/trunk/producer/src/test/java/org/gatein/wsrp/producer/WSRPProducerBaseTest.java
components/wsrp/trunk/producer/src/test/java/org/gatein/wsrp/protocol/v1/
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/registration/
Modified:
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v1/RegistrationTestCase.java
Log:
GTNWSRP-46: Clean up duplicate tests.
Deleted:
components/wsrp/trunk/producer/src/test/java/org/gatein/wsrp/producer/WSRPProducerBaseTest.java
===================================================================
---
components/wsrp/trunk/producer/src/test/java/org/gatein/wsrp/producer/WSRPProducerBaseTest.java 2010-06-18
17:36:40 UTC (rev 3386)
+++
components/wsrp/trunk/producer/src/test/java/org/gatein/wsrp/producer/WSRPProducerBaseTest.java 2010-06-18
18:48:31 UTC (rev 3387)
@@ -1,130 +0,0 @@
-/*
- * JBoss, a division of Red Hat
- * Copyright 2010, Red Hat Middleware, LLC, and individual
- * contributors as indicated by the @authors tag. See the
- * copyright.txt in the distribution for a full listing of
- * individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.gatein.wsrp.producer;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.nio.channels.FileChannel;
-
-import junit.framework.TestCase;
-import org.gatein.common.NotYetImplemented;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw
Dawidowicz</a>
- * @version $Revision: 8808 $
- */
-public abstract class WSRPProducerBaseTest extends TestCase
-{
- protected WSRPProducerImpl producer = WSRPProducerImpl.getInstance();
-
- protected WSRPProducerBaseTest(String name) throws Exception
- {
- super(name);
- }
-
- public void deploy(String warFileName) throws Exception
- {
- File archiveDirectory = getDirectory("test.deployables.dir");
- File deployDirectory = getDirectory("jboss.server.home.dir",
"deploy");
- File archiveFile = getArchive(warFileName, archiveDirectory, true);
- File deployArchive = getArchive(warFileName, deployDirectory, false);
-
- FileChannel inputChannel = new FileInputStream(archiveFile).getChannel();
- FileChannel outputChannel = new FileOutputStream(deployArchive).getChannel();
-
- inputChannel.transferTo(0, inputChannel.size(), outputChannel);
-
- Thread.currentThread().sleep(10000);
- }
-
- public void undeploy(String warFileName) throws Exception
- {
- File deployDirectory = getDirectory("jboss.server.home.dir",
"deploy");
- File archive = getArchive(warFileName, deployDirectory, true);
-
- archive.delete();
-
- Thread.currentThread().sleep(10000);
- }
-
- private File getDirectory (String property) throws Exception
- {
- return getDirectory(property, null);
- }
-
- private File getDirectory (String property, String subDirectory) throws Exception
- {
- String deployableProperty = System.getProperty(property);
- if (deployableProperty != null)
- {
- if (subDirectory != null)
- {
- deployableProperty += File.separator + subDirectory;
- }
-
- File deployableDir = new File(deployableProperty);
- if (deployableDir.exists() && deployableDir.isDirectory())
- {
- return deployableDir;
- }
- else
- {
- throw new Error("Found a system property for \'" + property
+ "\' [" + deployableProperty + "] but value does not correspond to a
directory.");
- }
- }
- else
- {
- throw new Error ("Could not find the system property \'" +
property + "\' cannot deploy test archives.");
- }
-}
-
-
- private File getArchive(String fileName, File deployDirectory, boolean shouldExist)
throws Exception
- {
- if (fileName != null && deployDirectory != null &&
deployDirectory.exists() && deployDirectory.isDirectory())
- {
- File archiveFile = new File(deployDirectory.getAbsoluteFile() + File.separator
+ fileName);
- return archiveFile;
-// if (archiveFile.exists() && shouldExist)
-// {
-// return archiveFile;
-// }
-// else if (!archiveFile.exists() && !shouldExist)
-// {
-// return archiveFile;
-// }
-// else
-// {
-// //since its not what we are expecting we need to throw the opposite error
message
-// String existsString = shouldExist ? "does not exist" :
"exists";
-// throw new Exception("Archive " + fileName + " in directory
" + deployDirectory + " " + existsString + " which is not
expected.");
-// }
- }
- else
- {
- throw new Exception("Cannot find archive to deploy. Archive name ["
+ fileName + "] is null or the deploy directory + [" + deployDirectory + "]
is not a directory");
- }
- }
-}
Modified:
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v1/RegistrationTestCase.java
===================================================================
---
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v1/RegistrationTestCase.java 2010-06-18
17:36:40 UTC (rev 3386)
+++
components/wsrp/trunk/wsrp-producer-war/src/test/java/org/gatein/wsrp/protocol/v1/RegistrationTestCase.java 2010-06-18
18:48:31 UTC (rev 3387)
@@ -29,8 +29,19 @@
import org.gatein.wsrp.WSRPConstants;
import org.gatein.wsrp.WSRPUtils;
import org.gatein.wsrp.registration.RegistrationPropertyDescription;
+import org.gatein.wsrp.servlet.ServletAccess;
import org.gatein.wsrp.spec.v1.WSRP1TypeFactory;
import org.gatein.wsrp.test.ExtendedAssert;
+import org.gatein.wsrp.test.support.MockHttpServletRequest;
+import org.gatein.wsrp.test.support.MockHttpServletResponse;
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
import org.oasis.wsrp.v1.V1GetMarkup;
import org.oasis.wsrp.v1.V1GetServiceDescription;
import org.oasis.wsrp.v1.V1InvalidRegistration;
@@ -49,6 +60,7 @@
* @version $Revision: 12309 $
* @since 2.4
*/
+(a)RunWith(Arquillian.class)
public class RegistrationTestCase extends V1ProducerBaseTest
{
public RegistrationTestCase() throws Exception
@@ -56,11 +68,40 @@
super("RegistrationTestCase");
}
+ @Deployment
+ public static JavaArchive createDeployment()
+ {
+ return ShrinkWrap.create("test.jar", JavaArchive.class);
+ }
+
+ @Before
+ public void setUp() throws Exception
+ {
+ if (System.getProperty("test.deployables.dir") != null)
+ {
+ super.setUp();
+ //hack to get around having to have a httpservletrequest when accessing the
producer services
+ //I don't know why its really needed, seems to be a dependency where wsrp
connects with the pc module
+
ServletAccess.setRequestAndResponse(MockHttpServletRequest.createMockRequest(null),
MockHttpServletResponse.createMockResponse());
+ }
+ }
+
+
+ @After
+ public void tearDown() throws Exception
+ {
+ if (System.getProperty("test.deployables.dir") != null)
+ {
+ super.tearDown();
+ }
+ }
+
/**
* R355: The portal MUST pass a name for itself that uniquely identifies it.
*
* @throws Exception
*/
+ @Test
public void testUniqueNameRegistration() throws Exception
{
// not sure how to test this...
@@ -76,6 +117,7 @@
*
* @throws Exception
*/
+ @Test
public void testConsumerAgent() throws Exception
{
configureRegistrationSettings(true, false);
@@ -97,6 +139,7 @@
producer.register(regData);
}
+ @Test
public void testRegistrationHandle() throws V1OperationFailed, V1MissingParameters,
RegistrationException
{
// check that a registration handle was created
@@ -118,6 +161,7 @@
assertEquals(expectedHandle, registrationHandle);
}
+ @Test
public void testDeregister() throws Exception
{
// initiate registration
@@ -161,6 +205,7 @@
ExtendedAssert.assertNotNull(producer.getServiceDescription(gs));
}
+ @Test
public void testModifyRegistration() throws Exception
{
// initiate registration
@@ -237,6 +282,7 @@
checkServiceDescriptionWithOnlyBasicPortlet(gs);
}
+ @Test
public void testModifyRegistrationIncorrectData() throws Exception
{
// initiate registration
@@ -264,6 +310,7 @@
}
}
+ @Test
public void testRegister() throws Exception
{
configureRegistrationSettings(true, false);
@@ -280,6 +327,7 @@
checkServiceDescriptionWithOnlyBasicPortlet(gs);
}
+ @Test
public void testRegisterWhenRegistrationNotRequired() throws Exception
{
configureRegistrationSettings(false, false);
@@ -295,6 +343,7 @@
}
}
+ @Test
public void testDeregisterWhenRegistrationNotRequired() throws Exception
{
configureRegistrationSettings(false, false);
@@ -310,6 +359,7 @@
}
}
+ @Test
public void testModifyRegistrationWhenRegistrationNotRequired() throws Exception
{
configureRegistrationSettings(false, false);
@@ -325,6 +375,7 @@
}
}
+ @Test
public void testModifyRegistrationNoRegistrationWhenRegistrationRequired() throws
Exception
{
configureRegistrationSettings(true, false);
@@ -344,6 +395,7 @@
}
}
+ @Test
public void testDeregisterNoRegistrationWhenRegistrationRequired() throws Exception
{
configureRegistrationSettings(true, false);