Author: kono
Date: 2012-04-17 12:12:10 -0700 (Tue, 17 Apr 2012)
New Revision: 28852
Added:
core3/api/trunk/webservice-api/src/test/
core3/api/trunk/webservice-api/src/test/java/
core3/api/trunk/webservice-api/src/test/java/org/
core3/api/trunk/webservice-api/src/test/java/org/cytoscape/
core3/api/trunk/webservice-api/src/test/java/org/cytoscape/webservice/
core3/api/trunk/webservice-api/src/test/java/org/cytoscape/webservice/AbstractWebServiceClientTest.java
Modified:
core3/api/trunk/webservice-api/src/main/java/org/cytoscape/io/webservice/WebServiceClient.java
core3/api/trunk/webservice-api/src/main/java/org/cytoscape/io/webservice/client/AbstractWebServiceClient.java
Log:
refs #864 Some unit tests had been added.
Modified:
core3/api/trunk/webservice-api/src/main/java/org/cytoscape/io/webservice/WebServiceClient.java
===================================================================
---
core3/api/trunk/webservice-api/src/main/java/org/cytoscape/io/webservice/WebServiceClient.java
2012-04-17 18:59:02 UTC (rev 28851)
+++
core3/api/trunk/webservice-api/src/main/java/org/cytoscape/io/webservice/WebServiceClient.java
2012-04-17 19:12:10 UTC (rev 28852)
@@ -46,25 +46,23 @@
* @CyAPI.Spi.Interface
*/
public interface WebServiceClient {
-
+
/**
- * Returns resource location of this service, i.e., service URL.
- * This is guaranteed to be globally unique and can be used as
identifier.
+ * Returns resource location of this service, i.e., service URL. This is
+ * guaranteed to be globally unique and can be used as identifier.
*
* @return URI of the service.
*/
URI getServiceLocation();
-
/**
* Returns display name of this client. This is more human readable
name for
- * this client. This may not be unique.
+ * this client. This may not be unique.
*
* @return display name for this client.
*/
String getDisplayName();
-
-
+
/**
* Get human-readable description of this client.
*
@@ -72,13 +70,13 @@
* return value.
*/
String getDescription();
-
-
+
/**
* Set query for the tasks to be executed.
*
- * @param query query object. This is client-dependent.
+ * @param query
+ * query object. This is client-dependent.
*/
TaskIterator createTaskIterator(Object query);
-
+
}
Modified:
core3/api/trunk/webservice-api/src/main/java/org/cytoscape/io/webservice/client/AbstractWebServiceClient.java
===================================================================
---
core3/api/trunk/webservice-api/src/main/java/org/cytoscape/io/webservice/client/AbstractWebServiceClient.java
2012-04-17 18:59:02 UTC (rev 28851)
+++
core3/api/trunk/webservice-api/src/main/java/org/cytoscape/io/webservice/client/AbstractWebServiceClient.java
2012-04-17 19:12:10 UTC (rev 28852)
@@ -31,7 +31,7 @@
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
-*/
+ */
package org.cytoscape.io.webservice.client;
import java.net.URI;
@@ -39,58 +39,57 @@
import org.cytoscape.io.webservice.WebServiceClient;
-
-
/**
- * Abstract class for all web service clients.
- * All clients MUST extend this class.
+ * Abstract class for all web service clients. All clients MUST extend this
+ * class.
+ *
* @CyAPI.Abstract.Class
*/
public abstract class AbstractWebServiceClient implements WebServiceClient {
// Globally-unique service location.
- protected final URI serviceURI;
-
+ private final URI serviceURI;
+
// Display Name for this client.
private final String displayName;
private final String description;
-
+
/**
* Constructs this AbstractWebServiceClient.
- * @param uri Service Location.
+ *
+ * @param uri
+ * Service Location.
*/
public AbstractWebServiceClient(final String uri, final String
displayName, final String description) {
-
+
// Create URI
try {
this.serviceURI = new URI(uri);
} catch (URISyntaxException e) {
- e.printStackTrace();
throw new IllegalArgumentException("URI string is
invalid.");
}
-
+
this.displayName = displayName;
this.description = description;
}
-
- @Override public String getDisplayName() {
+ @Override
+ public final String getDisplayName() {
return displayName;
}
-
- @Override public String getDescription() {
+ @Override
+ public final String getDescription() {
return description;
}
-
- @Override public String toString() {
+
+ @Override
+ public final String toString() {
return this.displayName;
}
-
@Override
- public URI getServiceLocation() {
+ public final URI getServiceLocation() {
return this.serviceURI;
}
-
}
Added:
core3/api/trunk/webservice-api/src/test/java/org/cytoscape/webservice/AbstractWebServiceClientTest.java
===================================================================
---
core3/api/trunk/webservice-api/src/test/java/org/cytoscape/webservice/AbstractWebServiceClientTest.java
(rev 0)
+++
core3/api/trunk/webservice-api/src/test/java/org/cytoscape/webservice/AbstractWebServiceClientTest.java
2012-04-17 19:12:10 UTC (rev 28852)
@@ -0,0 +1,60 @@
+package org.cytoscape.webservice;
+
+import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.net.URI;
+
+import org.cytoscape.io.webservice.WebServiceClient;
+import org.cytoscape.work.TaskIterator;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public abstract class AbstractWebServiceClientTest {
+
+ protected WebServiceClient client;
+ protected URI locationUri;
+ protected String displayName;
+ protected String description;
+
+ protected Object queryObject;
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+
+
+ @Test
+ public void testGetServiceLocation() {
+ final URI serviceLocation = client.getServiceLocation();
+ assertNotNull(serviceLocation);
+ assertEquals(locationUri, serviceLocation);
+ }
+
+ @Test
+ public void testGetDisplayName() {
+ final String displayName = client.getDisplayName();
+ assertEquals(this.displayName, displayName);
+ }
+
+ @Test
+ public void testGetDescription() {
+ final String description = client.getDescription();
+ assertEquals(this.description, description);
+ }
+
+ @Test
+ public void testCreateTaskIterator() {
+ final TaskIterator itr = client.createTaskIterator(queryObject);
+ assertNotNull(itr);
+ assertFalse(itr.getNumTasks() == 0);
+ }
+
+}
--
You received this message because you are subscribed to the Google Groups
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/cytoscape-cvs?hl=en.