Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New exception message is confusing #210

Closed
sravanr opened this issue Dec 2, 2014 · 8 comments
Closed

New exception message is confusing #210

sravanr opened this issue Dec 2, 2014 · 8 comments

Comments

@sravanr
Copy link
Contributor

sravanr commented Dec 2, 2014

Regression test TestCRUDModulesDb is failing in nightly regression

public void testXQueryModuleCRUDXmlFileNegative() {

    DatabaseClient client = DatabaseClientFactory.newClient("localhost", 8011, "rest-admin", "x", Authentication.DIGEST);

    // get a manager
    ExtensionLibrariesManager libsMgr = client.newServerConfigManager().newExtensionLibrariesManager();

    String Path = "/foo/my/path/to/my/module.xqy";
    FileHandle f = new FileHandle(new File("src/test/java/com/marklogic/javaclient/data/all_well.xml")).withFormat(Format.XML);

    // write XQuery file to the modules database
    try{
    libsMgr.write(Path, f);
    }catch(ResourceNotFoundException e){
        assertEquals("Negative test Passed as","Local message: Could not write resource at /foo/my/path/to/my/module.xqy. Server Message: /v1/foo/my/path/to/my/module.xqy" , e.getMessage());
    }
    // delete it
    try{
        libsMgr.delete(Path);
    }catch(Exception e){
        assertEquals("", "Local message: Could not delete resource at /foo/my/path/to/my/module.xqy. Server Message: /v1/foo/my/path/to/my/module.xqy", e.getMessage());
    }

}

Actual:
Local message: Could not write resource at /foo/my/path/to/my/module.xqy. Server Message: Request failed. Error body not received from server
@sammefford
Copy link
Contributor

Sravan, can you help me understand what's happening here? The inline comments don't clarify it for me. It looks like you're writing a valid module. Yet the method name implies to me these are negative tests. Are these? If so, why do they fail?

I need to translate this into REST language to send this error on to the lower layers.

@sravanr
Copy link
Contributor Author

sravanr commented Dec 4, 2014

This an existing test in regression which started failing because of exception message mismatch, I have not tried in understanding the test but I see the message it is spitting now is confusing, here is the complete test for your reference
https://github.com/marklogic/java-client-api/blob/dev/test-complete/src/test/java/com/marklogic/javaclient/TestCRUDModulesDb.java

@sammefford
Copy link
Contributor

The error changed in lower layers, so I need to create an issue for them. Can you provide a wire trace? That should help the most.

@sammefford sammefford modified the milestones: 8.0-2, 8.0-1 Dec 9, 2014
@grechaw grechaw modified the milestones: 8.0-2, java-client-api-3.0.2 Feb 25, 2015
@sammefford sammefford removed this from the java-client-api-3.0.4 milestone Jun 9, 2015
@gvaidees gvaidees added this to the java-client-api-3.0.4 milestone Jun 11, 2015
@sammefford sammefford modified the milestone: java-client-api-3.0.4 Jul 1, 2015
@sammefford sammefford assigned srinathgit and unassigned sammefford and srinathgit Nov 8, 2016
@sammefford sammefford added test and removed verify labels Nov 8, 2016
@sammefford sammefford added this to the java-client-api-4.0-ea4 milestone Nov 8, 2016
@sammefford
Copy link
Contributor

@srinathgit can you verify that this test is no longer failing? I'm guessing this issue has just lingerred unnecessarily.

@srinathgit
Copy link
Contributor

Assigning the case to @georgeajit

@srinathgit srinathgit assigned georgeajit and unassigned srinathgit Nov 9, 2016
@srinathgit srinathgit added verify and removed test labels Dec 8, 2016
@srinathgit srinathgit assigned sammefford and unassigned georgeajit Dec 8, 2016
@srinathgit
Copy link
Contributor

@sammefford The same (confusing) exception is still being thrown "Local message: Could not write resource at /foo/my/path/to/my/module.xqy. Server Message: Request failed. Error body not received from server". But the test has been changed as below and so it passess

@Test
public void testXQueryModuleCRUDXmlFileNegative() throws KeyManagementException, NoSuchAlgorithmException, IOException {
	
	DatabaseClient client = getDatabaseClient("rest-admin", "x", Authentication.DIGEST);
	
	// get a manager
	ExtensionLibrariesManager libsMgr = client.newServerConfigManager().newExtensionLibrariesManager();
	
	String Path = "/foo/my/path/to/my/module.xqy";
	FileHandle f = new FileHandle(new File("src/test/java/com/marklogic/client/functionaltest/data/all_well.xml")).withFormat(Format.XML);

	// write XQuery file to the modules database
	try{
	libsMgr.write(Path, f);
	}catch(ResourceNotFoundException e){
		//Issue 210 logged for meaningful error
		assertEquals("Local message: Could not write resource at /foo/my/path/to/my/module.xqy. Server Message: Request failed. Error body not received from server" , e.getMessage());
	}
	// delete it
	try{
		libsMgr.delete(Path);
	}catch(Exception e){
		assertEquals("", "Local message: Could not delete resource at /foo/my/path/to/my/module.xqy. Server Message: Request failed. Error body not received from server", e.getMessage());
	}
		
}

@sammefford
Copy link
Contributor

Ok, you'll need to update that test. See the unit test I added. ExtensionLibrariesManager will now throw an IllegalStateException with the message "libraryPath (the modules database path under which you install an asset) must begin with /ext/". Let me know if you feel that message is still confusing.

srinathgit added a commit that referenced this issue Mar 15, 2017
@srinathgit
Copy link
Contributor

The test has been modified with new exception message

@srinathgit srinathgit added ship and removed test labels Mar 15, 2017
@sammefford sammefford added closed and removed ship labels May 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants