IDEA-CR-1119 fix tests

This commit is contained in:
Vladimir Krivosheev
2014-12-29 10:48:30 +01:00
parent 9a7e6541d7
commit cec218603b
4 changed files with 13 additions and 14 deletions
@@ -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() {