java - How do I use jdepend's JavaPackage.containsCycle() in junit to detect whether my package is on a package cycle? -


I want to test through jdepend to see if my package tree is a package cycle (i.e., a direct cyclical dependency is) at is currently, it is not (see the output below, and jdepend's Eclipse plugin for tree Cycle is not found). But the below given idea, suggested in jdepend's manual, failed:

  // setup .... JavaPackage p = jdepend.getPackage ("tree"); System.out.println (p.getName (+ "Expiration Packages:"); For (object jp: p.getEfferents ()) {System.out.println (javaPackage) jp) .getName ()); } AssertThat (p.containsCycle (), is (wrong));   

Output is:

  Tree's dependency packages: java.util java.lang java.lang.reflect java.util.logging java.io org Hmmmbrist The reason for this argument failure is that the  cycles in ()  recursively getEfferents () calls, the resulting package puts it in the list and  True  If some package is already in it, therefore  in the cycle ()  checks if there is a  accessible  package cycle (i.e. tree indirect cyclical dependence is).  

But how can I test only the direct cyclical dependencies, i.e. that tree on package cycle (and no, it leads to any other package cycle, such as org .hamcrest)?

The following solutions do not work as usual, but as an alternative solution:

Instead of checking that there is a direct package dependency of the tree, you can go through the p.containsCycle () , but only indirect package dependency after the following code (i.e. ):

  final package filter filter = new package filter (); Jdepend.setFilter (filter); Filter.addPackage ("org.hamcrest");   

In this way, the tree-dependent package (see the output listed in question), but those who have their own chakra, they are already filtered

the downside That is, if you import new ones, you may have to add a package to the filter and you have to set up separate tests for different tests, because you do not want to use that filter to calculate other metrics , Such as Main sequence distance, d. Last but not least, if the tree - & gt; Your filter package is part of the direct cycle, it will not be detected: (

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -