コード例 #1
0
  protected void setUp() throws Exception {
    super.setUp();
    supplier = new FakeServerSupplier();
    supplierSecurity = supplier.getSecurity();
    handler = new SupplierSideMirroringHandler(supplier, supplierSecurity);

    callerSecurity = MockMartusSecurity.createClient();
    callerAccountId = callerSecurity.getPublicKeyString();

    authorSecurity = MockMartusSecurity.createOtherClient();
  }
コード例 #2
0
  protected void setUp() throws Exception {
    super.setUp();
    logger = new LoggerToNull();
    MockMartusSecurity serverSecurity = MockMartusSecurity.createServer();
    coreServer = new MockMartusServer(this);
    coreServer.setSecurity(serverSecurity);
    server = new ServerForMirroring(coreServer, logger);

    clientSecurity1 = MockMartusSecurity.createClient();
    clientSecurity2 = MockMartusSecurity.createOtherClient();

    Database db = coreServer.getWriteableDatabase();

    bhp1 = new BulletinHeaderPacket(clientSecurity1);
    bhp1.setStatus(BulletinConstants.STATUSIMMUTABLE);
    DatabaseKey key1 = bhp1.createKeyWithHeaderStatus(bhp1.getUniversalId());
    bhp1.writeXmlToDatabase(db, key1, false, clientSecurity1);

    bhp2 = new BulletinHeaderPacket(clientSecurity1);
    bhp2.setStatus(BulletinConstants.STATUSIMMUTABLE);
    DatabaseKey key2 = bhp2.createKeyWithHeaderStatus(bhp2.getUniversalId());
    bhp2.writeXmlToDatabase(db, key2, false, clientSecurity1);

    bhp3 = new BulletinHeaderPacket(clientSecurity2);
    bhp3.setStatus(BulletinConstants.STATUSIMMUTABLE);
    DatabaseKey key3 = bhp3.createKeyWithHeaderStatus(bhp3.getUniversalId());
    bhp3.writeXmlToDatabase(db, key3, false, clientSecurity2);

    bhp4 = new BulletinHeaderPacket(clientSecurity2);
    bhp4.setStatus(BulletinConstants.STATUSMUTABLE);
    DatabaseKey key4 = bhp4.createKeyWithHeaderStatus(bhp4.getUniversalId());
    bhp4.writeXmlToDatabase(db, key4, false, clientSecurity2);

    UniversalId fdpUid = FieldDataPacket.createUniversalId(clientSecurity1);
    FieldSpec[] tags = {LegacyCustomFields.createFromLegacy("whatever")};
    FieldDataPacket fdp1 = new FieldDataPacket(fdpUid, new FieldSpecCollection(tags));
    fdp1.writeXmlToClientDatabase(db, false, clientSecurity1);

    UniversalId otherPacketId =
        UniversalIdForTesting.createFromAccountAndPrefix(clientSecurity2.getPublicKeyString(), "X");
    DatabaseKey key = DatabaseKey.createImmutableKey(otherPacketId);
    db.writeRecord(key, "Not a valid packet");
  }
コード例 #3
0
  public void testFindLegacyRecords() throws Exception {
    Database mockDatabase = new MockClientDatabase();
    MartusCrypto security = MockMartusSecurity.createClient();

    File tempDir = createTempFile();
    tempDir.delete();
    tempDir.mkdir();
    Database clientFileDatabase = new ClientFileDatabase(tempDir, security);
    clientFileDatabase.initialize();

    internalTestFindLegacyRecords(mockDatabase);
    internalTestFindLegacyRecords(clientFileDatabase);
  }
コード例 #4
0
  private void internalTestFindLegacyRecords(Database db) throws Exception {
    MartusCrypto security = MockMartusSecurity.createClient();

    UniversalId uid = UniversalIdForTesting.createDummyUniversalId();
    DatabaseKey legacyKey = DatabaseKey.createLegacyKey(uid);
    db.writeRecord(legacyKey, smallString);
    InputStream inLegacy = db.openInputStream(legacyKey, security);
    assertNotNull("legacy not found?", inLegacy);
    inLegacy.close();

    InputStream inDraft = db.openInputStream(legacyKey, security);
    assertNotNull("draft not found?", inDraft);
    inDraft.close();

    DatabaseKey sealedKey = DatabaseKey.createSealedKey(uid);
    InputStream inSealed = db.openInputStream(sealedKey, security);
    assertNotNull("sealed not found?", inSealed);
    inSealed.close();

    db.deleteAllData();
  }
コード例 #5
0
 public MockMartusServer(File dataDir, Database databaseToUse) throws Exception {
   super(dataDir, new LoggerToNull());
   getStore().setSignatureGenerator(MockMartusSecurity.createServer());
   initializeBulletinStore(databaseToUse);
 }
コード例 #6
0
 public void setUp() throws Exception {
   rr = new ReportRunner(MockMartusSecurity.createClient(), new MiniLocalization());
   context = new VelocityContext();
 }