Federate extends ConsoleCommand { @Override public void execute(String... parameters) throws IOException { if (parameters.length < 4) { writeln(getHelpLong()); } else { LinkedList<String> plist = new LinkedList<>(Arrays.asList(parameters)); plist.remove(); boolean distinct = getOptionalParamValue(plist, "distinct", false); boolean readonly = getOptionalParamValue(plist, "readonly", true); if (distinctValues(plist)) { String fedID = plist.pop(); federate(distinct, readonly, fedID, plist); } else { writeError("Duplicate repository id's specified."); } } } Federate(ConsoleIO consoleIO, ConsoleState state); @Override String getName(); @Override String getHelpShort(); @Override String getHelpLong(); @Override void execute(String... parameters);  }
@Test public void testInvalidArgumentPrintsError() throws Exception { execute("type=memory", FED_ID, MEMORY_MEMBER_ID1, MEMORY_MEMBER_ID2); verifyFailure(); }
@Test public void testDuplicateMembersPrintsError() throws Exception { execute(FED_ID, MEMORY_MEMBER_ID1, MEMORY_MEMBER_ID1); verifyFailure(); }
@Test public void testFedSameAsMemberPrintsError() throws Exception { execute(FED_ID, MEMORY_MEMBER_ID1, FED_ID, MEMORY_MEMBER_ID1); verifyFailure(); }
@Test public void testSparqlAndNotReadOnlyPrintsError() throws Exception { execute("readonly=false", FED_ID, SPARQL_MEMBER_ID, SPARQL2_MEMBER_ID); verifyFailure(SPARQL_MEMBER_ID + " is read-only."); verifyFailure(SPARQL2_MEMBER_ID + " is read-only."); }
@Test public void testFedAlreadyExistsPrintsSpecificError() throws Exception { execute(MEMORY_MEMBER_ID1, FED_ID, MEMORY_MEMBER_ID2); verifyFailure(MEMORY_MEMBER_ID1 + " already exists."); }
@Test public void testNonexistentMemberPrintsSpecificError() throws Exception { execute(FED_ID, MEMORY_MEMBER_ID1, "FreeLunch"); verifyFailure("FreeLunch does not exist."); }
@Test public void testFederateMemoryMembersSuccess() throws Exception { execute(FED_ID, MEMORY_MEMBER_ID1, MEMORY_MEMBER_ID2); verifySuccess(ProxyRepositoryFactory.REPOSITORY_TYPE, ProxyRepositoryFactory.REPOSITORY_TYPE); long expectedSize = getSize(MEMORY_MEMBER_ID1) + getSize(MEMORY_MEMBER_ID2); assertThat(getSize(FED_ID)).isEqualTo(expectedSize); }
@Test public void testFederateSucceedsWithHTTPandSPARQLmembers() throws Exception { execute(FED_ID, HTTP_MEMBER_ID, SPARQL_MEMBER_ID); verifySuccess(HTTPRepositoryFactory.REPOSITORY_TYPE, SPARQLRepositoryFactory.REPOSITORY_TYPE); }
@Test public void testFederateHTTPtypeSucceeds() throws Exception { execute(FED_ID, HTTP_MEMBER_ID, HTTP2_MEMBER_ID); verifySuccess(HTTPRepositoryFactory.REPOSITORY_TYPE, HTTPRepositoryFactory.REPOSITORY_TYPE); }
@Test public void testFederateSPARQLtypeSucceeds() throws Exception { execute(FED_ID, SPARQL_MEMBER_ID, SPARQL2_MEMBER_ID); verifySuccess(SPARQLRepositoryFactory.REPOSITORY_TYPE, SPARQLRepositoryFactory.REPOSITORY_TYPE); }
@Test public void testSuccessWithNonDefaultReadonlyAndDistinct() throws Exception { execute(FED_ID, "distinct=true", "readonly=false", MEMORY_MEMBER_ID1, MEMORY_MEMBER_ID2); verifySuccess(false, true, ProxyRepositoryFactory.REPOSITORY_TYPE, ProxyRepositoryFactory.REPOSITORY_TYPE); long expectedSize = getSize(MEMORY_MEMBER_ID1) + getSize(MEMORY_MEMBER_ID2); assertThat(getSize(FED_ID)).isEqualTo(expectedSize); }
@Test public void testFullyHeterogeneousSuccess() throws Exception { execute(FED_ID, SPARQL_MEMBER_ID, MEMORY_MEMBER_ID1, HTTP_MEMBER_ID); verifySuccess(SPARQLRepositoryFactory.REPOSITORY_TYPE, ProxyRepositoryFactory.REPOSITORY_TYPE, HTTPRepositoryFactory.REPOSITORY_TYPE); }