Skip to content

Commit

Permalink
Adding new test case, to show the entire (current) API; Running again…
Browse files Browse the repository at this point in the history
…st RHCLOUD.....
  • Loading branch information
matzew committed Aug 24, 2012
1 parent 40fa2e8 commit 80fd0f2
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 11 deletions.
6 changes: 6 additions & 0 deletions AeroGear-iOS/AeroGear-iOS.xcodeproj/project.pbxproj
Expand Up @@ -17,6 +17,7 @@
573CBDA415E4F31B0071E7A6 /* AGPipelineSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 573CBDA315E4F31B0071E7A6 /* AGPipelineSpec.m */; };
573CBDAA15E546A20071E7A6 /* AGRestAdapterTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 573CBDA915E546A20071E7A6 /* AGRestAdapterTests.m */; };
573CBDAD15E546B70071E7A6 /* AGRestAdapterSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 573CBDAC15E546B70071E7A6 /* AGRestAdapterSpec.m */; };
574708FF15E7792A00C1F3A2 /* AGPipelineUsecaseTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 574708FE15E7792A00C1F3A2 /* AGPipelineUsecaseTests.m */; };
57737FDD15E3D01D006B97BB /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 57737FDC15E3D01D006B97BB /* Foundation.framework */; };
57737FEC15E3D01D006B97BB /* SenTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 57737FEB15E3D01D006B97BB /* SenTestingKit.framework */; };
57737FEE15E3D01D006B97BB /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 57737FED15E3D01D006B97BB /* UIKit.framework */; };
Expand Down Expand Up @@ -65,6 +66,8 @@
573CBDA815E546A20071E7A6 /* AGRestAdapterTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AGRestAdapterTests.h; sourceTree = "<group>"; };
573CBDA915E546A20071E7A6 /* AGRestAdapterTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AGRestAdapterTests.m; sourceTree = "<group>"; };
573CBDAC15E546B70071E7A6 /* AGRestAdapterSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AGRestAdapterSpec.m; sourceTree = "<group>"; };
574708FD15E7792A00C1F3A2 /* AGPipelineUsecaseTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AGPipelineUsecaseTests.h; sourceTree = "<group>"; };
574708FE15E7792A00C1F3A2 /* AGPipelineUsecaseTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AGPipelineUsecaseTests.m; sourceTree = "<group>"; };
57737FD915E3D01D006B97BB /* libAeroGear-iOS.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libAeroGear-iOS.a"; sourceTree = BUILT_PRODUCTS_DIR; };
57737FDC15E3D01D006B97BB /* Foundation.framework */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
57737FE015E3D01D006B97BB /* AeroGear-iOS-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "AeroGear-iOS-Prefix.pch"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -113,6 +116,8 @@
573CBDA015E4CEDD0071E7A6 /* AGPipelineTests.m */,
573CBDA815E546A20071E7A6 /* AGRestAdapterTests.h */,
573CBDA915E546A20071E7A6 /* AGRestAdapterTests.m */,
574708FD15E7792A00C1F3A2 /* AGPipelineUsecaseTests.h */,
574708FE15E7792A00C1F3A2 /* AGPipelineUsecaseTests.m */,
);
name = "Unit Tests";
sourceTree = "<group>";
Expand Down Expand Up @@ -346,6 +351,7 @@
573CBDA415E4F31B0071E7A6 /* AGPipelineSpec.m in Sources */,
573CBDAA15E546A20071E7A6 /* AGRestAdapterTests.m in Sources */,
573CBDAD15E546B70071E7A6 /* AGRestAdapterSpec.m in Sources */,
574708FF15E7792A00C1F3A2 /* AGPipelineUsecaseTests.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
11 changes: 0 additions & 11 deletions AeroGear-iOS/AeroGear-iOSTests/AGPipelineTests.m
Expand Up @@ -123,15 +123,4 @@ -(void) testPipeURLProperty {
STAssertEqualObjects(@"http://server.com/project", fooPipe.url, @"verifying the given URL");
}



//// Integration tests....
//-(void) testReadFromRESTfulPipe {
//
// NSURL* projectURL = [NSURL URLWithString:@"http://todo-aerogear.rhcloud.com/todo-server/projects"];
//
// AGPipeline* todoPipeline = [AGPipeline pipelineWithPipe:@"projects" url:projectURL type:@"REST"];
//
//
//}
@end
13 changes: 13 additions & 0 deletions AeroGear-iOS/AeroGear-iOSTests/AGPipelineUsecaseTests.h
@@ -0,0 +1,13 @@
//
// AGPipelineUsecaseTests.h
// AeroGear-iOS
//
// Created by matzew on 24.08.12.
// Copyright (c) 2012 JBoss. All rights reserved.
//

#import <SenTestingKit/SenTestingKit.h>

@interface AGPipelineUsecaseTests : SenTestCase

@end
113 changes: 113 additions & 0 deletions AeroGear-iOS/AeroGear-iOSTests/AGPipelineUsecaseTests.m
@@ -0,0 +1,113 @@
//
// AGPipelineUsecaseTests.m
// AeroGear-iOS
//
// Created by matzew on 24.08.12.
// Copyright (c) 2012 JBoss. All rights reserved.
//

#import "AGPipelineUsecaseTests.h"
#import "AGPipeline.h"
#import "AGPipe.h"

@implementation AGPipelineUsecaseTests {
BOOL _finishedFlag;

id<AGPipe> projects;
}

// TODO: static hack...
NSMutableDictionary* projectEntity;

-(void)setUp {
[super setUp];
_finishedFlag = NO;

// basic setup, for every test:
// create the 'todo' pipeline;
NSURL* projectsURL = [NSURL URLWithString:@"http://todo-aerogear.rhcloud.com/todo-server/projects/"];
AGPipeline* todo = [AGPipeline pipelineWithPipe:@"projects" url:projectsURL type:@"REST"];

// get access to the projects pipe
projects = [todo get:@"projects"];


}

-(void)tearDown {
projects = nil;
[super tearDown];
}

-(void) testCreateTodoPipelineAndCreateProject{
// PIPELINE is created in setup


// create a 'new' project entity...
// using NS(Mutable)Dictionary, for now..........

projectEntity = [NSMutableDictionary dictionary];
[projectEntity setValue:@"Hello World" forKey:@"title"];


// save the 'new' project:
[projects save:projectEntity success:^(id responseObject) {
NSLog(@"CREATE RESPONSE\n%@", [responseObject description]);

// get the id of the new project:
id resourceId = [responseObject valueForKey:@"id"];
// update the 'object'.....
[projectEntity setValue:[resourceId stringValue] forKey:@"id"];

_finishedFlag = YES;

} failure:^(NSError *error) {

NSLog(@"SAVE: An error occured! \n%@", error);
}];


while(!_finishedFlag) {
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]];
}
}


-(void) testCreateTodoPipelineAndUpdateProject{

// change the title of the project:
[projectEntity setValue:@"Hello Update World!" forKey:@"title"];


[projects save:projectEntity success:^(id responseObject) {
NSLog(@"UPDATE RESPONSE\n%@", [responseObject description]);
_finishedFlag = YES;

} failure:^(NSError *error) {

NSLog(@"UPDATE: An error occured! \n%@", error);
}];


while(!_finishedFlag) {
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]];
}
}

-(void) testCreateTodoPipelineAnd_RemoveProject{
// just remove this project:
[projects remove:[projectEntity objectForKey:@"id"] success:^(id responseObject) {
NSLog(@"DELETE RESPONSE\n%@", [responseObject description]);
_finishedFlag = YES;

} failure:^(NSError *error) {

NSLog(@"DELETE: An error occured! \n%@", error);
}];
while(!_finishedFlag) {
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]];
}
}


@end

0 comments on commit 80fd0f2

Please sign in to comment.