|
From: <ble...@us...> - 2010-09-14 17:39:53
|
Revision: 3545
http://bigdata.svn.sourceforge.net/bigdata/?rev=3545&view=rev
Author: blevine218
Date: 2010-09-14 17:39:46 +0000 (Tue, 14 Sep 2010)
Log Message:
-----------
Move certain dependencies on extensions to Assert into new com.bigdata.test.util.Assert class.
Modified Paths:
--------------
branches/maven_scaleout/bigdata-integ/pom.xml
Added Paths:
-----------
branches/maven_scaleout/bigdata-integ/src/test/java/com/bigdata/test/util/Assert.java
Removed Paths:
-------------
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
Modified: branches/maven_scaleout/bigdata-integ/pom.xml
===================================================================
--- branches/maven_scaleout/bigdata-integ/pom.xml 2010-09-14 17:19:56 UTC (rev 3544)
+++ branches/maven_scaleout/bigdata-integ/pom.xml 2010-09-14 17:39:46 UTC (rev 3545)
@@ -45,7 +45,7 @@
In the ANT script, hostname is obtained by an exec of the
'hostname' command. Hard-coding for now.
-->
- <hostname>blevine-laptop</hostname>
+ <hostname>blevine-desktop</hostname>
<test.codebase>http://${hostname}:${test.codebase.port}/jsk-dl.jar</test.codebase> <!-- Not used??? -->
<federation.name>bigdata.test.group-${hostname}</federation.name>
</properties>
@@ -206,7 +206,6 @@
<groupId>com.bigdata</groupId>
<artifactId>bigdata-core</artifactId>
<version>${project.version}</version>
-
</dependency>
<dependency>
<groupId>junit</groupId>
Deleted: 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-14 17:19:56 UTC (rev 3544)
+++ branches/maven_scaleout/bigdata-integ/src/test/java/com/bigdata/service/jini/AbstractServerTestCase.java 2010-09-14 17:39:46 UTC (rev 3545)
@@ -1,286 +0,0 @@
-/**
-
-Copyright (C) SYSTAP, LLC 2006-2007. All rights reserved.
-
-Contact:
- SYSTAP, LLC
- 4501 Tower Road
- Greensboro, NC 27410
- lic...@bi...
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; version 2 of the License.
-
-This program 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 General Public License for more details.
-
-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
- */
-
-package com.bigdata.service.jini;
-
-import java.io.IOException;
-
-import junit.framework.Assert;
-import junit.framework.AssertionFailedError;
-
-import net.jini.core.discovery.LookupLocator;
-import net.jini.core.lookup.ServiceID;
-import net.jini.core.lookup.ServiceRegistrar;
-import net.jini.core.lookup.ServiceTemplate;
-
-import com.bigdata.journal.ITx;
-import com.bigdata.mdi.IResourceMetadata;
-import com.bigdata.mdi.LocalPartitionMetadata;
-import com.bigdata.mdi.PartitionLocator;
-import com.bigdata.service.DataService;
-import com.bigdata.service.IDataService;
-import com.bigdata.service.MetadataService;
-import com.sun.jini.tool.ClassServer;
-import com.bigdata.util.config.NicUtil;
-
-/**
- * Abstract base class for tests of remote services.
- * <p>
- * Note: jini MUST be running. You can get the jini starter kit and install it
- * to get jini running.
- * </p>
- * <p>
- * Note: You MUST specify a security policy that is sufficiently lax.
- * </p>
- * <p>
- * Note: You MUST specify the codebase for downloadable code.
- * </p>
- * <p>
- * Note: The <code>bigdata</code> JAR must be current in order for the client
- * and the service to agree on interface definitions, etc. You can use
- * <code>build.xml</code> in the root of this module to update that JAR.
- * </p>
- * <p>
- * Note: A {@link ClassServer} will be started on port 8081 by default. If that
- * port is in use then you MUST specify another port.
- * </p>
- *
- * The following system properties will do the trick unless you have something
- * running on port 8081.
- *
- * <pre>
- * -Djava.security.policy=policy.all -Djava.rmi.server.codebase=http://localhost:8081
- * </pre>
- *
- * To use another port, try:
- *
- * <pre>
- * -Djava.security.policy=policy.all -Dbigdata.test.port=8082 -Djava.rmi.server.codebase=http://localhost:8082
- * </pre>
- *
- * You can enable NIO using:
- *
- * <pre>
- * -Dcom.sun.jini.jeri.tcp.useNIO=true
- * </pre>
- *
- * @author <a href="mailto:tho...@us...">Bryan Thompson</a>
- * @version $Id$
- */
-public abstract class AbstractServerTestCase
-{
-
- /**
- * Equal to {@link ITx#UNISOLATED}.
- */
- protected final long UNISOLATED = ITx.UNISOLATED;
-
- /**
- *
- */
- public AbstractServerTestCase()
- {
- }
-
- /**
- * Return the {@link ServiceID} of a server that we started ourselves. The
- * method waits until the {@link ServiceID} becomes available on
- * {@link AbstractServer#getServiceID()}.
- *
- * @exception AssertionFailedError
- * If the {@link ServiceID} can not be found after a timeout.
- *
- * @exception InterruptedException
- * if the thread is interrupted while it is waiting to retry.
- */
- static public ServiceID getServiceID(final AbstractServer server) throws AssertionFailedError, InterruptedException
- {
- ServiceID serviceID = null;
-
- 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)
- {
- /*
- * We wait a bit and retry until we have it or timeout.
- */
- Thread.sleep(200);
- }
- }
-
- 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.
- */
- Assert.assertEquals("serviceID", server.getServiceID(), serviceID);
-
- return serviceID;
-
- }
-
- /**
- * Lookup a {@link DataService} by its {@link ServiceID} using unicast
- * discovery on localhost.
- *
- * @param serviceID
- * The {@link ServiceID}.
- *
- * @return The service.
- *
- * @todo Modify to return the service item?
- *
- * @todo Modify to not be specific to {@link DataService} vs
- * {@link MetadataService} (we need a common base interface for both
- * that carries most of the functionality but allows us to make
- * distinctions easily during discovery).
- */
- public IDataService lookupDataService(ServiceID serviceID) throws IOException, ClassNotFoundException, InterruptedException
- {
- /*
- * Lookup the discover service (unicast on localhost).
- */
-
- // get the hostname.
- String hostname = NicUtil.getIpAddress("default.nic", "default", true);
-
- // Find the service registrar (unicast protocol).
- final int timeout = 4 * 1000; // seconds.
- LookupLocator lookupLocator = new LookupLocator("jini://" + hostname);
- ServiceRegistrar serviceRegistrar = lookupLocator.getRegistrar(timeout);
-
- /*
- * Prepare a template for lookup search.
- *
- * Note: The client needs a local copy of the interface in order to be
- * able to invoke methods on the service without using reflection. The
- * implementation class will be downloaded from the codebase identified
- * 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);
-
- /*
- * Lookup a service. This can fail if the service registrar has not
- * finished processing the service registration. If it does, you can
- * generally just retry the test and it will succeed. However this
- * points out that the client may need to wait and retry a few times if
- * you are starting everything up at once (or just register for
- * 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);
-
- if (service == null)
- {
- System.err.println("Service not found: sleeping...");
- Thread.sleep(200);
- }
-
- }
-
- 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.
- *
- * @param expected
- * @param actual
- */
- 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.
- *
- * @param expected
- * @param 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());
-
- final IResourceMetadata[] expectedResources = expected.getResources();
- final IResourceMetadata[] actualResources = actual.getResources();
-
- 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.
-
- Assert.assertEquals("filename[" + i + "]", expectedResources[i].getFile(), actualResources[i].getFile());
-
- // assertEquals("size[" + i + "]", expectedResources[i].size(),
- // actualResources[i].size());
-
- Assert.assertEquals("UUID[" + i + "]", expectedResources[i].getUUID(), actualResources[i].getUUID());
-
- // verify by equals.
- Assert.assertTrue("resourceMetadata", expectedResources[i].equals(actualResources[i]));
- }
- }
-}
Deleted: 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-14 17:19:56 UTC (rev 3544)
+++ branches/maven_scaleout/bigdata-integ/src/test/java/com/bigdata/service/jini/TestBigdataClient.java 2010-09-14 17:39:46 UTC (rev 3545)
@@ -1,208 +0,0 @@
-/**
-
-Copyright (C) SYSTAP, LLC 2006-2007. All rights reserved.
-
-Contact:
- SYSTAP, LLC
- 4501 Tower Road
- Greensboro, NC 27410
- lic...@bi...
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; version 2 of the License.
-
-This program 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 General Public License for more details.
-
-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 23, 2007
- */
-
-package com.bigdata.service.jini;
-
-import java.io.Serializable;
-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;
-import com.bigdata.btree.IndexMetadata;
-
-import com.bigdata.btree.proc.BatchInsert.BatchInsertConstructor;
-import com.bigdata.journal.ITx;
-import com.bigdata.service.DataService;
-import com.bigdata.service.IBigdataFederation;
-import com.bigdata.service.IDataService;
-import com.bigdata.service.jini.util.JiniServicesHelper;
-import com.bigdata.test.util.Util;
-
-/**
- * Test suite for the {@link JiniClient}.
- * <p>
- * Note: The core test suite has already verified the basic semantics of the
- * {@link IDataService} interface and partitioned indices so all we have to
- * focus on here is the jini integration and verifying that the serialization
- * imposed by RMI goes off without a hitch (e.g., that everything implements
- * {@link Serializable} and that those {@link Serializable} implementations can
- * correctly round trip the data).
- *
- * @author <a href="mailto:tho...@us...">Bryan Thompson</a>
- * @version $Id$
- */
-public class TestBigdataClient extends AbstractServerTestCase {
-
- protected boolean serviceImplRemote;
-
- public TestBigdataClient() {
- this.serviceImplRemote = false;
- }
-
- public TestBigdataClient(boolean serviceImplRemote) {
- 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 {
- helper = new JiniServicesHelper(serviceImplRemote);
- helper.start();
- }
-
- protected JiniServicesHelper helper = null;
-
- /**
- * Destroy the test services.
- */
- @After
- public void tearDown() throws Exception {
- if (helper != null) {
- helper.destroy();
- }
- }
-
- /**
- * Test ability to registers a scale-out index on one of the
- * {@link DataService}s.
- *
- * @throws Exception
- */
- @Test
- public void test_registerIndex1() throws Exception {
- final IBigdataFederation<?> fed = helper.client.connect();
- final String name = "testIndex";
- final IndexMetadata metadata = new IndexMetadata(name, UUID.randomUUID());
-
- metadata.setDeleteMarkers(true);
- fed.registerIndex(metadata);
- final IIndex ndx = fed.getIndex(name, ITx.UNISOLATED);
-
- Assert.assertEquals("indexUUID", metadata.getIndexUUID(), ndx.getIndexMetadata().getIndexUUID());
-
- doBasicIndexTests(ndx);
- }
-
- /**
- * Test ability to registers a scale-out index on both of the
- * {@link DataService}s.
- *
- * @throws Exception
- */
- @Test
- public void test_registerIndex2() throws Exception {
- final IBigdataFederation<?> fed = helper.client.connect();
- final String name = "testIndex";
- final IndexMetadata metadata = new IndexMetadata(name,UUID.randomUUID());
-
- metadata.setDeleteMarkers(true);
-
- final UUID indexUUID = fed.registerIndex( metadata, //
- // separator keys.
- new byte[][] {
- new byte[]{},
- Util.asSortKey(500)
- },//
- // data service assignments.
- new UUID[] { //
- helper.getDataService0().getServiceUUID(),//
- helper.getDataService1().getServiceUUID() //
- });
-
- final IIndex ndx = fed.getIndex(name, ITx.UNISOLATED);
-
- Assert.assertEquals("indexUUID", indexUUID, ndx.getIndexMetadata().getIndexUUID());
-
- // verify partition 0 on dataService0
- Assert.assertNotNull(helper.getDataService0().getIndexMetadata(DataService.getIndexPartitionName(name, 0), ITx.UNISOLATED));
-
- // verify partition 1 on dataService1
- Assert.assertNotNull(helper.getDataService1().getIndexMetadata(DataService.getIndexPartitionName(name, 1), ITx.UNISOLATED));
-
- doBasicIndexTests(ndx);
- }
-
- /**
- * Test helper reads and writes some data on the index in order to verify
- * that these operations can be performed without serialization errors
- * arising from the RPC calls.
- *
- * @param ndx
- */
- protected void doBasicIndexTests(final IIndex ndx) {
-
- final int limit = 1000;
-
- final byte[][] keys = new byte[limit][];
- final byte[][] vals = new byte[limit][];
-
- final Random r = new Random();
-
- for (int i = 0; i < limit; i++) {
- keys[i] = Util.asSortKey(i);
- final byte[] val = new byte[10];
- r.nextBytes(val);
- vals[i] = val;
- }
-
- // batch insert.
- ndx.submit(0/* fromIndex */, limit/* toIndex */, keys, vals, BatchInsertConstructor.RETURN_NO_VALUES, null);
-
- // verify #of index entries.
- Assert.assertEquals(limit, ndx.rangeCount(null, null));
-
- // verify data.
- {
- final ITupleIterator<?> itr = ndx.rangeIterator(null, null);
-
- int i = 0;
-
- while (itr.hasNext()) {
- final ITuple<?> tuple = itr.next();
-
- Assert.assertEquals(keys[i], tuple.getKey());
- Assert.assertEquals(vals[i], tuple.getValue());
- i++;
- }
-
- Assert.assertEquals(limit, i);
- }
- }
-}
Deleted: 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-14 17:19:56 UTC (rev 3544)
+++ branches/maven_scaleout/bigdata-integ/src/test/java/com/bigdata/service/jini/TestBigdataClientRemote.java 2010-09-14 17:39:46 UTC (rev 3545)
@@ -1,36 +0,0 @@
-/**
-
-Copyright (C) SYSTAP, LLC 2006-2007. All rights reserved.
-
-Contact:
- SYSTAP, LLC
- 4501 Tower Road
- Greensboro, NC 27410
- lic...@bi...
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; version 2 of the License.
-
-This program 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 General Public License for more details.
-
-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
-*/
-
-package com.bigdata.service.jini;
-
-/**
- * Test suite for the {@link JiniClient} using the purely remote
- * service implementations.
- */
-public class TestBigdataClientRemote extends TestBigdataClient {
-
- public TestBigdataClientRemote() {
- super(true);
- }
-}
Added: branches/maven_scaleout/bigdata-integ/src/test/java/com/bigdata/test/util/Assert.java
===================================================================
--- branches/maven_scaleout/bigdata-integ/src/test/java/com/bigdata/test/util/Assert.java (rev 0)
+++ branches/maven_scaleout/bigdata-integ/src/test/java/com/bigdata/test/util/Assert.java 2010-09-14 17:39:46 UTC (rev 3545)
@@ -0,0 +1,82 @@
+/**
+
+Copyright (C) SYSTAP, LLC 2006-2007. All rights reserved.
+
+Contact:
+ SYSTAP, LLC
+ 4501 Tower Road
+ Greensboro, NC 27410
+ lic...@bi...
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; version 2 of the License.
+
+This program 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 General Public License for more details.
+
+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
+*/
+package com.bigdata.test.util;
+
+
+/**
+ * Utility class that extends JUnit's Assert class with additional utilities.
+ *
+ * @author blevine
+ *
+ */
+public class Assert extends org.junit.Assert
+{
+ public static void assertEquals(byte[] expected, byte[] actual)
+ {
+ assertEquals(null, expected, actual);
+ }
+ public static void assertEquals(String message, byte[] expected, byte[] actual)
+ {
+ if (expected == null && actual == null)
+ {
+ return;
+ }
+
+ if ( (expected == null) && (actual != null) )
+ {
+ assertNull(message, actual);
+ }
+
+ if ( (expected != null) && (actual == null) )
+ {
+ assertNotNull(message, actual);
+ }
+
+ if (expected.length != actual.length)
+ {
+ String msg = "(array lengths do not match).";
+
+ if (message != null)
+ {
+ msg = message + " " + msg;
+ }
+
+ fail(msg);
+ }
+
+ for (int i = 0; i < expected.length; i++)
+ {
+ if (expected[i] != actual[i])
+ {
+ String msg = "(index = i).";
+
+ if (message != null)
+ {
+ msg = message + " " + msg;
+ }
+ assertEquals(msg, expected[i], actual[i]);
+ }
+ }
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|