Skip to content
This repository
Browse code

Added posted delivery handling & filtering on mastership

  • Loading branch information...
commit 4a7409146ec9c5deb4656620463fa0ef3243900f 1 parent b4cc1db
Leif Sorensen authored March 15, 2012
59  bin/TestPostedDelivery.bat
... ...
@@ -0,0 +1,59 @@
  1
+
  2
+@echo OFF
  3
+
  4
+set program=%1
  5
+set args=%*
  6
+set package=net.praqma.cli
  7
+echo set COOL_HOME=C:\Users\les\workspace\cool
  8
+
  9
+IF NOT "%program%"=="" GOTO programok
  10
+
  11
+echo.
  12
+echo The program was not given
  13
+echo.
  14
+
  15
+EXIT /B 1
  16
+
  17
+:programok
  18
+
  19
+IF NOT "%COOL_HOME%"=="" GOTO coolhomeok
  20
+
  21
+echo.
  22
+echo COOL_HOME is not set
  23
+echo.
  24
+
  25
+EXIT /B 1
  26
+
  27
+:coolhomeok
  28
+
  29
+set COOL_JAR=%COOL_HOME%\build\COOL.jar
  30
+echo set COOL_JAR=%COOL_HOME%\build\COOL-0.3.41-jar-with-dependencies.jar
  31
+
  32
+if exist "%COOL_JAR%" goto start
  33
+
  34
+
  35
+echo.
  36
+echo %COOL_JAR% was not found
  37
+echo.
  38
+
  39
+EXIT /B 1
  40
+
  41
+:start
  42
+
  43
+echo cool=java -Dtest="1" -classpath %COOL_JAR% %package%.%program% %args%
  44
+set cool=java -Dcleartool=mock -classpath %COOL_JAR% %package%.%program% %args%
  45
+
  46
+rem echo %cool%
  47
+
  48
+call %cool%
  49
+
  50
+
  51
+@GOTO :EOF
  52
+
  53
+
  54
+:WRONG_PARAMS
  55
+ECHO %1 is missing
  56
+
  57
+
  58
+EXIT /B 
  59
+GOTO :EOF
42  src/main/java/net/praqma/clearcase/cleartool/CommandLineMock.java
@@ -4,16 +4,22 @@
4 4
 import java.util.ArrayList;
5 5
 import java.util.Map;
6 6
 
7  
-import net.praqma.util.debug.Logger;
  7
+import org.junit.AfterClass;
  8
+import org.junit.BeforeClass;
  9
+
  10
+import net.praqma.clearcase.ucm.entities.UCM;
  11
+import net.praqma.util.debug.*;
  12
+import net.praqma.util.debug.Logger.LogLevel;
  13
+import net.praqma.util.debug.appenders.*;
8 14
 import net.praqma.util.execute.AbnormalProcessTerminationException;
9 15
 import net.praqma.util.execute.CmdResult;
10 16
 import net.praqma.util.execute.CommandLineException;
11 17
 import net.praqma.util.execute.CommandLineInterface;
12 18
 
