Search in sources :

Example 96 with ByteSource

use of com.google.common.io.ByteSource in project solution-finder by knewjade.

the class UtilFigFileCaseTest method useFileCase1.

@Test
void useFileCase1() throws Exception {
    // オプションなし
    ConfigFileHelper.createFieldFile("v115@vhIKJYzAFLDmClcJSAVDEHBEooRBPoAVBsHMMC0vyt?C6eNPCMe/wCM9aFDzn9wCv/7LCz3fBA0qBvrBxxBlgBOaBT?oBTnBshBBgh0Heg0EeAtCeg0AeywBtCeglBewwQ4AtTpAPg?HBtR4TpAPglAeBtQ4wSyhgHA8SpBtC8gWB8QpwhAtzwgWA8?BtxhzwgWg0A8BtwhT4Je3DBvhDZ5AWPBtQB5MBTfwhHexhH?exhEeh0AexhR4Ceg0BewhR4Atg0BehlAeAtQpQ4zhAeB8R4?E8AeB8R4E8gHglA8R4xhC8gHB8Q4xhAtglB8h0A8BtwhR4Q?aQ4A8GeAAAeA8GeAAAeA8GeAAAeA8GeAAKe+7AvhJq1AdzA?q0ATpAM2AXsAMyAJwANyAT0AwwCeRpwhCexwTpwhAeR4g0B?ewhR4Ati0hlAeBtQ4zhAeI8AeI8AeI8AeQ8AeI8AeA8QpC8?xwQ4A8AeA8RpzwQ4A8wDwhglB8Q4xhAtglgHglh0A8APAtw?hT4A8BeAAFeA8BeAAaeAAFeA8BeAAFeA8BeAAFeA8IeA8AA?HeA8AAJeAAA");
    String command = "util fig";
    RunnerHelper.runnerCatchingLog(() -> EntryPointMain.main(command.split(" ")));
    ByteSource actual = FigureFileHelper.loadGifByteSource();
    ByteSource expect = FigureFileHelper.loadResourceByteSource(UtilFigResources.FileCase1);
    assertThat(actual.contentEquals(expect)).isTrue();
}
Also used : ByteSource(com.google.common.io.ByteSource) Test(org.junit.jupiter.api.Test)

Example 97 with ByteSource

use of com.google.common.io.ByteSource in project solution-finder by knewjade.

the class UtilFigTetfuCaseTest method useTetfuCase6.

@Test
void useTetfuCase6() throws Exception {
    // オプション: frame:no, line:4
    String tetfu = "v115@vhLNJYkBFLDmClcJSAVDEHBEooRBUoAVBvHkPCpC8L?Cq+jFDvvbgCa+VWCvu/VCpHkFDv/NMCzCWWCaXNPCzn9wCz?vKWCUuKWCqHMMCvXUPCUtPFDPN8LCUNUPCUXNFDUentC0fB?XqBWyBToBCjBJnBarBpmBlqB2uB/kBBgQ4IeR4Heg0Q4Hei?0GeI8AeI8AewhH8AexhG8AeglwhG8AeilF8Ke0MBvhKTOBv?NBGDBECBpoBTjB6tBTsB1pB+tByxBIhwwFeglg0wwAewwCe?hlBeSpC8h0gWglJeZaBfgwhdewwFeglg0AtAewwCehlBeSp?C8h0gWglCeAADeA8KeUbBVgwhTeBtHewhAeAtDeglg0AtAe?whAPBehlBeSpC8h0gWglCeAADeA8Ue/YBvhFlcBzbBMjBuh?BllBXoB9gwhDeh0AeR4BeywAewhQ4AewSQ4A8QpQLQpglyh?AtCeA8DeAAKe6fBvhDllB5iBMtBywB6gwhHeglwhAeAthlB?eilAeBtF8g0Q4A8APh0B8i0Q4AtAPJeTaBvhRugBncBJbB0?WBNjB3iB2bBTfBKVBpoBlrBxxB6kBWtB8lBTjBpUBTVBKgw?hIewhRpHeRpHeRaBeAtCeQpglRaAeBtBeg0QpglBeg0AtAP?Beg0RpBeg0hlAewhQLhWh0glAtAeB8ilh0hlgHA8T4JecWB?vhDiMB3TB2GB/8AjfQ4JeQ4HeQaHewhAeQag0GexSAPhlHe?glgWBeR4AeRaglAeAtAeQ4AeAPglFewDQaDeglAeAPCeRpC?eglg0AewhSLh0hlgHA8T4KeAABeA8OeeFBvhB09AT2AZfQ4?GeRpAeQ4HeQaAeBtDeQpgWAeQaglAeAtEexSAPhWBeg0Eeg?lgWBexhAeRaglAeAtAeQ4AeAPglFewDQaDeglAeAPCeRpCe?glg0AewhSLh0hlgHA8T4KeAABeA8FeA8FeAAKePuAvhH6uA?lIBlXBXTBCTBZNBFYBuXBmhI8AoFvhAAAA";
    String command = String.format("util fig -t %s -f no -l 4", tetfu);
    RunnerHelper.runnerCatchingLog(() -> EntryPointMain.main(command.split(" ")));
    ByteSource actual = FigureFileHelper.loadGifByteSource();
    ByteSource expect = FigureFileHelper.loadResourceByteSource(UtilFigResources.TetfuCase6);
    assertThat(actual.contentEquals(expect)).isTrue();
}
Also used : ByteSource(com.google.common.io.ByteSource) Test(org.junit.jupiter.api.Test)

