ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jlboud...@apache.org
Subject svn commit: r1557968 [19/26] - in /ant/ivy/core/trunk: src/java/org/apache/ivy/ src/java/org/apache/ivy/ant/ src/java/org/apache/ivy/core/ src/java/org/apache/ivy/core/cache/ src/java/org/apache/ivy/core/check/ src/java/org/apache/ivy/core/deliver/ src...
Date Tue, 14 Jan 2014 08:27:43 GMT
Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/core/module/id/ModuleIdTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/core/module/id/ModuleIdTest.java?rev=1557968&r1=1557967&r2=1557968&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/core/module/id/ModuleIdTest.java (original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/core/module/id/ModuleIdTest.java Tue Jan 14 08:27:37 2014
@@ -25,15 +25,15 @@ public class ModuleIdTest extends TestCa
         String org = "apache";
         String name = "some-new-module";
         ModuleId moduleId = new ModuleId(org, name);
-        
+
         assertEquals(org, moduleId.getOrganisation());
         assertEquals(name, moduleId.getName());
     }
-    
+
     public void testModuleIdIllegalArgumentException() {
         String org = "apache";
         String name = "some-new-module";
-        
+
         try {
             new ModuleId(null, name);
         } catch (IllegalArgumentException iae) {
@@ -53,7 +53,7 @@ public class ModuleIdTest extends TestCa
         String name = "some-new-module";
         ModuleId moduleId = new ModuleId(org, name);
         ModuleId moduleId2 = new ModuleId(org, name);
-        
+
         assertTrue(moduleId.equals(moduleId));
         assertTrue(moduleId.equals(moduleId2));
         assertTrue(moduleId2.equals(moduleId));
@@ -64,17 +64,17 @@ public class ModuleIdTest extends TestCa
         String name = "some-new-module";
         ModuleId moduleId = new ModuleId(org, name);
         ModuleId moduleId2 = new ModuleId(null, name);
-        
+
         assertFalse(moduleId.equals(null));
         assertFalse(moduleId.equals(moduleId2));
         assertFalse(moduleId2.equals(moduleId));
     }
-    
+
     public void testEncodeToString() {
         String org = "apache";
         String name = "some-new-module";
         ModuleId moduleId = new ModuleId(org, name);
-        
+
         assertEquals(org + ModuleId.ENCODE_SEPARATOR + name, moduleId.encodeToString());
     }
 
@@ -82,19 +82,18 @@ public class ModuleIdTest extends TestCa
         String org = "apache";
         String name = "some-new-module";
         ModuleId moduleId = new ModuleId(org, name);
-        
+
         ModuleId moduleId2 = ModuleId.decode(moduleId.encodeToString());
         assertEquals(moduleId, moduleId2);
     }
 
