Skip to content

Commit e68451a

Browse files
committed
write LongLS output to file
1 parent f61c5f8 commit e68451a

3 files changed

Lines changed: 62 additions & 6 deletions

File tree

Jenkinsfiles/mac

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ pipeline {
1515
}
1616

1717
sh '''
18+
mkdir -p testoutput
1819
echo "Build OSXScraper..."
1920
cd osxscraper
2021
xcodebuild -list -project OSXScraper.xcodeproj
2122
xcodebuild -scheme OSXScraper build
23+
ls -lht ../testoutput/
2224
2325
echo "Build OSXProxy..."
2426
cd ../osxproxy

osxscraper/OSXScraper/Settings.plist

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,9 @@
1414
<string>osxsinter.p12</string>
1515
<key>certificate_passcode</key>
1616
<string>123456</string>
17+
<key>xml_logfolder</key>
18+
<string></string>
19+
<key>jenkins_output_dir</key>
20+
<string>/Users/jenkins/workspace/sinter-mac/testoutput</string>
1721
</dict>
1822
</plist>

osxscraper/OSXScraperTests/OSXScraperTests.m

Lines changed: 56 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#import "Config.h"
3232
#import "XMLTags.h"
3333
#import "Scraper.h"
34+
#import "Serializer.h"
3435

3536

3637
@interface OSXScrapperTests : XCTestCase
@@ -70,15 +71,33 @@ - (void)tearDown
7071

7172
}
7273

73-
- (void) test001LS
74+
- (int) exportSinter:(Sinter *) sinter {
75+
NSString * message = [Serializer objectToXml:sinter];
76+
NSDictionary * instanceSetting = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Settings" ofType:@"plist"]];
77+
NSString * logfolder = [instanceSetting objectForKey:@"jenkins_output_dir"];
78+
NSFileManager *fileManager = [[NSFileManager alloc] init];
79+
BOOL isDir;
80+
if ([fileManager fileExistsAtPath:logfolder isDirectory:&isDir] && isDir){
81+
NSString * filename = [NSString stringWithFormat:@"%@/scraper_%@.xml", logfolder, self.name];
82+
NSError * error = NULL;
83+
if([message writeToFile:filename atomically:NO encoding:NSUTF8StringEncoding error:&error])
84+
{
85+
NSLog( @"xml saving to %@", filename);
86+
return 0;
87+
}
88+
}
89+
return -1;
90+
}
91+
92+
- (void) test001_LS_Self
7493
{
7594
//test 'list of applications', should see itself (OSXScraper)
7695
Sinter * sinterInput = [[Sinter alloc] initWithServiceCode:[serviceCodes objectForKey:STRLsReq]];
7796
Sinter * sinterOutput = [scraper execute:sinterInput];
7897
XCTAssertNotNil(sinterOutput);
7998
XCTAssertTrue([sinterOutput.header.service_code isEqualToNumber: [serviceCodes objectForKey:STRLsRes]]);
8099
XCTAssertTrue(sinterOutput.entities.count >= 1);
81-
100+
82101
BOOL bFoundSelf = NO;
83102
NSLog(@"%s entities count: %ld", __PRETTY_FUNCTION__, [sinterOutput.entities count]);
84103
for (Entity* e in sinterOutput.entities){
@@ -90,15 +109,15 @@ - (void) test001LS
90109
XCTAssertTrue(bFoundSelf);
91110
}
92111

93-
- (void) test001LSCalc
112+
- (void) test001_LS_Calc
94113
{
95-
//test 'list of applications', should see itself (OSXScraper)
114+
//test 'list of applications', should see Calculator
96115
Sinter * sinterInput = [[Sinter alloc] initWithServiceCode:[serviceCodes objectForKey:STRLsReq]];
97116
Sinter * sinterOutput = [scraper execute:sinterInput];
98117
XCTAssertNotNil(sinterOutput);
99118
XCTAssertTrue([sinterOutput.header.service_code isEqualToNumber: [serviceCodes objectForKey:STRLsRes]]);
100119
XCTAssertTrue(sinterOutput.entities.count >= 1);
101-
120+
102121
BOOL bFound = NO;
103122
NSLog(@"%s entities count: %ld", __PRETTY_FUNCTION__, [sinterOutput.entities count]);
104123
for (Entity* e in sinterOutput.entities){
@@ -110,7 +129,7 @@ - (void) test001LSCalc
110129
XCTAssertTrue(bFound);
111130
}
112131

113-
- (void) test002LongLS
132+
- (void) test002_LongLS_Self
114133
{
115134
// first get the process_id of itself, then test long LS (scrape it and output a response sinter)
116135
Sinter * sinterOutput = [AccAPI getListOfApplications];
@@ -133,6 +152,37 @@ - (void) test002LongLS
133152
XCTAssertTrue([sinterOutput2.header.process_id isEqualToString:process_id]);
134153
XCTAssertTrue([sinterOutput2.header.service_code isEqualToNumber: [serviceCodes objectForKey:STRLsLongRes]]);
135154
XCTAssertNotNil(sinterOutput2.entity);
155+
XCTAssertTrue([self exportSinter:sinterOutput2] == 0);
156+
}
157+
158+
- (void) test002_LongLS_Calc
159+
{
160+
// first get the process_id of itself, then test long LS (scrape it and output a response sinter)
161+
Sinter * sinterOutput = [AccAPI getListOfApplications];
162+
NSString* process_id;
163+
for (Entity* e in sinterOutput.entities){
164+
if ([e.name isEqualToString:@"Calculator"]){
165+
NSLog(@"%s %@, %@", __PRETTY_FUNCTION__, e.name, e.process_id);
166+
process_id = e.process_id;
167+
break;
168+
}
169+
}
170+
XCTAssertNotNil(process_id);
171+
172+
// create a sinterInput2 with process_id to test
173+
if (process_id != nil) {
174+
Sinter * sinterInput2 = [[Sinter alloc] init];
175+
sinterInput2.header = [[Header alloc] initWithServiceCode:[serviceCodes objectForKey:STRLsLongReq]
176+
subCode:[serviceCodes objectForKey:STRLsLongReq]
177+
processId:process_id
178+
parameters:nil];
179+
Sinter * sinterOutput2 = [scraper execute:sinterInput2];
180+
XCTAssertNotNil(sinterOutput2);
181+
XCTAssertTrue([sinterOutput2.header.process_id isEqualToString:process_id]);
182+
XCTAssertTrue([sinterOutput2.header.service_code isEqualToNumber: [serviceCodes objectForKey:STRLsLongRes]]);
183+
XCTAssertNotNil(sinterOutput2.entity);
184+
XCTAssertTrue([self exportSinter:sinterOutput2] == 0);
185+
}
136186
}
137187

138188
@end

0 commit comments

Comments
 (0)