Example 98 with ByteSource

use of com.google.common.io.ByteSource in project solution-finder by knewjade.

the class UtilFigTetfuCaseTest method useTetfuCase8.

@Test
void useTetfuCase8() throws Exception {
    // オプション: next:-1
    String tetfu = "v115@vhTRQY2AFLDmClcJSAVDEHBEooRBUoAVBpiHgCzHkF?D0vCMCsC+tCp3HgCMeLuCq+aPCTuKxC6CBAAKpBWyBToBPn?BUmBveBFqB0pB2qBTfBlsBywB6sBpjBvmBlqBsmBmsBzXBa?gRpHeRpHewSwhHexhBewhDeQ4Atglh0whDeQ4QpgWglg0Ae?A8AeB8whAtilQ4A8AeB8xhh0glQ4JeqYBvhB5kBZkBefRpH?eRpglBewhEeAtglBewhDeBthlyhBeQ4Ati0yhBeR4hlg0wh?F8AeI8AeH8wwwSH8wwwSg0B8Q4E8APg0B8Q4D8AtAPh0S4B?8whAtgHhlS4B8xhgWg0glQ4JeU9AvhCH+A+CBTFBieRpFeg?0AeRpglRpwhBeg0R4AtglRpF8AeI8AeI8AeI8AeI8AeI8Ae?H8wwwSF8glA8wwwSg0xwQ4A8AeglxhAtg0xwBeAACeA8EeA?ACeA8EeAACeA8IeA8BeAAFeA8BeAAFeA8BeAAFeA8BeAAFe?A8BeAAJe9UAwhwwAeg0R4AtglRpF8AeI8AeD8QpC8wwwSC8?RpA8glA8wwwSg0xwQ4QpA8glxhAPg0xwfeAACeA8EeAACeA?8EeAACeA8EeAACeA8IeA8BeAABeA8FeAABeA8FeAABeA8Fe?AABeA8FeAAHeAAA8HeAAA8HeAAA8HeAAA8HeAAA8JeAAA";
    String command = String.format("util fig -t %s -n -1", tetfu);
    RunnerHelper.runnerCatchingLog(() -> EntryPointMain.main(command.split(" ")));
    ByteSource actual = FigureFileHelper.loadGifByteSource();
    ByteSource expect = FigureFileHelper.loadResourceByteSource(UtilFigResources.TetfuCase8);
    assertThat(actual.contentEquals(expect)).isTrue();
}
Also used : ByteSource(com.google.common.io.ByteSource) Test(org.junit.jupiter.api.Test)

Example 99 with ByteSource

use of com.google.common.io.ByteSource in project solution-finder by knewjade.