-    
     public void testCompareToNullObject() {
         String org = "apache";
         String name = "some-new-module";
         ModuleId moduleId = new ModuleId(org, name);
 
         try {
-            moduleId.compareTo(null);            
+            moduleId.compareTo(null);
             fail("A NullPointerException was expected.");
         } catch (NullPointerException npe) {
             // success
@@ -107,7 +106,7 @@ public class ModuleIdTest extends TestCa
         ModuleId moduleId = new ModuleId(org, name);
 
         try {
-            moduleId.compareTo(new String());            
+            moduleId.compareTo(new String());
             fail("A ClassCastException was expected.");
         } catch (ClassCastException cce) {
             // success
@@ -132,7 +131,7 @@ public class ModuleIdTest extends TestCa
 
         assertTrue(moduleId.compareTo(moduleId2) < 0);
     }
-    
+
     public void testCompareToGreatherThan() {
         String org = "apache";
         String name = "some-new-module";
@@ -140,7 +139,7 @@ public class ModuleIdTest extends TestCa
         String name2 = "the-new-module";
         ModuleId moduleId2 = new ModuleId(org, name2);
         System.out.println(moduleId + "\n" + moduleId2);
-        
+
         assertTrue(moduleId2.compareTo(moduleId) > 0);
     }
 }

Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/core/module/id/ModuleRevisionIdTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/core/module/id/ModuleRevisionIdTest.java?rev=1557968&r1=1557967&r2=1557968&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/core/module/id/ModuleRevisionIdTest.java (original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/core/module/id/ModuleRevisionIdTest.java Tue Jan 14 08:27:37 2014
@@ -23,7 +23,7 @@ import java.util.Map;
 import junit.framework.TestCase;
 
 public class ModuleRevisionIdTest extends TestCase {
-    
+
     public void testParse() throws Exception {
         testParse("#A;1.0");
         testParse("org#module;2.0");
@@ -32,7 +32,7 @@ public class ModuleRevisionIdTest extend
         testParse("org#module#branch;working@test");
         testParse(" org#module#branch;[1.2,1.3] ");
         testParse(" org#module#branch;[1.2,1.3) ");
-        
+
         testParseFailure("bad");
         testParseFailure("org#mod");
         testParseFailure("#;1");
@@ -42,9 +42,9 @@ public class ModuleRevisionIdTest extend
     private void testParseFailure(String mrid) {
         try {
             ModuleRevisionId.parse(mrid);
-            fail("ModuleRevisionId.parse is supposed to raise an exception with "+mrid);
+            fail("ModuleRevisionId.parse is supposed to raise an exception with " + mrid);
         } catch (IllegalArgumentException ex) {
-            assertTrue(ex.getMessage().indexOf(mrid) != - 1);
+            assertTrue(ex.getMessage().indexOf(mrid) != -1);
         }
     }
 
@@ -70,7 +70,7 @@ public class ModuleRevisionIdTest extend
     private void testEncodeDecodeToString(ModuleRevisionId mrid) {
         assertEquals(mrid, ModuleRevisionId.decode(mrid.encodeToString()));
     }
-    
+
     private void testParse(String mrid) {
         assertEquals(mrid.trim(), ModuleRevisionId.parse(mrid).toString());
     }

Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/core/module/id/ModuleRulesTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/core/module/id/ModuleRulesTest.java?rev=1557968&r1=1557967&r2=1557968&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/core/module/id/ModuleRulesTest.java (original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/core/module/id/ModuleRulesTest.java Tue Jan 14 08:27:37 2014
@@ -30,7 +30,8 @@ import org.apache.ivy.util.filter.NoFilt
 import junit.framework.TestCase;
 
 public class ModuleRulesTest extends TestCase {
-	private ModuleRules rules;
+    private ModuleRules rules;
+
     private Object[] rule;
 
     protected void setUp() throws Exception {
@@ -42,12 +43,12 @@ public class ModuleRulesTest extends Tes
     }
 
     // tests
-    
+
     public void testGetRule() throws Exception {
         // fixture
         rules.defineRule(mapMatcher().organization("apache").build(), rule[0]);
         rules.defineRule(mapMatcher().organization("other").build(), rule[1]);
-        
+
         // test
         assertRule(rule[0], "apache#module1;1.5");
         assertRule(rule[0], "apache#module2;3.0");
@@ -60,7 +61,7 @@ public class ModuleRulesTest extends Tes
         rules.defineRule(mapMatcher().organization("apache").build(), rule[0]);
         rules.defineRule(mapMatcher().module("module1").build(), rule[1]);
         rules.defineRule(mapMatcher().module("module2").build(), rule[2]);
-        
+
         // test
         assertRule(rule[0], "apache#module1;1.5", acceptAll());
         assertRule(rule[1], "apache#module1;1.5", acceptSecond());
@@ -70,9 +71,8 @@ public class ModuleRulesTest extends Tes
         assertRule(null, "unknown#module4;1.5", acceptAll());
     }
 
-    
     // test helpers
-    
+
     private Filter acceptNone() {
         return new Filter() {
             public boolean accept(Object o) {
@@ -92,7 +92,7 @@ public class ModuleRulesTest extends Tes
             public boolean accept(Object o) {
                 return ++cpt == 2;
             }
-        
+
             public String toString() {
                 return "AcceptSecond";
             }
@@ -105,23 +105,17 @@ public class ModuleRulesTest extends Tes
 
     private void assertRule(Object rule, String mrid) {
         Object ruleFound = rules.getRule(ModuleRevisionId.parse(mrid));
-        assertEquals(
-            "unexcepted rule for " + mrid,
-            rule, ruleFound);
+        assertEquals("unexcepted rule for " + mrid, rule, ruleFound);
     }
 
     private void assertRule(Object rule, String mrid, Filter filter) {
         Object ruleFound = rules.getRule(ModuleRevisionId.parse(mrid), filter);
-        assertEquals(
-            "unexcepted rule for " + mrid + " filtered by " + filter,
-            rule, ruleFound);
+        assertEquals("unexcepted rule for " + mrid + " filtered by " + filter, rule, ruleFound);
     }
 
     private void assertModuleIdRule(Object rule, String mid, Filter filter) {
         Object ruleFound = rules.getRule(ModuleId.parse(mid), filter);
-        assertEquals(
-            "unexcepted rule for " + mid + " filtered by " + filter,
-            rule, ruleFound);
+        assertEquals("unexcepted rule for " + mid + " filtered by " + filter, rule, ruleFound);
     }
 
     private MridMatcherBuilder mapMatcher() {
@@ -130,8 +124,9 @@ public class ModuleRulesTest extends Tes
 
     public class MridMatcherBuilder {
         private Map attributes = new HashMap();
+
         private PatternMatcher matcher = ExactPatternMatcher.INSTANCE;
-        
+
         public MridMatcherBuilder organization(String org) {
             attributes.put(IvyPatternHelper.ORGANISATION_KEY, org);
             return this;

Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/core/publish/PublishEngineTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/core/publish/PublishEngineTest.java?rev=1557968&r1=1557967&r2=1557968&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/core/publish/PublishEngineTest.java (original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/core/publish/PublishEngineTest.java Tue Jan 14 08:27:37 2014
@@ -44,6 +44,7 @@ public class PublishEngineTest extends T
         System.setProperty("ivy.cache.dir", new File("build/test/publish/cache").getAbsolutePath());
         FileUtil.forceDelete(new File("build/test/publish"));
     }
+
     protected void tearDown() throws Exception {
         FileUtil.forceDelete(new File("build/test/publish"));
     }
@@ -52,18 +53,18 @@ public class PublishEngineTest extends T
         IvySettings settings = new IvySettings();
         final PublishEngine engine = new PublishEngine(settings, new EventManager());
         final int[] counter = new int[] {0};
-        
+
         final DefaultModuleDescriptor md = DefaultModuleDescriptor
-            .newDefaultInstance(ModuleRevisionId.parse("#A;1.0"));
+                .newDefaultInstance(ModuleRevisionId.parse("#A;1.0"));
         final FileSystemResolver resolver = new FileSystemResolver() {
             public void publish(Artifact artifact, File src, boolean overwrite) throws IOException {
                 super.publish(artifact, src, overwrite);
                 synchronized (PublishEngineTest.this) {
-                    counter[0] ++;
+                    counter[0]++;
                 }
                 sleepSilently(50);
                 synchronized (PublishEngineTest.this) {
-                    counter[0] ++;
+                    counter[0]++;
                 }
             }
         };
@@ -72,10 +73,9 @@ public class PublishEngineTest extends T
         String publishRepoDir = new File("build/test/publish/repo").getAbsolutePath();
         resolver.addIvyPattern(publishRepoDir + "/[module]/[revision]/[artifact].[ext]");
         resolver.addArtifactPattern(publishRepoDir + "/[module]/[revision]/[artifact].[ext]");
-        
-        FileUtil.copy(
-            new File("test/repositories/1/org1/mod1.1/jars/mod1.1-1.0.jar"), 
-            new File("build/test/publish/module/A.jar"), null);
+
+        FileUtil.copy(new File("test/repositories/1/org1/mod1.1/jars/mod1.1-1.0.jar"), new File(
+                "build/test/publish/module/A.jar"), null);
         XmlModuleDescriptorWriter.write(md, new File("build/test/publish/module/ivy.xml"));
 
         resolveAndAssertNotFound(settings, resolver, "#A;latest.integration", "before publishing");
@@ -84,13 +84,12 @@ public class PublishEngineTest extends T
         new Thread() {
             public void run() {
                 try {
-                    engine.publish(
-                        md, 
-                        Arrays.asList(new String[] {"build/test/publish/module/[artifact].[ext]"}), 
-                        resolver, 
-                        new PublishOptions().setSrcIvyPattern("build/test/publish/module/[artifact].[ext]"));
+                    engine.publish(md, Arrays
+                            .asList(new String[] {"build/test/publish/module/[artifact].[ext]"}),
+                        resolver, new PublishOptions()
+                                .setSrcIvyPattern("build/test/publish/module/[artifact].[ext]"));
                     synchronized (PublishEngineTest.this) {
-                        counter[0] ++;
+                        counter[0]++;
                     }
                 } catch (IOException e) {
                     throw new RuntimeException(e);
@@ -98,42 +97,41 @@ public class PublishEngineTest extends T
             }
         }.start();
 
-        while(true) {
+        while (true) {
             sleepSilently(5);
             synchronized (this) {
                 if (counter[0] == 5) {
                     break;
                 } else if (counter[0] < 4) {
-                    resolveAndAssertNotFound(settings, resolver, 
-                        "#A;latest.integration", "after "+(counter[0] / 2)+" artifacts published");
+                    resolveAndAssertNotFound(settings, resolver, "#A;latest.integration", "after "
+                            + (counter[0] / 2) + " artifacts published");
                 }
             }
         }
         resolveAndAssertFound(settings, resolver, "#A;1.0");
     }
-    private void resolveAndAssertNotFound(
-            IvySettings settings, FileSystemResolver resolver, String module, String context)
-            throws ParseException {
+
+    private void resolveAndAssertNotFound(IvySettings settings, FileSystemResolver resolver,
+            String module, String context) throws ParseException {
         ResolvedModuleRevision rmr = resolveModule(settings, resolver, module);
-        assertNull("module found " + context + ". module="+rmr, rmr);
+        assertNull("module found " + context + ". module=" + rmr, rmr);
     }
 
-    private void resolveAndAssertFound(
-            IvySettings settings, FileSystemResolver resolver, String module)
-            throws ParseException {
+    private void resolveAndAssertFound(IvySettings settings, FileSystemResolver resolver,
+            String module) throws ParseException {
         ResolvedModuleRevision rmr = resolveModule(settings, resolver, module);
         assertNotNull(rmr);
         assertEquals(module, rmr.getId().toString());
     }
-    private ResolvedModuleRevision resolveModule(
-            IvySettings settings, FileSystemResolver resolver, String module)
-            throws ParseException {
+
+    private ResolvedModuleRevision resolveModule(IvySettings settings, FileSystemResolver resolver,
+            String module) throws ParseException {
         return resolver.getDependency(
-            new DefaultDependencyDescriptor(ModuleRevisionId.parse(module), false), 
-            new ResolveData(
-                new ResolveEngine(settings, new EventManager(), new SortEngine(settings)), 
-                new ResolveOptions()));
+            new DefaultDependencyDescriptor(ModuleRevisionId.parse(module), false),
+            new ResolveData(new ResolveEngine(settings, new EventManager(),
+                    new SortEngine(settings)), new ResolveOptions()));
     }
+
     private void sleepSilently(int timeout) {
         try {
             Thread.sleep(timeout);

Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/core/publish/PublishEventsTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/core/publish/PublishEventsTest.java?rev=1557968&r1=1557967&r2=1557968&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/core/publish/PublishEventsTest.java (original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/core/publish/PublishEventsTest.java Tue Jan 14 08:27:37 2014
@@ -42,92 +42,108 @@ import junit.framework.TestCase;
 
 public class PublishEventsTest extends TestCase {
 
-    //maps ArtifactRevisionId to PublishTestCase instance.
+    // maps ArtifactRevisionId to PublishTestCase instance.
     private HashMap expectedPublications;
-    //expected values for the current artifact being published.
+
+    // expected values for the current artifact being published.
     private PublishTestCase currentTestCase;
+
     private boolean expectedOverwrite;
-    
-    //number of times PrePublishTrigger has been invoked successfully
+
+    // number of times PrePublishTrigger has been invoked successfully
     private int preTriggers;
-    //number of times PostPublishTrigger has been invoked successfully
+
+    // number of times PostPublishTrigger has been invoked successfully
     private int postTriggers;
-    //number of times an artifact has been successfully published by the resolver
+
+    // number of times an artifact has been successfully published by the resolver
     private int publications;
 
-    //dummy test data that is reused by all cases.
+    // dummy test data that is reused by all cases.
     private File ivyFile;
+
     private Artifact ivyArtifact;
+
     private File dataFile;
+
     private Artifact dataArtifact;
-    
+
     private ModuleDescriptor publishModule;
+
     private Collection publishSources;
+
     private PublishOptions publishOptions;
 
-    //if non-null, InstrumentedResolver will throw this exception during publish
+    // if non-null, InstrumentedResolver will throw this exception during publish
     private IOException publishError;
-    
-    //the ivy instance under test
+
+    // the ivy instance under test
     private Ivy ivy;
+
     private PublishEngine publishEngine;
 
     protected void setUp() throws Exception {
         super.setUp();
-        
-        //reset test case state.
+
+        // reset test case state.
         resetCounters();
-        
-        //this ivy settings should configure an InstrumentedResolver, PrePublishTrigger, and PostPublishTrigger
-        //(see inner classes below).
+
+        // this ivy settings should configure an InstrumentedResolver, PrePublishTrigger, and
+        // PostPublishTrigger
+        // (see inner classes below).
         ivy = Ivy.newInstance();
         ivy.configure(PublishEventsTest.class.getResource("ivysettings-publisheventstest.xml"));
         ivy.pushContext();
         publishEngine = ivy.getPublishEngine();
 
-        //setup dummy ivy and data files to test publishing.  since we're testing the engine and not the resolver,
-        //we don't really care whether the file actually gets published.  we just want to make sure
-        //that the engine calls the correct methods in the correct order, and fires required events.
+        // setup dummy ivy and data files to test publishing. since we're testing the engine and not
+        // the resolver,
+        // we don't really care whether the file actually gets published. we just want to make sure
+        // that the engine calls the correct methods in the correct order, and fires required
+        // events.
         ivyFile = new File("test/java/org/apache/ivy/core/publish/ivy-1.0-dev.xml");
         assertTrue("path to ivy file not found in test environment", ivyFile.exists());
-        //the contents of the data file don't matter.
+        // the contents of the data file don't matter.
         dataFile = File.createTempFile("ivydata", ".jar");
         dataFile.deleteOnExit();
-        
+
         publishModule = XmlModuleDescriptorParser.getInstance().parseDescriptor(ivy.getSettings(),
             ivyFile.toURI().toURL(), false);
-        //always use the same source data file, no pattern substitution is required.
+        // always use the same source data file, no pattern substitution is required.
         publishSources = Collections.singleton(dataFile.getAbsolutePath());
-        //always use the same ivy file, no pattern substitution is required.
+        // always use the same ivy file, no pattern substitution is required.
         publishOptions = new PublishOptions();
         publishOptions.setSrcIvyPattern(ivyFile.getAbsolutePath());
-        
-        //set up our expectations for the test.  these variables will
-        //be checked by the resolver and triggers during publication.
+
+        // set up our expectations for the test. these variables will
+        // be checked by the resolver and triggers during publication.
         dataArtifact = publishModule.getAllArtifacts()[0];
         assertEquals("sanity check", "foo", dataArtifact.getName());
         ivyArtifact = MDArtifact.newIvyArtifact(publishModule);
 
         expectedPublications = new HashMap();
-        expectedPublications.put(dataArtifact.getId(), new PublishTestCase(dataArtifact, dataFile, true));
-        expectedPublications.put(ivyArtifact.getId(), new PublishTestCase(ivyArtifact, ivyFile, true));
-        assertEquals("hashCode sanity check:  two artifacts expected during publish", 2, expectedPublications.size());
+        expectedPublications.put(dataArtifact.getId(), new PublishTestCase(dataArtifact, dataFile,
+                true));
+        expectedPublications.put(ivyArtifact.getId(), new PublishTestCase(ivyArtifact, ivyFile,
+                true));
+        assertEquals("hashCode sanity check:  two artifacts expected during publish", 2,
+            expectedPublications.size());
 
-        //push the TestCase instance onto the context stack, so that our
-        //triggers and resolver instances can interact with it it.
+        // push the TestCase instance onto the context stack, so that our
+        // triggers and resolver instances can interact with it it.
         IvyContext.getContext().push(PublishEventsTest.class.getName(), this);
     }
-    
+
     protected void tearDown() throws Exception {
         super.tearDown();
 
-        //reset test state.
+        // reset test state.
         resetCounters();
-        
-        //test case is finished, pop the test context off the stack.
+
+        // test case is finished, pop the test context off the stack.
         IvyContext.getContext().pop(PublishEventsTest.class.getName());
-        
-        //cleanup ivy resources
+
+        // cleanup ivy resources
         if (ivy != null) {
             ivy.popContext();
             ivy = null;
@@ -143,45 +159,50 @@ public class PublishEventsTest extends T
         preTriggers = 0;
         postTriggers = 0;
         publications = 0;
-        
+
         expectedPublications = null;
         expectedOverwrite = false;
         publishError = null;
         currentTestCase = null;
-        
+
         ivyArtifact = null;
         dataArtifact = null;
     }
-    
+
     /**
      * Test a simple artifact publish, without errors or overwrite settings.
      */
     public void testPublishNoOverwrite() throws IOException {
-        //no modifications to input required for this case -- call out to the resolver, and verify that
-        //all of our test counters have been incremented.
-        Collection missing = publishEngine.publish(publishModule.getModuleRevisionId(), publishSources, "default", publishOptions);
+        // no modifications to input required for this case -- call out to the resolver, and verify
+        // that
+        // all of our test counters have been incremented.
+        Collection missing = publishEngine.publish(publishModule.getModuleRevisionId(),
+            publishSources, "default", publishOptions);
         assertEquals("no missing artifacts", 0, missing.size());
-        
-        //if all tests passed, all of our counter variables should have been updated.
+
+        // if all tests passed, all of our counter variables should have been updated.
         assertEquals("pre-publish trigger fired and passed all tests", 2, preTriggers);
         assertEquals("post-publish trigger fired and passed all tests", 2, postTriggers);
         assertEquals("resolver received a publish() call, and passed all tests", 2, publications);
         assertEquals("all expected artifacts have been published", 0, expectedPublications.size());
     }
-    
+
     /**
      * Test a simple artifact publish, with overwrite set to true.
      */
     public void testPublishWithOverwrite() throws IOException {
-        //we expect the overwrite settings to be passed through the event listeners and into the publisher.
+        // we expect the overwrite settings to be passed through the event listeners and into the
+        // publisher.
         this.expectedOverwrite = true;
-        
-        //set overwrite to true.  InstrumentedResolver will verify that the correct argument value was provided.
+
+        // set overwrite to true. InstrumentedResolver will verify that the correct argument value
+        // was provided.
         publishOptions.setOverwrite(true);
-        Collection missing = publishEngine.publish(publishModule.getModuleRevisionId(), publishSources, "default", publishOptions);
+        Collection missing = publishEngine.publish(publishModule.getModuleRevisionId(),
+            publishSources, "default", publishOptions);
         assertEquals("no missing artifacts", 0, missing.size());
-        
-        //if all tests passed, all of our counter variables should have been updated.
+
+        // if all tests passed, all of our counter variables should have been updated.
         assertEquals("pre-publish trigger fired and passed all tests", 2, preTriggers);
         assertEquals("post-publish trigger fired and passed all tests", 2, postTriggers);
         assertEquals("resolver received a publish() call, and passed all tests", 2, publications);
@@ -192,247 +213,274 @@ public class PublishEventsTest extends T
      * Test an attempted publish with an invalid data file path.
      */
     public void testPublishMissingFile() throws IOException {
-        //delete the datafile.  the publish should fail
-        //and the ivy artifact should still publish successfully.
+        // delete the datafile. the publish should fail
+        // and the ivy artifact should still publish successfully.
         assertTrue("datafile has been destroyed", dataFile.delete());
-        PublishTestCase dataPublish = (PublishTestCase)expectedPublications.get(dataArtifact.getId());
+        PublishTestCase dataPublish = (PublishTestCase) expectedPublications.get(dataArtifact
+                .getId());
         dataPublish.expectedSuccess = false;
-        Collection missing = publishEngine.publish(publishModule.getModuleRevisionId(), publishSources, "default", publishOptions);
+        Collection missing = publishEngine.publish(publishModule.getModuleRevisionId(),
+            publishSources, "default", publishOptions);
         assertEquals("one missing artifact", 1, missing.size());
-        assertSameArtifact("missing artifact was returned", dataArtifact, (Artifact)missing.iterator().next());
-        
-        //if all tests passed, all of our counter variables should have been updated.
+        assertSameArtifact("missing artifact was returned", dataArtifact, (Artifact) missing
+                .iterator().next());
+
+        // if all tests passed, all of our counter variables should have been updated.
         assertEquals("pre-publish trigger fired and passed all tests", 1, preTriggers);
         assertEquals("post-publish trigger fired and passed all tests", 1, postTriggers);
         assertEquals("only the ivy file published successfully", 1, publications);
-        assertEquals("publish of all expected artifacts has been attempted", 1, expectedPublications.size());
+        assertEquals("publish of all expected artifacts has been attempted", 1,
+            expectedPublications.size());
     }
 
     /**
      * Test an attempted publish in which the target resolver throws an IOException.
      */
     public void testPublishWithException() {
-        //set an error to be thrown during publication of the data file.
+        // set an error to be thrown during publication of the data file.
         this.publishError = new IOException("boom!");
-        //we don't care which artifact is attempted; either will fail with an IOException.
-        for (Iterator it = expectedPublications.values().iterator(); it.hasNext(); )
-            ((PublishTestCase)it.next()).expectedSuccess = false;
+        // we don't care which artifact is attempted; either will fail with an IOException.
+        for (Iterator it = expectedPublications.values().iterator(); it.hasNext();)
+            ((PublishTestCase) it.next()).expectedSuccess = false;
 
         try {
-            publishEngine.publish(publishModule.getModuleRevisionId(), publishSources, "default", publishOptions);
+            publishEngine.publish(publishModule.getModuleRevisionId(), publishSources, "default",
+                publishOptions);
             fail("if the resolver throws an exception, the engine should too");
         } catch (IOException expected) {
-            assertSame("exception thrown by the resolver should be propagated by the engine", 
-                       this.publishError, expected);
+            assertSame("exception thrown by the resolver should be propagated by the engine",
+                this.publishError, expected);
         }
-        
-        //the publish engine gives up after the resolver throws an exception on the first artifact,
-        //so only one set of events should have been fired.
-        //note that the initial publish error shouldn't prevent the post-publish trigger from firing.
+
+        // the publish engine gives up after the resolver throws an exception on the first artifact,
+        // so only one set of events should have been fired.
+        // note that the initial publish error shouldn't prevent the post-publish trigger from
+        // firing.
         assertEquals("pre-publish trigger fired and passed all tests", 1, preTriggers);
         assertEquals("post-publish trigger fired and passed all tests", 1, postTriggers);
         assertEquals("resolver never published successfully", 0, publications);
         assertEquals("publication aborted after first failure", 1, expectedPublications.size());
     }
-    
+
     /**
      * Assert that two Artifact instances refer to the same artifact and contain the same metadata.
      */
     public static void assertSameArtifact(String message, Artifact expected, Artifact actual) {
         assertEquals(message + ": name", expected.getName(), actual.getName());
         assertEquals(message + ": id", expected.getId(), actual.getId());
-        assertEquals(message + ": moduleRevisionId", expected.getModuleRevisionId(), actual.getModuleRevisionId());
-        assertTrue(message + ": configurations", Arrays.equals(expected.getConfigurations(), actual.getConfigurations()));
+        assertEquals(message + ": moduleRevisionId", expected.getModuleRevisionId(),
+            actual.getModuleRevisionId());
+        assertTrue(message + ": configurations",
+            Arrays.equals(expected.getConfigurations(), actual.getConfigurations()));
         assertEquals(message + ": type", expected.getType(), actual.getType());
         assertEquals(message + ": ext", expected.getExt(), actual.getExt());
-        assertEquals(message + ": publicationDate", expected.getPublicationDate(), actual.getPublicationDate());
+        assertEquals(message + ": publicationDate", expected.getPublicationDate(),
+            actual.getPublicationDate());
         assertEquals(message + ": attributes", expected.getAttributes(), actual.getAttributes());
         assertEquals(message + ": url", expected.getUrl(), actual.getUrl());
     }
-    
+
     public static class PublishTestCase {
         public Artifact expectedArtifact;
+
         public File expectedData;
+
         public boolean expectedSuccess;
-        
+
         public boolean preTriggerFired;
+
         public boolean published;
+
         public boolean postTriggerFired;
-        
+
         public PublishTestCase(Artifact artifact, File data, boolean success) {
             this.expectedArtifact = artifact;
             this.expectedData = data;
             this.expectedSuccess = success;
         }
     }
-    
+
     /**
-     * Base class for pre- and post-publish-artifact triggers.  When the trigger receives an event,
+     * Base class for pre- and post-publish-artifact triggers. When the trigger receives an event,
      * the contents of the publish event are examined to make sure they match the variable settings
      * on the calling {@link PublishEventsTest#currentTestCase} instance.
      */
     public static class TestPublishTrigger extends AbstractTrigger {
-        
+
         public void progress(IvyEvent event) {
-            PublishEventsTest test = (PublishEventsTest)IvyContext.getContext().peek(PublishEventsTest.class.getName());
-            InstrumentedResolver resolver = (InstrumentedResolver)test.ivy.getSettings().getResolver("default");
-            
+            PublishEventsTest test = (PublishEventsTest) IvyContext.getContext().peek(
+                PublishEventsTest.class.getName());
+            InstrumentedResolver resolver = (InstrumentedResolver) test.ivy.getSettings()
+                    .getResolver("default");
+
             assertNotNull("instrumented resolver configured", resolver);
             assertNotNull("got a reference to the current unit test case", test);
 
-            //test the proper sequence of events by comparing the number of pre-events,
-            //post-events, and actual publications.
-            assertTrue("event is of correct base type", 
-                        event instanceof PublishEvent);
-            
-            PublishEvent pubEvent = (PublishEvent)event;
+            // test the proper sequence of events by comparing the number of pre-events,
+            // post-events, and actual publications.
+            assertTrue("event is of correct base type", event instanceof PublishEvent);
+
+            PublishEvent pubEvent = (PublishEvent) event;
             Artifact expectedArtifact = test.currentTestCase.expectedArtifact;
             File expectedData = test.currentTestCase.expectedData;
-            
-            assertSameArtifact("event records correct artifact", 
-                               expectedArtifact, pubEvent.getArtifact());
+
+            assertSameArtifact("event records correct artifact", expectedArtifact,
+                pubEvent.getArtifact());
             try {
-                assertEquals("event records correct file", 
-                             expectedData.getCanonicalPath(), pubEvent.getData().getCanonicalPath());
-            
-                assertEquals("event records correct overwrite setting", test.expectedOverwrite, pubEvent.isOverwrite());
+                assertEquals("event records correct file", expectedData.getCanonicalPath(),
+                    pubEvent.getData().getCanonicalPath());
+
+                assertEquals("event records correct overwrite setting", test.expectedOverwrite,
+                    pubEvent.isOverwrite());
                 assertSame("event presents correct resolver", resolver, pubEvent.getResolver());
-    
-                String[] attributes = {
-                        "organisation", "module", "revision", "artifact", "type", "ext", "resolver", "overwrite"
-                };
-                String[] values = {
-                        "apache", "PublishEventsTest", "1.0-dev", expectedArtifact.getName(), expectedArtifact.getType(), expectedArtifact.getExt(), "default", String.valueOf(test.expectedOverwrite)
-                };
-                
+
+                String[] attributes = {"organisation", "module", "revision", "artifact", "type",
+                        "ext", "resolver", "overwrite"};
+                String[] values = {"apache", "PublishEventsTest", "1.0-dev",
+                        expectedArtifact.getName(), expectedArtifact.getType(),
+                        expectedArtifact.getExt(), "default",
+                        String.valueOf(test.expectedOverwrite)};
+
                 for (int i = 0; i < attributes.length; ++i)
-                    assertEquals("event declares correct value for " + attributes[i],
-                                 values[i], event.getAttributes().get(attributes[i]));
-                //we test file separately, since it is hard to guaranteean exact path match, but we want
-                //to make sure that both paths point to the same canonical location on the filesystem
+                    assertEquals("event declares correct value for " + attributes[i], values[i],
+                        event.getAttributes().get(attributes[i]));
+                // we test file separately, since it is hard to guaranteean exact path match, but we
+                // want
+                // to make sure that both paths point to the same canonical location on the
+                // filesystem
                 String filePath = event.getAttributes().get("file").toString();
-                assertEquals("event declares correct value for file", 
-                             expectedData.getCanonicalPath(), new File(filePath).getCanonicalPath());
+                assertEquals("event declares correct value for file",
+                    expectedData.getCanonicalPath(), new File(filePath).getCanonicalPath());
             } catch (IOException ioe) {
                 throw new RuntimeException(ioe);
             }
         }
-        
+
     }
-    
+
     /**
      * Extends the tests done by {@link TestPublishTrigger} to check that pre-publish events are
-     * fired before DependencyResolver.publish() is called, and before post-publish events are fired.
+     * fired before DependencyResolver.publish() is called, and before post-publish events are
+     * fired.
      */
     public static class PrePublishTrigger extends TestPublishTrigger {
 
         public void progress(IvyEvent event) {
-            
-            PublishEventsTest test = (PublishEventsTest)IvyContext.getContext().peek(PublishEventsTest.class.getName());
-            assertTrue("event is of correct concrete type", 
-                        event instanceof StartArtifactPublishEvent);
-            StartArtifactPublishEvent startEvent = (StartArtifactPublishEvent)event;
-            
-            //verify that the artifact being publish was in the expected set.  set the 'currentTestCase'
-            //pointer so that the resolver and post-publish trigger can check against it.
+
+            PublishEventsTest test = (PublishEventsTest) IvyContext.getContext().peek(
+                PublishEventsTest.class.getName());
+            assertTrue("event is of correct concrete type",
+                event instanceof StartArtifactPublishEvent);
+            StartArtifactPublishEvent startEvent = (StartArtifactPublishEvent) event;
+
+            // verify that the artifact being publish was in the expected set. set the
+            // 'currentTestCase'
+            // pointer so that the resolver and post-publish trigger can check against it.
             Artifact artifact = startEvent.getArtifact();
             assertNotNull("event defines artifact", artifact);
- 
-            PublishTestCase currentTestCase = (PublishTestCase)test.expectedPublications.remove(artifact.getId());
-            assertNotNull("artifact " + artifact.getId() + " was expected for publication", currentTestCase);
-            assertFalse("current publication has not been visited yet", currentTestCase.preTriggerFired);
+
+            PublishTestCase currentTestCase = (PublishTestCase) test.expectedPublications
+                    .remove(artifact.getId());
+            assertNotNull("artifact " + artifact.getId() + " was expected for publication",
+                currentTestCase);
+            assertFalse("current publication has not been visited yet",
+                currentTestCase.preTriggerFired);
             assertFalse("current publication has not been visited yet", currentTestCase.published);
-            assertFalse("current publication has not been visited yet", currentTestCase.postTriggerFired);
+            assertFalse("current publication has not been visited yet",
+                currentTestCase.postTriggerFired);
             test.currentTestCase = currentTestCase;
-            
-            //superclass tests common attributes of publish events
+
+            // superclass tests common attributes of publish events
             super.progress(event);
-            
-            //increment the call counter in the test
+
+            // increment the call counter in the test
             currentTestCase.preTriggerFired = true;
             ++test.preTriggers;
         }
-        
+
     }
-    
+
     /**
      * Extends the tests done by {@link TestPublishTrigger} to check that post-publish events are
-     * fired after DependencyResolver.publish() is called, and that the "status" attribute is
-     * set to the correct value.
+     * fired after DependencyResolver.publish() is called, and that the "status" attribute is set to
+     * the correct value.
      */
     public static class PostPublishTrigger extends TestPublishTrigger {
-        
+
         public void progress(IvyEvent event) {
-            //superclass tests common attributes of publish events
+            // superclass tests common attributes of publish events
             super.progress(event);
-            
-            PublishEventsTest test = (PublishEventsTest)IvyContext.getContext().peek(PublishEventsTest.class.getName());
-            
-            //test the proper sequence of events by comparing the current count of pre-events,
-            //post-events, and actual publications.
-            assertTrue("event is of correct concrete type", 
-                        event instanceof EndArtifactPublishEvent);
+
+            PublishEventsTest test = (PublishEventsTest) IvyContext.getContext().peek(
+                PublishEventsTest.class.getName());
+
+            // test the proper sequence of events by comparing the current count of pre-events,
+            // post-events, and actual publications.
+            assertTrue("event is of correct concrete type",
+                event instanceof EndArtifactPublishEvent);
             assertTrue("pre-publish event has been triggered", test.preTriggers > 0);
 
-            //test sequence of events
+            // test sequence of events
             assertTrue("pre-trigger event has already been fired for this artifact",
-                       test.currentTestCase.preTriggerFired);
-            assertEquals("publication has been done if possible", 
-                         test.currentTestCase.expectedSuccess, test.currentTestCase.published);
+                test.currentTestCase.preTriggerFired);
+            assertEquals("publication has been done if possible",
+                test.currentTestCase.expectedSuccess, test.currentTestCase.published);
             assertFalse("post-publish event has not yet been fired for this artifact",
-                        test.currentTestCase.postTriggerFired);
-                        
-            //test the "status" attribute of the post- event.
-            EndArtifactPublishEvent endEvent = (EndArtifactPublishEvent)event;
-            assertEquals("status bit is set correctly", 
-                         test.currentTestCase.expectedSuccess, endEvent.isSuccessful());
-            
+                test.currentTestCase.postTriggerFired);
+
+            // test the "status" attribute of the post- event.
+            EndArtifactPublishEvent endEvent = (EndArtifactPublishEvent) event;
+            assertEquals("status bit is set correctly", test.currentTestCase.expectedSuccess,
+                endEvent.isSuccessful());
+
             String expectedStatus = test.currentTestCase.expectedSuccess ? "successful" : "failed";
-            assertEquals("status attribute is set to correct value", 
-                         expectedStatus, endEvent.getAttributes().get("status"));
-            
-            //increment the call counter in the wrapper test
+            assertEquals("status attribute is set to correct value", expectedStatus, endEvent
+                    .getAttributes().get("status"));
+
+            // increment the call counter in the wrapper test
             test.currentTestCase.postTriggerFired = true;
             ++test.postTriggers;
         }
 
     }
-    
+
     /**
-     * When publish() is called, verifies that a pre-publish event has been fired, and also verifies that
-     * the method arguments have the correct value.  Also simulates an IOException if the current
-     * test case demands it.
+     * When publish() is called, verifies that a pre-publish event has been fired, and also verifies
+     * that the method arguments have the correct value. Also simulates an IOException if the
+     * current test case demands it.
      */
     public static class InstrumentedResolver extends MockResolver {
 
         public void publish(Artifact artifact, File src, boolean overwrite) throws IOException {
 
-            //verify that the data from the current test case has been handed down to us
-            PublishEventsTest test = (PublishEventsTest)IvyContext.getContext().peek(PublishEventsTest.class.getName());
+            // verify that the data from the current test case has been handed down to us
+            PublishEventsTest test = (PublishEventsTest) IvyContext.getContext().peek(
+                PublishEventsTest.class.getName());
 
-            //test sequence of events.
+            // test sequence of events.
             assertNotNull(test.currentTestCase);
             assertTrue("preTrigger has already fired", test.currentTestCase.preTriggerFired);
             assertFalse("postTrigger has not yet fired", test.currentTestCase.postTriggerFired);
             assertFalse("publish has not been called", test.currentTestCase.published);
-            
-            //test event data
-            assertSameArtifact("publisher has received correct artifact", 
-                                test.currentTestCase.expectedArtifact, artifact);
-            assertEquals("publisher has received correct datafile", 
-                         test.currentTestCase.expectedData.getCanonicalPath(), src.getCanonicalPath());
-            assertEquals("publisher has received correct overwrite setting", 
-                         test.expectedOverwrite, overwrite);
-            assertTrue("publisher only invoked when source file exists", test.currentTestCase.expectedData.exists());
-            
-            //simulate a publisher error if the current test case demands it.
+
+            // test event data
+            assertSameArtifact("publisher has received correct artifact",
+                test.currentTestCase.expectedArtifact, artifact);
+            assertEquals("publisher has received correct datafile",
+                test.currentTestCase.expectedData.getCanonicalPath(), src.getCanonicalPath());
+            assertEquals("publisher has received correct overwrite setting",
+                test.expectedOverwrite, overwrite);
+            assertTrue("publisher only invoked when source file exists",
+                test.currentTestCase.expectedData.exists());
+
+            // simulate a publisher error if the current test case demands it.
             if (test.publishError != null)
                 throw test.publishError;
-            
-            //all assertions pass.  increment the publication count
+
+            // all assertions pass. increment the publication count
             test.currentTestCase.published = true;
             ++test.publications;
         }
     }
-    
+
 }
\ No newline at end of file

Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/core/repository/RepositoryManagementEngineTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/core/repository/RepositoryManagementEngineTest.java?rev=1557968&r1=1557967&r2=1557968&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/core/repository/RepositoryManagementEngineTest.java (original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/core/repository/RepositoryManagementEngineTest.java Tue Jan 14 08:27:37 2014
@@ -29,38 +29,33 @@ import org.apache.ivy.core.sort.SortEngi
 
 public class RepositoryManagementEngineTest extends TestCase {
     private RepositoryManagementEngine repository;
+
     private TestFixture fixture;
-    
+
     protected void setUp() throws Exception {
         fixture = new TestFixture();
         IvySettings settings = fixture.getSettings();
         repository = new RepositoryManagementEngine(settings, new SearchEngine(settings),
                 new ResolveEngine(settings, new EventManager(), new SortEngine(settings)));
     }
-    
+
     protected void tearDown() throws Exception {
         fixture.clean();
     }
-    
+
     public void testLoad() throws Exception {
-        fixture
-            .addMD("o1#A;1").addMD("o1#A;2").addMD("o1#A;3")
-            .addMD("o1#B;1").addMD("o1#B;2->o1#A;2")
-            .addMD("o2#C;1->{o1#B;1 o1#A;1}")
-            .init();
-        
+        fixture.addMD("o1#A;1").addMD("o1#A;2").addMD("o1#A;3").addMD("o1#B;1")
+                .addMD("o1#B;2->o1#A;2").addMD("o2#C;1->{o1#B;1 o1#A;1}").init();
+
         repository.load();
         assertEquals(3, repository.getModuleIdsNumber());
         assertEquals(6, repository.getRevisionsNumber());
     }
-    
+
     public void testOrphans() throws Exception {
-        fixture
-            .addMD("o1#A;1").addMD("o1#A;2").addMD("o1#A;3")
-            .addMD("o1#B;1").addMD("o1#B;2->o1#A;2")
-            .addMD("o2#C;1->{o1#B;1 o1#A;1}")
-            .init();
-        
+        fixture.addMD("o1#A;1").addMD("o1#A;2").addMD("o1#A;3").addMD("o1#B;1")
+                .addMD("o1#B;2->o1#A;2").addMD("o2#C;1->{o1#B;1 o1#A;1}").init();
+
         repository.load();
         repository.analyze();
         TestHelper.assertModuleRevisionIds("o1#A;3 o1#B;2 o2#C;1", repository.getOrphans());

Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveEngineTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveEngineTest.java?rev=1557968&r1=1557967&r2=1557968&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveEngineTest.java (original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveEngineTest.java Tue Jan 14 08:27:37 2014
@@ -52,41 +52,38 @@ public class ResolveEngineTest extends T
     }
 
     public void testInlineResolveWithNonExistingModule() throws Exception {
-        ResolveEngine engine = new ResolveEngine(ivy.getSettings(), 
-            ivy.getEventManager(), ivy.getSortEngine());
-        
+        ResolveEngine engine = new ResolveEngine(ivy.getSettings(), ivy.getEventManager(),
+                ivy.getSortEngine());
+
         ResolveOptions options = new ResolveOptions();
         options.setConfs(new String[] {"*"});
-        
+
         ModuleRevisionId mRevId = ModuleRevisionId.newInstance("org1XX", "mod1.0XX", "1.0XX");
         ResolveReport report = engine.resolve(mRevId, options, true);
-        
+
         assertNotNull("The ResolveReport may never be null", report);
         assertTrue(report.hasError());
     }
-    
+
     public void testLocateThenDownload() throws Exception {
-        ResolveEngine engine = new ResolveEngine(ivy.getSettings(), 
-            ivy.getEventManager(), ivy.getSortEngine());
-        
-        testLocateThenDownload(
-            engine, 
-            DefaultArtifact.newIvyArtifact(ModuleRevisionId.parse("org1#mod1.1;1.0"), new Date()), 
+        ResolveEngine engine = new ResolveEngine(ivy.getSettings(), ivy.getEventManager(),
+                ivy.getSortEngine());
+
+        testLocateThenDownload(engine,
+            DefaultArtifact.newIvyArtifact(ModuleRevisionId.parse("org1#mod1.1;1.0"), new Date()),
             new File("test/repositories/1/org1/mod1.1/ivys/ivy-1.0.xml"));
-        testLocateThenDownload(
-            engine, 
-            new DefaultArtifact(ModuleRevisionId.parse("org1#mod1.1;1.0"), new Date(), "mod1.1", "jar", "jar"), 
-            new File("test/repositories/1/org1/mod1.1/jars/mod1.1-1.0.jar"));
+        testLocateThenDownload(engine,
+            new DefaultArtifact(ModuleRevisionId.parse("org1#mod1.1;1.0"), new Date(), "mod1.1",
+                    "jar", "jar"), new File("test/repositories/1/org1/mod1.1/jars/mod1.1-1.0.jar"));
     }
 
     private void testLocateThenDownload(ResolveEngine engine, Artifact artifact, File artifactFile) {
         ArtifactOrigin origin = engine.locate(artifact);
         assertNotNull(origin);
         assertTrue(origin.isLocal());
-        assertEquals(
-            artifactFile.getAbsolutePath(), 
+        assertEquals(artifactFile.getAbsolutePath(),
             new File(origin.getLocation()).getAbsolutePath());
-        
+
         ArtifactDownloadReport r = engine.download(origin, new DownloadOptions());
         assertNotNull(r);
         assertEquals(DownloadStatus.SUCCESSFUL, r.getDownloadStatus());



Mime
View raw message