NSURL - How to test for directory (in 10.5)?
Hi,
I've used this in 10.6 to test whether the resource pointed to is a directory:
[myURL getResourceValue:&value forKey:NSURLIsDirectoryKey error:NULL];
Is there any way to achieve the same test in 10.5 or earlier? I've pored through the
docs but can''t find anything.
Thanks
Steve
Thanks. It works, but I'm getting a warning:
warning: passing argument 1 of 'CFURLHasDirectoryPath' from incompatible pointer type
when I pass in an NSURL instance.
From the docs:
"CFURL is “toll-free bridged” with its Cocoa Foundation counterpart, NSURL. This means that the Core Foundation type is interchangeable in function or method calls with the bridged Foundation object. In other words, in a method where you see an NSURL * parameter, you can pass in a CFURLRef, and in a function where you see a CFURLRef parameter, you can pass in an NSURL instance"
( I'd also been using
[[NSFileManager defaultManager] fileExistsAtPath:[myURL path] isDirectory: &isFolder ];
but CFURLHasDirectoryPath is easier if it's safe to ignore the warning. )
Thanks
Steve
Similar Messages
-
How to test for existence of AcroXFA test objects?
Hi -
I'm writing scripts to test an XFA form with dynamic subforms. For example, at the end of Part 4, the user hits a Validate button, and if their data is correct, then the Validate button disappears and a Part 5 subform appears.
So my script looks something like this:
Function GetButtonPart4Validate()
Set GetButtonPart4Validate = PDFDoc("TestForm").AcroXFAForm("form").AcroXFAForm("form1")
.AcroXFAForm("sfPart4").AcroXFAButton("sfValidate")
End Function
Function GetPart5()
Set GetPart5 = PDFDoc("TestForm").AcroXFAForm("form").AcroXFAForm("form1").AcroXFAForm("sfPart5")
End Function
GetButtonPart4Validate().Click
PDFDoc( "TestForm" ).WaitProperty "ready", true, 60000 ' Wait for event processing complete
If DataTable("boolValidates", dtLocalSheet) = "TRUE" Then
If( GetPart5().Exist ) Then
' A: Checkpoint Succeeds: Validation was successful
Else
' B: Checkpoint fails: Validation failed
Endif
Else
If( GetPart5().Exist ) Then
' C: Checkpoint Fails: Validation was unexpected
Else
' D: Checkpoint Succeeds: Validation failed as expected
Endif
Endif
Unfortunately it appears that XfaSubForm.Exist always returns TRUE. In other QTP testing domains (eg "Exist Property (WinObject)" in QTP Help), the documented behaviour of the Exist property is to be true if the desired test object can be found in the application-under-test. Typically this means that when the script tries to access an XFA widget which doesn't exist (even something like GetPart5().getROProperty("visible") ), the script stops and thinks for a minute or so, and eventually produces a test error that the object doesn't exist then muddles onward. It is the "stops and thinks for a minute or so" which frustrates me, since these are delays which I am trying to avoid.
Another possible angle I looked into was counting the subforms under Part 5's parent.
PDFDoc("TestForm").AcroXFAForm("form").AcroXFAForm("form1").RefreshObject
PDFDoc("TestForm").AcroXFAForm("form").AcroXFAForm("form1").AcroXFAForm("sfPart5").Refresh Object
' check to see if there is a 'sfPart5'
Dim MyChildren, i
Set MyChildren = PDFDoc("TestForm").AcroXFAForm("form").AcroXFAForm("form1").ChildObjects
For i=0 to MyChildren.Count - 1
print i & " name=" & MyChildren(i).GetROProperty("name")
Next
This also seems to fail: Part5 doesn't appear among its parent's children (at least before QTP actually tries to use it).
The PDF Test Toolkit User Guide doesn't specifically mention that Exist or RefreshObject or ChildObjects are implemented, so I can't say AcroQTP isn't working as designed, but if you're looking for suggestions for improvement, I'll vote for fulfilling these parts to the QTP. Please confirm my conclusions that these are not properly implemented, or whether I'm missing something.
In the meantime, do you have any recommendation on how to proceed? My present workaround is to look for a "validation error" windows dialog that indicates Part 5 won't exist, but this won't work in future test scripts.
Cheers,
BrentHi,
816387 wrote:
... QUERY:- Find all customers who have at most one account at the Perryridge branch.
SOLUTION *1* :-
select customer_name
from depositor,account
where account.account_number=depositor.account_number and
branch_name='Perryridge'
group by customer_name
having count(account.account_number) <=1
ok running correctly
That finds customers who have exactly one account at Perryridge.
The assignment is to find customers who have at most one account at Perryridge. You need to include customers with 0 accounts at Perryridge, as well. You could use an outer join, or MINUS, or a NOT IN subquery, or a NOT EXISTS sub-query (as mentioned above) to do that.
Can there be customers who have no accounts at all, at any branch? If so, you'll need to use the customer table in this problem, as well as depositor and account.
>
SOLUTION *2* :-
select D1.customer_name
from depositor D1
where unique
(select customer_name
from depositor D2,account A1
where D1.customer_name=D2.customer_name
D2.account_number=A1.account_number and
branch_name='Perryridge'
gives error:-
where unique
..........*^*
ERROR at line 3:
ORA-00936: missing expression
Logic of both solution are correct . But Solution 2 gives error in oracle. I want unique construct to work.Sorry, it doesn't in Oracle. I don't know of anything like that in Oracle.
Does "WHERE UNIQUE (SELECT ...)" work in some other database system? Which?
How to do it. Or How can i test for the absence of duplicate tuples ??????
Your Solution 1 is the best way to find customers with exatly 1 account (rather than 0 or 1 accounts) at Perryridge. Is there any reason why you wouldn't want to use it, if you ever needed to find customers with exactly one account there? -
How to test for différent Select into a single PL/SQL block ?
Hi,
I am relatively new to PL/SQL and I am trying to do multiple selects int a single PL/SQL block. I am confronted to the fact that if a single select returns no data, I have to go to the WHEN DATA_NOT_FOUND exception.
Or, I would like to test for different selects.
In an authentification script, I am searching in a table for a USER ID (USERID) and an application ID, to check if a user is registered under this USERID for this APPLICATION.
There are different possibilities : 4 possibilities :
- USERID Existing or not Existing and
- Aplication ID found or not found for this particular USERID.
I would like to test for thes 4 possibilities to get the status of this partiular user regardin this application.
The problem is that if one select returns no row, I go to the exception data not found.
In the example below you see that if no row returned, go to the exception
DECLARE
P_USERID VARCHAR2(400) DEFAULT NULL;
P_APPLICATION_ID NUMBER DEFAULT NULL;
P_REGISTERED VARCHAR2(400) DEFAULT NULL;
BEGIN
SELECT DISTINCT(USERID) INTO P_USERID FROM ACL_EMPLOYEES
WHERE USERID = :P39_USERID AND APPLICATION_ID = :APP_ID ;
:P39_TYPE_UTILISATEUR := 'USER_REGISTERED';
EXCEPTION
WHEN NO_DATA_FOUND THEN
:P39_TYPE_UTILISATEUR := 'USER_NOT_FOUND';
END;I would like to do first this statement :
SELECT DISTINCT(USERID) INTO P_USERID FROM ACL_EMPLOYEES
WHERE USERID = :P39_USERID Then to do this one if the user is found :
SELECT DISTINCT(USERID) INTO P_USERID FROM ACL_EMPLOYEES
WHERE USERID = :P39_USERID AND APPLICATION_ID = :APP_ID ;etc...
I basically don't want to go to the not found exception before having tested the 4 possibilities.
Do you have a suggestion ?
Thank you for your kind help !
ChristianSurely there are only 3 conditions to check?
1. The user exists and has that app
2. The user exists and doesn't have that app
3. The user doesn't exist
You could do this in one sql statement like:
with mimic_data_table as (select 1 userid, 1 appid from dual union all
select 1 userid, 2 appid from dual union all
select 2 userid, 1 appid from dual),
-- end of mimicking your table
params_table as (select :p_userid userid, :p_appid appid from dual)
select pt.userid,
pt.appid,
decode(min(case when dt.userid = pt.userid and dt.appid = pt.appid then 1
when dt.userid = pt.userid then 2
else 3
end), 1, 'User and app exist',
2, 'User exists but not for this app',
3, 'User doesn''t exist') user_app_check
from mimic_data_table dt,
params_table pt
where pt.userid = dt.userid (+)
group by pt.userid, pt.appid;
:p_userid = 1
:p_appid = 2
USERID APPID USER_APP_CHECK
1 2 User and app exist
:p_userid = 1
:p_appid = 3
USERID APPID USER_APP_CHECK
1 3 User exists but not for this app
:p_userid = 3
:p_appid = 2
USERID APPID USER_APP_CHECK
3 2 User doesn't exist -
SESSION VARIABLES : HOW TO TEST FOR MULTIPLE USERS
I have a username session variable set up on a localhost testing envirnoment.
This works fine for one user, but when I open another occurence of the browser (or just another tab) to test for multiple users the system overwrites the session variable with the last username input.
So the question is:
Why doesn't dreamweaver hold an instance of the session variable for each browser session? and if not what are your suggestions?
Thanks
Adam.Thanks for that.
After scouring the internet I found the only way of running 2 instances of firefox without them sharing the session variables is to create 2 new firefox profiles in windows + set the MOZ_NO_REMOTE environment variable.
Internet explorer is much easier as it has a 'new session' option in the file menu, but seems to have more trouble displaying tables correctly.
Hope this helps anyone with a similar problem. -
JSTL Core - How to test for null?
How do I test an attribute for null using JSLT's if statement? The below code does not work (the JSTL if statement does not return true). The scriptlet however does work and displays the statement.
- Chris
index.jsp
<%@ taglib uri="c.tld" prefix="c"%>
<%@ taglib uri="fmt.tld" prefix="fmt"%>
<%@page import="java.util.*"%>
<%
request.setAttribute("null", null);
%>
<html>
<head>
<title>JSTL Test Page</title>
</head>
<body>
<c:if test="${null}==null">
The value was null (JSTL)
</c:if>
<%
if (request.getAttribute("null")==null) out.print("The value was null (Scriptlet)");
%>
</body>
</html>
<%out.flush();%>Well, I figured out. If anyone is interested, here is the code:
<c:if test="${empty varName}">
Its null
</c:if> -
How to test Active Directory health?
Hi,
I need to test my AD replication and health. Also need to check if AD sites and services is configured properly. What can I use for that?You can check the replication issue using this.
repadmin /replsum /bysrc /bydest /sort:delta
You need to check the client computers if those are getting correct DC or not for AD sites configuration.
Regards~Biswajit
Disclaimer: This posting is provided & with no warranties or guarantees and confers no rights.
MCP 2003,MCSA 2003, MCSA:M 2003, CCNA, MCTS, Enterprise Admin
MY BLOG
Domain Controllers inventory-Quest Powershell
Generate Report for Bulk Servers-LastBootUpTime,SerialNumber,InstallDate
Generate a Report for installed Hotfix for Bulk Servers -
OpenScript: How do you test for object/text existance programmatically?
Hi, All;
I hope someone can help me; kind of new to OATS. I can’t figure out how to test for object/text existence and return results back to the script. There are methods for verifying text and objects; i.e.
Web.verifyText
Web.assertText
These methods just report pass or fail to the test. I need to get the data back programmatically so I can use it logically. I know you can do this pretty easily in Selenium and QTP so there must be a way in OATS.
Thanks,
EricHi Eric,
You can use the Object Explorer to find the xpath of the object you are interested and check for its existence, and then grab some attribute of that object for use elsewhere.
if (web.element(6,"/web:window[@index='0' or @title='Software and Services - SCL']/web:document[@index='0']/web:span[@text='Services' or @index='14']")
.exists()){
System.out.println("OBJECT EXISTS");
// get an attribute of object here ,e.g
String myval = web.element(41,"/web:window[@index='0' or @title='Software and Services - SCL']/web:document[@index='0']/web::span[@text='Services' or @index='14'].getAttribute("innerText");
// use myval elsewhere
Hope it helps.
Jamie -
IPhone SDK - test for sound input availability?
Should one try to determine if the device has a microphone available before calling AudioQueueNewInput and AudioQueueStart? I didn't see any mention of this requirement in the Audio Queue Services Programming Guide. (But in ancient MacOS history, one used to at least check the gestaltSoundAttr for the gestaltPlayAndRecord flags before trying to use the Sound Manager...)
I have some audio queue input code which seems to work on the SDK simulator; what will happen if someone tries to run this code on an iPod Touch, which doesn't have a mic (AFAIK)? And if someone attaches a mic to the iPod dock connector, can this be detected and used?Good Question. I did just that. It seems that the iPod touch thinks that the input device is present and the call to AudioQueueStart returns 0. Good or bad, I don't know. I assume that this function should trigger the callback function to the delegate, but it only works in the simulator. This can be seen with the Speak Here app that is posted for examples. The debugger console shows a call to updateUserInterfaceOnAudioQueueStateChange when recording begins and when recording ends. On the iPod touch the call to the delegate is only done when recording stops.
I would also like to know how to test for an input device. -
How to test if a number is prime?
Hi, I'm doing an exercise. I'm iterating through numbers from 2 to 100 (since 1 is not a prime number) and I need to test if the current number is a prime, if it is print it out. But I can't figure out the condition, how to test if a number is prime? So far I got this, but it prints all subsequent numbers, which is now obvious to me, but how to test for primes?
public class Main {
public static void main(String[] args) {
for (int i = 2; i <= 100; i++) {
//Test if a number is a prime, if it is print it
// The (i + 1) is because I want to divide i by any other number, so I thought i + 1
if (((i % i) == 0) && ((i % 1) == 0) && ((i % (i + 1)) > 0)) {
System.out.println(i);
}Aardenon wrote:
I understand your point. But it seems unsafe to assume a number from which the checks are unnecessary. That could lead to an error. I'm sure it is mathematically provable somehow, but I'm not that good in Math. I mean to write a safe (and optimized) version of the code, I would still have to go through all uneven numbers and 2.Nope. In fact, for an optimized version, definitely not; however, I wouldn't worry too much about optimization at the moment.
One little tip I remember from school, back in the dark ages, is that all prime numbers other than 2 and 3 have the form 6k ± 1. That is NOT to say that all such numbers are prime, but it does eliminate a lot of the ones you need to check.
You might also want to check out the [url http://en.wikipedia.org/wiki/Prime_number#Verifying_primality]Wikipedia page on prime numbers; it's very good.
Winston -
I am writting a test using a sequencer to test for multiple button click
I'm using flex sdk 4.1 and have a situation where a button click is sometimes called twice. I am writting a test for this using a sequencer and it will run for at least one button click, what I am not sure is how to test for multiple click events(which shouldn't happen, but occours randomly in my project)
package tests.view
import flash.events.MouseEvent;
import flexunit.framework.Assert;
import mx.events.FlexEvent;
import org.flexunit.async.Async;
import org.fluint.sequence.SequenceEventDispatcher;
import org.fluint.sequence.SequenceRunner;
import org.fluint.sequence.SequenceWaiter;
import org.fluint.uiImpersonation.UIImpersonator;
import views.AddComments;
public class TestAddComments
private var view:AddComments;
[Before(async,ui)]
public function setUp() : void
view = new AddComments;
Async.proceedOnEvent( this, view, FlexEvent.CREATION_COMPLETE, 600 );
UIImpersonator.addChild( view );
[Test]
public function testButtonClick():void
view.addCommentBtn
var sequence:SequenceRunner = new SequenceRunner( this );
sequence.addStep( new SequenceEventDispatcher( view.addCommentBtn, new MouseEvent( 'click', true, false ) ) );
sequence.addStep( new SequenceWaiter( view.addCommentBtn, MouseEvent.CLICK, 100 ) );
sequence.run();The only way you could test for that type of circumstance... one where something may happen... is to do so with a timeout. In other words, you cannot let the test pass simply because the first event occurred.
Two ways to handle this... with sequences:
Instead, you write a test that expects 2 clicks. In the assertion handler (which would only be reached if both clicks occur) you would fail the test:
fail('i shouldnt be here');
In the Waiter for the 2nd click, you would specify a timeout handler. That timeout handler will get called in the 2nd click does not occur in the specified time... (finding that time is the hard part). The default timeout handler fails the test, however, in your case, your timeout handler would just happily do any assertions needed and move on. A timeout does not necessarily mean failure... in your case, it is correct
Second choice:
You could create a timer. Create an event handler for the button click which increments a counter. Start the timer, do your test. However, have your test pending on the timer's completion rather than something like the click.. In that case, you would then be able to just check the count:
private var clickCount:int = 0;
[Test]
public function testButtonClick():void {
var timer:Timer = new Timer( 100, 1 );
Async.handleEvent( this, timer, TimerEvent.COMPLETE, checkClickCount );
view.addCommentBtn.addEventListener( 'click', function( e:Event ):void { clickCount++ } );
view.addCommentBtn.dispatchEvent( new MouseEvent( 'click;, true, false ) );
private function checkClickCount( e:Event ):void {
assertEquals( 1, clickCount );
However, I can't imagine how the test you are describing could ever yield more than one click event... I am guessing the problem is elsewhere, but this will help you verify
Mike -
How to download and restore test data directory / se37
Hello comunity,
ahead of me lies a system refresh. in tc se37 according to several function modules i have recorded several test-data-sets in test directory. After the system refresh they will be gone. i assume there are ddic-tables behind my personally saved test data records.
now i wonder, does anyone know a functionality (program, fm, etc.) on
1. how to download "my" test data directory entries ?
2. how to restore them into the test data directory once after the system refresh ?
for sure, somebody does. please gimme a hint. answers will be rewarded with credit points.
Thanx in advance!
Gunther
Message was edited by:
Gunther StauchHmm...
Maybe this is useful -> table <b>EUFUNC</b>
Check the FMs from Function group <b>SEUJ</b> ,
FM <b>RS_TESTDATA_GET</b> looks promising-reading.. and so also <b>RS_RFC_TESTDATA_GROUP_TRANSFER</b>
Maybe you can write a small program which downloads all the contents of the table and later updates it using one of the above FMs
Also check with the BASIS team about the options -> There are many options available like maintaining the previous settings... (I know that passwords may not be refreshed similarly this option may also be available..)
REgards,
Arun -
How to creat Test Data Directory
Hi Experts,
I want to create a TEST DATA DIRECTORY for the following function module CLOI_CHANGES_UPL_31. How to create this?
Actually now i have some process order numbers. Using this how to create the test data directory??
Plz guide this.
Point will be sure.
MohanaHi Mohana,
Test data directory is similar to variants in reports.
After executing the function module give some input and click the save button . It will prompt a name . Give the name and click enter. So this test data is saved in the test data directory.
So that you need not not give the test input again and again. you can simply click the test dat directory and select your test data .
Regards,
Charumathi.B -
Transporting BAPi 's Test Data Directory(like Variants), How?
Hi Experts,
I hv created some Test Data Directory elements for BAPi, in DEV, so, now, I wanna to move them to TEST system!
Pls. let me know,
1 - How to get it done? Is there any SAP prog./Transaction/Menu path?
Thank you,Hi,
In DEV system:
As usual, I entered some inputs in FM screen, then Saved-Floppy them, the system prompted me, to give some name, I hv given <b><i>my_s_cust_#_1000000</i></b> name. So, its stored in TEST DATA DIRECTORY. I hv been used it from TEST DATA DIRECTORY for my trials.
So, now, I wanna to move my_s_cust_#_1000000 to TEST system, How?
Hope U got it!
thanq. -
How to look for kMAT material in Testing client?
Hi PP members:
How to look for KMAT material in Test client,
Note: I went to mm60 and entered material type: KMAT it did not populate any
materials
Is there any way where I can find the materials, If yes please let me know
thanks
SurenHi Saritha:
When I went to SE16, and entered MTART as KMAT it giving the following
It is replying me back "No table entries found for specified key"
Also want to bring to your kind attention I left MATNR field blank as I donot know
the VC materials
thanks -
How can I check for directory creation?
Hi,
I want to check whether I can create a directory at a particular location.
Let's say at c:\windows, can create a directory called c:\windows\mydir. But I won't be knowing the parent location (i.e., c:\windows here) at compile time.
And I would also like to check for creating a directory like c:\windows\mydir1\mydir2 (mydir1 may not even exist).
What I was doing was, I created the file object for my new directory (i.e., mydir here) and used the canWrite() method on the parent directory. But this method worked only when the parent directory existed. But how can check for a directory path like c:\windows\mydir1\mydir2 where I have to create both mydir1 for mydir2.
Is there any other methods that I can use to perform this kind of a check.
Thank youI finally figured out a workaround, but i don't know whether this is a good way of checking. :)
import java.io.File;
public class TryMKDIRs {
public static void main(String[] args) {
File file = new File("c:\\mydir1\\mydir2\\mydir3");
boolean canICreateDir = false;
if(false == (canICreateDir = file.canWrite())) {
System.out.println(file.getAbsoluteFile() + " cannot be created.");
File fileparent = file.getParentFile();
while(fileparent != null && (canICreateDir = fileparent.canWrite()) == false) {
System.out.println(fileparent.getAbsoluteFile() + " cannot be created.");
fileparent = fileparent.getParentFile();
if(canICreateDir) {
file.mkdirs();
System.out.println("Directory can be created. . .");
}
Maybe you are looking for
-
HT5622 can I use one apple ID for both iPhone and iPad?
hello, i just bought a new ipad and want to use the same apple ID that i used in my iphone. is it possible? thank you for helping me
-
Exception Error Message on MRP Type
Hi Gurus, Currently system does not set exception message. Any purchase requisition should generate an exception message. How will we configure in the system? Thanks in Advance. Neo.
-
Is it possible to add code to iWeb templates? Using iWeb version 1.1.2. Thanks in advance. Roy
-
Jdev 9iRC: deployment of BC4J-UIX components to OC4J !2.0! does not work
in different threads the problem of deployment of BC4J UIX components to OC4J 1.2.2.x is addressed (see http://forums.oracle.com/forums/message.jsp?id=679060 for example). contrary to the sayings of different members of the jdev-team i face the same
-
Why do I keep getting the windows messenger error even after disabling it?
Hi, I am trying to download the flash player 10 on my windows XP computer. I get the error(s) close "Internet Explorer" and close "Windows messenger" during download. I closed Internet Explorer ok, but still keep getting the Windows messenger er