From e4874e6076b0fe409718d2585ebd57eb3b972ddd Mon Sep 17 00:00:00 2001 From: Aman Sharma Date: Thu, 1 Aug 2024 15:49:25 +0200 Subject: [PATCH] tests: add test that shows difference in classfile version only --- .../diff/visitor/ClassFileVisitorTest.java | 25 ++++++++++++++++++ .../classfileVersion/ClientMain6.class | Bin 0 -> 6046 bytes .../classfileVersion/ClientMain8.class | Bin 0 -> 6025 bytes 3 files changed, 25 insertions(+) create mode 100644 src/test/resources/classfileVersion/ClientMain6.class create mode 100644 src/test/resources/classfileVersion/ClientMain8.class diff --git a/src/test/java/io/github/algomaster99/bytecode/diff/visitor/ClassFileVisitorTest.java b/src/test/java/io/github/algomaster99/bytecode/diff/visitor/ClassFileVisitorTest.java index 04e7df99f5..d4584a987a 100644 --- a/src/test/java/io/github/algomaster99/bytecode/diff/visitor/ClassFileVisitorTest.java +++ b/src/test/java/io/github/algomaster99/bytecode/diff/visitor/ClassFileVisitorTest.java @@ -100,4 +100,29 @@ void shouldShowDiffIf_orderOfFieldAndMethodsAreFlipped() throws IOException { List rootOperations = diff.getSimplifiedOperations().asList(); assertThat(rootOperations).size().isEqualTo(12); } + + @Test + void shouldShowDiff_onlyInClassfileVersion() throws IOException { + // arrange + Path proxy1 = RESOURCES.resolve("classfileVersion").resolve("ClientMain6.class"); + Path proxy2 = RESOURCES.resolve("classfileVersion").resolve("ClientMain8.class"); + byte[] bytes1 = Files.readAllBytes(proxy1); + byte[] bytes2 = Files.readAllBytes(proxy2); + final Builder scanner = new Builder(); + + // act + DiffImpl diff = new DiffImpl(scanner.getTreeContext(), scanner.getTree(bytes1), scanner.getTree(bytes2)); + diff.computeDiff(); + + // assert + List rootOperations = diff.getSimplifiedOperations().asList(); + assertThat(rootOperations).size().isEqualTo(1); + + Update classfileVersion = (Update) rootOperations.get(0); + assertThat(classfileVersion.getNode().getType()).isEqualTo(TypeSet.type(DiffTypes.DIFF_IN_MAJOR_VERSION)); + String oldVersion = classfileVersion.getNode().getLabel(); + assertThat(oldVersion).isEqualTo("50"); + String newVersion = classfileVersion.getValue(); + assertThat(newVersion).isEqualTo("52"); + } } diff --git a/src/test/resources/classfileVersion/ClientMain6.class b/src/test/resources/classfileVersion/ClientMain6.class new file mode 100644 index 0000000000000000000000000000000000000000..f645b71deb816815b1a0b4c5cf469990cc9f3bc3 GIT binary patch literal 6046 zcmb7I349!775{(DCbOALn(ek}yKQN=r7cOf=|X5I-L!?A5SlbGM>UjMr`bue?Ph1$ zo$Vna77-K=6hSSBASwm9i*5o{C?2SQx8j8dhzEF};>98L|IN%MyJ^yDo8LFzyzjmD zz5BhL$6tTwVF0zFNkt!SQt=7gESFo#@JZY%mrp79w1Us5D8X$C4yh=`O-}UQThCmf-jfiEBLC4DmP?8|#BePDNop0w?w;2+Eb0kvh{fRU6Eq!s*A!M`X+Can)qj`^+)VrICD4zlPb zLm#P^o)A=|(z$BVDUC5gn^N+sZ4N@dizV$0Q~I#ezH|I?0j({OFj7r%-7%9ic4{ac z9!g}wO(Rk1@-97{>@f#7uLt`ejwF*8;&Lr;6th7s+JjmQ8P(f9Qwqd)PT_%lQ~y0kw9x?Dr?w=ixj-9;T629;Whk+A*SJV9MgEM5SU{p zd@g&&Gp(`!oJ%TA%n(HaXE=w9v4LTo@exml`x5C)GHIqPBkJ<#Wmb&4l96DCZzSl* z7u;q#(Y-ym!A<{7ituQnSd?(VMXVkTd-PabR*s;H8xg1r25W{_*VIU-29NvKGi>e+ z%K8$t&-Fw!XzYtwYXmlt&Lo}Vs30p|K5@69N5gwlG0O->bxRLgW-uB{83UATzr-a2 zd2x&kY~KdkS{s^L@;EfcconIbjz&tB3kQRAyr(8jIvEDRo|dN0EzLa>gfg%soqehg zk~kQ3ql%?BSQRw}^-SD~kny1Owh`Z7O{UFc8YNRkOid0yxVbS*{^Z@E?;Gb5WEnH^ z_+%3C*a-PVC7VXF$+&DXc3@91aoD)f6EO+O2BRnSfng)euERbfyM-Ay8j?vP5tU77 z@o^|!x6h(M7Q7TlH>1oQ3 z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z96>7$bzXnKCq{ApDB7~PAmFQ1v)FtX?EyNnBa1Bup-2s-?!Lq5^1neIbO(G7qQ`?` zp4`uf=wmc)r^8+nTSY%3w#bg@TL}T#z?E*w09RD=9A}?d7C? zI~{x(UHuM5-2qa(i~p}=yj_KBa5Zkk`*0iH&+n|);BkDAA2YATv-mKc$8~rS*W)Fo z-^;jxzpZW*^Kr9Sf?LE&e%0EDL!ueCi*DQ@w&EU2cc<8fyF?s!izM!~gX%5@&JJeV zK3oDXsW;(ml*&iEN=kJZ1CwDzxeid9h2(NM-pQa_E;?`prJI2o-tcbjim*;Z7_?V0 zCmY1+cn^2Q*i1RD=B@;NVv((nLT#R+KK;zG+wcUn>SrkP3o<@H?NsV_h#G!~>G3o* zyOz6h>Us^eJ%9>3XZxWXqshDqu2XQmf{#r4gHZ6%xeJalt7cAzqu^uw6GcTt0A9t; zMg<4wQluNkD`mBv>dZ5L?HGC=K$lEjVf%KbT?Iqbelb Zl+ud}aV4MU@k8=&sOJmVD9%1N@Lz=Ge%}B9 literal 0 HcmV?d00001 diff --git a/src/test/resources/classfileVersion/ClientMain8.class b/src/test/resources/classfileVersion/ClientMain8.class new file mode 100644 index 0000000000000000000000000000000000000000..6748d08a4e457ceac034aa5da82c45daadcd0501 GIT binary patch literal 6025 zcmb7I349z?9sXXj$!xZhX4#(Gb9bS$;DrYWDqe_q0#d&>Gn;PG6tK;2_RV|$`+jre zjfWlvuu`n?p#X&nJSvJ%Ea2a+?b0F%E!iLG*tT7dS^~vu;>ozRR-mw=a-$Dklqm42 zm;zNGXoDwpE3#g@2 z*-TYY20uk2omN8C$6}_QPU~s1t#FYuRy+}DPG$ymQ?uemvTh0jn5JO5iW!(GFvI3L z5lWzJKufn9rrw;;2lb>yl2mS!M4qi8h&cjNlKPP49t%v*G0d|}oq~Bh8M8p1j0zUy zcuV!<$x2szALb&YVi6V#sMM^@h-!&*j5G~BJI5r4uD zt@WW2RSLo?mZMr=n$3*7HqccT9j0r80!m80C6d%_GJi5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