public void testRemoteFileDescCreatorsAreAskedIfTheyCanCreateRFD() {
   final RemoteFileDescCreator creator = context.mock(RemoteFileDescCreator.class);
   remoteFileDescFactory.register(creator);
   final Address address = context.mock(Address.class);
   final byte[] clientGuid = GUID.makeGuid();
   context.checking(
       new Expectations() {
         {
           one(creator).canCreateFor(address);
           will(returnValue(true));
           one(creator)
               .create(
                   address,
                   1,
                   "hello",
                   2,
                   clientGuid,
                   1,
                   1,
                   true,
                   null,
                   URN.NO_URN_SET,
                   false,
                   "vendor",
                   -1,
                   false);
           will(returnValue(null));
         }
       });
   RemoteFileDesc rfd =
       remoteFileDescFactory.createRemoteFileDesc(
           address,
           1,
           "hello",
           2,
           clientGuid,
           1,
           1,
           true,
           null,
           URN.NO_URN_SET,
           false,
           "vendor",
           -1,
           false,
           null);
   assertNull(rfd);
   context.assertIsSatisfied();
 }
Esempio n. 2
0
 private RemoteFileDescContext newRFDWithURN(String host, int speed) throws Exception {
   Set set = new HashSet();
   try {
     // for convenience, don't require that they pass the urn.
     // assume a null one is the TestFile's hash.
     set.add(TestFile.hash());
   } catch (Exception e) {
     fail("SHA1 not created");
   }
   return toContext(
       remoteFileDescFactory.createRemoteFileDesc(
           new ConnectableImpl(host, 1, false),
           0,
           "asdf",
           TestFile.length(),
           new byte[16],
           speed,
           4,
           false,
           null,
           set,
           false,
           "",
           -1));
 }
Esempio n. 3
0
 private RemoteFileDescContext newRFD(String host, int speed) throws Exception {
   return toContext(
       remoteFileDescFactory.createRemoteFileDesc(
           new ConnectableImpl(host, 1, false),
           0,
           "asdf",
           TestFile.length(),
           new byte[16],
           speed,
           4,
           false,
           null,
           URN.NO_URN_SET,
           false,
           "",
           -1));
 }