{
Ref[] refs = new Ref[0];
Service[] services = new Service[0];
// IIOP-safe authority
Service oSubAuth = new Service();
moAdmin.registerSubsegment(
oAuth, "*free", refs, services,
oSubAuth);
}
catch (StoreException oEx)
{
oEx.printStackTrace();
fail(
"Caught unexpected exception '" + oEx.getExKey() + "' '" +
oEx.getExMessage() + "'.");
}
} // if(bIIOPFailure)
bIIOPFailure = false;
///
// Register a duplicate subsegment
///
try
{
Ref[] refs = new Ref[0];
Service[] services = new Service[0];
// IIOP-safe authority
Service oSubAuth = new Service();
moAdmin.registerSubsegment(
oAuth, "*foo", refs, services,
oSubAuth);
fail("Expected exception, but received none.");
}
catch (StoreException oEx)
{
assertEquals(StoreException.KEY_DUPNAME, oEx.getExKey());
}
///
// NEW Retrieve a descriptor
///
try
{
String sDescriptor =
moAdmin.lookup(oAuth, "*foo", false)
.getXRD().toString();
assertNotNull(sDescriptor);
assertTrue(sDescriptor.length() > 0);
// XXX is the value correct?
}
catch (StoreException oEx)
{
oEx.printStackTrace();
fail(
"Caught unexpected exception '" + oEx.getExKey() + "' '" +
oEx.getExMessage() + "'.");
}
///
// Lookup a subsegment
///
try {
oSubSegment = moAdmin.findSubSegment(oAuth, "*foo");
} catch (StoreException oEx)
{
oEx.printStackTrace();
fail(
"Caught unexpected exception '" + oEx.getExKey() + "' '" +
oEx.getExMessage() + "'.");
}
///
// Release a subsegment
///
try
{
moAdmin.releaseSubsegment(oSubSegment);
}
catch (StoreException oEx)
{
oEx.printStackTrace();
fail(
"Caught unexpected exception '" + oEx.getExKey() + "' '" +
oEx.getExMessage() + "'.");
}
///
// Re-Release a subsegment
///
try
{
moAdmin.releaseSubsegment(oSubSegment);
fail("Expected exception, but received none.");
}
catch (StoreException oEx)
{
assertEquals(StoreException.KEY_NOTFOUND, oEx.getExKey());
}
///
// NEW Retrieve a deleted descriptor
///
try
{
String sDescriptor =
moAdmin.lookup(oAuth, "*foo", false)
.getXRD().toString();
assertNull(sDescriptor);
}
catch (StoreException oEx)
{
oEx.printStackTrace();
fail(
"Caught unexpected exception '" + oEx.getExKey() + "' '" +
oEx.getExMessage() + "'.");
}
///
// Re-Register a subsegment
///
try
{
Ref[] refs = new Ref[0];
Service[] services = new Service[0];
// IIOP-safe authority
Service oSubAuth = new Service();
moAdmin.registerSubsegment(
oAuth, "*foo", refs, services,
oSubAuth);
}
catch (StoreException oEx)
{
oEx.printStackTrace();
fail(
"Caught unexpected exception '" + oEx.getExKey() + "' '" +
oEx.getExMessage() + "'.");
}
///
// NEW Retrieve a re-registered descriptor
///
try
{
String sDescriptor =
moAdmin.lookup(oAuth, "*foo", false)
.getXRD().toString();
assertNotNull(sDescriptor);
assertTrue(sDescriptor.length() > 0);
// XXX is the value correct?
}
catch (StoreException oEx)
{
oEx.printStackTrace();
fail(
"Caught unexpected exception '" + oEx.getExKey() + "' '" +
oEx.getExMessage() + "'.");
}
///
// Register a local authority
///
try
{
Ref[] refs = new Ref[0];
Service[] services = new Service[0];
SubSegment subSegment =
moAdmin.registerLocalAuthority(
oAuth, "*boo", refs, services);
assertNotNull(subSegment);
}
catch (StoreException oEx)
{
oEx.printStackTrace();
fail(
"Caught unexpected exception '" + oEx.getExKey() + "' '" +
oEx.getExMessage() + "'.");
}
///
// Delete a namespace (root authority)
///
try
{
moAdmin.deleteRootAuthority("SomeNS");
}
catch (StoreException oEx)
{
oEx.printStackTrace();
fail(
"Caught unexpected exception '" + oEx.getExKey() + "' '" +
oEx.getExMessage() + "'.");
}
///
// Delete an authority
///
try
{
moAdmin.deleteAuthority(oAuth);
}
catch (StoreException oEx)
{
oEx.printStackTrace();
fail(
"Caught unexpected exception '" + oEx.getExKey() + "' '" +
oEx.getExMessage() + "'.");
}
///
// Re-Delete an authority
///
try
{
moAdmin.deleteAuthority(oAuth);
}
catch (StoreException oEx)
{
fail("Received unexpected exception " + oEx.getExMessage());
}
///
// Retrieve the list of namespaces (no leftovers)
///
try
{
assertEquals(0, moAdmin.listRootAuthorities().length);
}
catch (StoreException oEx)
{
oEx.printStackTrace();
fail(
"Caught unexpected exception '" + oEx.getExKey() + "' '" +
oEx.getExMessage() + "'.");
}
///
// One last, comprehensive test
///
Authority oDefaultAuth = null;
Authority oHostIDAuth = null;
try
{
Ref[] oRefs = new Ref[1];
Service[] oServices = new Service[1];
oRefs[0] = new Ref();
oRefs[0].setValue("http://www.myresolver.com/resolve?1234");
// IIOP-safe Service structure
oServices[0] = new Service();
oServices[0].setType("xri:@epok/tdx/xrixns");
oServices[0].setMediaType("text/xml");
oServices[0].addURI("xri://@!42!3");
oHostIDAuth = moAdmin.createRootAuthority("hostid");
oDefaultAuth = moAdmin.createRootAuthority("default");
SubSegment subSegment =
moAdmin.registerLocalAuthority(
oDefaultAuth, "*email", oRefs, oServices
);
// IIOP-safe Authority
Service oEmptyAuth = new Service();
moAdmin.registerSubsegment(
oDefaultAuth, "*chetan", new Ref[0], new Service[0],
oEmptyAuth);