本文整理汇总了Java中org.fest.assertions.Fail.fail方法的典型用法代码示例。如果您正苦于以下问题:Java Fail.fail方法的具体用法?Java Fail.fail怎么用?Java Fail.fail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.fest.assertions.Fail
的用法示例。
在下文中一共展示了Fail.fail方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: currentUser_AuthorizedRequest_Ok
import org.fest.assertions.Fail; //导入方法依赖的package包/类
@Test
public void currentUser_AuthorizedRequest_Ok() {
User user = new User("[email protected]", "password", "John", "Doe");
user.save();
Result result = callAction(routes.ref.UserController.currentUser(),
authorizeRequest(fakeRequest(), user));
assertThat(status(result)).isEqualTo(Http.Status.OK);
try {
JsonNode responseJson = JsonHelper.removeRootElement(Json.parse(contentAsString(result)), User.class, false);
assertThat(Json.fromJson(responseJson, User.class)).isEqualTo(user);
} catch (JsonHelper.InvalidJSONException e) {
e.printStackTrace();
Fail.fail(e.getMessage());
}
}
示例2: deleteChildObject
import org.fest.assertions.Fail; //导入方法依赖的package包/类
@Test
public void deleteChildObject() throws Exception {
String methodName = "testDeleteChildObject";
assertThat(db.getCollectionNames().contains(methodName)).isFalse();
// create the object using the mongo driver directly
BasicDBObject object = new BasicDBObject();
object.append("foo", new BasicDBObject("bar", new BasicDBObject("ABC", 123)));
db.getCollection(methodName).insert(object);
String id = object.getObjectId("_id").toString();
assertThat(db.getCollection(methodName).findOne(new BasicDBObject("_id", new ObjectId(id)))).isNotNull();
// we should not be able to directly delete a child object
try {
client.delete(new RequestContext.Builder().returnFields(new DefaultReturnFields("bar(ABC(*))")).build(), "/testApp/" + BASEPATH + "/" + methodName
+ "/" + id + "/foo");
Fail.fail("We should not be able to directly delete a child object");
} catch (ResourceNotFoundException e) {
// expected
}
assertThat((DBObject) object).isEqualTo(db.getCollection(methodName).findOne());
}
示例3: deleteChildProperty
import org.fest.assertions.Fail; //导入方法依赖的package包/类
@Test
public void deleteChildProperty() throws Exception {
String methodName = "testDeleteChildProperty";
assertThat(db.getCollectionNames().contains(methodName)).isFalse();
// create the object using the mongo driver directly
BasicDBObject object = new BasicDBObject();
object.append("foo", new BasicDBObject("bar", new BasicDBObject("ABC", 123)));
db.getCollection(methodName).insert(object);
String id = object.getObjectId("_id").toString();
assertThat(db.getCollection(methodName).findOne(new BasicDBObject("_id", new ObjectId(id)))).isNotNull();
// we should not be able to directly delete a child property
try {
client.delete(new RequestContext.Builder().build(), "/testApp/" + BASEPATH + "/" + methodName + "/" + id + "/foo/bar");
Fail.fail("We should not be able to directly delete a property on a child object");
} catch (ResourceNotFoundException e) {
// expected
}
assertThat((DBObject) object).isEqualTo(db.getCollection(methodName).findOne());
}
示例4: deleteGrandchildObject
import org.fest.assertions.Fail; //导入方法依赖的package包/类
@Test
public void deleteGrandchildObject() throws Exception {
String methodName = "testDeleteGrandchildObject";
assertThat(db.getCollectionNames().contains(methodName)).isFalse();
// create the object using the mongo driver directly
BasicDBObject object = new BasicDBObject();
object.append("foo", new BasicDBObject("bar", new BasicDBObject("ABC", new BasicDBObject("123", "XYZ"))));
db.getCollection(methodName).insert(object);
String id = object.getObjectId("_id").toString();
assertThat(db.getCollection(methodName).findOne(new BasicDBObject("_id", new ObjectId(id)))).isNotNull();
// we should not be able to directly delete a child object
try {
client.delete(new RequestContext.Builder().returnFields(new DefaultReturnFields("bar(ABC(*))")).build(), "/testApp/" + BASEPATH + "/" + methodName
+ "/" + id + "/foo");
Fail.fail();
} catch (ResourceNotFoundException e) {
// expected
}
assertThat((DBObject) object).isEqualTo(db.getCollection(methodName).findOne());
}
示例5: getChildDirectly
import org.fest.assertions.Fail; //导入方法依赖的package包/类
@Test
public void getChildDirectly() throws Exception {
String methodName = "testGetChildDirectly";
assertThat(db.collectionExists(methodName)).isFalse();
// create the object using the mongo driver directly
BasicDBObject object = new BasicDBObject();
object.append("foo", "bar").append("abc", "123").append("obj", new BasicDBObject("foo2", "bar2"));
object.append("child", new BasicDBObject("grandchild", new BasicDBObject("foo3", "bar3")));
db.getCollection(methodName).insert(object);
assertEquals(1, db.getCollection(methodName).getCount());
String id = "ObjectId(\"" + object.getObjectId("_id").toString() + "\")";
try {
client.read(new RequestContext.Builder().build(), "/testApp/" + BASEPATH + "/" + methodName + "/" + id + "/child");
Fail.fail();
} catch (ResourceNotFoundException e) {
// expected
}
}
示例6: getCollection
import org.fest.assertions.Fail; //导入方法依赖的package包/类
@Test
public void getCollection() throws Exception {
String methodName = "testGetCollection";
assertThat(db.collectionExists(methodName)).isFalse();
// create the object using the mongo driver directly
BasicDBObject object = new BasicDBObject("_id", "foobaz");
BasicDBList list = new BasicDBList();
list.add(1);
list.add("A");
list.add(new BasicDBObject("_id", "test123").append("foo", "bar"));
object.append("array", list);
db.getCollection(methodName).insert(object);
assertEquals(1, db.getCollection(methodName).getCount());
try {
client.read(new RequestContext.Builder().build(), "/testApp/" + BASEPATH + "/" + methodName + "/foobaz/array");
Fail.fail();
} catch (ResourceNotFoundException e) {
// expected
}
}
示例7: getEmptyCollection
import org.fest.assertions.Fail; //导入方法依赖的package包/类
@Test
public void getEmptyCollection() throws Exception {
String methodName = "testEmptyCollection";
// check that the collection really is empty
assertFalse(db.collectionExists(methodName));
try {
client.read(new RequestContext.Builder().build(), "/testApp/" + BASEPATH + "/" + methodName);
Fail.fail();
} catch (ResourceNotFoundException e) {
// expected
}
db.createCollection(methodName, new BasicDBObject());
ResourceState result = client.read(new RequestContext.Builder().build(), "/testApp/" + BASEPATH + "/" + methodName);
// verify the result
assertThat(result.id()).isEqualTo(methodName);
assertThat(result.getProperty("type")).isEqualTo("collection");
assertThat(result.members()).isEmpty();
// check that the collection is still empty
assertEquals(0, db.getCollection(methodName).getCount());
}
示例8: deleteElementCappedCollection
import org.fest.assertions.Fail; //导入方法依赖的package包/类
@Test
public void deleteElementCappedCollection() throws Exception {
// check that we can create the resource
ResourceState state = new DefaultResourceState("onlyThree");
state.putProperty("capped", "true");
state.putProperty("size", 1024);
state.putProperty("max", 3);
ResourceState createdResource = client.create(new RequestContext.Builder().build(), "/testApp/storage", state);
assertThat(createdResource).isNotNull();
assertThat(createdResource.id()).isEqualTo("onlyThree");
client.create(new RequestContext.Builder().build(), "/testApp/storage/onlyThree", new DefaultResourceState("first"));
// this should fail since you cannot delete from a capped collection
try {
client.delete(new RequestContext.Builder().build(), "/testApp/storage/onlyThree/first");
Fail.fail();
} catch (DeleteNotSupportedException dnse) {
//expected
}
}
示例9: childDirectUpdate
import org.fest.assertions.Fail; //导入方法依赖的package包/类
@Test
public void childDirectUpdate() throws Exception {
String methodName = "testChildDirectUpdate";
assertThat(db.getCollection(methodName).getCount()).isEqualTo(0);
// create the object using the mongo driver directly
BasicDBObject object = new BasicDBObject();
object.append("foo", new BasicDBObject("bar", "baz"));
db.getCollection(methodName).insert(object);
assertEquals(1, db.getCollection(methodName).getCount());
String id = "ObjectId(\"" + object.getObjectId("_id").toString() + "\")";
// update the resource using the client.update method
ResourceState resourceState = new DefaultResourceState();
resourceState.putProperty("bar", 123);
// should not be able to directly update a child object
try {
client.update(new RequestContext.Builder().build(), "/testApp/" + BASEPATH + "/" + methodName + "/" + id + "/foo", resourceState);
Fail.fail();
} catch (CreateNotSupportedException e) {
// expected
}
assertThat((DBObject) object).isEqualTo(db.getCollection(methodName).findOne());
}
示例10: grandchildDirectUpdate
import org.fest.assertions.Fail; //导入方法依赖的package包/类
@Test
public void grandchildDirectUpdate() throws Exception {
String methodName = "testGrandChildDirectUpdate";
assertThat(db.getCollection(methodName).getCount()).isEqualTo(0);
// create the object using the mongo driver directly
BasicDBObject object = new BasicDBObject();
object.append("foo", new BasicDBObject("bar", new BasicDBObject("baz", "ABC")));
db.getCollection(methodName).insert(object);
assertEquals(1, db.getCollection(methodName).getCount());
String id = "ObjectId(\"" + object.getObjectId("_id").toString() + "\")";
// update the resource using the client.update method
ResourceState resourceState = new DefaultResourceState();
resourceState.putProperty("baz", "XYZ");
try {
client.update(new RequestContext.Builder().build(), "/testApp/" + BASEPATH + "/" + methodName + "/" + id + "/foo/bar", resourceState);
Fail.fail();
} catch (ResourceNotFoundException e) {
// expected
}
assertThat((DBObject) object).isEqualTo(db.getCollection(methodName).findOne());
}
示例11: invalidType
import org.fest.assertions.Fail; //导入方法依赖的package包/类
@Test
public void invalidType() throws Exception {
ResourceState config = new DefaultResourceState();
config.putProperty("db", "testInvalidTypeDB");
config.putProperty("servers", new ArrayList());
ResourceState configReadPref = new DefaultResourceState();
configReadPref.putProperty(ReadPreferenceState.TYPE, "foobar");
config.putProperty(ReadPreferenceState.ID, configReadPref);
try {
setUpSystem(config);
Fail.fail();
} catch (InitializationException e) {
//expected
}
}
示例12: renameCollectionAlreadyExists
import org.fest.assertions.Fail; //导入方法依赖的package包/类
@Test
public void renameCollectionAlreadyExists() throws Exception {
db.dropDatabase(); // TODO: create a new DB here instead of dropping the old one
assertThat(db.getCollectionNames()).hasSize(0);
// create a couple of collections
db.createCollection("foo", new BasicDBObject());
db.createCollection("bar", new BasicDBObject());
// check that the collections are there (Note: there is an internal index collection, so one more than expected)
assertThat(db.getCollectionNames()).hasSize(3);
assertThat(db.collectionExists("foo"));
assertThat(db.collectionExists("bar"));
// set the update resource state to include a new id value
// Note that this matches an already existing collection
ResourceState updateResourceState = new DefaultResourceState("bar");
try {
client.update(new RequestContext.Builder().build(), "/testApp/" + BASEPATH + "/foo", updateResourceState);
Fail.fail();
} catch (ResourceAlreadyExistsException e) {
//expected
}
}
示例13: updateProperty
import org.fest.assertions.Fail; //导入方法依赖的package包/类
@Test
public void updateProperty() throws Exception {
db.dropDatabase(); // TODO: create a new DB here instead of dropping the old one
assertThat(db.getCollectionNames()).hasSize(0);
// create a collection
DBCollection collection = db.createCollection("foo", new BasicDBObject());
DBObject dbObject = new BasicDBObject("_id", "testObject");
dbObject.put("hello", "world");
collection.insert(dbObject);
// check that the collection is there (Note: there is an internal index collection, so one more than expected)
assertThat(db.getCollectionNames()).hasSize(2);
assertThat(db.getCollection("foo").count() == 1);
// set the update resource state to include the same id value
ResourceState updateResourceState = new DefaultResourceState();
updateResourceState.putProperty("count", 500L);
try {
client.update(new RequestContext.Builder().build(), "/testApp/" + BASEPATH + "/foo", updateResourceState);
Fail.fail();
} catch (NotAcceptableException e) {
//expected
}
}
示例14: matches
import org.fest.assertions.Fail; //导入方法依赖的package包/类
@Override
public boolean matches(final File file) {
try {
return FileUtils.readFileToString(file).contains(expectedContent);
} catch (final IOException e) {
Fail.fail("could not check file contents", e);
return false;
}
}
示例15: optionalNestedSettings_ShouldFailWhenBroken
import org.fest.assertions.Fail; //导入方法依赖的package包/类
@Test
public void optionalNestedSettings_ShouldFailWhenBroken() {
try {
from("broken-nested").load(OptionalNestedType.class);
Fail.fail();
} catch(RuntimeException e) {
assertThat(e.getMessage()).contains("Cannot find mandatory setting address.street");
}
}