@Test public void usesFilerToOpenStream() throws IOException { Filer filer = mock(Filer.class); FileObject fileObject = mock(FileObject.class); when(filer.createResource(Mockito.<Location> any(), anyString(), anyString())).thenReturn(fileObject); OutputStream expectedOS = mock(OutputStream.class); when(fileObject.openOutputStream()).thenReturn(expectedOS); ResourceCodeWriter resourceCodeWriter = new ResourceCodeWriter(filer); JPackage jPackage = new JCodeModel()._package("some.package"); OutputStream resultingOS = resourceCodeWriter.openBinary(jPackage, null); assertSame(expectedOS, resultingOS); }
@Override public OutputStream openBinary(JPackage pkg, String fileName) throws IOException { FileObject resource = filer.createResource(StandardLocation.SOURCE_OUTPUT, pkg.name(), fileName); return resource.openOutputStream(); }
ResourceCodeWriter extends CodeWriter { @Override public OutputStream openBinary(JPackage pkg, String fileName) throws IOException { FileObject resource = filer.createResource(StandardLocation.SOURCE_OUTPUT, pkg.name(), fileName); return resource.openOutputStream(); } }
ResourceCodeWriter extends CodeWriter { @Override public OutputStream openBinary(JPackage pkg, String fileName) throws IOException { FileObject resource = filer.createResource(StandardLocation.SOURCE_OUTPUT, pkg.name(), fileName); return resource.openOutputStream(); } ResourceCodeWriter(Filer filer); }
ResourceCodeWriter extends CodeWriter { @Override public OutputStream openBinary(JPackage pkg, String fileName) throws IOException { FileObject resource = filer.createResource(StandardLocation.SOURCE_OUTPUT, pkg.name(), fileName); return resource.openOutputStream(); } ResourceCodeWriter(Filer filer); @Override OutputStream openBinary(JPackage pkg, String fileName); @Override void close(); }
ResourceCodeWriter extends CodeWriter { @Override public OutputStream openBinary(JPackage pkg, String fileName) throws IOException { FileObject resource = filer.createResource(StandardLocation.SOURCE_OUTPUT, pkg.name(), fileName); return resource.openOutputStream(); } ResourceCodeWriter(Filer filer); @Override OutputStream openBinary(JPackage pkg, String fileName); @Override void close();  }