the class UtilFigTetfuCaseTest method pngCase1.

@Test
void pngCase1() throws Exception {
    // オプション: format:png
    String tetfu = "v115@vhPRQYGBFLDmClcJSAVDEHBEooRBUoAVBJ3jPC6ijW?CTuKxCqiLuCJn/wCPt/wCsn1LCaHUPCUdNPCUnLuCMtPFDU?X9VC0/AAATpB3mB+tBcqBykBlsBKkBXtBUnBRiBNrBuqBSy?BzpB0qBrgBtIeBtEeI8AeI8AeB8BtE8AeC8BtD8KexdBvhA?vXBZgQ4GeBtAeQ4FeAPAewSAezhC8BtwhS4QaleAAA8Je2V?BvhATTBFgQ4AeRpBeg0AeBtR4RpBeI8AeD8whA8xwA8Aegl?A8BtxhxwA8SeAAA8GeAAAeA8GeAAAeA8GeAAA8KelBBvhBv?KBGHBCgi0FewwRaAeQ4AeRpQ4AeSpglwhA8xwwhceAAA8Ge?AAA8beA8AAKelDBvhAi8AFfilGegli0ywCeywg0Q4wwRpQ4?AeI8AeI8Aei0F8Aeg0ilSpA8AeA8SpglwhQpwwwSwhA8GeA?AAeA8GeAAAeA8HeAAA8FeAAAeA8GeAAA8HeAAA8HeAAA8He?AAAeA8KeTZAvhDp2AMAB5JB0MBZfRpHeRpBtFeilBtDeAtH?8AeG8AeC8xwD8AeC8xwBtB8AeC8i0BtA8AeB8AtFeAAAeA8?CeAACeA8EeAACeA8EeAACeA8EeAACeA8We6xAvehlRpGegl?RpBtEejlBtDeAtH8gWg0xwD8AeB8g0xwBtB8AeB8j0BtA8A?eB8AtFeAAAeA8MeAACeA8EeAACeA8EeAACeA8EeAACeA8Ee?A8CeAAEeA8DeAADeA8DeAADeA8DeAAHeA8AALemaAvhFTPA?XhAdnApgAOwA1uAxeRpAewwAewhDeRpywwhBehlRpi0whh0?AeglxwA8QpA8Q4AeC8xwSpQ4AeA8h0xwilQ4gHglA8g0BeA?ACeA8EeAACeA8EeAACeA8OeA8CeAAEeA8DeAADeA8DeAAHe?A8AALeAAFeA8BeAAFeA8BeAAFeA8LeTcAvhEMiAfgAPfAar?AMsAAeT4hlAeBtF8AeE8AeI8AeI8AeI8AeM8AeJ8AeA8AtA?8whA8whC8AeBtA8zhh0AeBtFeA8AABeAAAeA8GeAAAeA8Ge?AAAeA8IeA8EeAAGeA8AeAAoeA8FeAABeA8GeAAAeA8FeAAL?eAAA";
    String command = String.format("util fig -F png -t %s -s 5 -e 30", tetfu);
    Log log = RunnerHelper.runnerCatchingLog(() -> EntryPointMain.main(command.split(" ")));
    // 出力ディレクトリを取得
    String output = log.getOutput();
    String outputDirectory = extractOutputDirectory(output);
    // 出力されたPNGを取得
    List<ByteSource> actuals = java.nio.file.Files.walk(Paths.get(outputDirectory)).map(Path::toFile).filter(File::isFile).sorted(Comparator.comparing(File::getName)).map(Files::asByteSource).collect(Collectors.toList());
    // Assertion
    List<ByteSource> expects = FigureFileHelper.loadResourcesByteSource(UtilFigResources.PngCase1);
    assertThat(actuals).hasSameSizeAs(expects);
    for (int index = 0; index < actuals.size(); index++) assertThat(actuals.get(index).contentEquals(expects.get(index))).isTrue();
    // 出力されたPNGを削除
    // noinspection ResultOfMethodCallIgnored
    new File(outputDirectory).delete();
}
Also used : Path(java.nio.file.Path) Log(_usecase.Log) ByteSource(com.google.common.io.ByteSource) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 100 with ByteSource

