Skip to content

Commit

Permalink
Use Maven
Browse files Browse the repository at this point in the history
  • Loading branch information
jhollinger committed Jan 20, 2013
1 parent 9fcb8d9 commit f2a472c
Show file tree
Hide file tree
Showing 13 changed files with 115 additions and 106 deletions.
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
src/org/**/*.class
src/org/json
test/*.class
test/*.jar
target/
*.ipr
*.iws
*.iml
21 changes: 14 additions & 7 deletions README → README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,28 @@ DOCUMENTATION
For now, the best documentation is reading through the methods available in the EPLiteClient class: https://raw.github.com/jhollinger/java-etherpad-lite/master/src/org/etherpad_lite_client/EPLiteClient.java. The methods are 1:1 with the EPLite API methods.

DEPENDENCIES
Depends on JSON.simple - http://code.google.com/p/json-simple/. Tested against version 1.1.1.
Depends on JSON.simple (http://code.google.com/p/json-simple/) version 1.1.1.

DOWNLOADS
You may download pre-compiled .jar files from http://jordanhollinger.com/etherpad-lite-java-client

NOTES
org.etherpad_lite_client uses Maven.

HEAD currently targets Etherpad Lite API v1.2.1. The plan is to keep up with the most recent version of the Etherpad Lite API. (Note that we're talking about API versions here, not release versions).

EXAMPLES
EPLiteClient client = new EPLiteClient("http://etherpad.mysite.com", "FJ7jksalksdfj83jsdflkj");

# Get pad text
String text = client.getText("my_pad").get("text").toString();

EPLiteClient client = new EPLiteClient("http://etherpad.mysite.com", "FJ7jksalksdfj83jsdflkj");
# Get list of all pad ids
HashMap result = client.listAllPads();
List padIds = (List) result.get("padIDs");

# Get pad text
String text = client.getText("my_pad").get("text").toString();
TESTING
Testing requires a copy of EtherpadLite running at http://localhost:9001 with an API key of K8OF91QMQYUvrNu3e9rJ7FnnVgaB3m9q
Run tests with maven:

# Get list of all pad ids
HashMap result = client.listAllPads();
List padIds = (List) result.get("padIDs");
mvn test
31 changes: 31 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org</groupId>
<artifactId>etherpad_lite_client</artifactId>
<version>1.2</version>
<packaging>jar</packaging>

<name>Etherpad Lite Client</name>
<url>http://github.com/jhollinger/java-etherpad-lite</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public HashMap createSession(String groupID, String authorID, long validUntil) {
HashMap args = new HashMap();
args.put("groupID", groupID);
args.put("authorID", authorID);
args.put("validUntil", validUntil);
args.put("validUntil", String.valueOf(validUntil));
return this.connection.post("createSession", args);
}

Expand Down Expand Up @@ -540,13 +540,13 @@ public HashMap getLastEdited(String padId) {
* Get the number of users currently editing a pad.
*
* @param padId the pad's id string
* @return Integer
* @return Long
*/
public Integer padUsersCount(String padId) {
public Long padUsersCount(String padId) {
HashMap args = new HashMap();
args.put("padID", padId);
String userCount = this.connection.get("padUsersCount", args).get("padUsersCount").toString();
return Integer.parseInt(userCount);
Long userCount = (Long) this.connection.get("padUsersCount", args).get("padUsersCount");
return userCount;
}

/**
Expand Down Expand Up @@ -643,9 +643,9 @@ public void sendClientsMessage(String padId, String msg) {
/**
* Returns true if the connection is using SSL/TLS, false if not.
*
* @return Boolean
* @return boolean
*/
public Boolean isSecure() {
public boolean isSecure() {
if (this.connection.uri.getPort() == 443) {
return true;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ public void checkServerTrusted(
}

HostnameVerifier hv = new HostnameVerifier() {
@Override
//@Override
public boolean verify(String hostname, SSLSession session) {
return true;
}
Expand Down
File renamed without changes.
61 changes: 61 additions & 0 deletions src/test/java/org/etherpad_lite_client/EPLiteClientTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package org.etherpad_lite_client;

import java.util.List;
import java.util.HashMap;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

/**
* Unit test for simple App.
*/
public class EPLiteClientTest extends TestCase {
private EPLiteClient client;

/**
* Create the test case
*
* @param testName name of the test case
*/
public EPLiteClientTest( String testName ) {
super( testName );
}

/**
* @return the suite of tests being tested
*/
public static Test suite() {
return new TestSuite( EPLiteClientTest.class );
}

/**
* Rigourous Testing
*/
public void testEPLiteClient() {
this.client = new EPLiteClient("http://localhost:9001", "K8OF91QMQYUvrNu3e9rJ7FnnVgaB3m9q");
assertTrue( this.testPadContents() );
assertTrue( this.testListAllPads() );
}

private boolean testPadContents() {
client.createPad("java_test_pad");
client.setText("java_test_pad", "foo!!!");
HashMap pad = client.getText("java_test_pad");
client.deletePad("java_test_pad");

String text = pad.get("text").toString();
return text.equals("foo!!!\n");
}

private boolean testListAllPads() {
client.createPad("java_test_pad_1");
client.createPad("java_test_pad_2");
HashMap result = client.listAllPads();
client.deletePad("java_test_pad_1");
client.deletePad("java_test_pad_2");

List padIDs = (List) result.get("padIDs");
return padIDs.get(0).equals("java_test_pad_1");
}
}
51 changes: 0 additions & 51 deletions test/EPLiteTest.java

This file was deleted.

9 changes: 0 additions & 9 deletions test/README

This file was deleted.

27 changes: 0 additions & 27 deletions test/test

This file was deleted.

0 comments on commit f2a472c

Please sign in to comment.