13 19
 public class CommandLineMock implements CommandLineInterface {
14  
-	private Logger logger = Logger.getLogger();
15  
-
16  
-	private CommandLineMock() {
  20
+    private static Logger logger = Logger.getLogger();
  21
+    
  22
+    private CommandLineMock() {
17 23
 
18 24
 	}
19 25
 
@@ -80,7 +86,17 @@ public CmdResult run( String cmd, File dir, boolean merge, boolean ignore ) thro
80 86
 		if( cmd.equals( "cleartool desc -fmt %n::%X[component]p::%X[bl_stream]p::%[plevel]p::%u::%Nd::%[label_status]p baseline:CHW_BASELINE_51_no@\\Cool_PVOB" ) ) {
81 87
 			throw new AbnormalProcessTerminationException( "cleartool: Error: Baseline not found: \"CHW_BASELINE_51_no\"." );
82 88
 		}
83  
-
  89
+		
  90
+		if( cmd.equals( "cleartool desc -fmt %n::%X[component]p::%X[bl_stream]p::%[plevel]p::%u::%Nd::%[label_status]p baseline:CHW_BASELINE_51_posted_delivery@\\Cool_PVOB" ) ) {
  91
+			res.stdoutBuffer.append( "CHW_BASELINE_51::_System::Server_int::TESTED::chw::20110810.232400::full" );
  92
+		}
  93
+		/*
  94
+		if( cmd.equals( "cleartool desc -fmt %n::%X[component]p::%X[bl_stream]p::%[plevel]p::%u::%Nd::%[label_status]p baseline:CHW_BASELINE_51_posted_delivery@\\Cool_PVOB" ) ) {
  95
+			res.stdoutBuffer.append( "Deliver operation in progress on stream astream. Dadada. Operation posted from replica xxxx is ready to integrate at replica yyyy. DaDa ");
  96
+		}
  97
+		*/
  98
+		
  99
+		
84 100
 		if( cmd.equals( "cleartool chbl -level RELEASED baseline baseline:CHW_BASELINE_51@\\Cool_PVOB" ) ) {
85 101
 
86 102
 		}
@@ -143,6 +159,7 @@ public CmdResult run( String cmd, File dir, boolean merge, boolean ignore ) thro
143 159
 		 */
144 160
 		/* STREAMS */
145 161
 
  162
+		//logger.debug("CMD = " + cmd);
146 163
 		if( cmd.equals( "cleartool desc -fmt %[rec_bls]p stream:bn_stream@\\Cool_PVOB" ) ) {
147 164
 			res.stdoutBuffer.append( "rec_baseline000001" );
148 165
 		}
@@ -155,6 +172,14 @@ public CmdResult run( String cmd, File dir, boolean merge, boolean ignore ) thro
155 172
 			res.stdoutBuffer.append( "rec_baseline000001" );
156 173
 		}
157 174
 
  175
+		//logger.debug("CMD = " + "cleartool describe -fmt %[name]p\\n%[project]Xp\\n%X[def_deliver_tgt]p\\n%[read_only]p\\n%[found_bls]Xp stream:bn_stream@\\Cool_PVOB");
  176
+		if( cmd.contains( "cleartool describe -fmt %[name]p\\n%[project]Xp\\n%X[def_deliver_tgt]p\\n%[read_only]p\\n%[found_bls]Xp stream:bn_stream@\\Cool_PVOB" ) ) {
  177
+			res.stdoutList.add( "rec_baseline7" );
  178
+			res.stdoutList.add( "bn_project@\\Cool_PVOB" );
  179
+			res.stdoutList.add( "" );
  180
+			res.stdoutList.add( "" );
  181
+		}
  182
+		
158 183
 		/* Baselines */
159 184
 
160 185
 		/*
@@ -208,6 +233,13 @@ public CmdResult run( String cmd, File dir, boolean merge, boolean ignore ) thro
208 233
 			res.stdoutList.add( "   nobuildnumber.file@1234@\\Cool_PVOB ->  " + ( versionDotH != null ? versionDotH.getAbsolutePath() : "version.h" ) + " " );
209 234
 		}
210 235
 
  236
+		// cleartool deliver
  237
+		// 
  238
+		logger.debug("CMD = " + cmd);
  239
+		if( cmd.equals( "cleartool deliver -baseline baseline:CHW_BASELINE_51_posted_delivery@\\Cool_PVOB -stream stream:bn_stream@\\Cool_PVOB -target stream:bn_stream@\\Cool_PVOB -to viewtag" ) ) {
  240
+			logger.debug( "CMD = " + cmd );
  241
+			res.stdoutBuffer.append( "Deliver operation in progress on stream astream. Dadada. Operation posted from replica xxxx is ready to integrate at replica yyyy. DaDa ");
  242
+		}
211 243
 		return res;
212 244
 	}
213 245
 
26  src/main/java/net/praqma/clearcase/ucm/entities/Baseline.java
@@ -204,14 +204,7 @@ public Stream getStream() throws UCMException {
204 204
     public boolean deliverForced(Stream stream, Stream target, File viewcontext, String viewtag) throws UCMException {
205 205
         //logger.info( "Trying to deliver the Baseline " + this.GetFQName() + " from " + stream.GetFQName() + " to " + target.GetFQName() );
206 206
 
207  
-        try {
208  
-            context.deliver(this, stream, target, viewcontext, viewtag, true, true, true);
209  
-        } catch (UCMException e) {
210  
-            logger.warning("Could not deliver baseline: " + e.getMessage());
211  
-            throw e;
212  
-        }
213  
-
214  
-        return true;
  207
+        return this.deliver(stream, target, viewcontext, viewtag, true, true, true);
215 208
     }
216 209
 
217 210
     /**
@@ -228,8 +221,23 @@ public boolean deliverForced(Stream stream, Stream target, File viewcontext, Str
228 221
      */
229 222
     public boolean deliver(Stream stream, Stream target, File viewcontext, String viewtag, boolean force, boolean complete, boolean abort) throws UCMException {
230 223
         try {
231  
-            return context.deliver(this, stream, target, viewcontext, viewtag, force, complete, abort);
  224
+            return context.deliver(this, stream, target, viewcontext, viewtag, force, complete, abort, false);
232 225
         } catch (UCMException e) {
  226
+        	if (e.type == UCMType.DELIVER_IN_PROGRESS) { //could be a posted delivery
  227
+        		String status = context.deliverStatus(stream);
  228
+        		if(status.replace( System.getProperty( "line.separator" ), " " ).contains( "Operation posted from" ) ) {
  229
+        	        try {
  230
+        	            return context.deliver(null, stream, null, viewcontext, viewtag, force, complete, abort, true);
  231
+        	        } catch (UCMException e1) {
  232
+        	            logger.warning("Could not resume posted delivery: " + e1.getMessage());
  233
+        	            logger.warning(e1);
  234
+        	            throw e1;
  235
+        	        }
  236
+
  237
+        		} 
  238
+        		
  239
+        	}
  240
+        		
233 241
             logger.warning("Could not deliver baseline: " + e.getMessage());
234 242
             logger.warning(e);
235 243
             throw e;
18  src/main/java/net/praqma/clearcase/ucm/entities/Component.java
@@ -45,14 +45,26 @@ public String getRootDir() throws UCMException {
45 45
 	public List<Baseline> getBaselines( Stream stream ) throws UCMException {
46 46
 		logger.debug( "Getting Baselines from " + stream.getFullyQualifiedName() + " and " + getFullyQualifiedName() );
47 47
 
48  
-		return UCM.context.getBaselines( stream, this, null, getPvobString() );
49  
-		//return new BaselineList( this, stream, null );
  48
+		return this.getBaselines(stream, null, false);
50 49
 	}
51 50
 
52 51
 	public List<Baseline> getBaselines( Stream stream, Project.Plevel plevel ) throws UCMException {
  52
+		logger.debug( "Getting Baselines from " + stream.getFullyQualifiedName() + " and " + getFullyQualifiedName() );
  53
+
  54
+		return this.getBaselines(stream, plevel, false);
  55
+	}
  56
+
  57
+	public List<Baseline> getBaselines( Stream stream, boolean multisitePolling ) throws UCMException {
  58
+		logger.debug( "Getting Baselines from " + stream.getFullyQualifiedName() + " and " + getFullyQualifiedName() );
  59
+
  60
+		return this.getBaselines(stream, null, multisitePolling);
  61
+		//return new BaselineList( this, stream, null );
  62
+	}
  63
+
  64
+	public List<Baseline> getBaselines( Stream stream, Project.Plevel plevel, boolean multisitePolling ) throws UCMException {
53 65
 		logger.debug( "Getting Baselines from " + stream.getFullyQualifiedName() + " and " + this.getFullyQualifiedName() + " with plevel " + plevel );
54 66
 
55  
-		return UCM.context.getBaselines( stream, this, plevel, getPvobString() );
  67
+		return stream.getBaselines(this, plevel, multisitePolling);
56 68
 		//return new BaselineList( this, stream, plevel );
57 69
 	}
58 70
 
96  src/main/java/net/praqma/clearcase/ucm/entities/Stream.java
@@ -6,9 +6,12 @@
6 6
 import java.util.Date;
7 7
 import java.util.Iterator;
8 8
 import java.util.List;
  9
+import java.util.regex.Matcher;
  10
+import java.util.regex.Pattern;
9 11
 
10 12
 import net.praqma.clearcase.interfaces.Diffable;
11 13
 import net.praqma.clearcase.ucm.UCMException;
  14
+import net.praqma.clearcase.ucm.UCMException.UCMType;
12 15
 import net.praqma.clearcase.ucm.entities.Project.Plevel;
13 16
 import net.praqma.clearcase.ucm.view.SnapshotView;
14 17
 import net.praqma.util.debug.Logger;
@@ -31,6 +34,8 @@
31 34
 	private Stream defaultTarget = null;
32 35
 	private boolean readOnly = true;
33 36
 	private Baseline foundation;
  37
+
  38
+	private String status = null;
34 39
 	
35 40
 	private Stream parent;
36 41
 
@@ -91,16 +96,26 @@ public void load() throws UCMException {
91 96
 		this.loaded = true;
92 97
 	}
93 98
 
94  
-	public List<Baseline> getBaselines( Plevel plevel ) throws UCMException {
95  
-		return context.getBaselines( this, getSingleTopComponent(), plevel, pvob );
  99
+	public List<Baseline> getBaselines( Plevel plevel, boolean multisitePolling ) throws UCMException {
  100
+		return this.getBaselines(getSingleTopComponent(), plevel, multisitePolling);
96 101
 	}
97 102
 
98  
-	public List<Baseline> getBaselines( Component component, Plevel plevel ) throws UCMException {
99  
-		return context.getBaselines( this, component, plevel, pvob );
  103
+	public List<Baseline> getBaselines( Component component, Plevel plevel, boolean multisitePolling ) throws UCMException {
  104
+		return this.getBaselines( component, plevel, null, multisitePolling );
100 105
 	}
101 106
 
102  
-	public List<Baseline> getBaselines( Component component, Plevel plevel, Date date ) throws UCMException {
103  
-		List<Baseline> baselines = context.getBaselines( this, component, plevel, pvob );
  107
+	public List<Baseline> getBaselines( Component component, Plevel plevel, Date date, boolean multisitePolling ) throws UCMException {
  108
+		
  109
+		List<Baseline> baselines = null;
  110
+		
  111
+		if(this.hasPostedDelivery()) {
  112
+			if(multisitePolling)
  113
+				baselines = this.getPostedBaselines(component, plevel);
  114
+			else
  115
+				baselines = new ArrayList<Baseline>();
  116
+		}
  117
+		else
  118
+			baselines = context.getBaselines( this, component, plevel, pvob );
104 119
 
105 120
 		if( date == null ) {
106 121
 			return baselines;
@@ -119,7 +134,7 @@ public void load() throws UCMException {
119 134
 		return baselines;
120 135
 	}
121 136
 
122  
-	public List<Stream> getChildStreams() throws UCMException {
  137
+	public List<Stream> getChildStreams(boolean multisitePolling) throws UCMException {
123 138
 
124 139
 		List<Stream> res = new ArrayList<Stream>();
125 140
 		try {
@@ -127,6 +142,23 @@ public void load() throws UCMException {
127 142
 		} catch (UCMException e) {
128 143
 			logger.debug( "The Stream has no child streams" );
129 144
 		}
  145
+
  146
+		Iterator<Stream> it = res.iterator();
  147
+		String mastership = this.getMastership();
  148
+		while( it.hasNext() ) {
  149
+			Stream stream = it.next();
  150
+			String childMastership = stream.getMastership();
  151
+			logger.debug( "Child Mastership = %s" + childMastership );
  152
+
  153
+			if(stream.hasPostedDelivery() && !multisitePolling) {
  154
+				logger.debug( "Removing [" + stream.getShortname() + "] due to non-supported posted delivery" );
  155
+				it.remove();
  156
+			}
  157
+			else if(!mastership.equals(childMastership)) {
  158
+				logger.debug( "Removing [" + stream.getShortname() + "] due to different mastership" );
  159
+				it.remove();
  160
+			}
  161
+		}
130 162
 		return res;
131 163
 	}
132 164
 
@@ -261,14 +293,50 @@ public Stream getDefaultTarget() throws UCMException {
261 293
 		return this.defaultTarget;
262 294
 	}
263 295
 
264  
-	public boolean deliver( Baseline baseline, Stream target, File viewcontext, String viewtag, boolean force, boolean complete, boolean abort ) throws UCMException {
265  
-		try {
266  
-			return context.deliver( baseline, this, target, viewcontext, viewtag, force, complete, abort );
267  
-		} catch (UCMException e) {
268  
-			logger.warning( "Could not deliver baseline: " + e.getMessage() );
269  
-			logger.warning( e );
270  
-			throw e;
  296
+	public boolean hasPostedDelivery() throws UCMException {
  297
+		if( status == null ) 
  298
+			status = context.deliverStatus(this); 
  299
+		return status.contains( "Operation posted from" );
  300
+	}
  301
+
  302
+	public List<Baseline> getPostedBaselines( Component component, Plevel plevel) throws UCMException {
  303
+		List<Baseline> res = new ArrayList<Baseline>();
  304
+		if( status == null ) 
  305
+			status = context.deliverStatus(this); 
  306
+        Matcher m = Pattern.compile(".*baseline:(\\S*).*").matcher(status); 
  307
+		if (m.find()) {
  308
+            logger.warning("Posted baseline : " + m.group(1));
  309
+            //should maybe also select on component
  310
+            Baseline b = UCMEntity.getBaseline( m.group(1), true );
  311
+            if(b.getPromotionLevel(true) == plevel)
  312
+            	res.add(b);
271 313
 		}
  314
+		return res;
  315
+	}
  316
+	
  317
+
  318
+	public boolean deliver( Baseline baseline, Stream target, File viewcontext, String viewtag, boolean force, boolean complete, boolean abort ) throws UCMException {
  319
+        try {
  320
+            return context.deliver(baseline, this, target, viewcontext, viewtag, force, complete, abort, false);
  321
+        } catch (UCMException e) {
  322
+        	if (e.type == UCMType.DELIVER_IN_PROGRESS) { //could be a posted delivery
  323
+        		if(this.hasPostedDelivery()) {
  324
+        	        try {
  325
+        	            return context.deliver(null, this, null, viewcontext, viewtag, force, complete, abort, true);
  326
+        	        } catch (UCMException e1) {
  327
+        	            logger.warning("Could not resume posted delivery: " + e1.getMessage());
  328
+        	            logger.warning(e1);
  329
+        	            throw e1;
  330
+        	        }
  331
+
  332
+        		} 
  333
+        		
  334
+        	}
  335
+        		
  336
+            logger.warning("Could not deliver baseline: " + e.getMessage());
  337
+            logger.warning(e);
  338
+            throw e;
  339
+        }
272 340
 	}
273 341
 
274 342
 	public void cancelDeliver( File viewcontext ) throws UCMException {
9  src/main/java/net/praqma/clearcase/ucm/persistence/UCMContext.java
@@ -353,7 +353,7 @@ public void recommendBaseline( Stream stream, Baseline baseline ) throws UCMExce
353 353
 	private static final Pattern rx_deliver_find_baseline = Pattern.compile( "Baselines to be delivered:\\s*baseline:", Pattern.MULTILINE | Pattern.CASE_INSENSITIVE );
354 354
 	private static final Pattern rx_deliver_find_nobaseline = Pattern.compile( "Baselines to be delivered:\\s*baseline:", Pattern.MULTILINE | Pattern.CASE_INSENSITIVE );
355 355
 
356  
-	public boolean deliver( Baseline baseline, Stream stream, Stream target, File context, String viewtag, boolean force, boolean complete, boolean abort ) throws UCMException {
  356
+	public boolean deliver( Baseline baseline, Stream stream, Stream target, File context, String viewtag, boolean force, boolean complete, boolean abort, boolean resume  ) throws UCMException {
357 357
 		logger.debug( "Delivering " + baseline + ", " + stream + ", " + target + ", " + context + ", " + viewtag );
358 358
 		String bl = baseline != null ? baseline.getFullyQualifiedName() : null;
359 359
 		String st = stream != null ? stream.getFullyQualifiedName() : null;
@@ -361,7 +361,7 @@ public boolean deliver( Baseline baseline, Stream stream, Stream target, File co
361 361
 		// strategy.deliver( baseline.GetFQName(), stream.GetFQName(),
362 362
 		// target.GetFQName(), view.GetViewRoot(), view.GetViewtag(), force,
363 363
 		// complete, abort );
364  
-		String result = strategy.deliver( bl, st, ta, context, viewtag, force, complete, abort );
  364
+		String result = strategy.deliver( bl, st, ta, context, viewtag, force, complete, abort, resume  );
365 365
 
366 366
 		// System.out.println( "I GOT: \n\"" + result + "\"\n" );
367 367
 
@@ -383,6 +383,11 @@ public boolean deliver( Baseline baseline, Stream stream, Stream target, File co
383 383
 		return true;
384 384
 	}
385 385
 
  386
+	public String deliverStatus(Stream stream ) throws UCMException {
  387
+		String st = stream != null ? stream.getFullyQualifiedName() : null;
  388
+		return strategy.deliverStatus( st );
  389
+	}
  390
+
386 391
 	public void cancelDeliver( File viewcontext, Stream stream ) throws UCMException {
387 392
 		strategy.cancelDeliver( viewcontext, stream );
388 393
 	}
4  src/main/java/net/praqma/clearcase/ucm/persistence/UCMStrategyCleartool.java
@@ -546,8 +546,8 @@ public String getBaselineActivities( String baseline ) {
546 546
 	private static final Pattern rx_checkDeliverDenied = Pattern.compile( "does not allow deliver operations from streams in other", Pattern.DOTALL );
547 547
 	private static final Pattern rx_checkProgress = Pattern.compile( "which is currently involved in an.*?active deliver or rebase operation", Pattern.DOTALL );
548 548
 
549  
-	public String deliver( String baseline, String stream, String target, File context, String viewtag, boolean force, boolean complete, boolean abort ) throws UCMException {
550  
-		String cmd = "deliver" + ( force ? " -force" : "" ) + ( complete ? " -complete" : "" ) + ( abort ? " -abort" : "" );
  549
+	public String deliver( String baseline, String stream, String target, File context, String viewtag, boolean force, boolean complete, boolean abort, boolean resume  ) throws UCMException {
  550
+		String cmd = "deliver" + ( force ? " -force" : "" ) + ( complete ? " -complete" : "" ) + ( abort ? " -abort" : "" ) + ( resume ? " -resume" : "" );
551 551
 		cmd += ( baseline != null ? " -baseline " + baseline : "" );
552 552
 		cmd += ( stream != null ? " -stream " + stream : "" );
553 553
 		cmd += ( target != null ? " -target " + target : "" );
2  src/main/java/net/praqma/clearcase/ucm/persistence/UCMStrategyInterface.java
@@ -59,7 +59,7 @@
59 59
 
60 60
 	public String getBaselineActivities( String baseline );
61 61
 
62  
-	public String deliver( String baseline, String stream, String target, File viewroot, String viewtag, boolean force, boolean complete, boolean abort ) throws UCMException;
  62
+	public String deliver( String baseline, String stream, String target, File viewroot, String viewtag, boolean force, boolean complete, boolean abort, boolean resume ) throws UCMException;
63 63
 	public void cancelDeliver( File viewcontext, Stream stream ) throws UCMException;
64 64
 	public String deliverStatus( String stream ) throws UCMException;
65 65
 
2  src/main/java/net/praqma/clearcase/ucm/persistence/UCMStrategyXML.java
@@ -838,7 +838,7 @@ public String getBaselineActivities(String baseline) {
838 838
     }
839 839
 
840 840
     @Override
841  
-    public String deliver(String baseline, String stream, String target, File viewroot, String viewtag, boolean force, boolean complete, boolean abort)
  841
+    public String deliver(String baseline, String stream, String target, File viewroot, String viewtag, boolean force, boolean complete, boolean abort, boolean resume)
842 842
             throws UCMException {
843 843
         // TODO Auto-generated method stub
844 844
         return null;
57  src/main/java/net/praqma/cli/PostedDelivery.java
... ...
@@ -0,0 +1,57 @@
  1
+package net.praqma.cli;
  2
+
  3
+import static org.junit.Assert.assertNotNull;
  4
+
  5
+import java.io.File;
  6
+import java.util.Map;
  7
+
  8
+import net.praqma.clearcase.ucm.UCMException;
  9
+import net.praqma.clearcase.ucm.entities.Baseline;
  10
+import net.praqma.clearcase.ucm.entities.Stream;
  11
+import net.praqma.clearcase.ucm.entities.UCM;
  12
+import net.praqma.clearcase.ucm.entities.UCMEntity;
  13
+import net.praqma.clearcase.ucm.view.SnapshotView;
  14
+import net.praqma.util.debug.Logger;
  15
+import net.praqma.util.debug.Logger.LogLevel;
  16
+import net.praqma.util.debug.appenders.StreamAppender;
  17
+import net.praqma.util.option.Option;
  18
+import net.praqma.util.option.Options;
  19
+
  20
+public class PostedDelivery {
  21
+	
  22
+	private static Logger logger = Logger.getLogger();
  23
+	private static StreamAppender app = new StreamAppender( System.out );
  24
+	
  25
+	public static void main( String[] args ) throws UCMException {
  26
+		try {
  27
+			run( args );
  28
+		} catch( UCMException e ) {
  29
+			System.err.println( UCM.getMessagesAsString() );
  30
+			throw e;
  31
+		}
  32
+	}
  33
+
  34
+	public static void run( String[] args ) throws UCMException {
  35
+
  36
+        //app.setTemplate( "[%level]%space %message%newline" );
  37
+        Logger.addAppender( app );
  38
+        app.setMinimumLevel( LogLevel.DEBUG );
  39
+
  40
+		/* Do the ClearCase thing... */
  41
+		UCM.setContext( UCM.ContextType.CLEARTOOL );
  42
+
  43
+		try {
  44
+			Baseline bl = null; //UCMEntity.getBaseline( "CHW_BASELINE_51_posted_delivery@\\Cool_PVOB", true );
  45
+			Stream source = UCMEntity.getStream("stream:moon-vobadmin_Client@\\Cool_PVOB");
  46
+			Stream target = null;
  47
+			//bl.deliver(source, target, (File) null, "viewtag", false, false, false);
  48
+			source.deliver(bl, target, (File) null, "night-vobadmin_Client_int", true, false, false);
  49
+		} catch( Exception e ) {
  50
+			logger.error( "Error: " + e.getMessage() );
  51
+			System.exit( 1 );
  52
+		}
  53
+		
  54
+		logger.debug( "Done");
  55
+	}
  56
+
  57
+}
34  src/test/java/net/praqma/clearcase/ucm/entities/BaselineTest.java
@@ -2,18 +2,34 @@
2 2
 
3 3
 import static org.junit.Assert.*;
4 4
 
  5
+import java.io.File;
  6
+
5 7
 import org.junit.*;
6 8
 
7 9
 import net.praqma.clearcase.ucm.UCMException;
  10
+import net.praqma.util.debug.Logger;
  11
+import net.praqma.util.debug.Logger.LogLevel;
  12
+import net.praqma.util.debug.appenders.Appender;
  13
+import net.praqma.util.debug.appenders.ConsoleAppender;
8 14
 
9 15
 public class BaselineTest
10 16
 {
  17
+    private static Appender app;
  18
+		
11 19
 	@BeforeClass
12  
-	public static void startup()
13  
-	{
  20
+	public static void startup() {
14 21
 		UCM.setContext( UCM.ContextType.CLEARTOOL );
  22
+		
  23
+        app = new ConsoleAppender();
  24
+        app.setMinimumLevel( LogLevel.DEBUG );
  25
+        Logger.addAppender( app );
15 26
 	}
16  
-
  27
+	
  28
+    @AfterClass
  29
+    public static void end() {
  30
+        Logger.removeAppender( app ); 
  31
+       }
  32
+    
17 33
 	@Test
18 34
 	public void testLoad()
19 35
 	{
@@ -90,6 +106,18 @@ public void testPromote() throws UCMException
90 106
 		bl.promote();
91 107
 	}
92 108
 
  109
+	@Test
  110
+	public void testDeliver() throws UCMException
  111
+	{
  112
+		Baseline bl = UCMEntity.getBaseline( "CHW_BASELINE_51_posted_delivery@\\Cool_PVOB", true );
  113
+		Stream source = UCMEntity.getStream("stream:bn_stream@\\Cool_PVOB");
  114
+		Stream target = UCMEntity.getStream("stream:bn_stream@\\Cool_PVOB");
  115
+		assertNotNull( bl.stringify() );
  116
+		assertNotNull( source.stringify() );
  117
+		assertNotNull( target.stringify() );
  118
+		bl.deliver(source, target, (File) null, "viewtag", false, false, false);
  119
+	}
  120
+
93 121
 	/*
94 122
 	@Test
95 123
 	public void testDemote()
17  src/test/java/net/praqma/clearcase/ucm/entities/ComponentTest.java
@@ -9,13 +9,28 @@
9 9
 import net.praqma.clearcase.ucm.UCMException;
10 10
 import net.praqma.clearcase.ucm.entities.Project.Plevel;
11 11
 import net.praqma.clearcase.ucm.utils.BaselineList;
  12
+import net.praqma.util.debug.Logger;
  13
+import net.praqma.util.debug.Logger.LogLevel;
  14
+import net.praqma.util.debug.appenders.Appender;
  15
+import net.praqma.util.debug.appenders.ConsoleAppender;
12 16
 
13 17
 public class ComponentTest {
14  
-
  18
+    private static Appender app;
  19
+    
15 20
 	@BeforeClass
16 21
 	public static void startup() {
17 22
 		UCM.setContext( UCM.ContextType.CLEARTOOL );
  23
+		
  24
+        app = new ConsoleAppender();
  25
+        app.setMinimumLevel( LogLevel.DEBUG );
  26
+        Logger.addAppender( app );
18 27
 	}
  28
+	
  29
+    @AfterClass
  30
+    public static void end() {
  31
+        Logger.removeAppender( app ); 
  32
+       }
  33
+    
19 34
 
20 35
 	@Test
21 36
 	public void testLoad() throws UCMException {
18  src/test/java/net/praqma/clearcase/ucm/entities/StreamTest.java
@@ -7,12 +7,26 @@
7 7
 import org.junit.*;
8 8
 
9 9
 import net.praqma.clearcase.ucm.UCMException;
  10
+import net.praqma.util.debug.Logger;
  11
+import net.praqma.util.debug.Logger.LogLevel;
  12
+import net.praqma.util.debug.appenders.Appender;
  13
+import net.praqma.util.debug.appenders.ConsoleAppender;
10 14
 
11 15
 public class StreamTest {
  16
+    private static Appender app;
  17
+	
12 18
 	@BeforeClass
13  
-	public static void startup()
14  
-	{
  19
+	public static void startup() {
15 20
 		UCM.setContext( UCM.ContextType.CLEARTOOL );
  21
+		
  22
+        app = new ConsoleAppender();
  23
+        app.setMinimumLevel( LogLevel.DEBUG );
  24
+        Logger.addAppender( app );
16 25
 	}
  26
+	
  27
+    @AfterClass
  28
+    public static void end() {
  29
+        Logger.removeAppender( app ); 
  30
+       }
17 31
 
18 32
 }
17  src/test/java/net/praqma/clearcase/ucm/entities/TagTest.java
@@ -8,14 +8,31 @@
8 8
 
9 9
 import net.praqma.clearcase.Cool;
10 10
 import net.praqma.clearcase.ucm.UCMException;
  11
+import net.praqma.util.debug.Logger;
  12
+import net.praqma.util.debug.Logger.LogLevel;
  13
+import net.praqma.util.debug.appenders.Appender;
  14
+import net.praqma.util.debug.appenders.ConsoleAppender;
  15
+
  16
+import org.junit.AfterClass;
11 17
 import org.junit.BeforeClass;
12 18
 import org.junit.Test;
13 19
 
14 20
 public class TagTest extends Cool {
  21
+    private static Appender app;
  22
+	
15 23
 	@BeforeClass
16 24
 	public static void startup() {
17 25
 		UCM.setContext( UCM.ContextType.CLEARTOOL );
  26
+		
  27
+        app = new ConsoleAppender();
  28
+        app.setMinimumLevel( LogLevel.DEBUG );
  29
+        Logger.addAppender( app );
18 30
 	}
  31
+	
  32
+    @AfterClass
  33
+    public static void end() {
  34
+        Logger.removeAppender( app ); 
  35
+       }
19 36
 
20 37
 	/*
21 38
 	 * @Test public void testPostProcess() { fail( "Not yet implemented" ); }

0 notes on commit 4a74091

Please sign in to comment.
Something went wrong with that request. Please try again.