/** Copies this attribute and returns a new copy. */ public AttributeInfo copy(ConstPool newCp, Map classnames) { Copier copier = new Copier(info, constPool, newCp, classnames); try { copier.annotationArray(); return new AnnotationsAttribute(newCp, getName(), copier.close()); } catch (Exception e) { throw new RuntimeException(e); } }
@Override public Object copy(Object object) { for (Copier copier : COPIERS) { try { return copier.copy(object); } catch (Exception ignore) { continue; } } throw new IllegalStateException( "Can't copy object of type " + object.getClass() + ". No copier appeared to be capable of copying it."); }
@Test public void testParseComObjetosInner() { InnerObjectSource de = new InnerObjectSource(new NoAnnotationSource("BB", "123321")); DestinyInnerObject para = copier.from(de).doCopy(); assertEquals("BB", para.getObject().getFirst()); }
@Test public void testParseComObjetosDeInnerEParaOuter() { InnerObjectMultipleObjectFieldsToFields de = new InnerObjectMultipleObjectFieldsToFields(new NoAnnotationSource("BB", "123321")); Destiny para = copier.from(de).doCopy(); assertEquals("BB", para.getFirst()); assertEquals("123321", para.getSecond()); }
@Test public void testParseComObjetosInnerEVariosAtributos() { InnerObjectMultipleObjectFieldsToObjectFields de = new InnerObjectMultipleObjectFieldsToObjectFields(new NoAnnotationSource("BB", "123321")); DestinyInnerObject para = copier.from(de).doCopy(); assertEquals("BB", para.getObject().getFirst()); assertEquals("123321", para.getObject().getSecond()); }
@Test public void testParseComObjetosParaInnerEDeOuter() { InnerObjectMultipleFieldsToObjectFields de = new InnerObjectMultipleFieldsToObjectFields("BB", "123321"); DestinyInnerObject para = copier.from(de).doCopy(); assertEquals("BB", para.getObject().getFirst()); assertEquals("123321", para.getObject().getSecond()); }
@Test public void testParseAtributosComAnnotacaoParaPreenchido() { InvertedFieldsSource de = new InvertedFieldsSource("BB", "123321", "M"); Destiny para = copier.from(de).doCopy(); assertEquals("123321", para.getFirst()); assertEquals("BB", para.getSecond()); assertEquals(null, para.getOther()); }
@Test public void testParseAtributosComAnnotacaoDefault() { FieldAnnotationSource de = new FieldAnnotationSource("BB", "123321", "M"); Destiny para = copier.from(de).doCopy(); assertEquals("BB", para.getFirst()); assertEquals("123321", para.getSecond()); assertEquals(null, para.getOther()); }
@Test public void testParseAtributosComMesmoNome() { ClassAnnotationSource de = new ClassAnnotationSource("BB", "123321", "M"); Destiny para = copier.from(de).doCopy(); assertEquals("BB", para.getFirst()); assertEquals("123321", para.getSecond()); assertEquals(null, para.getOther()); }
@Test public void testParseObjetoSimples() { ClassAnnotationSource de = new ClassAnnotationSource("BB", "123321", null); ClassAnnotationSource para = copier.from(de).doCopy(ClassAnnotationSource.class); assertEquals("BB", para.getFirst()); assertEquals("123321", para.getSecond()); assertEquals(null, para.getThird()); }
public void stop(Channel channel) throws Exception { channel.close(); channel.join(10 * 1000); // System.out.println("north completed"); executor.shutdown(); copier.join(); int r = proc.waitFor(); // System.out.println("south completed"); Assert.assertEquals("exit code should have been 0", 0, r); }
public Channel start() throws Exception { System.out.println("forking a new process"); // proc = Runtime.getRuntime().exec("java -Xdebug // -Xrunjdwp:transport=dt_socket,server=y,address=8000 hudson.remoting.Launcher"); System.out.println(getClasspath()); proc = Runtime.getRuntime() .exec(new String[] {"java", "-cp", getClasspath(), "hudson.remoting.Launcher"}); copier = new Copier("copier", proc.getErrorStream(), System.out); copier.start(); executor = Executors.newCachedThreadPool(); OutputStream out = proc.getOutputStream(); if (RECORD_OUTPUT) { File f = File.createTempFile("remoting", ".log"); System.out.println("Recording to " + f); out = new TeeOutputStream(out, new FileOutputStream(f)); } return new Channel("north", executor, proc.getInputStream(), out); }
@Test(expected = RuntimeException.class) public void testParseSemAnnotacao() { copier.from(new NoAnnotationSource("BB", "123321")).doCopy(); }
@Test(expected = IllegalArgumentException.class) public void whenPassingNullToFromAnnotedObject() { copier.from(null); }
@Override public CopyResponse copy(final CopyRequest request) throws Exception { return Copier.copy(request); }