use of com.google.common.io.ByteSource in project controller by opendaylight.

the class MigratedMessagesTest method doTestSnapshotAfterStartupWithMigratedMessage.

@SuppressWarnings("checkstyle:IllegalCatch")
private TestActorRef<MockRaftActor> doTestSnapshotAfterStartupWithMigratedMessage(String id, boolean persistent, Consumer<Snapshot> snapshotVerifier, final State snapshotState) {
    InMemorySnapshotStore.addSnapshotSavedLatch(id);
    InMemoryJournal.addDeleteMessagesCompleteLatch(id);
    DefaultConfigParamsImpl config = new DefaultConfigParamsImpl();
    config.setCustomRaftPolicyImplementationClass(DisableElectionsRaftPolicy.class.getName());
    RaftActorSnapshotCohort snapshotCohort = new RaftActorSnapshotCohort() {

        @Override
        public void createSnapshot(ActorRef actorRef, java.util.Optional<OutputStream> installSnapshotStream) {
            actorRef.tell(new CaptureSnapshotReply(snapshotState, installSnapshotStream), actorRef);
        }

        @Override
        public void applySnapshot(State newState) {
        }

        @Override
        public State deserializeSnapshot(ByteSource snapshotBytes) {
            throw new UnsupportedOperationException();
        }
    };
    TestActorRef<MockRaftActor> raftActorRef = factory.createTestActor(MockRaftActor.builder().id(id).config(config).snapshotCohort(snapshotCohort).persistent(Optional.of(persistent)).peerAddresses(ImmutableMap.of("peer", "")).props().withDispatcher(Dispatchers.DefaultDispatcherId()), id);
    MockRaftActor mockRaftActor = raftActorRef.underlyingActor();
    mockRaftActor.waitForRecoveryComplete();
    Snapshot snapshot = InMemorySnapshotStore.waitForSavedSnapshot(id, Snapshot.class);
    snapshotVerifier.accept(snapshot);
    InMemoryJournal.waitForDeleteMessagesComplete(id);
    assertEquals("InMemoryJournal size", 0, InMemoryJournal.get(id).size());
    return raftActorRef;
}
Also used : CaptureSnapshotReply(org.opendaylight.controller.cluster.raft.base.messages.CaptureSnapshotReply) Optional(com.google.common.base.Optional) ActorRef(akka.actor.ActorRef) TestActorRef(akka.testkit.TestActorRef) Snapshot(org.opendaylight.controller.cluster.raft.persisted.Snapshot) ByteState(org.opendaylight.controller.cluster.raft.persisted.ByteState) State(org.opendaylight.controller.cluster.raft.persisted.Snapshot.State) DisableElectionsRaftPolicy(org.opendaylight.controller.cluster.raft.policy.DisableElectionsRaftPolicy) ByteSource(com.google.common.io.ByteSource)

Aggregations

ByteSource (com.google.common.io.ByteSource)139 IOException (java.io.IOException)59 Test (org.junit.Test)58 InputStream (java.io.InputStream)42 ByteArrayInputStream (java.io.ByteArrayInputStream)33 File (java.io.File)33 ContentItemImpl (ddf.catalog.content.data.impl.ContentItemImpl)18 Metacard (ddf.catalog.data.Metacard)17 ContentItem (ddf.catalog.content.data.ContentItem)16 StringWriter (java.io.StringWriter)14 FileInputStream (java.io.FileInputStream)13 Test (org.junit.jupiter.api.Test)12 URI (java.net.URI)11 URL (java.net.URL)11 Path (java.nio.file.Path)11 ArrayList (java.util.ArrayList)11 CreateStorageRequestImpl (ddf.catalog.content.operation.impl.CreateStorageRequestImpl)9 ByteArrayOutputStream (java.io.ByteArrayOutputStream)9 TemporaryFileBackedOutputStream (org.codice.ddf.platform.util.TemporaryFileBackedOutputStream)9 FilterInputStream (java.io.FilterInputStream)8