Search in sources :

Example 1 with HandleException

use of org.opencastproject.mediapackage.identifier.HandleException in project opencast by opencast.

the class HandleBuilderTest method testUpdate.

/**
 * Test method for
 * {@link org.opencastproject.mediapackage.identifier.HandleBuilderImpl#update(org.opencastproject.mediapackage.identifier.Id, java.net.URL)}
 */
@Test
public void testUpdate() {
    try {
        Handle newHandle = handleBuilder.createNew(url);
        newHandles.add(newHandle);
        // Create new target and update
        URL newTarget = new URL("http://www.apple.com");
        boolean updated = handleBuilder.update(newHandle, newTarget);
        assertTrue(updated);
    // TODO: Our handle server at the moment does caching in the
    // webservice, so this test always fails, although resolving
    // is working properly
    // URL resolvedUrl = handleBuilder.resolve(newHandle);
    // assertEquals(newTarget, resolvedUrl);
    } catch (HandleException e) {
        fail("Error updating handle: " + e.getMessage());
    } catch (MalformedURLException e) {
        fail("Error creating new handle url: " + e.getMessage());
    }
}
Also used : HandleException(org.opencastproject.mediapackage.identifier.HandleException) MalformedURLException(java.net.MalformedURLException) URL(java.net.URL) Handle(org.opencastproject.mediapackage.identifier.Handle) Test(org.junit.Test)

Example 2 with HandleException

use of org.opencastproject.mediapackage.identifier.HandleException in project opencast by opencast.

the class HandleBuilderTest method testCreateNewURL.

/**
 * Test method for {@link org.opencastproject.mediapackage.identifier.HandleBuilderImpl#createNew(java.net.URL)} .
 */
@Test
public void testCreateNewURL() {
    Handle handle = null;
    try {
        handle = handleBuilder.createNew(url);
        newHandles.add(handle);
        assertNotNull(handle);
        assertNotNull(handle.getNamingAuthority());
        assertNotNull(handle.getLocalName());
        assertNotNull(handle.resolve());
        assertEquals(url, handle.resolve());
    } catch (HandleException e) {
        fail("Error creating handle: " + e.getMessage());
    }
}
Also used : HandleException(org.opencastproject.mediapackage.identifier.HandleException) Handle(org.opencastproject.mediapackage.identifier.Handle) Test(org.junit.Test)

Example 3 with HandleException

use of org.opencastproject.mediapackage.identifier.HandleException in project opencast by opencast.

the class HandleTest method testUpdate.

/**
 * Test method for {@link org.opencastproject.mediapackage.identifier.HandleImpl#update(java.net.URL)} .
 */
@Test
public void testUpdate() {
    try {
        URL newTarget = new URL("http://www.apple.com");
        Handle newHandle = handleBuilder.createNew(url);
        newHandles.add(newHandle);
        newHandle.update(newTarget);
        URL resolvedUrl = newHandle.resolve();
        assertEquals(newTarget, resolvedUrl);
    } catch (HandleException e) {
        fail("Error updating handle: " + e.getMessage());
    } catch (MalformedURLException e) {
        fail("Error creating new handle url: " + e.getMessage());
    }
}
Also used : HandleException(org.opencastproject.mediapackage.identifier.HandleException) MalformedURLException(java.net.MalformedURLException) URL(java.net.URL) Handle(org.opencastproject.mediapackage.identifier.Handle) Test(org.junit.Test)

Example 4 with HandleException

use of org.opencastproject.mediapackage.identifier.HandleException in project opencast by opencast.

the class HandleTest method testGetValue.

/**
 * Test method for {@link org.opencastproject.mediapackage.identifier.HandleImpl#resolve()}.
 */
@Test
public void testGetValue() {
    try {
        Handle newHandle = handleBuilder.createNew(url);
        newHandles.add(newHandle);
        URL resolvedUrl = newHandle.resolve();
        assertEquals(url, resolvedUrl);
    } catch (HandleException e) {
        fail("Error resolving handle: " + e.getMessage());
    }
}
Also used : HandleException(org.opencastproject.mediapackage.identifier.HandleException) URL(java.net.URL) Handle(org.opencastproject.mediapackage.identifier.Handle) Test(org.junit.Test)

Example 5 with HandleException

use of org.opencastproject.mediapackage.identifier.HandleException in project opencast by opencast.

the class HandleBuilderTest method testCreateNew.

/**
 * Test method for {@link org.opencastproject.mediapackage.identifier.HandleBuilderImpl#createNew()} .
 */
@Test
public void testCreateNew() {
    Handle handle = null;
    try {
        handle = handleBuilder.createNew();
        newHandles.add(handle);
        assertNotNull(handle);
        assertNotNull(handle.getNamingAuthority());
        assertNotNull(handle.getLocalName());
        assertNotNull(handle.resolve());
    } catch (HandleException e) {
        fail("Error creating handle: " + e.getMessage());
    }
}
Also used : HandleException(org.opencastproject.mediapackage.identifier.HandleException) Handle(org.opencastproject.mediapackage.identifier.Handle) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)5 Handle (org.opencastproject.mediapackage.identifier.Handle)5 HandleException (org.opencastproject.mediapackage.identifier.HandleException)5 URL (java.net.URL)3 MalformedURLException (java.net.MalformedURLException)2