Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Implemented the DydraRepositoryManager#setUsernameAndPassword() method.

  • Loading branch information...
commit 2a73059cbb3931f45cf021e79005122ac89d6897 1 parent 9f97474
@bendiken bendiken authored
View
20 src/com/dydra/sesame/DydraRepositoryManager.java
@@ -9,6 +9,7 @@
import org.openrdf.repository.manager.RemoteRepositoryManager;
import org.openrdf.repository.manager.RepositoryManager;
+import org.openrdf.repository.manager.RepositoryInfo;
/**
* A manager for repositories hosted on Dydra.
@@ -40,12 +41,23 @@ public DydraRepositoryManager(@NotNull final String accountName,
this.accountName = accountName;
}
+ public boolean isAuthenticated() {
+ return this.isAuthenticated;
+ }
+
public void setPassword(@Nullable final String password) {
- this.isAuthenticated = (password != null);
- this.setUsernameAndPassword(this.isAuthenticated ? this.accountName : null, password);
+ this.setUsernameAndPassword(this.accountName, password);
}
- public boolean isAuthenticated() {
- return this.isAuthenticated;
+ @Override
+ public void setUsernameAndPassword(@Nullable final String userName,
+ @Nullable final String password) {
+ this.isAuthenticated = (password != null);
+ if (this.isAuthenticated) {
+ super.setUsernameAndPassword(userName, password);
+ }
+ else {
+ super.setUsernameAndPassword(null, null);
+ }
}
}
View
53 test/com/dydra/sesame/DydraRepositoryManagerTest.java
@@ -6,6 +6,9 @@
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
import java.util.*;
+import org.openrdf.repository.RepositoryException;
+import org.openrdf.repository.config.RepositoryConfigException;
+import org.openrdf.repository.manager.RepositoryInfo;
public class DydraRepositoryManagerTest {
public static void main(String[] args) {
@@ -15,17 +18,21 @@ public static void main(String[] args) {
private Properties properties;
private String accountName;
private String password;
+ private String repositoryName;
private String serverURL;
+ private String repositoryURL;
private DydraRepositoryManager manager;
@Before
public void setUp() {
- this.properties = System.getProperties();
- this.accountName = properties.getProperty("com.dydra.sesame.account", "jhacker");
- this.password = properties.getProperty("com.dydra.sesame.password", null);
- this.serverURL = properties.getProperty("com.dydra.sesame.url",
+ this.properties = System.getProperties();
+ this.accountName = properties.getProperty("com.dydra.sesame.account", "jhacker");
+ this.password = properties.getProperty("com.dydra.sesame.password", null);
+ this.repositoryName = properties.getProperty("com.dydra.sesame.repository", "test");
+ this.serverURL = properties.getProperty("com.dydra.sesame.url",
"http://api.dydra.com/sesame2") + "/" + this.accountName + "/";
- this.manager = new DydraRepositoryManager(accountName);
+ this.repositoryURL = this.serverURL + "repositories/" + this.repositoryName;
+ this.manager = new DydraRepositoryManager(accountName);
}
@After
@@ -34,8 +41,8 @@ public void tearDown() {
}
@Test
- public void testInitialize() {
- // TODO
+ public void testInitialize() throws RepositoryException {
+ //manager.initialize();
}
@Test
@@ -55,8 +62,20 @@ public void testSetPassword() {
}
@Test
- public void testGetNewRepositoryID() {
- // TODO
+ public void testSetUsernameAndPassword() {
+ assertFalse(manager.isAuthenticated());
+ if (this.password != null) {
+ manager.setUsernameAndPassword(this.accountName, this.password);
+ assertTrue(manager.isAuthenticated());
+ }
+ manager.setUsernameAndPassword(this.accountName, null);
+ assertFalse(manager.isAuthenticated());
+ }
+
+ @Test
+ public void testGetNewRepositoryID()
+ throws RepositoryException, RepositoryConfigException {
+ //System.out.println(manager.getNewRepositoryID(this.repositoryName));
}
@Test
@@ -65,8 +84,20 @@ public void testGetRepositoryIDs() {
}
@Test
- public void testGetRepositoryInfo() {
- // TODO
+ public void testGetRepositoryInfo() throws RepositoryException {
+ RepositoryInfo info = manager.getRepositoryInfo(this.repositoryName);
+ assertNotNull(info);
+ assertEquals(this.repositoryName, info.getId());
+ assertEquals(this.repositoryURL, info.getLocation().toString());
+ assertNotNull(info.getDescription());
+ assertTrue(info.isReadable());
+ }
+
+ @Test
+ public void testGetAllRepositoryInfos() throws RepositoryException {
+ Collection<RepositoryInfo> infos = manager.getAllRepositoryInfos(true);
+ assertNotNull(infos);
+ assertFalse(infos.isEmpty());
}
@Test
Please sign in to comment.
Something went wrong with that request. Please try again.