hypersonicMgr.useCleanupWith(new Executor() {
public void execute() throws Exception {
InternalJDBCRepository repository = createRepository(
hypersonicMgr.getSource(), null, "#dp");
JDBCRepositoryConnection connection =
(JDBCRepositoryConnection) repository.connect();
JDBCDeviceRepositoryAccessor accessor =
new JDBCDeviceRepositoryAccessor(repository, location);
Connection conn = connection.getConnection();
createTables(conn);
DefaultPolicyDescriptor descriptor =
new DefaultPolicyDescriptor();
// boolean
descriptor.setCategory("category1");
descriptor.setPolicyType(new DefaultBooleanPolicyType());
accessor.addPolicyDescriptor(connection, "bool1", descriptor);
accessor.addPolicyDescriptor(connection, "bool2", descriptor);
policyCategoryCount+=1;
policyTypeCount+=2;
typesCount+=2;
checkCounts(conn);
// int
descriptor.setPolicyType(new DefaultIntPolicyType());
accessor.addPolicyDescriptor(connection, "int1", descriptor);
accessor.addPolicyDescriptor(connection, "int2", descriptor);
policyTypeCount+=2;
typesCount+=2;
checkCounts(conn);
// range
descriptor.setPolicyType(new DefaultRangePolicyType(6, 9));
accessor.addPolicyDescriptor(connection, "range1", descriptor);
accessor.addPolicyDescriptor(connection, "range2", descriptor);
policyTypeCount+=2;
typesCount+=2;
typesRangeCount+=2;
checkCounts(conn);
// selection
descriptor.setCategory("category2");
DefaultSelectionPolicyType selection =
new DefaultSelectionPolicyType();
selection.addKeyword("keyword1");
selection.addKeyword("keyword2");
selection.complete();
descriptor.setPolicyType(selection);
accessor.addPolicyDescriptor(connection, "selection1", descriptor);
accessor.addPolicyDescriptor(connection, "selection2", descriptor);
policyCategoryCount+=1;
policyTypeCount+=2;
typesCount+=2;
typesSelectionCount+=4;
checkCounts(conn);
// text
descriptor.setPolicyType(new DefaultTextPolicyType());
accessor.addPolicyDescriptor(connection, "text1", descriptor);
accessor.addPolicyDescriptor(connection, "text2", descriptor);
policyTypeCount+=2;
typesCount+=2;
checkCounts(conn);
// ordered set
PolicyType oset = new DefaultUnorderedSetPolicyType(
new DefaultBooleanPolicyType());
descriptor.setPolicyType(oset);
accessor.addPolicyDescriptor(connection, "oset1", descriptor);
accessor.addPolicyDescriptor(connection, "oset2", descriptor);
policyTypeCount+=2;
typesCount+=4;
typesSetCount+=2;
checkCounts(conn);
// unordered set
descriptor.setCategory("category3");
PolicyType uset = new DefaultUnorderedSetPolicyType(
new DefaultIntPolicyType());
descriptor.setPolicyType(uset);
accessor.addPolicyDescriptor(connection, "uset1", descriptor);
accessor.addPolicyDescriptor(connection, "uset2", descriptor);
policyCategoryCount+=1;
policyTypeCount+=2;
typesCount+=4;
typesSetCount+=2;
checkCounts(conn);
// structure
DefaultStructurePolicyType type =
new DefaultStructurePolicyType();
type.addFieldType("field1", new DefaultBooleanPolicyType());
type.addFieldType("field2", new DefaultRangePolicyType(2, 99));
type.complete();
descriptor.setPolicyType(type);
accessor.addPolicyDescriptor(connection, "structure1", descriptor);
accessor.addPolicyDescriptor(connection, "structure2", descriptor);
policyTypeCount+=2;
typesCount+=6;
typesStructureCount+=4;
typesRangeCount+=2;
checkCounts(conn);
accessor.removePolicyDescriptor(connection, "bool1");
accessor.removePolicyDescriptor(connection, "bool2");
accessor.removePolicyDescriptor(connection, "int1");
accessor.removePolicyDescriptor(connection, "int2");
accessor.removePolicyDescriptor(connection, "range1");
accessor.removePolicyDescriptor(connection, "range2");
accessor.removePolicyDescriptor(connection, "selection1");
accessor.removePolicyDescriptor(connection, "selection2");
accessor.removePolicyDescriptor(connection, "text1");
accessor.removePolicyDescriptor(connection, "text2");
accessor.removePolicyDescriptor(connection, "oset1");
accessor.removePolicyDescriptor(connection, "oset2");
accessor.removePolicyDescriptor(connection, "uset1");
accessor.removePolicyDescriptor(connection, "uset2");
accessor.removePolicyDescriptor(connection, "structure1");
accessor.removePolicyDescriptor(connection, "structure2");
checkAllEmpty(conn);
connection.disconnect();
repository.terminate();
}
});
}