|
From: <ble...@us...> - 2010-09-13 19:56:31
|
Revision: 3537
http://bigdata.svn.sourceforge.net/bigdata/?rev=3537&view=rev
Author: blevine218
Date: 2010-09-13 19:56:24 +0000 (Mon, 13 Sep 2010)
Log Message:
-----------
Remove dependencies on cweb-junit
Move to JUnit 4
fix-up deploy directories in POM
Enable TestBigdataClientRemote
Modified Paths:
--------------
branches/maven_scaleout/bigdata-integ/pom.xml
branches/maven_scaleout/bigdata-integ/src/test/java/com/bigdata/service/jini/AbstractServerTestCase.java
branches/maven_scaleout/bigdata-integ/src/test/java/com/bigdata/service/jini/TestBigdataClient.java
branches/maven_scaleout/bigdata-integ/src/test/java/com/bigdata/service/jini/TestBigdataClientRemote.java
Property Changed:
----------------
branches/maven_scaleout/bigdata-integ/
Property changes on: branches/maven_scaleout/bigdata-integ
___________________________________________________________________
Modified: svn:ignore
- target
+ target
.classpath
.project
.settings
Modified: branches/maven_scaleout/bigdata-integ/pom.xml
===================================================================
--- branches/maven_scaleout/bigdata-integ/pom.xml 2010-09-13 15:17:50 UTC (rev 3536)
+++ branches/maven_scaleout/bigdata-integ/pom.xml 2010-09-13 19:56:24 UTC (rev 3537)
@@ -43,10 +43,10 @@
<!--
In the ANT script, hostname is obtained by an exec of the
- 'hostname' command. Hard-coding to localhost for now.
+ 'hostname' command. Hard-coding for now.
-->
- <hostname>blevine-desktop</hostname>
- <test.codebase>http://${hostname}:${test.codebase.port}/jsk-dl.jar</test.codebase>
+ <hostname>blevine-laptop</hostname>
+ <test.codebase>http://${hostname}:${test.codebase.port}/jsk-dl.jar</test.codebase> <!-- Not used??? -->
<federation.name>bigdata.test.group-${hostname}</federation.name>
</properties>
@@ -69,7 +69,7 @@
<artifactId>bigdata-core</artifactId>
<classifier>deploy</classifier>
<type>tar.gz</type>
- <outputDirectory>${deploy.directory}</outputDirectory>
+ <outputDirectory>${deploy.root.dir}</outputDirectory>
</artifactItem>
</artifactItems>
<useSubdirPerArtifact>true</useSubdirPerArtifact>
@@ -106,10 +106,9 @@
<include>**/*Test.java</include>
</includes>
<excludes>
- <exclude>**/TestBigdataClientRemote.java</exclude>
+ <exclude>**/TestBigdataClientremove.java</exclude>
</excludes>
<systemPropertyVariables>
- <foo.bar.prop>hello</foo.bar.prop>
<java.security.policy>${java.security.policy}</java.security.policy>
<java.net.preferIPv4Stack>{java.net.preferIPv4Stack}"</java.net.preferIPv4Stack>
<log4j.configuration>${log4j.configuration}</log4j.configuration>
@@ -217,14 +216,6 @@
<version>4.7</version>
<scope>test</scope>
</dependency>
-
- <dependency>
- <groupId>com.bigdata.thirdparty</groupId>
- <artifactId>cweb-junit-ext</artifactId>
- <version>1.1.0-b3-dev</version>
- <scope>test</scope>
- </dependency>
-
</dependencies>
</project>
Modified: branches/maven_scaleout/bigdata-integ/src/test/java/com/bigdata/service/jini/AbstractServerTestCase.java
===================================================================
--- branches/maven_scaleout/bigdata-integ/src/test/java/com/bigdata/service/jini/AbstractServerTestCase.java 2010-09-13 15:17:50 UTC (rev 3536)
+++ branches/maven_scaleout/bigdata-integ/src/test/java/com/bigdata/service/jini/AbstractServerTestCase.java 2010-09-13 19:56:24 UTC (rev 3537)
@@ -20,7 +20,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*/
+ */
/*
* Created on Apr 22, 2007
*/
@@ -28,10 +28,10 @@
package com.bigdata.service.jini;
import java.io.IOException;
-import java.net.InetAddress;
+import junit.framework.Assert;
import junit.framework.AssertionFailedError;
-import junit.framework.TestCase2;
+
import net.jini.core.discovery.LookupLocator;
import net.jini.core.lookup.ServiceID;
import net.jini.core.lookup.ServiceRegistrar;
@@ -45,7 +45,6 @@
import com.bigdata.service.IDataService;
import com.bigdata.service.MetadataService;
import com.sun.jini.tool.ClassServer;
-import com.bigdata.util.config.ConfigDeployUtil;
import com.bigdata.util.config.NicUtil;
/**
@@ -84,6 +83,7 @@
* </pre>
*
* You can enable NIO using:
+ *
* <pre>
* -Dcom.sun.jini.jeri.tcp.useNIO=true
* </pre>
@@ -91,210 +91,22 @@
* @author <a href="mailto:tho...@us...">Bryan Thompson</a>
* @version $Id$
*/
-public abstract class AbstractServerTestCase extends TestCase2 {
+public abstract class AbstractServerTestCase
+{
/**
* Equal to {@link ITx#UNISOLATED}.
*/
- protected final long UNISOLATED = ITx.UNISOLATED;
-
+ protected final long UNISOLATED = ITx.UNISOLATED;
+
/**
*
*/
- public AbstractServerTestCase() {
+ public AbstractServerTestCase()
+ {
}
/**
- * @param arg0
- */
- public AbstractServerTestCase(String arg0) {
- super(arg0);
- }
-
-// /**
-// * Return an open port on current machine. Try the suggested port first. If
-// * suggestedPort is zero, just select a random port
-// */
-// private static int getPort(int suggestedPort) throws IOException {
-// ServerSocket openSocket;
-// try {
-// openSocket = new ServerSocket(suggestedPort);
-// } catch (BindException ex) {
-// // the port is busy, so look for a random open port
-// openSocket = new ServerSocket(0);
-// }
-//
-// int port = openSocket.getLocalPort();
-// openSocket.close();
-//
-// return port;
-// }
-
-// /**
-// * This may be used to verify that a specific port is available. The method
-// * will return iff the port is available at the time that this method was
-// * called. The method will retry a few times since sometimes it takes a bit
-// * for a socket to get released and we are reusing the same socket for the
-// * {@link ClassServer} for each test.
-// *
-// * @param port
-// * The port to try.
-// *
-// * @exception AssertionFailedError
-// * if the port is not available.
-// */
-// protected static void assertOpenPort(final int port) throws IOException {
-//
-// ServerSocket openSocket;
-//
-// int i = 0;
-//
-// final int maxTries = 3;
-//
-// while (i < maxTries) {
-//
-// try {
-//
-// // try to open a server socket on that port.
-// openSocket = new ServerSocket(port);
-//
-// // close the socket - it is available for the moment.
-// openSocket.close();
-//
-// return;
-//
-// } catch (BindException ex) {
-//
-// if (i++ < maxTries) {
-//
-// log.warn("Port " + port + " is busy - retrying: " + ex);
-//
-// try {
-// Thread.sleep(100/* ms */);
-// } catch (InterruptedException t) {
-// /* ignore */
-// }
-//
-// } else {
-//
-// fail("Port is busy: " + ex + " - use " + PORT_OPTION
-// + " to specify another port?");
-//
-// }
-//
-// }
-//
-// }
-//
-// }
-
-// private ClassServer classServer;
-//
-// /**
-// * The name of the System property that may be used to change the port on which
-// * the {@link ClassServer} will be started.
-// */
-// public static final String PORT_OPTION = "bigdata.test.port";
-//
-// /**
-// * The default port on which the {@link ClassServer} will be started.
-// * <p>
-// * Note: Outlook appears to conflict with 8081.
-// */
-// public static final String DEFAULT_PORT = "8082";
-//
-// /**
-// * Starts a {@link ClassServer} that supports downloadable code for the unit
-// * test. The {@link ClassServer} will start on the port named by the System
-// * property {@link #PORT_OPTION} and on port {@link #DEFAULT_PORT} if that
-// * system property is not set.
-// *
-// * @throws IOException
-// */
-// protected void startClassServer() throws IOException {
-//
-// // Note: See below.
-//// if(true) return;
-//
-// Logger.getLogger("com.sun.jini.tool.ClassServer").setLevel(Level.ALL);
-//
-// /*
-// * Obtain port from System.getProperties() so that other ports may be
-// * used.
-// */
-// final int port = Integer.parseInt(System.getProperty(PORT_OPTION,DEFAULT_PORT));
-//
-// /*
-// * The directories containing the JARs and the compiled classes for the
-// * bigdata project.
-// */
-// String dirlist =
-// "lib"+File.pathSeparatorChar+
-// "lib"+File.separatorChar+"icu"+File.pathSeparatorChar+
-// "lib"+File.separatorChar+"jini"+File.pathSeparatorChar
-// /*
-// * FIXME This does not seem to be resolving the bigdata classes
-// * necessitating that we list that jar explicitly below (and that it
-// * be up to date). The problem can be seen in the Jini Service
-// * Browser and the console for the Service Browser. In fact, the
-// * test suite executes just fine if you do NOT use the ClassServer!
-// *
-// * I can only get this working right now by placing bigdata-core.jar into
-// * the lib directory (or some other directory below the current
-// * working directory, but not ant-build since that gives the ant
-// * script fits).
-// *
-// * I still see a ClassNotFound problem in the Jini console complaining
-// * that it can not find IDataService, but only when I select the
-// * registrar on which the services are running!
-// */
-//// +
-//// "bin"
-// //+File.pathSeparatorChar+
-//// "ant-build"
-// ;
-//
-// assertOpenPort(port);
-//
-// classServer = new ClassServer(
-// port,
-// dirlist,
-// true, // trees - serve up files inside of JARs,
-// true // verbose
-// );
-//
-// classServer.start();
-//
-// }
-
- public void setUp() throws Exception {
-
- if (log.isInfoEnabled())
- log.info(getName());
-
-// startClassServer();
-
- }
-
- /**
- * Stops the {@link ClassServer}.
- */
- public void tearDown() throws Exception {
-
-// if (classServer != null) {
-//
-// classServer.terminate();
-//
-// }
-
- super.tearDown();
-
- if (log.isInfoEnabled())
- log.info(getName());
-
- }
-
- /**
* Return the {@link ServiceID} of a server that we started ourselves. The
* method waits until the {@link ServiceID} becomes available on
* {@link AbstractServer#getServiceID()}.
@@ -305,45 +117,40 @@
* @exception InterruptedException
* if the thread is interrupted while it is waiting to retry.
*/
- static public ServiceID getServiceID(final AbstractServer server)
- throws AssertionFailedError, InterruptedException {
-
+ static public ServiceID getServiceID(final AbstractServer server) throws AssertionFailedError, InterruptedException
+ {
ServiceID serviceID = null;
- for(int i=0; i<10 && serviceID == null; i++) {
-
+ for (int i = 0; i < 10 && serviceID == null; i++)
+ {
/*
* Note: This can be null since the serviceID is not assigned
* synchronously by the registrar.
*/
-
serviceID = server.getServiceID();
-
- if(serviceID == null) {
-
+
+ if (serviceID == null)
+ {
/*
* We wait a bit and retry until we have it or timeout.
*/
-
Thread.sleep(200);
-
}
-
}
-
- assertNotNull("serviceID",serviceID);
-
+
+ Assert.assertNotNull("serviceID", serviceID);
+
/*
* Verify that we have discovered the _correct_ service. This is a
* potential problem when starting a stopping services for the test
* suite.
*/
- assertEquals("serviceID", server.getServiceID(), serviceID);
+ Assert.assertEquals("serviceID", server.getServiceID(), serviceID);
return serviceID;
-
+
}
-
+
/**
* Lookup a {@link DataService} by its {@link ServiceID} using unicast
* discovery on localhost.
@@ -360,10 +167,9 @@
* that carries most of the functionality but allows us to make
* distinctions easily during discovery).
*/
- public IDataService lookupDataService(ServiceID serviceID)
- throws IOException, ClassNotFoundException, InterruptedException {
-
- /*
+ public IDataService lookupDataService(ServiceID serviceID) throws IOException, ClassNotFoundException, InterruptedException
+ {
+ /*
* Lookup the discover service (unicast on localhost).
*/
@@ -371,10 +177,9 @@
String hostname = NicUtil.getIpAddress("default.nic", "default", true);
// Find the service registrar (unicast protocol).
- final int timeout = 4*1000; // seconds.
- System.err.println("hostname: "+hostname);
- LookupLocator lookupLocator = new LookupLocator("jini://"+hostname);
- ServiceRegistrar serviceRegistrar = lookupLocator.getRegistrar( timeout );
+ final int timeout = 4 * 1000; // seconds.
+ LookupLocator lookupLocator = new LookupLocator("jini://" + hostname);
+ ServiceRegistrar serviceRegistrar = lookupLocator.getRegistrar(timeout);
/*
* Prepare a template for lookup search.
@@ -385,19 +190,20 @@
* by the server.
*/
ServiceTemplate template = new ServiceTemplate(//
- /*
- * use this to request the service by its serviceID.
- */
- serviceID,
- /*
- * Use this to filter services by an interface that they expose.
- */
-// new Class[] { IDataService.class },
- null,
- /*
- * use this to filter for services by Entry attributes.
- */
- null);
+ /*
+ * use this to request the service by its serviceID.
+ */
+ serviceID,
+ /*
+ * Use this to filter services by an interface that they
+ * expose.
+ */
+ // new Class[] { IDataService.class },
+ null,
+ /*
+ * use this to filter for services by Entry attributes.
+ */
+ null);
/*
* Lookup a service. This can fail if the service registrar has not
@@ -408,52 +214,42 @@
* notification events for the service if it is not found and enter a
* wait state).
*/
-
+
IDataService service = null;
-
- for (int i = 0; i < 10 && service == null; i++) {
-
- service = (IDataService) serviceRegistrar
- .lookup(template /* , maxMatches */);
-
- if (service == null) {
-
+
+ for (int i = 0; i < 10 && service == null; i++)
+ {
+ service = (IDataService) serviceRegistrar.lookup(template);
+
+ if (service == null)
+ {
System.err.println("Service not found: sleeping...");
-
Thread.sleep(200);
-
}
-
+
}
- if (service != null) {
-
+ if (service != null)
+ {
System.err.println("Service found.");
-
}
return service;
-
}
/**
- * Compares two representations of the {@link PartitionLocator}
- * without the left- and right-separator keys that bound the index
- * partition.
+ * Compares two representations of the {@link PartitionLocator} without the
+ * left- and right-separator keys that bound the index partition.
*
* @param expected
* @param actual
*/
- protected void assertEquals(PartitionLocator expected, PartitionLocator actual) {
-
- assertEquals("partitionId", expected.getPartitionId(), actual
- .getPartitionId());
-
- assertEquals("dataServiceUUID", expected.getDataServiceUUID(), actual
- .getDataServiceUUID());
-
+ protected void assertEquals(PartitionLocator expected, PartitionLocator actual)
+ {
+ Assert.assertEquals("partitionId", expected.getPartitionId(), actual.getPartitionId());
+ Assert.assertEquals("dataServiceUUID", expected.getDataServiceUUID(), actual.getDataServiceUUID());
}
-
+
/**
* Compares two representations of the {@link LocalPartitionMetadata} for an
* index partition including the optional resource descriptions.
@@ -461,43 +257,30 @@
* @param expected
* @param actual
*/
- protected void assertEquals(LocalPartitionMetadata expected,
- LocalPartitionMetadata actual) {
+ protected void assertEquals(LocalPartitionMetadata expected, LocalPartitionMetadata actual)
+ {
+ Assert.assertEquals("partitionId", expected.getPartitionId(), actual.getPartitionId());
+ Assert.assertEquals("leftSeparatorKey", expected.getLeftSeparatorKey(), ((LocalPartitionMetadata) actual).getLeftSeparatorKey());
+ Assert.assertEquals("rightSeparatorKey", expected.getRightSeparatorKey(), ((LocalPartitionMetadata) actual).getRightSeparatorKey());
- assertEquals("partitionId",expected.getPartitionId(), actual.getPartitionId());
-
- assertEquals("leftSeparatorKey", expected.getLeftSeparatorKey(),
- ((LocalPartitionMetadata) actual)
- .getLeftSeparatorKey());
-
- assertEquals("rightSeparatorKey", expected.getRightSeparatorKey(),
- ((LocalPartitionMetadata) actual)
- .getRightSeparatorKey());
-
final IResourceMetadata[] expectedResources = expected.getResources();
-
final IResourceMetadata[] actualResources = actual.getResources();
-
- assertEquals("#resources",expectedResources.length,actualResources.length);
- for(int i=0;i<expected.getResources().length; i++) {
-
+ Assert.assertEquals("#resources", expectedResources.length, actualResources.length);
+
+ for (int i = 0; i < expected.getResources().length; i++)
+ {
// verify by components so that it is obvious what is wrong.
-
- assertEquals("filename[" + i + "]", expectedResources[i].getFile(),
- actualResources[i].getFile());
-// assertEquals("size[" + i + "]", expectedResources[i].size(),
-// actualResources[i].size());
+ Assert.assertEquals("filename[" + i + "]", expectedResources[i].getFile(), actualResources[i].getFile());
- assertEquals("UUID[" + i + "]", expectedResources[i].getUUID(),
- actualResources[i].getUUID());
+ // assertEquals("size[" + i + "]", expectedResources[i].size(),
+ // actualResources[i].size());
+ Assert.assertEquals("UUID[" + i + "]", expectedResources[i].getUUID(), actualResources[i].getUUID());
+
// verify by equals.
- assertTrue("resourceMetadata",expectedResources[i].equals(actualResources[i]));
-
+ Assert.assertTrue("resourceMetadata", expectedResources[i].equals(actualResources[i]));
}
-
}
-
}
Modified: branches/maven_scaleout/bigdata-integ/src/test/java/com/bigdata/service/jini/TestBigdataClient.java
===================================================================
--- branches/maven_scaleout/bigdata-integ/src/test/java/com/bigdata/service/jini/TestBigdataClient.java 2010-09-13 15:17:50 UTC (rev 3536)
+++ branches/maven_scaleout/bigdata-integ/src/test/java/com/bigdata/service/jini/TestBigdataClient.java 2010-09-13 19:56:24 UTC (rev 3537)
@@ -31,6 +31,12 @@
import java.util.Random;
import java.util.UUID;
+import junit.framework.Assert;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
import com.bigdata.btree.IIndex;
import com.bigdata.btree.ITuple;
import com.bigdata.btree.ITupleIterator;
@@ -65,27 +71,18 @@
this.serviceImplRemote = false;
}
- public TestBigdataClient(String name) {
- super(name);
- this.serviceImplRemote = false;
- }
-
public TestBigdataClient(boolean serviceImplRemote) {
this.serviceImplRemote = serviceImplRemote;
}
- public TestBigdataClient(String name, boolean serviceImplRemote) {
- super(name);
- this.serviceImplRemote = serviceImplRemote;
- }
/**
* Starts a {@link DataServer} ({@link #dataServer1}) and then a
* {@link MetadataServer} ({@link #metadataServer0}). Each runs in its own
* thread.
*/
+ @Before
public void setUp() throws Exception {
- super.setUp();
helper = new JiniServicesHelper(serviceImplRemote);
helper.start();
}
@@ -95,12 +92,11 @@
/**
* Destroy the test services.
*/
+ @After
public void tearDown() throws Exception {
if (helper != null) {
helper.destroy();
}
-
- super.tearDown();
}
/**
@@ -109,6 +105,7 @@
*
* @throws Exception
*/
+ @Test
public void test_registerIndex1() throws Exception {
final IBigdataFederation<?> fed = helper.client.connect();
final String name = "testIndex";
@@ -118,8 +115,7 @@
fed.registerIndex(metadata);
final IIndex ndx = fed.getIndex(name, ITx.UNISOLATED);
- assertEquals("indexUUID", metadata.getIndexUUID(), ndx
- .getIndexMetadata().getIndexUUID());
+ Assert.assertEquals("indexUUID", metadata.getIndexUUID(), ndx.getIndexMetadata().getIndexUUID());
doBasicIndexTests(ndx);
}
@@ -130,6 +126,7 @@
*
* @throws Exception
*/
+ @Test
public void test_registerIndex2() throws Exception {
final IBigdataFederation<?> fed = helper.client.connect();
final String name = "testIndex";
@@ -151,16 +148,13 @@
final IIndex ndx = fed.getIndex(name, ITx.UNISOLATED);
- assertEquals("indexUUID", indexUUID, ndx.getIndexMetadata()
- .getIndexUUID());
+ Assert.assertEquals("indexUUID", indexUUID, ndx.getIndexMetadata().getIndexUUID());
// verify partition 0 on dataService0
- assertNotNull(helper.getDataService0().getIndexMetadata(
- DataService.getIndexPartitionName(name, 0), ITx.UNISOLATED));
+ Assert.assertNotNull(helper.getDataService0().getIndexMetadata(DataService.getIndexPartitionName(name, 0), ITx.UNISOLATED));
// verify partition 1 on dataService1
- assertNotNull(helper.getDataService1().getIndexMetadata(
- DataService.getIndexPartitionName(name, 1), ITx.UNISOLATED));
+ Assert.assertNotNull(helper.getDataService1().getIndexMetadata(DataService.getIndexPartitionName(name, 1), ITx.UNISOLATED));
doBasicIndexTests(ndx);
}
@@ -192,7 +186,7 @@
ndx.submit(0/* fromIndex */, limit/* toIndex */, keys, vals, BatchInsertConstructor.RETURN_NO_VALUES, null);
// verify #of index entries.
- assertEquals(limit, ndx.rangeCount(null, null));
+ Assert.assertEquals(limit, ndx.rangeCount(null, null));
// verify data.
{
@@ -203,12 +197,12 @@
while (itr.hasNext()) {
final ITuple<?> tuple = itr.next();
- assertEquals(keys[i], tuple.getKey());
- assertEquals(vals[i], tuple.getValue());
+ Assert.assertEquals(keys[i], tuple.getKey());
+ Assert.assertEquals(vals[i], tuple.getValue());
i++;
}
- assertEquals(limit, i);
+ Assert.assertEquals(limit, i);
}
}
}
Modified: branches/maven_scaleout/bigdata-integ/src/test/java/com/bigdata/service/jini/TestBigdataClientRemote.java
===================================================================
--- branches/maven_scaleout/bigdata-integ/src/test/java/com/bigdata/service/jini/TestBigdataClientRemote.java 2010-09-13 15:17:50 UTC (rev 3536)
+++ branches/maven_scaleout/bigdata-integ/src/test/java/com/bigdata/service/jini/TestBigdataClientRemote.java 2010-09-13 19:56:24 UTC (rev 3537)
@@ -33,8 +33,4 @@
public TestBigdataClientRemote() {
super(true);
}
-
- public TestBigdataClientRemote(String name) {
- super(name, true);
- }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|