@@ -0,0 +1,2887 @@
+/**%0A * Copyright 2013 Julien Silland%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage io.soliton.protobuf.plugin;%0A%0Aimport com.google.protobuf.DescriptorProtos;%0Aimport com.google.protobuf.Descriptors;%0Aimport com.google.protobuf.compiler.PluginProtos;%0Aimport io.soliton.protobuf.plugin.testing.Testing;%0Aimport org.junit.Assert;%0Aimport org.junit.Test;%0A%0Aimport javax.tools.JavaCompiler;%0Aimport javax.tools.JavaFileObject;%0Aimport javax.tools.SimpleJavaFileObject;%0Aimport javax.tools.ToolProvider;%0Aimport java.io.ByteArrayOutputStream;%0Aimport java.net.URI;%0A%0Apublic class ProtoServiceHandlerTest %7B%0A%0A  private static class JavaSourceFromString extends SimpleJavaFileObject %7B%0A%0A    final String code;%0A%0A    /**%0A     * Constructs a new JavaSourceFromString.%0A     * @param name the name of the compilation unit represented by this file object%0A     * @param code the source code for the compilation unit represented by this file object%0A     */%0A    JavaSourceFromString(String name, String code) %7B%0A      super(URI.create(%22string:///%22 + name.replace('.', '/') + Kind.SOURCE.extension),%0A          Kind.SOURCE);%0A      this.code = code;%0A    %7D%0A%0A    @Override%0A    public CharSequence getCharContent(boolean ignoreEncodingErrors) %7B%0A      return code;%0A    %7D%0A  %7D%0A%0A  @Test%0A  public void testHandle() throws Exception %7B%0A    Descriptors.Descriptor personDescriptor = Testing.Person.getDescriptor();%0A    DescriptorProtos.FileDescriptorProto protoFile = personDescriptor.getFile().toProto();%0A    TypeMap types = TypeMap.of(protoFile);%0A    ByteArrayOutputStream output = new ByteArrayOutputStream();%0A    ProtoServiceHandler serviceHandler = new ProtoServiceHandler(%0A        %22io.soliton.protobuf.plugin.testing%22, types, output);%0A    serviceHandler.handle(protoFile.getServiceList().get(0));%0A    PluginProtos.CodeGeneratorResponse response = PluginProtos.CodeGeneratorResponse.parseFrom(%0A        output.toByteArray());%0A    Assert.assertNotNull(response);%0A    Assert.assertEquals(1, response.getFileCount());%0A    Assert.assertEquals(%22io/soliton/protobuf/plugin/testing/PhoneBookService.java%22,%0A        response.getFile(0).getName());%0A    String fileContent = response.getFile(0).getContent();%0A    JavaFileObject file = new JavaSourceFromString%0A        (%22io/soliton/protobuf/plugin/testing/PhoneBookService.java%22, fileContent);%0A    JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();%0A  %7D%0A%7D%0A

Add test code for the plugin