mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-CR-1119 fix tests
This commit is contained in:
@@ -109,11 +109,11 @@ public abstract class ArchivedProjectTemplate implements ProjectTemplate {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static abstract class StreamConsumer<T> {
|
||||
public static abstract class StreamProcessor<T> {
|
||||
public abstract T consume(@NotNull ZipInputStream stream) throws IOException;
|
||||
}
|
||||
|
||||
public abstract <T> void getStream(@NotNull StreamConsumer<T> consumer) throws IOException;
|
||||
public abstract <T> T processStream(@NotNull StreamProcessor<T> consumer) throws IOException;
|
||||
|
||||
@Nullable
|
||||
public String getCategory() {
|
||||
@@ -137,9 +137,9 @@ public abstract class ArchivedProjectTemplate implements ProjectTemplate {
|
||||
});
|
||||
}
|
||||
|
||||
static <T> void consumeZipStream(@NotNull StreamConsumer<T> consumer, @NotNull ZipInputStream stream) throws IOException {
|
||||
static <T> T consumeZipStream(@NotNull StreamProcessor<T> consumer, @NotNull ZipInputStream stream) throws IOException {
|
||||
try {
|
||||
consumer.consume(stream);
|
||||
return consumer.consume(stream);
|
||||
}
|
||||
finally {
|
||||
StreamUtil.closeStream(stream);
|
||||
|
||||
@@ -87,7 +87,7 @@ public class LocalArchivedTemplate extends ArchivedProjectTemplate {
|
||||
@Nullable
|
||||
String readEntry(@NotNull final String endsWith) {
|
||||
try {
|
||||
getStream(new StreamConsumer<String>() {
|
||||
return processStream(new StreamProcessor<String>() {
|
||||
@Override
|
||||
public String consume(@NotNull ZipInputStream stream) throws IOException {
|
||||
ZipEntry entry;
|
||||
@@ -101,8 +101,8 @@ public class LocalArchivedTemplate extends ArchivedProjectTemplate {
|
||||
});
|
||||
}
|
||||
catch (IOException ignored) {
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -125,8 +125,8 @@ public class LocalArchivedTemplate extends ArchivedProjectTemplate {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void getStream(@NotNull StreamConsumer<T> consumer) throws IOException {
|
||||
consumeZipStream(consumer, new ZipInputStream(myArchivePath.openStream()));
|
||||
public <T> T processStream(@NotNull StreamProcessor<T> consumer) throws IOException {
|
||||
return consumeZipStream(consumer, new ZipInputStream(myArchivePath.openStream()));
|
||||
}
|
||||
|
||||
public URL getArchivePath() {
|
||||
|
||||
@@ -163,12 +163,11 @@ public class RemoteTemplatesFactory extends ProjectTemplatesFactory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void getStream(@NotNull final StreamConsumer<T> consumer) throws IOException {
|
||||
HttpRequests.request(URL + myPath).connect(new HttpRequests.RequestProcessor<Void>() {
|
||||
public <T> T processStream(@NotNull final StreamProcessor<T> consumer) throws IOException {
|
||||
return HttpRequests.request(URL + myPath).connect(new HttpRequests.RequestProcessor<T>() {
|
||||
@Override
|
||||
public Void process(@NotNull HttpRequests.Request request) throws IOException {
|
||||
consumeZipStream(consumer, new ZipInputStream(request.getInputStream()));
|
||||
return null;
|
||||
public T process(@NotNull HttpRequests.Request request) throws IOException {
|
||||
return consumeZipStream(consumer, new ZipInputStream(request.getInputStream()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ public class TemplateModuleBuilder extends ModuleBuilder {
|
||||
};
|
||||
|
||||
final File dir = new File(path);
|
||||
myTemplate.getStream(new ArchivedProjectTemplate.StreamConsumer<Void>() {
|
||||
myTemplate.processStream(new ArchivedProjectTemplate.StreamProcessor<Void>() {
|
||||
@Override
|
||||
public Void consume(@NotNull ZipInputStream stream) throws IOException {
|
||||
ZipUtil.unzip(ProgressManager.getInstance().getProgressIndicator(), dir, stream, pathConvertor, new ZipUtil.ContentProcessor() {
|
||||
|
||||
Reference in New Issue
Block a user