Have Western attitudes to the rise of China been based on wishful thinking? China's increasingly tough approach to diplomacy is leading governments in the U.S. and in Europe to rethink their policies towards China. Western leaders are starting to question some of the optimistic assumptions on which those policies have been based.

Until very recently, many Western bankers, business people and politicians were broadly optimistic about the rise of China. They assumed that as China became more developed it would become more Western. As it integrated into the global economy its society would open up, it would play a constructive role in multilateral institutions, and it would help Western governments sort out key foreign policy challenges. China's leaders seemed to understand that their top priority - the economic development of their country - required friendly relations with other major powers, notably the U.S.

There has also been a pessimistic view of China's rise, held by people in the U.S. defence establishment, some right-wing think-tanks and the human rights lobbies. They have argued that as China develops it is becoming more assertive, less willing to compromise with the West, less welcoming to foreign investors and more repressive politically. Like other rising powers throughout history, the pessimists have thought, China would disrupt the international system. They have pointed to China's soaring defence budget as support for their case.

Of course, both views have been based on truth. China is not a monolithic entity. Within the leadership, many institutions and personal and ideological factions compete for power. But until recently the optimists dominated Western views of China. I was an optimist when, two years ago, I wrote (with Katinka Barysch) Can Europe and China Shape a New World Order? Our report argued that China was evolving into the "responsible global stakeholder" that Robert Zoellick had urged it to become when he was US deputy secretary of state.

Over the past year the optimists have found it increasingly difficult to sustain their view. There are still examples of China being helpful - for example, it has sent ships to catch pirates in the Indian Ocean, and engaged in G20 discussions - but overall it has become a much pricklier partner.

China's foreign policy has become more assertive. Its claims to the Indian state of Arunachal Pradesh have become more vociferous. It is being less helpful to the West over the Iranian nuclear problem - and has become more hostile than Russia to further sanctions on Iran. Its treatment of the EU is sometimes contemptuous - it cancelled one summit and regularly punishes countries whose leaders meet the Dalai Lama in an official setting. Western governments have suffered increasingly powerful cyber-attacks that have been traced to mainland China.

China's political system has become more repressive. Moves to introduce greater democracy into local government and the Communist Party have faltered. Dissidents are facing a tougher time. In December Liu Xiaobo was sentenced to 11 years in prison for organising a pro-democracy petition.

China's economic policies have become more nationalist. Many foreign investors in China complain about exclusion from key markets and unofficial forms of discrimination. China's manipulation of its currency downwards, driven by a mercantilist desire to boost exports and foreign currency reserves, exacerbates the problem of global economic imbalances and is fuelling protectionist sentiment in other countries.

Recent events have brought home to public opinion in the West how China is changing. At the Copenhagen climate change conference in December, China worked hard behind the scenes to scupper the kind of deal that Western countries and many poor nations wanted (at one point it sent a deputy foreign minister to negotiate with Barack Obama). And this month Google has said that it may leave China because of cyber attacks on its business and increasingly stringent internet censorship.

If one talks to people in China about the troubled state of relations between China and the West, many of them are baffled. They know little of the incidents that have caused problems, which are unreported in the Chinese media. They say that most Chinese people are focused on domestic issues - such as jobs, pollution and soaring house prices - rather than foreign policy.

So the source of China's tougher line seems to be the leadership, rather than pressure from the people. Three factors may explain why hard-liners are winning more arguments within the leadership.

China's economy has performed impressively during the global recession, growing by 9 per cent in 2009. Meanwhile the Western economic model is viewed as discredited. China's leaders would not be human if they did not feel a bit cocky - especially since they have been on the receiving end of patronising lectures from Western leaders about the superiority of Western capitalism. The emerging super-power feels it has the right to assert its own interests more forcefully.

Yet China's leaders feel insecure. The unrest in Tibet (in 2008) and Xinjiang (in 2009) caught them by surprise. Rapid economic growth and urbanisation are creating huge social tensions. Endemic corruption makes local party bureaucrats unpopular. The booming housing market - fuelled by the government selling land to property speculators - means that many young middle class people cannot afford to buy flats. Few Chinese people want Western-style democracy, but the leaders know their legitimacy is built on thin foundations. Hence their reluctance to allow a more open society.

The current leadership, led by Hu Jintao and Wen Xiabao, is due to hand over to the 'fifth generation' of leaders in 2012. There is much manoeuvring for position. The machinations within Zhongnanhai, where the top communists live and work, are impossible to decipher. But some key figures seem to be pushing a nationalist line in order to boost their support among party cadres. In China, as in most countries, nationalist policies can be popular.

American attitudes to China are palpably hardening. At some point this year the US may declare China to be a currency manipulator and then apply protectionist measures. The EU finds it very difficult to get tough with anyone. But European leaders are increasingly critical of China, at least in private. China's leaders should not assume that European markets will remain open to them indefinitely.

China's attitude to international relations is ultra-realist. It will take what it can get, while respecting power and facts. But China's leaders may have miscalculated by underestimating the impact of their harder line on Washington and European capitals. How well-informed are the people in Jonghnanhai? Do they receive objective reports on how Chinese words and actions impact on Western political systems? And do they care what Western leaders think?

Undoubtedly, there are Chinese leaders who stand by the premise of the 'peaceful rise' slogan - that China's economic development requires some modesty in international affairs and good relations with the West. When the most senior leaders see that their current approach may spur several powerful countries to work together to contain China, they may wish to modify their course. But if they maintain the hard line for a prolonged period, China's relations with the West will become very tense. Free trade and the world economy may well suffer.